IP - Internet Protocol (Based on Kurose & Ross) Performs network and internetworking functions Probably the most important protocol No Internet without IP Rich, complex and beautiful!
Datagram networks: the Internet model Packets between same source-destination pair may take different paths application transport network data link physical 1. Send data 2. Receive data
Internet Network layer functions Transport layer: TCP, UDP IP protocol addressing conventions datagram format packet handling conventions Routing protocols path selection RIP, OSPF, BGP Network layer forwarding table ICMP protocol error reporting router “signaling” Link layer physical layer
IP Features Connectionless (best effort) End to end delivery Data Units are datagrams or packets Global Addressing Routing Fragmentation and Reassembly Route recording, time stamping options QoS options, but seldom used in v4
32 bit destination IP address IP datagram format ver length 32 bits data (variable length, typically a TCP or UDP segment) 16-bit identifier Internet checksum time to live 32 bit source IP address IP protocol version number header length (bytes) max number remaining hops (decremented at each router) for fragmentation/ reassembly total datagram length (bytes) upper layer protocol to deliver payload to head. len type of service “type” of data flgs fragment offset upper layer 32 bit destination IP address Options (if any) E.g. timestamp, record route taken, specify list of routers to visit. how much overhead with TCP? 20 bytes of TCP 20 bytes of IP = 40 bytes + app layer overhead
Header Fields (1) Version Internet header length Currently 4 IP v6 Internet header length In 4 byte words Including options if used Type of service – priority (3 bits), DTR (Delay, Throughput, Reliability) Total length Of datagram, in octets <= 65535
Header Fields (2) Identification (datagram) Flags Sequence number Used with addresses and user protocol to identify datagram uniquely Flags M - More bit D - Don’t fragment Fragmentation offset – units of 8 octets Time to live TTL (<= 255) Protocol Next higher layer to receive data field at destination ICMP (1), TCP (6), UDP (17)
Protocol numbers http://www. iana Protocol numbers http://www.iana.org/assignments/protocol-numbers c:/winnt/system32/drivers/etc 0 HOPOPT IPv6 Hop-by-Hop Option ICMP Internet Control Message IGMP Internet Group Management GGP Gateway-to-Gateway IP IP in IP (encapsulation) ST Stream TCP Transmission Control EGP Exterior Gateway Protocol] IGP any private interior gateway (used by Cisco for their IGRP) 17 UDP User Datagram
Header Fields (3) Header checksum Source address Destination address Reverified and recomputed at each router 16 bit ones-complement sum of all 16 bit words in header Set to zero during calculation Source address Destination address Options Padding To fill to multiple of 4 bytes long
Options Specified as Type + length + value Security – classification level Strict Source Routing Loose Source Routing Record Route Time Stamp
Data Field Carries user data from next layer up – TCP, UDP, ICMP etc. Integer multiple of 8 bits long (octet) Max length of datagram (header plus data) 65,535 octets
Fragmentation & Re-assembly Different packet sizes for different networks When to re-assemble At destination (IP approach) Results in packets getting smaller as data traverses internet Intermediate re-assembly (possible, but not used) Need large buffers at routers Buffers may fill with fragments All fragments must go through same router Inhibits dynamic routing
Fragmentation - fields Uses fields in header D flag – don’t fragment Datagram Identifier (ID) Total length (data length + 20 bytes) Offset Position of fragment of user data in original datagram In multiples of 64 bits (8 octets) ‘M’ or More flag - last fragment?
Another example An IP packet with: total length 4820, datagram ID = 571 (decimal), fragment offset 32 and M=0 has to be fragmented for an Ethernet network. Show how this could be done, giving the values of the relevant header fields in all the fragments.
Solution Frag ID M D Offset Comments 1 571 32 The original offset 2 217 185 (1480/8) + 32 3 402 Another 185 4 587 The original datagram is the last fragment of a larger packet, offset = 32. Ethernet payload = 1500 (1480 + IP header)
Dealing with Failure Re-assembly may fail if some fragments get lost Need to detect failure Re-assembly time out Assigned to first fragment to arrive If timeout expires before all fragments arrive, discard partial data
Node Addresses - MAC & IP MAC addresses (6 bytes) Defined at layer 2 OSI AKA Physical addresses Fixed, burned-in to NIC Guaranteed globally-unique IP addresses (4 bytes, 4.295 x 109 addresses) Defined at layer 3 Referred to as Logical addresses Configured by network manager Facilitates logical grouping The total number of possible combinations of 32 bits is 4.295 billion, but not all addresses are actually usable.
IP addresses An IP address consists of two parts: The network address The first part of the address Identifies the network to which a host belongs Used by routers in path determination The host address The last part of the address Used in the local network to identify a host Network portion Host portion 32-bit IP address A subnet mask is used to mark the length of the network part A ‘1’ indicates a network bit, a ‘0’ indicates a host bit If network portion is 24 bits and host portion is 8 bits subnet mask will be 11111111111111111111111100000000 written in dotted decimal format as 255.255.255.0 Mask: 1111111 …. 111111 00000 …. 00000
IP Address Classes Class E: 1111xxxx: reserved for IAB R&D network host 10 110 1110 multicast address A B C D class 1.0.0.0 to 127.255.255.255 128.0.0.0 to 191.255.255.255 192.0.0.0 to 223.255.255.255 224.0.0.0 to 239.255.255.255 32 bits Class E: 1111xxxx: reserved for IAB R&D Mask: 1’s for network bits, 0 for host bits e.g. 255.255.0.0, 255.255.255.0, 255.255.224.0 etc Three main classes of address are used, based on the organisation size: Class A Range 0.0.0.0 – 127.255.255.255 First octet 0xxxxxxx Number of hosts per network 224 = 16,777,216 Usable hosts per network 224 -2 = 16,777,214 Subnet mask 255.0.0.0 Class B Range 128.0.0.0 – 191.255.255.255 First octet 10xxxxxx Number of hosts per network 216 = 65536 Usable hosts per network 216 -2 = 65534 Subnet mask 255.255.0.0 Class C Range 192.0.0.0 – 223.255.255.255 First octet 110xxxxx Number of hosts per network 28 = 256 Usable hosts per network 28 -2 = 254 Subnet mask 255.255.255.0
Class A Start with binary 0 (first bit) Addresses starting with 00000000 reserved 01111111 (127) reserved for loopback Range 1.x.x.x to 126.x.x.x All allocated 16,777 million hosts per network
Class B Start 10 (first 2 binary bits) Range 128.x.x.x to 191.x.x.x Second octet also included in network address 214 = 16,384 class B networks All allocated 216 = 65536 host-ids per networks
Class C Start 110 (first 3 binary bits) Range 192.x.x.x to 223.x.x.x Second and third octet also part of network address 221 = 2,097,152 addresses Nearly all allocated 256 host-ids per network
Special Addresses First octet >= 224 (E0 1110 0000) - multicast. First octet >= 240 (F0 11110000): IAB use 127.X.X.X - local loop back address for debugging Host-id = 0 refers to network. 194.203.121.0 Net-id = 0 - 'this network‘ 128.0.124.56 (class B address) 0.0.0.0: used by RARP, BOOTP DHCP – own address unknown 0.0.0.0: destination address for default route in routers. Broadcast addresses: host part is all 1’s Local broadcast 255.255.255.255 Not forwarded by routers, to all hosts in sender’s broadcast domain Directed broadcast: <Network Address>.255: forwarded by routers to specified network; to all hosts in specified network
Private Addresses 10.0.0.0 – 10.255.255.255 172.16.0.0 – 172.31.255.255 192.168.0.0 – 192.168.255.255 Not routable on the public Internet. Can be reused on private (home, company, campus) networks. A home router may use these for PCs connected to its ports, with NAT
IP addressing: suffix notation Address Class scheme wastes addresses CIDR: Classless InterDomain Routing Network portion of address of arbitrary length address format: a.b.c.d/x x is the number of bits in network portion of address Will be discussed later
Addresses & Interfaces 223.1.1.1 IP address: for each host, for each router interface interface: connection between host/router and physical link router’s typically have multiple interfaces host may have multiple interfaces 223.1.2.1 223.1.1.2 223.1.1.4 223.1.2.9 223.1.2.2 223.1.1.3 223.1.3.27 223.1.3.1 223.1.3.2 223.1.1.1 = 11011111 00000001 00000001 00000001 223 1 1 1
What is an ‘IP Network’? From IP address perspective device interfaces with same network part of IP address can physically reach each other without intervening router 223.1.1.1 223.1.2.1 223.1.1.2 223.1.1.4 223.1.2.9 223.1.2.2 223.1.1.3 223.1.3.27 LAN 223.1.3.1 223.1.3.2 A network consisting of 3 IP networks (for IP addresses starting with 223, first 24 bits are network address)
How to find the networks? 223.1.1.2 Detach each interface from router, host create “islands of isolated networks 223.1.1.1 223.1.1.4 223.1.1.3 223.1.9.2 223.1.7.0 223.1.9.1 223.1.7.1 223.1.8.1 223.1.8.0 223.1.2.6 223.1.3.27 223.1.2.1 223.1.2.2 223.1.3.1 223.1.3.2
Address Allocation I How does host get IP address? hard-coded by system admin in a file Windows: control-panel->network->configuration->tcp/ip->properties UNIX: /etc/rc.config DHCP: Dynamic Host Configuration Protocol: dynamically get address from as server “plug-and-play”
Address Allocation II Q: How does network get network address? A: gets allocated portion of its provider ISP’s address space ISP's block 11001000 00010111 00010000 00000000 200.23.16.0/20 Organization 0 11001000 00010111 00010000 00000000 200.23.16.0/23 Organization 1 11001000 00010111 00010010 00000000 200.23.18.0/23 Organization 2 11001000 00010111 00010100 00000000 200.23.20.0/23 ... ….. …. …. Organization 7 11001000 00010111 00011110 00000000 200.23.30.0/23
Address Allocation III Q: How does an ISP get a block of addresses? A: IANA: Internet Assigned Numbers Authority Names and Numbers allocates addresses manages DNS assigns domain names, resolves disputes http://www.iana.org/
Getting a datagram from source to destination (1) forwarding table in A Dest. Net. next router Nhops 223.1.1 1 223.1.2 223.1.1.4 2 223.1.3 223.1.1.4 2 IP datagram: misc fields source IP addr dest data 223.1.1.1 223.1.1.2 223.1.1.3 223.1.1.4 223.1.2.9 223.1.2.2 223.1.2.1 223.1.3.2 223.1.3.1 223.1.3.27 A B E datagram remains unchanged, as it travels source to destination addr fields of interest here
Getting a datagram from source to destination (2) forwarding table in A misc fields Dest. Net. next router Nhops 223.1.1 1 223.1.2 223.1.1.4 2 223.1.3 223.1.1.4 2 223.1.1.1 223.1.1.3 data Starting at A, send IP datagram addressed to B: look up net. address of B in forwarding table find B is on same net. as A link layer will send datagram directly to B inside link-layer frame B and A are directly connected 223.1.1.1 223.1.1.2 223.1.1.3 223.1.1.4 223.1.2.9 223.1.2.2 223.1.2.1 223.1.3.2 223.1.3.1 223.1.3.27 A B E
Getting a datagram from source to destination (3) forwarding table in A misc fields Dest. Net. next router Nhops 223.1.1 1 223.1.2 223.1.1.4 2 223.1.3 223.1.1.4 2 223.1.1.1 223.1.2.2 data Starting at A, dest. E: look up network address of E in forwarding table E on different network A, E not directly attached routing table: next hop router to E is 223.1.1.4 link layer sends datagram to router 223.1.1.4 inside link-layer frame datagram arrives at 223.1.1.4 continued….. 223.1.1.1 223.1.1.2 223.1.1.3 223.1.1.4 223.1.2.9 223.1.2.2 223.1.2.1 223.1.3.2 223.1.3.1 223.1.3.27 A B E
Getting a datagram from source to destination (4) forwarding table in router Dest. Net router Nhops interface 223.1.1 - 1 223.1.1.4 223.1.2 - 1 223.1.2.9 223.1.3 - 1 223.1.3.27 misc fields 223.1.1.1 223.1.2.2 data Arriving at 223.1.1.4, destined for 223.1.2.2 look up network address of E in router’s forwarding table E on same network as router’s interface 223.1.2.9 router, E directly attached link layer sends datagram to 223.1.2.2 inside link-layer frame via interface 223.1.2.9 datagram arrives at 223.1.2.2 223.1.1.1 223.1.1.2 223.1.1.3 223.1.1.4 223.1.2.9 223.1.2.2 223.1.2.1 223.1.3.2 223.1.3.1 223.1.3.27 A B E