Network Layer PREPARED BY AHMED ABDEL-RAOUF
Network layer transport segment from sending to receiving host on sending side encapsulates segments into datagrams on receiving side, delivers segments to transport layer network layer protocols in every host, router router examines header fields in all IP datagrams passing through it application transport network data link physical network data link physical network data link physical network data link physical network data link physical network data link physical network data link physical network data link physical network data link physical network data link physical network data link physical network data link physical application transport network data link physical
Two Key Network-Layer Functions routing algorithm Forwarding move packets from router s input to appropriate router output Within single router local forwarding table header value output link 0100 0101 0111 1001 3 2 2 1 Routing determine route taken by packets from source to dest. Process of planning trip from source to dest. value in arriving packet s header 0111 3 2 1
What s inside the router(router Arch.) Two key router functions: run routing algorithms/protocol (RIP, OSPF, BGP) forwarding datagrams from incoming to outgoing link
Input Port Functions Physical layer: bit-level reception Data link layer: e.g., Ethernet see chapter 5 Decentralized switching: given datagram dest., lookup output port using forwarding table in input port memory goal: complete input port processing at line speed queuing: if datagrams arrive faster than forwarding rate into switch fabric
Three types of switching fabrics
Router Architecture Consider a router with a switch fabric, 2 input ports (A and B) and 2 output ports (C and D). Suppose the switch fabric operates at 1.5 times the line speed. If, for some reason, all packets from A are destined to D, and all packets from B are destined to C, can a switch fabric be designed so that there is no input port queuing? Explain why or why not in one sentence.
Router Architecture Consider a router with a switch fabric, 2 input ports (A and B) and 2 output ports (C and D). Suppose the switch fabric operates at 1.5 times the line speed. If, for some reason, all packets from A are destined to D, and all packets from B are destined to C, can a switch fabric be designed so that there is no input port queuing? Explain why or why not in one sentence. YES, Use crossbar fabric let A >D, B >C operate at line speed simultaneously (at the same time ).
Router Architecture (Problem) Consider a router with a switch fabric, 2 input ports (A and B) and 2 output ports (C and D). Suppose the switch fabric operates at 1.5 times the line speed. Suppose now packets from A and B are randomly destined to both C and D. Can a switch fabric be designed so that there is no input port queuing? Explain why or why not in one sentence.
Router Architecture (Problem) Consider a router with a switch fabric, 2 input ports (A and B) and 2 output ports (C and D). Suppose the switch fabric operates at 1.5 times the line speed. Suppose now packets from A and B are randomly destined to both C and D. Can a switch fabric be designed so that there is no input port queuing? Explain why or why not in one sentence. No. If A and B both send to C, we ll have input port queuing no matter which switch fabric is used.
IPV4 DATAGRAM FRAGMENTATION
IP datagram format IP protocol version number header length (bytes) type of data max number remaining hops (decremented at each router) upper layer protocol to deliver payload to how much overhead with TCP? 20 bytes of TCP 20 bytes of IP = 40 bytes + app layer 32 bits ver head. type of len service 16-bit identifier time to upper live layer flgs length fragment offset header checksum 32 bit source IP address 32 bit destination IP address Options (if any) data (variable length, typically a TCP or UDP segment) total datagram length (bytes) for fragmentation/ reassembly E.g. timestamp, record route taken, specify list of routers to visit.
IP Fragmentation & Reassembly network links have MTU (max.transfer size) - largest possible link-level frame. different link types, different MTUs large IP datagram divided ( fragmented ) within net one datagram becomes several datagrams reassembled only at final destination IP header bits used to identify, order related fragments reassembly fragmentation: in: one large datagram out: 3 smaller datagrams
IPV4 DATAGRAM FRAGMENTATION )Problem 1) Consider sending a 2,400-byte datagram into a link that has an MTU (Maximum Transmission Unit) of 700 bytes. Suppose the original datagram is stamped with the identification number 422 a. How many fragments are generated? b. What are the values in the various fields in the IP datagram(s) generated related to fragmentation?
IPV4 DATAGRAM FRAGMENTATION )Problem 1) Consider sending a 2,400-byte datagram into a link that has an MTU (Maximum Transmission Unit) of 700 bytes. Suppose the original datagram is stamped with the identification number 422 a. How many fragments are generated? - For the link, 20-byte for IP header, Each fragment can carry up to 700 20 = 680 bytes of data - The original IP datagram is carrying 2400 20 = 2380 bytes of data. - Number of fragments = ceil (amount of data in original IP datagram / amount of data in fragment) = ceil (2380 / 680) = 4 fragments.
IPV4 DATAGRAM FRAGMENTATION )Problem 1) Consider sending a 2,400-byte datagram into a link that has an MTU (Maximum Transmission Unit) of 700 bytes. Suppose the original datagram is stamped with the identification number 422 b. What are the values in the various fields in the IP datagram(s) generated related to fragmentation? - Each fragment will contain 680 bytes of data + 20 bytes of IP header = 700 bytes - The fourth fragment will contain 2380 (680) (3) = 340 bytes of data and 20 bytes of IP header, giving a total length of 360 bytes. - The offset value is expressed in units of 8-byte chunks. The offsets increment by amount of data in fragment / 8 = 680 / 8 = 85. The offsets of the 4 fragments will be 0, 85, 170, and 255.
IPV4 DATAGRAM FRAGMENTATION )Problem 2) Suppose datagrams are limited to 1,500 bytes (including header) between source Host A and destination Host B. Assuming a 20-byte IP header a. how many datagrams would be required to send an MP3 consisting of 5 million bytes? (Assume that the data is carried in TCP segments, with each TCP segment having 20 bytes of header. ) - Each datagram can carry up to 1500 40 = 1460 bytes of data. - Number of required datagrams = ceil (amount of data in MP3 / amount of data in datagram) = ceil ((5 10 6 ) / 1460) = 3425 datagrams. - The last datagram will contain (5 10 6 ) - (1460) (3424) = 960 bytes of data, 20 bytes of TCP header, and 20 bytes of IP header, giving a total length of 1000 bytes.
IPV4 SUBNETTING
IP Addressing: introduction IP address: 32-bit identifier for host, router interface interface: connection between host/router and physical link router s typically have multiple interfaces host typically has one interface IP addresses associated with each interface 223.1.1.1 223.1.2.1 223.1.1.2 223.1.1.4 223.1.2.9 223.1.1.3 223.1.3.27 223.1.2.2 223.1.3.1 223.1.3.2 223.1.1.1 = 11011111 00000001 00000001 00000001 223 1 1 1
Subnets IP address: subnet part (high order bits) host part (low order bits) What s a subnet? device interfaces with same subnet 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.1.3 223.1.3.1 223.1.2.2 223.1.3.27 subnet 223.1.3.2 network consisting of 3 subnets
Subnets 223.1.1.2 223.1.1.1 223.1.1.4 How many? 223.1.1.3 223.1.9.2 223.1.7.0 223.1.9.1 223.1.8.1 223.1.8.0 223.1.7.1 223.1.2.6 223.1.3.27 223.1.2.1 223.1.2.2 223.1.3.1 223.1.3.2
IP addressing: CIDR CIDR: Classless InterDomain Routing subnet portion of address of arbitrary length address format: a.b.c.d/x, where x is # bits in subnet portion of address subnet part host part 11001000 00010111 00010000 00000000 200.23.16.0/23
Subnet Mask Subnet Mask is also 32 bit number Tells the router which bits of the IP address for the network or host portion Example of Subnet mask with prefix /24 In binary 11111111. 11111111. 11111111.00000000 Network part host part In decimal 255.2555.255.0
IPV4 SUBNETTING (Problem 1) Consider a router that interconnects three subnets: Subnet 1, Subnet 2, and Subnet 3. Suppose all of the interfaces in each of these three subnets are required to have the prefix 223.1.17/24. Also suppose that Subnet 1 is required to support at least 60 interfaces, Subnet 2 is to support at least 90 interfaces, and Subnet 3 is to support at least 12 interfaces. Provide three network addresses (of the form a.b.c.d/x) that satisfy these constraints. Subnet 1 Subnet 3 Subnet 2
Subnet 2 (90 interfaces) 2 n 2 90 Notice that we subtract 2 from the total number of available IP addresses because 2 IP addresses are reserved for the network and broadcast addresses. 2 n 92 Number of bits allocated to host part = n = 7 Number of bits allocated to network part = Prefix length = 32 -n = 32-7 = 25 Network address of first subnet = 223.1.17.0/25 = 223.1.17/25 To obtain the broadcast address of a subnet, we keep the network part of the subnet's network address as it is, and convert all bits in its host part to 1s 255.255.255.10000000 -> 255.255.255.11111111. Broadcast address of first subnet = 223.1.17.01111111/25 = 223.1.17.127/25
Subnet 1 (60 interfaces) 2 n 2 60 Notice that we subtract 2 from the total number of available IP addresses because 2 IP addresses are reserved for the network and broadcast addresses. 2 n 62 Number of bits allocated to host part = n = 6 Number of bits allocated to network part = Prefix length = 32 -n = 32-6 = 26 Network address of second subnet = 223.1.17.128/26 Broadcast address of second subnet = 223.1.17.10111111/26 =223.1.17.191/26
Subnet 3 (12 interfaces) 2 n 2 12 Notice that we subtract 2 from the total number of available IP addresses because 2 IP addresses are reserved for the network and broadcast addresses. 2 n 14 Number of bits allocated to host part = n = 4 Number of bits allocated to network part = Prefix length = 32 -n = 32-4 = 28 Network address of third subnet = 223.1.17.192/28 Broadcast address of third subnet = 223.1.17.10111111/26 =223.1.17.207/28
NAT: Network Address Translation
NAT: Network Address Translation rest of Internet 138.76.29.7 local network (e.g., home network) 10.0.0/24 10.0.0.4 10.0.0.1 10.0.0.2 10.0.0.3 Datagrams with source or destination in this network have 10.0.0/24 address for source, destination (as usual)
NAT Translation table example 2: NAT router changes datagram source addr from 10.0.0.1, 3345 to 138.76.29.7, 5001, updates table 2 NAT translation table WAN side addr LAN side addr 138.76.29.7, 5001 10.0.0.1, 3345 S: 138.76.29.7, 5001 D: 128.119.40.186, 80 10.0.0.4 S: 10.0.0.1, 3345 D: 128.119.40.186, 80 1 1: host 10.0.0.1 sends datagram to 128.119.40.186, 80 10.0.0.1 10.0.0.2 138.76.29.7 S: 128.119.40.186, 80 D: 138.76.29.7, 5001 3 3: Reply arrives dest. address: 138.76.29.7, 5001 S: 128.119.40.186, 80 D: 10.0.0.1, 3345 4 10.0.0.3
NAT (Problem 1) Consider the following figure Suppose that the ISP instead assigns : The router the address 24.34.112.235 The network address of the home network is 192.168.1/24. a. Assign addresses to all interfaces in the home network. b. Suppose each host has two ongoing TCP connections, all to port 80 at host 128.119.40.86. Provide the six corresponding entries in the NAT translation table.
NAT (Problem 1) Consider the following figure Suppose that the ISP instead assigns : The router the address 24.34.112.235 The network address of the home network is 192.168.1/24. a. Assign addresses to all interfaces in the home network. Network address of home network = 192.168.1.0/24 There are three hosts, and thus three interfaces, in the home network. One solution is to assign the first three usable host addresses of the home network for the hosts. These addresses are 192.168.1.1/24, 192.168.1.2/24 and 192.168.1.3/24. Assigning any three addresses between and excluding the home network s network and broadcast addresses is also acceptable.
NAT (Problem 1) Consider the following figure Suppose that the ISP instead assigns : The router the address 24.34.112.235 The network address of the home network is 192.168.1/24. b. Suppose each host has two ongoing TCP connections, all to port 80 at host 128.119.40.86. Provide the six corresponding entries in the NAT translation table.