15-441 Computer Networking IP Address Classes Subnetting
Total Page:16
File Type:pdf, Size:1020Kb
IP Address Classes (Some are Obsolete) Network ID Host ID 15-441 816 24 32 15-441 Computer Networking 15-641 Class A 0 Network ID Host ID Class B 10 Lecture 8 – IP Addressing & Packets Class C 110 Peter Steenkiste Class D 1110 Multicast Addresses Fall 2013 Class E 1111 Reserved for experiments www.cs.cmu.edu/~prs/15-441-F13 2 Subnetting Important Concepts • Add another layer to hierarchy • Hierarchical addressing critical for scalable • Variable length subnet masks system • Could subnet a class B into several chunks • Don’t require everyone to know everyone else • Reduces number of updates when something changes Network Host • Interaction with routing tables Network Subnet Host • Sub-netting simplifies network management Subnet • Break up the network into smaller chunks 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 Mask • Managed internally in network 3 4 1 Outline IP Address Problem (1991) • CIDR addressing • Address space depletion • Suppose you need 216 + 1 addresses? • In danger of running out of classes A and B • IP protocol • Class C too small for most domains • Very few class A – very careful about using them • IPv6 • Class B – greatest problem • Class B sparsely populated • But people refuse to give it back • NATs • Large forwarding tables • 2 Million possible class C groups 5 6 IP Address Utilization (‘97) Classless Inter-Domain Routing (CIDR) – RFC1338 • Arbitrary split between network & host part of address more efficient use of address space • Do not use classes to determine network ID • Use common part of address as network identifier • E.g., addresses 192.4.16 - 192.4.31 have the first 20 bits in common. Thus, we use these 20 bits as the network number 192.4.16/20 • Merge forwarding entries smaller tables • Use single entry for range in forwarding tables • Combined forwarding entries when possible • “Adjacent” in address space and same egress 7 8 2 CIDR Example IP Addresses: How to Get One? • Network is allocated 8 class C chunks, Network (network portion): 200.10.0.0 to 200.10.7.255 • Get allocated portion of ISP’s address space: • Move 3 bits of class C address to host address • Network address is 21 bits: 201.10.0.0/21 ISP's block 11001000 00010111 00010000 00000000 200.23.16.0/20 • Replaces 8 class C routing Organization 0 11001000 00010111 00010000 00000000 200.23.16.0/23 8 times entries with 1 entry Organization 1 11001000 00010111 00010010 00000000 200.23.18.0/23 • But how do routers know Organization 2 11001000 00010111 00010100 00000000 200.23.20.0/23 size of network address? 3 bits ... ….. …. …. • Routing protocols must carry Organization 7 11001000 00010111 00011110 00000000 200.23.30.0/23 prefix length with address 9 10 IP Addresses: How to Get One? CIDR Illustration • How does an ISP get block of addresses? • From Regional Internet Registries (RIRs) Provider is given 201.10.0.0/21 • ARIN (North America, Southern Africa), APNIC (Asia-Pacific), RIPE (Europe, Northern Africa), LACNIC (South America) Provider • How about a single host? • Hard-coded by system admin in a file • DHCP: Dynamic Host Configuration Protocol: dynamically 201.10.0.0/22 201.10.4.0/24 201.10.5.0/24 201.10.6.0/23 get address: “plug-and-play” • Host broadcasts “DHCP discover” msg • DHCP server responds with “DHCP offer” msg • Host requests IP address: “DHCP request” msg • DHCP server sends address: “DHCP ack” msg 11 12 3 CIDR Implications Outline • Longest prefix match!! • CIDR addressing • Forwarding example Advertise 201.10.0.0/21 201.10.6.0/23 • IP protocol Provider 1 Provider 2 • IPv6 201.10.0.0/22 201.10.4.0/24 201.10.5.0/24 201.10.6.0/23 or Provider 2 address • NATs 13 14 Host Routing Table Example Routing to the Network Destination Gateway Genmask Iface • Packet to 10.1.1.2 10.1.1.4 10.1.1.3 128.2.209.100 0.0.0.0 255.255.255.255 eth0 128.2.0.0 0.0.0.0 255.255.0.0 eth0 10.1.1.3 arrives H1 H2 127.0.0.0 0.0.0.0 255.0.0.0 lo 10.1.1/24 0.0.0.0 128.2.254.36 0.0.0.0 eth0 • Path is R2 – R1 – 10.1.0.2 10.1.0.1 10.1.1.1 R1 H3 H1 – H2 10.1.2.2 • From “netstat –rn” 10.1.0/24 • Host 128.2.209.100 when plugged into CS ethernet 10.1.2/23 10.1/16 10.1.8/24 • Dest 128.2.209.100 routing to same machine Provider R2 10.1.8.1 • Dest 128.2.0.0 other hosts on same ethernet 10.1.2.1 10.1.16.1 H4 • Dest 127.0.0.0 special loopback address 10.1.8.4 • Dest 0.0.0.0 default route to rest of Internet • Main CS router: gigrouter.net.cs.cmu.edu (128.2.254.36) 15 16 4 Routing Within the Subnet Routing Within the Subnet 10.1.1.2 10.1.1.2 • Packet to 10.1.1.3 10.1.1.4 10.1.1.3 • Packet to 10.1.1.3 10.1.1.4 10.1.1.3 • Matches 10.1.0.0/23 H1 H2 • Matches 10.1.1.1/31 H1 H2 10.1.1/24 10.1.1/24 10.1.0.2 10.1.0.2 Routing table at R2 10.1.0.1 • Longest prefix match 10.1.0.1 10.1.1.1 R1 H3 10.1.1.1 R1 H3 10.1.2.2 10.1.2.2 Destination Next Hop Interface Routing table at R1 10.1.0/24 10.1.0/24 127.0.0.1 127.0.0.1 lo0 Destination Next Hop Interface 10.1.2/23 127.0.0.1 127.0.0.1 lo0 10.1.2/23 Default or 0/0 provider 10.1.16.1 10.1/16 10.1/16 R2 10.1.8/24 R2 10.1.8/24 10.1.8.0/24 10.1.8.1 10.1.8.1 Default or 0/0 10.1.2.1 10.1.2.2 10.1.2.0/23 10.1.2.1 10.1.2.1 10.1.8.1 10.1.0.0/24 10.1.0.1 10.1.0.1 10.1.8.1 10.1.2.1 H4 10.1.2.1 H4 10.1.0.0/23 10.1.2.2 10.1.2.1 10.1.16.1 10.1.1.0/24 10.1.1.1 10.1.1.1 10.1.16.1 10.1.8.4 10.1.8.4 10.1.2.0/23 10.1.2.2 10.1.2.2 10.1.1.2/31 10.1.1.2 10.1.1.1 17 18 Outline IP Service Model • Low-level communication model provided by Internet • CIDR addressing • Datagram • Each packet self-contained • All information needed to get to destination • No advance setup or connection maintenance • IP protocol • Analogous to letter or telegram 0 4 8 121619242831 version HLen TOS Length • IPv6 IPv4 Identifier Flag Offset Packet TTL Protocol Checksum Header Format Source Address • NATs Destination Address Options (if any) Data 20 21 5 IPv4 Header Fields IPv4 Header Fields 3 • Version: IP Version • Identifier, flags, fragment offset used for fragmentation 0481216192428 ver- 1 HLe sio TOS Length n • Time to live n Fl Identifier ag Offset • 4 for IPv4 s TTL Protocol Checksum • Must be decremented at each router Source Address • HLen: Header Length • Packets with TTL=0 are thrown away Destination Address Options (if any) • Ensure packets exit the network • 32-bit words (typically 5) 3 0 4 8 1216192428 Data ver- 1 HLe • Protocol sio TOS Length n n Fl • TOS: Type of Service Identifier ag Offset • Demultiplexing to higher layer protocols s TTL Protocol Checksum • Priority information • TCP = 6, ICMP = 1, UDP = 17… Source Address • Header checksum Destination Address • Length: Packet Length Options (if any) • Ensures some degree of header integrity • Bytes (including header) Data • Relatively weak – 16 bit • Header format can change with versions • Source and destination IP addresses • First byte identifies version • Options • Length field limits packets to 65,535 bytes • E.g. Source routing, record route, etc. • Performance issues • In practice, break into much smaller packets for network • Poorly supported performance considerations 22 23 IP Delivery Model IP Fragmentation • Best effort service MTU = • Network will do its best to get packet to destination 2000 host router router MTU = 1500 • Does NOT guarantee: host • Any maximum latency or even ultimate success MTU = 4000 • Sender will be informed if packet doesn’t make it • Every network has own Maximum Transmission Unit • Packets will arrive in same order sent (MTU) • Just one copy of packet will arrive • Largest IP datagram it can carry within its own packet frame • Implications • E.g., Ethernet is 1500 bytes • Scales very well • Don’t know MTUs of all intermediate networks in advance • Higher level protocols must make up for shortcomings • IP Solution • Reliably delivering ordered sequence of bytes TCP • When hit network with small MTU, router fragments packet • Some services not feasible • Destination host reassembles the paper – why? • Latency or bandwidth guarantees 24 25 6 Fragmentation Related Fields IP Fragmentation Example #1 • Length router • Length of IP fragment host MTU = 4000 • Identification • To match up with other fragments • Flags Length = 3820, M=0 IP IP • Don’t fragment flag Header Data • More fragments flag • Fragment offset • Where this fragment lies in entire IP datagram • Measured in 8 octet units (13 bit field) 26 27 IP Fragmentation Example #2 Fragmentation is Harmful MTU = • Uses resources poorly 2000 router • Forwarding costs per packet router • Best if we can send large chunks of data Length = 2000, M=1, Offset = 0 • Worst case: packet just bigger than MTU Length = 3820, M=0 IP IP • Poor end-to-end performance IP IP Header Data Header Data • Loss of a fragment 1980 bytes 3800 bytes • Path MTU discovery protocol determines minimum Length = 1840, M=0, Offset = 1980 MTU along route • Uses ICMP error messages IP IP Header Data • Common theme in system design • Assure correctness by implementing complete protocol • Optimize common cases to avoid full complexity 1820 bytes 28 29 7 Internet Control Message Protocol IP MTU Discovery with ICMP (ICMP) • Short messages used to send error & other control information MTU = • Examples 2000 host router • Ping request / response router MTU = 1500 • Can use to check whether remote host reachable host • Destination unreachable MTU = 4000 • Indicates how packet got & why couldn’t go further • Typically send series of packets from one host to another • Flow control • Typically, all will follow same route • Slow down packet delivery rate • Routes remain stable for minutes at a time • Redirect • Makes sense to determine path MTU before sending real packets • Suggest alternate routing path for future messages • Operation • Router solicitation / advertisement • Send max-sized packet with “do not fragment” flag set • Helps newly connected host discover local router • If encounters problem, ICMP message will be returned • Timeout • “Destination unreachable: Fragmentation needed” • Packet exceeded maximum hop limit • Usually indicates MTU problem encountered 30 31 IP MTU Discovery with ICMP IP MTU Discovery with ICMP ICMP ICMP Frag.