<<

CSC521 – Communication Protocols 網路通訊協定

Ch.7 : Connectionless Datagram Delivery (IPv4, IPv6)

吳俊興 國立高雄大學 資訊工程學系

Internetworking With TCP/IP, Vol I: Sixth Edition, Douglas E. Comer Outline

1 Introduction 2 A Virtual Network 3 Internet Architecture And Philosophy 4 Principles Behind The Structure 5 Connectionless Delivery System Characteristics 6 Purpose And Importance Of The Internet Protocol 7 The IP Datagram 8 Datagram Type Of Service And Differentiated Services 9 Datagram Encapsulation 10 Datagram Size, Network MTU, and Fragmentation 11 Datagram Reassembly 12 Header Fields Used For Datagram Reassembly 13 Time To Live (IPv4) And Hop Limit (IPv6) 14 Optional IP Items 15 Options Processing During Fragmentation 16 Network Byte Order 17 Summary 2 Concepts of The Internet Protocol •A Virtual Network IP allows a user to think of an internet as a single virtual network that interconnects all hosts, and through which communication is possible; its underlying architecture is both hidden and irrelevant •Three sets of internet services – conceptual separation Internet software is designed around three conceptual networking services arranged in a hierarchy; much of its success has resulted because this architecture is surprisingly robust and adaptable

• Two philosophical underpinnings – Build reliable service on top of an unreliable, connectionless base – The lowest level service exactly matches the facilities provided by underlying hardware networks and the second level provides the service that applications expect 3 IP Characteristics

• The most fundamental Internet service consists of a packet delivery system – Connectionless – Unreliable – Best-effort delivery • Defines three important items – Internet addressing scheme – Format of packets for the (virtual) Internet – Packet forwarding • Three important specifications – IP defines basic unit of data transfer used throughout a TCP/IP internet • The basic transfer unit: a header and payload – IP software performs the forwarding function, choosing a path over which a packet will be sent – IP includes a set of rules that embody the basis of unreliable delivery

4 Elements of a Protocol

• Addressing: source IP and destination IP • Length: header length and total length • Error control: checksum and time-to-live • Encapsulation: fragmentation and resembling support • Extensibility: – version – service type – de-multiplexing – IP option

5 IP Datagram Header Format

Vers HLen Service Type Total Length Identification Flags Fragment Offset Time to Live (TTL) Protocol Header Checksum Source IP Address Destination IP Address IP Options (If Any) Padding

Data (Payload) …

• VERS: 4 • Time to Live (TTL) • HLEN: header length in 32-bit words – how long allowed to remain in network • Service Type: support differentiated – hop limit (i.e. 30, 60, 64) services (DiffServ) • Protocol (1: ICMP; 6: TCP; 17: UDP) • Total Length: header + data • Header Checksum (MAX=65,535 octets) • Source IP; Destination IP

6 Datagram Encapsulation

Encapsulated in frame

• 20-octet IP header follows 14-octet Ethernet header – Ethernet Type Field set to 0x0800 • source IP: 128.10.2.3 (800a0203) • destination IP: 128.10.2.8 (800a0208) • IP type: 01 (ICMP)

7 IPv6 Datagram Format

IPv6 general form

Base header with TCP segment

One extension

Two extensions

8 IPv6 Base Header Format

9 A Potential Problem – MTU Issues

• Network hardware limits maximum size of frame – Known as the network Maximum Transmission Unit ( MTU ) – e.g., Ethernet limited to 1500 octets

• Possible ways to accommodate networks with differing MTUs – Force datagram to be less than smallest possible MTU • Inefficient • Cannot know minimum MTU – Hide the network MTU and accommodate arbitrary datagram size

• A datagram can contain up to 65535 total octets (including header) • Question: how is encapsulation handled if datagram exceeds network MTU? 10 Datagram Size, Network MTU, and Fragmentation

•PathMTU – The minimum of the MTUs on networks along the path •IPv4 – allows any router along a path to fragment a datagram •IPv6 – requires the original source to learn the path MTU and perform fragmentation 11 IPv4 Datagram Fragmentation • Usually performed by routers • Divides datagram into several, smaller datagrams called fragments • Fragment uses same header format as datagram • Each fragment forwarded independently

• Offset specifies where data belongs in original datagram • Offset actually stored as multiples of 8 octets • MORE FRAGMENTS bit turned off in header of fragment#3 12 IPv6 Fragmentation And Path MTU Discovery (PMTUD) • IPv6 uses a form of early binding • Path MTU Discovery (PMTUD) – A host should probe periodically by sending a larger datagram

13 Reassembly

• Ultimate destination puts fragments back together – Known as reassembly – No need to reassemble sub-fragments first • Timer used to ensure all fragments arrive – Timer started when first fragment arrives – If timer expires, entire datagram discarded • Header Fields Used For Datagram Reassembly – IPv4 datagram header • IDENTIFICATION •FLAGS • FRAGMENT OFFSET – IPv6 Fragment Extension Header • IDENTIFICATION •M • FRAGMENT OFFSET

14 Time to Live (IPv4) and Hop Limit (IPv6)

• how long allowed to remain in network • hop limit (i.e. 30, 60, 64)

• TTL field of datagram header decremented at each hop (i.e., each router) – If TTL reaches zero, datagram discarded • Prevents datagrams from looping indefinitely (in case forwarding error introduces loop) • IETF recommends initial value of 255 (max)

15 Optional IP Items

•IPv4 – the IP OPTIONS field that follows the destination address is used to send optional items •IPv6 – each of the extension headers is optional, and a given datagram may include multiple extensions

16 IPv4 Options

17 IPv6 Optional Extensions

18 Processing Options During Fragmentation

•IPv4 – The record route option should only be copied into one of the fragments – A source route option must be copied into all fragments •IPv6 – A datagram into two conceptual pieces: • unfragmentable • fragmentable – The Hop-By-Hop Header and Route Header are not fragmentable; other extension headers are fragmentable

19 IPv6 Processing Options During Fragmentation

20 Network Byte Order

• Little endian – The lowest memory address contains the low-order byte of the integer • Big endian – The lowest memory address holds the high-order byte of the integer

21 Checksum Field In IPv4 Datagram Header

• 16-bit 1's complement checksum • Over IP header only! • Recomputed at each hop

unsigned short checksum(char *ptr, int len) { unsigned short *buf = (unsigned short *) ptr; int nwords = len / 2; unsigned long sum;

for(sum = 0; nwords > 0; nwords--) sum += swap16(*buf++); sum = (sum >> 16) + (sum & 0xffff); sum += (sum >> 16); return swap16(~sum); }

22 Summary

• Internet Protocol (IP) – provides basic connectionless delivery service for the Internet – defines IP datagram to be the format of packets on the Internet • Datagram header – Has fixed fields – Specifies source, destination, and type – Allows options • Datagram encapsulated in network frame for transmission – Fragmentation • Needed when datagram larger than MTU • Usually performed by routers • Divides datagram into fragments – Reassembly • Performed by ultimate destination • If some fragment(s) do not arrive, datagram discarded – To accommodate all possible network hardware, IP does not require reliability (best-effort semantics)

23