CPSC 360 - Network Programming Internet Protocol (IP) Michele Weigle Department of Computer Science Clemson University mweigle@cs.clemson.edu March 14, 2005 http://www.cs.clemson.edu/~mweigle/courses/cpsc360 Internet Protocol (IP)! Addressing - Ch 18 " Classful " Classless (CIDR) " Special Addresses! Address Resolution (ARP) - Ch 19! Datagrams and Forwarding - Ch 20! Encapsulation and Fragmentation - Ch 21 "Encapsulation "Fragmentation "Reassembly
IP Addressing! Goal of internetworking: Provide seamless communication system "hide details of physical networks! Need addressing "use hardware addresses? IP Addressing! Each host assigned 32-bit number (IP address) "network prefix "host suffix! Why use hierarchical addressing? "each computer assigned a unique address "suffixes can be assigned locally w/o global coordination
IP Addressing Classful (or class-based) Addressing! Class A " 128 networks " 65,536 to 224 hosts! Class B " 16,384 networks " 256 to 65,536 hosts! Class C " 221 networks " less than 256 hosts! Class D " 28-bit multicast addresses " No origin or network information is encoded 0 1 2 3 4 8 16 24 31 0 1 0 1 2 3 4 8 16 24 31 1 net id 0 1 2 3 4 8 16 24 31 1 0 net id 0 1 2 3 4 8 16 24 31 1 0 net id host id (IP addresses 1.0.0.0 through 127.255.255.255) host id (IP addresses 128.0.0.0 through 191.255.255.255) 1 1 0 multicast address host id (IP addresses 192.0.0.0 through 223.255.255.255) (IP addresses 224.0.0.0 through 239.255.255.255) Addressing Classful Addressing Class A B C D Range 0-127 128-191 192-223 224-239
Addressing Classful Addressing! Classes aren t divided equally! 1/2 of all addresses are in Class A Addressing Private Addresses! Network addresses assigned by IANA (Internet Assigned Number Authority)! Private addresses available "10.0.0.0-10.255.255.255 "172.16.0.0-172.31.255.255 "192.168.0.0-192.168.225.255 (see RFC 1597)
Addressing Classful Addressing Addressing Classless Addressing (CIDR)! Why don t we use classful addressing anymore?! Today, we use subnet addressing, or classless addressing (CIDR)!Netmask "32-bit number to identify which bits are network prefix in the IP address
Addressing Classless Addressing (CIDR)! Router compares destination IP with known network IP "D is dest IP addr, M is mask, A is network IP addr "A == (D & M)! Example: "M = 11111111 11111111 00000000 00000000 (255.255.0.0) "D = 10000000 00001010 00000010 00000011 (128.10.2.3) "A = 10000000 00001010 00000000 00000000 (128.10.0.0) "Using binary AND between M and D, we get A. Addressing Classless Addressing (CIDR)! With CIDR, 128.10.0.0 Class B address becomes 128.10.0.0/16 "first 16 bits are network prefix "second 16 bits are host suffix "see Appendix 3 (pg. 686) 10000000 128 00001010 10 00000000 0 00000000 0 Network part 11001000 00010111 00010000 00000000 200.23.16.0 / 23 Host part
Addressing Classless Addressing (CIDR)! Example w/classful addressing "ISP has one class B address (128.211.0.0) "Two customers have 12 computers "ISP can t assign them (can t break up the class B address space)! Example w/classless addressing "one customer gets 128.211.0.16/28 "one customer gets 128.211.0.32/28 "ISP keeps rest of the addresses for other customers Addressing Classless Addressing (CIDR)! One customer gets 128.211.0.16/28 " 28 bits for network prefix, 4 bits for host suffix " 10000000 128 " 11010011 211 " 00000000 0 " 00001000 16! How do customers assign addresses to hosts?! 128.211.0.17-128.211.0.30 " host part all 0s and host part all 1s are reserved
/8 255.0.0.0 16777216 Class A /9 255.128.0.0 8388608 /10 255.192.0.0 4194304 /11 255.224.0.0 2097152 /12 255.240.0.0 1048576 /13 255.248.0.0 524288 /14 255.252.0.0 262144 /15 255.254.0.0 131072 /16 255.255.0.0 65536 Class B /17 255.255.128.0 32768 ISP / large business /18 255.255.192.0 16384 ISP / large business /19 255.255.224.0 8192 ISP / large business /20 255.255.240.0 4096 Small ISP / large business /21 255.255.248.0 2048 Small ISP / large business /22 255.255.252.0 1024 /23 255.255.254.0 512 /24 255.255.255.0 256 Class C /25 255.255.255.128 128 Large LAN /26 255.255.255.192 64 Small LAN /27 255.255.255.224 32 Small LAN /28 255.255.255.240 16 Small LAN /29 255.255.255.248 8 /30 255.255.255.252 4 /31 255.255.255.254 2 /32 255.255.255.255 1 Addressing Special IP Addresses! 127.0.0.1 is the most popular address for loopback
Internet Protocol (IP)! Addressing - Ch 18! Address Resolution (ARP) - Ch 19! Forwarding - Ch 20! Fragmentation - Ch 21 ARP!Each NIC has a MAC address and an IP address!when would we need to know the MAC address of a computer s interface?!how to find the MAC address given an IP address? "is there a direct mapping?
ARP! Address Resolution Protocol (ARP) "request message!ip address of destination "reply message!ip address of destination!mac address of destination! Request messages are broadcast! Reply messages are unicast ARP and Caching! Each computer maintains an ARP table "entries time out after ~20 minutes!entries added when ARP replies are received! Entries added when ARP request received and we re responding
ARP Sending Messages Across a WAN! Applications use IP addresses! How do messages get to the destination across a WAN?! Example: "User sends HTTP request "IP destination address is web server "What s the address in the link layer destination field? Internet Protocol (IP)! Addressing - Ch 18! Address Resolution (ARP) - Ch 19! Forwarding - Ch 20! Fragmentation - Ch 21
IP Datagrams and Forwarding IP Header! Once we add the IP header, our data packets are called datagrams! At the link layer (once we add the Ethernet header, for example), they are called frames ver head. len 16-bit identifier time to live 32 bits type of service protocol type flgs length fragment offset Internet checksum 32 bit source IP address 32 bit destination IP address Options (if any) data (variable length, typically a TCP segment or UDP datagram) IP Datagrams and Forwarding if (( mask[i] & D) == destination[i]) forward to nexthop[i];
IP Datagrams and Forwarding Best Effort! IP is connectionless! IP is not reliable! Makes the best effort to deliver datagrams! Does not go to extra effort to prevent "duplication "delays "out-of-order delivery "corruption of data "loss Internet Protocol (IP)! Addressing - Ch 18! Address Resolution (ARP) - Ch 19! Forwarding - Ch 20! Fragmentation - Ch 21
Encapsulation! Routers may need to translate from one type of physical network to another! Operation: "Frame arrives containing link-layer destination address of router "Router extracts IP datagram and throws away frame header "Router determines next-hop depending upon IP address "Router builds new frame header! what s the destination address in the frame? Encapsulation 2 8 bytes 6 bytes 6 bytes bytes 46 to 1500 bytes 4 bytes Preamble Destination Address Source Address Data CRC CRC Type Link layer addresses (not same as IP addresses) IP header TCP header data user data IP Datagram TCP Segment
Fragmentation! MTU - maximum transmission unit "defined for each type of hardware technology "maximum amount of data in a frame! What if frame travels from network with one MTU to one with smaller MTU? "fragmentation Fragmentation! Router sets bit in flags field! All fragments have same identifier! Fragment offset identifies how the fragment should be reassembled! Otherwise, IP header unchanged ver head. len 32 bits 16-bit identifier flgs time to live type of service protocol type length fragment offset Internet checksum 32 bit source IP address 32 bit destination IP address Options (if any) data (variable length, typically a TCP segment or UDP datagram)
Fragmentation Ethernet MTU example length = 4000 ID = x fragment = 0 offset = 0 One large IP datagram becomes several smaller IP datagrams IP datagram (20 byte IP header + 3,980 byte TCP segment) encapsulated in one FDDI frame length =1500 length =1500 length =1040 ID =x ID =x ID =x fragment =1 fragment =1 fragment =0 offset =0 offset =1480 offset =2960 Each IP datagram encapsulated in one Ethernet frame! Consider a 3,980 byte message sent in an FDDI frame! Generates 3 fragments when it transits an Ethernet " How much application data is in each fragment? Reassembly! Who reassembles the datagram?!why?! Fragmented datagram cannot be reassembled unless all fragments are received
Fragmentation of Fragments?! Can a fragment be fragmented?