Lecture 11. Lecture 11. The Internet Layer The Internet Layer IP (Internet Protocol) IP (Internet Protocol) & & ICMP (Internet Control Message Protocol) ICMP (Internet Control Message Protocol) Giuseppe Bianchi Internet Protocol (IP) Internet Protocol (IP) RFC 791 (1981) RFC 791 (1981) � Connectionless � datagram delivery service � best-effort � Unreliable � no guarantees of reception & packet order � error-handling algorithm: throw away packet! � Upon buffer congestion � upon error check failed Giuseppe Bianchi IP functions IP functions � ��������������� � �������������������������������������������� ��������� � ������������������� ������ ��������������� � ����� ������� ��������� � ���� �������� �� ����������������� � ������������� � �������������������������� ��������� � ���� ������ � ������������������������������������������ � ��������������� ������� �������������������� ������� �� ������ ����� �������� Giuseppe Bianchi 1
IP datagram IP datagram format format 20 bytes 20 bytes header header (minimum) (minimum) 0 3 7 15 31 Version Header Type of Service Total Length length TOS flags 16 bit identification 13 bit fragment offset 3 bit Time to Live Protocol Header checksum TTL 32 bit source IP address 32 bit destination IP address Options (if any) Padding (0s) Data (if any) Giuseppe Bianchi Version Header Type of Service Total Length length TOS flags 16 bit identification 13 bit fragment offset 3 bit Time to Live Protocol Header checksum TTL 32 bit source IP address 32 bit destination IP address � Version: 0100 (IPv4) � allows to use multiple IP versions simultaneously… � Header length: in 32bit words � default: 0101 (5 x 32bit words = 20 bytes) � may extend header length up to 60 bytes � SRC and DEST addresses � obvious… Giuseppe Bianchi Version Header Type of Service Total Length length TOS flags 16 bit identification 13 bit fragment offset 3 bit Time to Live Protocol Header checksum TTL 32 bit source IP address 32 bit destination IP address � Total length: 16 bits � up to 65535 (including header) � Necessary, as you cannot rely on datalink for data size � example: Ethernet has minimum payload size = 46 bytes � but you may send smaller IP datagram. � How to recognize how much of the 46 bytes is IP datagram? � Protocol: specifies to which upper layer protocol the datagram must be delivered � 1=ICMP; 2=IGMP, 6=TCP, 17=UDP Giuseppe Bianchi 2
Why the protocol field? Why the protocol field? Demultiplexing Demultiplexing! ! TCP UDP ICMP … ??????? Typical approach Adopted in most protocols IP (see e.g. datalink protocols) Demultiplexing was also a TCP/UDP feature (versus application layer) done by using full socket address <src IP, src Port, dest IP, dest Port> 8 bits: not too large (in principle the Internet is not doomed to TCP/UDP)! Giuseppe Bianchi Version Header Type of Service Total Length length TOS flags 16 bit identification 13 bit fragment offset 3 bit Time to Live Protocol Header checksum TTL 32 bit source IP address 32 bit destination IP address � TTL: max no. of hops the datagram can remain in the network � from 0 to 255; generally initially set to 64 � each router decrements TTL of 1 (or every 1second latency) � when TTL=0 (input datagram with TTL=1), packet thrown away � sender notified via ICMP message � Prevents datagrams from traveling forever (e.g. captured in loops) � Header Checksum: header only � Same approach of TCP/UDP � efficient incremental computation at routers (RFC 1141), since only TTL changes (decrements) Giuseppe Bianchi Version Header Type of Service Total Length length TOS flags 16 bit identification 13 bit fragment offset 3 bit Time to Live Protocol Header checksum TTL 32 bit source IP address 32 bit destination IP address � ������������������ TOS: 0 1 2 3 4 5 6 7 � ������������� Precedence TOS bits 0 � � !�������"�#�$�%�� field � ����"��������&������� � ����#����'���&������������ � ����(�� !������������������ � ����$����'���&������������� � ������������)�*��������������� � ����%��������&��������������� � ���������������� Giuseppe Bianchi 3
TOS bits TOS bits � RFC 1340 & 1349 specify how these bits should be set by standard apps. Examples: � FTP data = max_thr � telnet = min_del � SNMP (simple network management protocol) = max_reliability � NNTP (usenet news) = min_cost � Routers may ignore TOS � TOS is just a suggestion � In practice, TOS field not set by hosts and ignored by routers until 1992-1993 Today (from 1998), TOS field renascence: Differentiated Services Code Point (DSCP) Giuseppe Bianchi Options Options Up to 40 extra bytes (10 x 32bit words) available for options. Common options: � Record Route Option (RRO) � 60 bytes header set with remaining options field empty � each crossed router adds its IP address � maximum of 9 hops recordable - not practical today � Timestamp Option � like RRO, but routers also stamp crossing time instant � Source Route Option (Loose, Strict) � allows sender to specify which routers must be crossed by the datagram (i.e. bypasses network routing tables) � loose : cross the routers specified, in the order, plus others along the path (interconnecting specified ones) � strict : ALL routers specified, and no others! (may fail if routers not directly connected) Giuseppe Bianchi Record Route Option details Record Route Option details 39 bytes code len ptr IPaddr 1 IPaddr 2 IPaddr 9 Ptr=8 Ptr=36 Ptr=4 Ptr=12 Ptr=40 � Code (1 byte): specifies option � code for RRO = 7 � len (1 byte): specifies bytes reserved for option � max=39bytes as extra header is at most 40 bytes, generally 39 � ptr (1 byte): tells where next address must be stored � minimum ptr value = 4, others multiple (8, 12, 16, 20, 24, 28, 32, 36) � ptr=40 indicates that list is full Which router IP address recorded (there are two!)??? RFC791 says outgoing interface! Giuseppe Bianchi 4
Traceroute Traceroute � Originally a debugging software program written by Van Jacobson � Test TTL field � Makes smart use of TTL � Allows to trace the route from source to destination host � Not limited to 9 hops as when RR option is used � Does not require ANY specific router capability Giuseppe Bianchi Traceroute idea (1) idea (1) Traceroute � Send subsequent sets of 3 UDP packets to destination � Start using TTL=1 � after each set, increments TTL of 1 unit � Listen for the response… router router router router host host router Giuseppe Bianchi Traceroute Traceroute idea (2) idea (2) � When router decrements TTL to 0: � throws away packet � returns ICMP “time exceeded” message � clearly containing router IP address � Transmitting host: � records router (pretty print with reverse name lookup) � computes RTT to router router router n RTT router router host router host Giuseppe Bianchi 5
ICMP “Time exceeded” error ICMP “Time exceeded” error ICMP header ICMP data part 8 bytes IP header IP data carrying src IP = router IP 0 7 8 15 31 Type (11) Code (0 or 1) Checksum 8 bytes Unused (must be all 0s) IP Header (including options) + first 8 bytes of original IP data Code = 0: traceroute case (router detected a TTL decrement to 0) Code = 1: timed out while reassembling Giuseppe Bianchi Traceroute idea (3) idea (3) Traceroute � !��� +�,������� �� ������������������ -�./�0120�� .��3+45�.!� � ���������+,�������������������������������������������� �������164����������7����������������8 � 0������������������������������������������ �����������9 router router n router router ICMP port host router host unreachable Giuseppe Bianchi Router: which IP returned? Router: which IP returned? Traceroute from 131.175.21.3: 131.175.21.3 131.175.21.8 131.175.12.42 131.175.15.2 131.175.21.8 Traceroute from 131.175.15.2: 131.175.12.32 131.175.15.1 131.175.12.32 131.175.12.42 131.175.21.3 131.175.15.1 131.175.15.2 Giuseppe Bianchi 6
Recommend
More recommend