Savera Tanwir Internet Protocol
The IP Protocol The IPv4 (Internet Protocol) header.
IP Packet Details Header and payload Header itself has a fixed part and variable part Version IPv4, IPv5 or IPv6 IHL, header length How long is the header, minimum value is 20 and the maximum is 60 bytes -> Options <= 40 bytes Type of Service To distinguish between different classes of service Total Length Length of header + data
IP Packet Details Identification Used with fragmentation, to identify which datagram a fragment belongs to DF and MF DF : Don t Fragment MF: More Fragments. All fragments except the last one has this bit set. Fragment Offset All fragments except the last one in the datagram are multiple of 8 bytes, the elementary fragment unit 13 bits of FO means a maximum of 8192 fragments/datagram
IP Packet Details Time To Live Is a counter to limit packet lifetime. Maximum lifetime is 255 seconds. It must be decremented at each hop Protocol Tells which higher layer protocol is used TCP or UDP etc Header Checksum Checksum of the header only Options Options are variable length Each begins with 1-byte code to identify the option
The IP Protocol Some of the IP options. 5-54
IP address Every host and router on the Internet has an IP address, which encodes its network number and host number The combination is unique; no 2 machines on the internet can have the same IP address All IP addresses are 32 bits long IP address refers to the interface; if a host belong to two networks, it has 2 IP addresses IP addresses are written in dotted decimal notation so instead of C0290614, we read and write it as 192.41.6.20 The lowest IP address is 0.0.0.0 and the highest is 255.255.255.255
Classful Addressing Class First Byte # Networks Hosts per Network Comments A < 128 2 7 (128) 2 24 2 (16M) Mostly used B 128 191 2 14 (16384) 2 16 2 (65534) Mostly used C 192 223 2 21 (2M) 2 28 2 (254) D 224 239 2 28 (268M) - Dynamic, multicast E 240 255 2 27 (134M) - reserved
IP Addresses Special IP addresses.
Problems with IP Addresses If a host moves to a new network, its IP address changes Limited address space Class thresholds, e.g., what if a class C net grows beyond 254 hosts? Routing structure is not hierarchical, but flat requires one routing table entry per network too many networks Improvement: CIDR
Original IP Addressing (net_id, host_id) pair, three classes, but Class A (16M hosts) too large for most sites Class C (254 hosts) too small Class B (65,534 hosts) is OK the Goldilocks problem Organizations requested Class B addresses to avoid outgrowing the 8-bit host field of Class C: only 65,534 Class B addresses not enough more than half of all Class B networks have fewer than 50 hosts (!) inefficient use
Problems with IP Addressing Large number of networks routing table size temporary fix: same IP prefix must be shared by multiple physical networks Exhaustion of Class B addresses temporary fix: use multiple class C addresses instead
Requirements for Address Extensions Any solution should not destroy the original addressing scheme backwards compatibility Sites are free to modify addresses in any way, provided that: all hosts/routers at site agree to use the new addressing scheme other sites can treat addresses as in the classic scheme Routing algorithms must be modified to handle addressing extensions
Subnets A campus network consisting of LANs for various departments.
Non-subnetted Example
Subnet Addressing Standardized in RFCs 950, 1122 Relates to class B addresses mostly, although it can also be used with class A and C addresses Large organizations may have multiple LANs, sharing a single IP network address System administrator may (a) decide to subnet, and (b) how many bits to allocate to subnet ID and host IDs Class B example: 0 16 24 31 1 0 Net ID Subnet ID Host ID
Subnet Addressing (cont'd) Result: three-level hierarchical addressing enables more hierarchical routing hides internal network structure from outside world reduces the size of routing tables
Subnetted Example
Subnet Masks Masking: the process of extracting the address of the physical network from an IP address A mask is a 32-bit number. Bits are set to 1, indicating the corresponding bit of the IP address is part of the network address (net ID or subnet ID) 0, indicating the corresponding bit of the IP address is part of the host ID Based on first bits of the IP address, you can always figure out how long (how many bits) the network ID is With a subnet mask, you can also figure out what the subnet ID is
Applying Bitwise-AND Operator
Subnet Masks Apply bitwise-and operation on IP address and mask to find the net ID and subnet ID How can you tell if a destination IP address is On the same subnet as you? On the same network as you? IP Address = 141.14.2.21 Network Mask = 255.255.0.0 Net ID = 141.14 IP Address = 141.14.2.21 Subnet Mask = 255.255.255.0 Net ID = 141.14 Subnet ID = 2
In-class Work Given the following IP address and associated mask, answer the questions below: IP Address : 10101000 00110001 11001110 00111100 Mask : 11111111 11111111 11110000 00000000 (a) Write down the dotted decimal form of the IP address. (b) Is subnetting being used? (c) What is the host ID? Give both binary and decimal representations.
Example There is a university with 35 departments and it used class B addresses. We can use a 6-bit subnet which will allow 64 ethernets and 1022 hosts in each (Why 1022 not 1024?) What will be the subnet mask?? 255.255.252.0 Alternatively we can write /22
In-class Work A Class B site has 30 physical networks 120 hosts in each network What are possible subnet masks to use? There are several Which one should we use? Why? What happens if number of networks increases to 40? What if the 10 new networks have 200 hosts each?
Search Complexity Classful Addressing IP address is right shifted 28 buts to yield a 4-bit class number The packets were then sorted into Class A, B, C, D, E The code for each class then masked the 8, 16 or 24 bits network number and right align it in a 32-bit word The network number was then looked up in the table After finding, the packet was forwarded
Search Complexity Without Class One more field is required The subnet mask Are multiple matches possible?? Yes The longest mask is used e.g. /24 instead of /22 For speedy process, VLSI chips were used with these algorithms embedded in them
Classless InterDomain Routing (CIDR) Basic idea: allocate multiple IP addresses in a way that results in a smaller number of routing table entries IP addresses must share the same high-order bits A block of contiguous addresses is collapsed, or summarized, into a single routing table entry of the form (network_address, count), such that network_address: the smallest address in the block count: total number of addresses in the block
Classless InterDomain Routing (cont d) Not restricted to Class C addresses old Class A, B, C networks no longer used with CIDR classless The Cinderella solution In reality, count not used size of each block is a power of two 32-bit mask indirectly specifies the size of the block
CIDR Example Block of 131,072 Class C networks (32M total addresses), starting at 194.0.0.0 Address Lowest Highest Mask Dotted Decimal 194.0.0.0 195.255.255.255 254.0.0.0 Binary 11000010 00000000 00000000 00000000 11000011 11111111 11111111 11111111 11111110 00000000 00000000 00000000
Allocation of Class C Address Space Lowest 194.0.0.0 198.0.0.0 200.0.0.0 202.0.0.0 204.0.0.0 Highest 195.255.255.255 199.255.255.255 201.255.255.255 203.255.255.255 223.255.255.255 Allocation Europe North America Central and South America Asia and the Pacific Reserved All sites in Europe have a common prefix CIDR summarizes 32M addresses into one entry only a single entry needed in most U.S. routers Once the packet gets to Europe, more detailed routing tables are needed
CIDR Example Three sites in Europe ask for 2048, 1024, and 4096 addresses, respectively Site Lowest Highest Mask Count 1 194.24.0.0 194.24.7.255 255.255.248.0 2048 = 2 11 2 194.24.8.0 194.24.11.255 255.255.252.0 1024 = 2 10 3 194.24.16.0 194.24.31.255 255.255.240.0 4096 = 2 12
CIDR Example (cont'd) Routers all over Europe are now updated with three entries: Network Address 11000010 00011000 00000000 00000000 Mask 11111111 11111111 11111000 00000000 Next Hop R1 11000010 00011000 00001000 00000000 11111111 11111111 11111100 00000000 R2 11000010 00011000 00010000 00000000 11111111 11111111 11110000 00000000 R3
CIDR Example (cont'd) Packet comes in addressed to 194.24.17.4: IP address of packet in binary = 11000010 00011000 00010001 00000100 Boolean ANDed with Site 1 mask = 11000010 00011000 00010000 00000000 does not match Site 1 base address Boolean ANDed with Site 2 mask = 11000010 00011000 00010000 00000000 does not match Site 2 base address Boolean ANDed with Site 3 mask = 11000010 00011000 00010000 00000000 matches Site 3 base address sent to R3
CIDR Routing Router entries not tried sequentially; indexing tricks used Longest prefix match if two entries match, the one whose mask has the most 1 bits wins Studies claim that if: CIDR were applied to all IP addresses, and existing IP addresses were reallocated according to continental boundaries/isps Then routing table entries could be reduced significantly http://www.cidr-report.org/ Short-term solution long-term solution: IPv6
Network Address Translation RFC-1631 A short term solution to the problem of the depletion of IP addresses Long term solution is IP v6 (or whatever is finally agreed on) CIDR (Classless InterDomain Routing ) is a possible short term solution NAT is another NAT is a way to conserve IP addresses Hide a number of hosts behind a single IP address
Private Network Private IP network is an IP network that is not directly connected to the Internet IP addresses in a private network can be assigned arbitrarily. Not registered and not guaranteed to be globally unique Generally, private networks use addresses from the following experimental address ranges (non-routable 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
Private Addresses
Network Address Translation (NAT) NAT is a router function where IP addresses (and possibly port numbers) of IP datagrams are replaced at the boundary of a private network NAT is a method that enables hosts on private networks to communicate with hosts on the Internet NAT is run on routers that connect private networks to the public Internet, to replace the IP address-port pair of an IP packet with another IP address-port pair.
Basic operation of NAT Private network Internet Source = 10.0.1.2 Destination = 213.168.112.3 Source = 128.143.71.21 Destination = 213.168.112.3 private address: 10.0.1.2 public address: 128.143.71.21 NAT device public address: 213.168.112.3 H1 Source = 213.168.112.3 Destination = 10.0.1.2 Source = 213.168.112.3 Destination = 128.143.71.21 H5 Private Address Public Address 10.0.1.2 128.143.71.21 NAT device has address translation table
IP masquerading Also called: Network address and port translation (NAPT), port address translation (PAT). Scenario: Single public IP address is mapped to multiple hosts in a private network. NAT solution: Assign private addresses to the hosts of the corporate network NAT device modifies the port numbers for outgoing traffic
IP masquerading Source = 10.0.1.2 Source port = 2001 Source = 128.143.71.21 Source port = 2100 private address: 10.0.1.2 H1 Private network NAT device 128.143.71.21 Internet private address: 10.0.1.3 H2 Source = 10.0.1.3 Source port = 3020 Source = 128.143.71.21 Source Port = 4444 Private Address Public Address 10.0.1.2/2001 128.143.71.21/2100 10.0.1.3/3020 128.143.71.21/4444
Concerns about NAT Performance: Modifying the IP header by changing the IP address requires that NAT boxes recalculate the IP header checksum Modifying port number requires that NAT boxes recalculate TCP checksum Fragmentation Care must be taken that a datagram that is fragmented before it reaches the NAT device, is not assigned a different IP address or different port numbers for each of the fragments. Layering principle is violated
Concerns about NAT End-to-end connectivity: NAT destroys universal end-to-end reachability of hosts on the Internet. A host in the public Internet often cannot initiate communication to a host in a private network. The problem is worse, when two hosts that are in a private network need to communicate with each other. Connectionless -> Connection Oriented If NAT router fails, all connections fail
Concerns about NAT IP address in application data: Applications that carry IP addresses in the payload of the application data generally do not work across a privatepublic network boundary. Some NAT devices inspect the payload of widely used application layer protocols and, if an IP address is detected in the application-layer header or the application payload, translate the address according to the address translation table. FTP and other Protocols are not difficult to implement