1 / 153

Network Layer

Computer Networks Research Center (CNRC) Computer Science Department, CIIT, Lahore. http://research.ciitlahore.edu.pk/Groups/CNRC/. Network Layer. Agenda. Network Layer Internet Protocol IP Datagram NAT Subneting. Host, router network layer functions:. ICMP protocol error reporting

mpalmer
Download Presentation

Network Layer

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Computer Networks Research Center (CNRC) Computer Science Department, CIIT, Lahore. http://research.ciitlahore.edu.pk/Groups/CNRC/ Network Layer

  2. Agenda • Network Layer • Internet Protocol • IP Datagram • NAT • Subneting Network Layer

  3. Host, router network layer functions: • ICMP protocol • error reporting • router “signaling” • IP protocol • addressing conventions • datagram format • packet handling conventions • Routing protocols • path selection • RIP, OSPF, BGP forwarding table The Internet Network Layer Transport layer: TCP, UDP Network layer Link layer physical layer Network Layer

  4. IP protocol version number 32 bits total datagram length (bytes) header length (bytes) type of service head. len ver length for fragmentation/ reassembly fragment offset “type” of data flgs 16-bit identifier max number remaining hops (decremented at each router) upper layer time to live Internet checksum 32 bit source IP address 32 bit destination IP address upper layer protocol to deliver payload to E.g. timestamp, record route taken, specify list of routers to visit. Options (if any) data (variable length, typically a TCP or UDP segment) IP Datagram Format Network Layer

  5. IP Datagram Format • Note thatan IP datagram has a total of 20 bytes of header (assuming no options). If the datagram carries a TCP segment, then each (nonfragmented) datagram carries a total of 40 bytes of header (20 bytes of IP header plus 20 bytes of TCP header) along with the application-layer message. how much overhead with TCP? • 20 bytes of TCP • 20 bytes of IP • = 40 bytes + app layer overhead Network Layer

  6. The maximum amount of data that a link-layer frame can carry is called the maximum transmission unit (MTU). 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 IP Fragmentation & Reassembly fragmentation: in: one large datagram out: 3 smaller datagrams reassembly Some protocols can carry big datagrams, whereas other protocols can carry only little packets. For example, Ethernet frames can carry up to 1,500 bytes of data, whereas frames for some wide-area links can carry no more than 576 bytes. Network Layer

  7. length =1500 length =1040 length =4000 length =1500 ID =777 ID =777 ID =777 ID =777 fragflag =0 fragflag =0 fragflag =1 fragflag =1 offset =0 offset =0 offset =185 offset =370 One large datagram becomes several smaller datagrams IP Fragmentation and Reassembly A datagram of 4,000 bytes (20 bytes of IP header plus 3,980 bytes of IP payload) arrives at a router and must be forwarded to a link with an MTU of 1,500 bytes. This implies that the 3,980 data bytes in the original datagram must be allocated to three separate fragments (each of which is also an IP datagram). Suppose that the original datagram is stamped with an identification number of 777. Example • 4000 byte datagram • MTU = 1500 bytes 1480 bytes in data field offset = 1480/8 = 185 Network Layer

  8. IP Fragmentation and Reassembly Network Layer

  9. IP address: 32-bit identifier for host, router interface interface: connection between host/router and physical link router’s typically have multiple interfaces host may have multiple interfaces IP addresses associated with each interface 223.1.1.2 223.1.3.27 223.1.3.1 223.1.2.1 223.1.2.2 223.1.3.2 IP Addressing: Introduction 223.1.1.1 223.1.2.9 223.1.1.4 223.1.1.3 223.1.1.1 = 11011111 00000001 00000001 00000001 223 1 1 1 Network Layer

  10. 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 Subnets 223.1.1.1 223.1.2.1 223.1.1.2 223.1.2.9 223.1.1.4 223.1.2.2 223.1.1.3 223.1.3.27 LAN 223.1.3.2 223.1.3.1 network consisting of 3 subnets Network Layer

  11. Recipe To determine the subnets, detach each interface from its host or router, creating islands of isolated networks. Each isolated network is called a subnet. 223.1.1.0/24 223.1.2.0/24 223.1.3.0/24 Subnets Subnet mask: /24 Network Layer

  12. How many? Subnets 223.1.1.2 223.1.1.1 223.1.1.4 223.1.1.3 223.1.7.0 223.1.9.2 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 Network Layer

  13. IP Addresses: How to get one? Q: How does host get IP address? • hard-coded by system admin in a file • Wintel: 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” (more in next chapter) Network Layer

  14. IP Addressing Q: How does an ISP get block of addresses? A: ICANN: Internet Corporation for Assigned Names and Numbers • allocates addresses • manages DNS • assigns domain names, resolves disputes Network Layer

  15. NAT: Network Address Translation rest of Internet local network (e.g., home network) 10.0.0/24 10.0.0.1 10.0.0.4 10.0.0.2 138.76.29.7 10.0.0.3 Datagrams with source or destination in this network have 10.0.0/24 address for source, destination (as usual) All datagrams leaving local network have same single source NAT IP address: 138.76.29.7, different source port numbers Network Layer

  16. NAT: Network Address Translation • Motivation:local network uses just one IP address as far as outside word is concerned: • no need to be allocated range of addresses from ISP: - just one IP address is used for all devices • can change addresses of devices in local network without notifying outside world • can change ISP without changing addresses of devices in local network • devices inside local net not explicitly addressable, visible by outside world (a security plus). Network Layer

  17. NAT: Network Address Translation Implementation: NAT router must: • outgoing datagrams:replace (source IP address, port #) of every outgoing datagram to (NAT IP address, new port #) . . . remote clients/servers will respond using (NAT IP address, new port #) as destination address. • remember (in NAT translation table) every (source IP address, port #) to (NAT IP address, new port #) translation pair • incoming datagrams:replace (NAT IP address, new port #) in destination fields of every incoming datagram with corresponding (source IP address, port #) stored in NAT table Network Layer

  18. 3 1 2 4 S: 10.0.0.1, 3345 D: 128.119.40.186, 80 S: 138.76.29.7, 5001 D: 128.119.40.186, 80 1: host 10.0.0.1 sends datagram to 128.119.40, 80 2: NAT router changes datagram source addr from 10.0.0.1, 3345 to 138.76.29.7, 5001, updates table S: 128.119.40.186, 80 D: 10.0.0.1, 3345 S: 128.119.40.186, 80 D: 138.76.29.7, 5001 NAT: Network Address Translation NAT translation table WAN side addr LAN side addr 138.76.29.7, 5001 10.0.0.1, 3345 …… …… 10.0.0.1 10.0.0.4 10.0.0.2 138.76.29.7 10.0.0.3 4: NAT router changes datagram dest addr from 138.76.29.7, 5001 to 10.0.0.1, 3345 3: Reply arrives dest. address: 138.76.29.7, 5001 Network Layer

  19. NAT: Network Address Translation • 16-bit port-number field: • 60,000 simultaneous connections with a single LAN-side address! • NAT is controversial: • routers should only process up to layer 3 • violates end-to-end argument • NAT possibility must be taken into account by app designers, eg, P2P applications • address shortage should instead be solved by IPv6 Network Layer

  20. Binary and Decimal Conversions Network Layer

  21. An IP address is represented by a 32 bit binary number The value of the right-most bit (also called the least significant bit) is either 0 or 1 The corresponding decimal value of each bit doubles as you move left in the binary number So the decimal value of the 2nd bit from the right is either 0 or 2. The third bit is either 0 or 4, the fourth bit 0 or 8, etc ... IP addresses are expressed as dotted-decimal numbers we break up the 32 bits of the address into four octets (an octet is a group of 8 bits). The maximum decimal value of each octet is 255 The largest 8 bit binary number is 11111111 Those bits, from left to right, have decimal values of 128, 64, 32, 16, 8, 4, 2, and 1. Added together, they total 255 The 32 bit Binary IP Address Network Layer

  22. IP Address Component Fields • The network number of an IP address identifies the network to which a device is attached • The host portion of an IP address identifies the specific device on that network Network Layer

  23. IP Address Classes The American Registry for Internet Numbers (ARIN) is the Regional Internet Registry (RIR) forCanada, the United States, and many Caribbean and North Atlantic islands.  • When written in a binary format, the first (leftmost) bit of a Class A address is always 0. • Example of a Class A IP address is 124.95.44.15 • The first octet, 124, identifies the network number assigned by ARIN • which will range from 0-126. (127 does start with a 0 bit, but has been reserved for special purposes.) • The internal administrators of the network assign the remaining 24 bits • All Class A IP addresses use only the first 8 bits to identify the network part of the address • Every network that uses a Class A IP address can have assigned up to 2 to-the-power of 24 (224) (minus 2), or 16,777,214, possible IP addresses to devices that are attached to its network Network Layer

  24. The first 2 bits of a Class B address are always 10 (one and zero). example of a Class B IP address is 151.10.13.28 The first two octets identify the network number assigned by ARIN Class B IP addresses always have values ranging from 128 to 191 in their first octet Every network that uses a Class B IP address can have assigned up to 2 to-the-power of 16 (216) (minus 2 again!), or 65,534, possible IP addresses to devices that are attached to its network • The first 3 bits of a Class C address are always 110 (one, one and zero). • An example of a Class C IP address is 201.110.213.28 • The first three octets identify the network number • Class C IP addresses always have values ranging from 192 to 223 in their first octet. • All Class C IP addresses use the first 24 bits to identify the network part of the address • Every network that uses a Class C IP address can have assigned up to 28 (minus 2), or 254, possible IP addresses to devices that are attached to its network Network Layer

  25. If your computer wanted to communicate with all of the devices on a network, it would be quite unmanageable to write out the IP address for each device An IP address that ends with binary 0s in all host bits is reserved for the network address (sometimes called the wire address) Therefore, as a Class A network example, 113.0.0.0 is the IP address of the network containing the host 113.1.2.3 A router uses a network's IP address when it forwards data on the Internet. As a Class B network example, the IP address 176.10.0.0 is a network address. If you wanted to send data to all of the devices on a network, you would need to use a broadcastaddress IP Reserved Address • Broadcast IP addresses end with binary 1s in the entire host part of the address (the host field) • For the network in the example (176.10.0.0) • where the last 16 bits make up the host field (or host part of the address), the broadcast that would be sent out to all devices on that network would include a destination address of 176.10.255.255 (since 255 is the decimal value of an octet containing 11111111). • When you send a broadcast packet on a network, all devices on the network notice it Network Layer

  26. Network administrators sometimes need to divide networks, especially large ones, into smaller networks These smaller divisions are called subnetworks and provide addressing flexibility. Most of the time subnetworks are simply referred to as subnets each subnet address is unique. Subnet addresses include the Class A, Class B, or Class C network portion, plus a subnet field and a host field Subnets Network Layer

  27. The 32 bit Binary IP Address • The subnet field and the host field are created from the original host portion for the entire network • To create a subnet address, a network administrator borrows bits from the original host portion and designates them as the subnet field. • The minimum number of bits that can be borrowed is 2 Network Layer

  28. A primary reason for using subnets is to reduce the size of a broadcast domain When broadcast traffic begins to consume too much of the available bandwidth, network administrators may choose to reduce the size of the broadcast domain. Why Subnets! Network Layer

  29. The subnet mask (formal term: extended network prefix), is not an address, but determines which part of an IP address is the network field and which part is the host field A subnet mask is 32 bits long and has 4 octets, just like an IP address.  To determine the subnet mask for a particular subnetwork IP address follow these steps Express the subnetwork IP address in binary form Replace the network and subnet portion of the address with all 1s Replace the host portion of the address with all 0s As the last step convert the binary expression back to dotted-decimal notation. Subnet Mask • The term "operations" in mathematics refers to rules that define how one number combines with other numbers • The basic Boolean operations are AND, OR, and NOT. Network Layer

  30. The AND Function • In order to route a data packet, the router must first determine the destination network/subnet address by performing a logical AND using the destination host's IP address and the subnet mask • The result will be the network/subnet address • The router has received a packet for host 131.108.2.2 - it uses the AND operation to learn that this packet should be routed to subnet 131.108.2.0 Network Layer

  31. The process used to apply the subnet mask involves Boolean Algebra to filter out non-matching bits to identify the network address. Subnet Mask (Cont.) Boolean Algebra • Boolean Algebra is a process that applies binary logic to yield binary results. • Working with subnet masks, you need only 4 basic principles of Boolean Algebra: • 1 and 1 = 1 • 1 and 0 = 0 • 0 and 1 = 0 • 0 and 0 = 0 • In another words, the only way you can get a result of a 1 is to combine 1 & 1. Everything else will end up as a 0. • The process of combining binary values with Boolean Algebra is called Anding. Network Layer

  32. Subnet masks apply only to Class A, B or C IP addresses. The subnet mask is like a filter that is applied to a message’s destination IP address. Its objective is to determine if the local network is the destination network. The subnet mask goes like this: If a destination IP address is 206.175.162.21, we know that it is a Class C address & that its binary equivalent is: 11001110.10101111.10100010.00010101 We also know that the default standard Class C subnet mask is: 255.255.255.0 and that its binary equivalent is: 11111111.11111111.11111111.00000000 When these two binary numbers (the IP address & the subnet mask) are combined using Boolean Algebra, the Network ID of the destination network is the result: The result is the IP address of the network which in this case is the same as the local network & means that the message is for a node on the local network. A Trial Separation Network Layer

  33. There are default standard subnet masks for Class A, B and C addresses: Default Standard Subnet Masks Subnetting Networks ID • A 3-step example of how the default Class A subnet mask is applied to a Class A address: • The default Class A subnet mask (255.0.0.0) is AND’d with the Class A address (123.123.123.001) using Boolean Algebra, which results in the Network ID (123.0.0.0) being revealed. • The default Class B subnet mask (255.255.0.0) strips out the 16-bit network ID & the default Class C subnet mask (255.255.255.0) strips out the 24-bit network ID. Network Layer

  34. Subnetting, a subnet & a subnet mask are all different. In fact, the 1st creates the 2nd & is identified by the 3rd. Subnetting is the process of dividing a network & its IP addresses into segments, each of which is called a subnetwork or subnet. The subnet mask is the 32-bit number that the router uses to cover up the network address to show which bits are being used to identify the subnet. Subnetting, Subnet & Subnet Mask Subnetting • A network has its own unique address, such as a Class B network with the address 172.20.0.0 which has all zeroes in the host portion of the address. • From the basic definitions of a Class B network & the default Class B subnet mask, this network can be created as a single network that contains more than 65,000individual hosts. • Through the use of subnetting, the network from the previous slide can be logically divided into subnets with fewer hosts on each subnetwork. • It does not improve the available shared bandwidth only, but it cuts down on the amount of broadcast traffic generated over the entire network as well. • The 2 primary benefits of subnetting are: • Fewer IP addresses, often as few as one, are needed to provide addressing to a network & subnetting. • Subnettingusually results in smaller routing tables in routers beyond the local internetwork. Network Layer

  35. Example of subnetting: when the network administrator divides the 172.20.0.0 network into 5 smaller networks – 172.20.1.0, 172.20.2.0, 172.20.3.0, 172.20.4.0 & 172.20.5.0 – the outside world stills sees the network as 172.20.0.0, but the internal routers now break the network addressing into the 5 smaller subnetworks. In the above example, only a single IP address is used to reference the network & instead of 5 network addresses, only one network reference is included in the routing tables of routers on other networks. Bits Available for Creating Subnets Address Class Host Bits Bits Available for Subnet A 24 22 B 16 14 C 8 6 Subnetting Borrowing Bits to Grow a Subnet • The key concept in subnetting is borrowing bits from the host portion of the network to create a subnetwork. • Rules govern this borrowing, ensuring that some bits are left for a Host ID. • The rules require that two bits remain available to use for the Host ID& that all of the subnet bits cannot be all 1s or 0s at the same time. • For each IP address class, only a certain number of bits can be borrowed from the host portion for use in the subnet mask. Network Layer

  36. The default subnet mask for a class A network is 255.0.0.0 which allows for more than 16,000,000 hosts on a single network. The default subnet mask uses only 8 bits to identify network, leaving 24 bits for host addressing . Subnetting a Class A Network • To subnet a Class A network, you need to borrow a sufficient number of bits from the 24-bit host portion of the mask to allow for the number of subnets you plan to create, now & in the future. • Example: To create 2 subnets with more than 4 millions hosts per subnet, you must borrow 2 bits from the 2nd octet & use 10 masked (value equals one) bits for the subnet mask (11111111.11000000) or 255.192 in decimal. • Keep in mind that each of the 8-bit octets has binary place values. • When you borrow bits from the Host ID portion of the standard mask, you don’t change the value of the bits, only how they are grouped & used. • A sample of subnet mask options available for Class A addresses. Network Layer

  37. All subnet masks contain 32 bits; no more, no less. However a subnet mask cannot filter more than 30 bits. This means 2 things: One, that there cannot be more than 30 ones bits in the subnet mask. Two, that there must always be at least 2 bits available for the Host ID. Class A Subnet Masks • The subnet mask with the highest value (255.255.255.252) has a binary representation of: 11111111.11111111.11111111.11111100 • The 2 zeroes in this subnet mask represent the 2 positions set aside for the Host address portion of the address. • Remember that the addresses with all ones (broadcast address) & all zeroes (local network) cannot be used as they have special meanings. Network Layer

  38. The table on previous slide “Class A Subnet Masks” is similar to the tables used for Class B & Class C IP addresses & subnet masks. The only differences are that you have fewer options (due to a fewer number of bits available) & that you’re much more likely to work with Class B & Class C networks in real life. Subnetting Class B & Class C A sample of the subnet masks available for Class B networks. A list of the subnet masks available for Class C networks. Network Layer

  39. Knowing the relationships in this table will significantly reduce the time you spend calculating subnetting problems. Class C Subnets Class B Subnets • To calculate the number of subnets & hosts available from a Class B subnet mask, you use the same host & subnet formulas described for calculating Class C values. • Using these formulas I have constructed a table that contains the Class B subnet & host values. Network Layer

  40. Class B Subnets Network Layer

  41. We ask our ISP for a Class C license. They give us the Class C bank of 206.15.143.0 This gives us 1 Network (206.15.143.0) with the potential for 254 node addresses (206.15.143.1 to 206.15.143.254). But we have a LAN made up of 5 Networks with the largest one serving 25 nodes. So we need to Subnet our 1 IP address... So How Does This Work? • To calculate the number of subnets (networks) and/or nodes, we need to do some math: • Use the formula 2n-2 where the n can represent either how many subnets (networks) needed OR how many nodes per subnet needed. • We know we need at least 5 subnets. So 23-2 will give us 6 subnet addresses (Network Addresses). • We know we need at least 25 nodes per network. 25-2 will give us 30 nodes per subnet (network). • This will work, because we can steal the first 3 bits from the node’s portion of the address to give to the network portion and still have 5 (8-3) left for the node portion: Network Layer

  42. Let’s go back to what portion is what: We have a Class C address: NNNNNNNN.NNNNNNNN.NNNNNNNN.nnnnnnnn With a Subnet mask of: 11111111.11111111.11111111.00000000 We need to steal 3 bits from the node portion to give it to the Network portion: NNNNNNNN.NNNNNNNN.NNNNNNNN.NNNnnnnn Break it down: • NNNNNNNN.NNNNNNNN.NNNNNNNN.NNNnnnnn • This will change our subnet mask to the following: • 11111111.11111111.11111111.11100000 • Above is how the computer will see our new subnet mask, but we need to express it in decimal form as well: • 255.255.255.224 128+64+32=224 Network Layer

  43. Which of our 254 addresses will be a Subnet (or Network) address and which will be our node addresses? Because we are using the first 3 bits for our subnet mask, we can configure them into eight different ways (binary form): 000 001 010 011 100 101 110 111 What address is what? • We cannot use all “0”s or all “1”s 000 001 010 011 100 101 110 111 • We are left with 6 useable network numbers. Network Layer

  44. Remember our values: 128 64 32 16 8 4 2 1 Equals Now our 3 bit configurations: 0 0 1n n n n n 32 0 1 0n n n n n 64 0 1 1n n n n n 96 1 0 0n n n n n 128 1 0 1n n n n n 160 1 1 0n n n n n 192 Network (Subnet) Addresses Network Layer

  45. 0 0 1n n n n n 32 0 1 0n n n n n 64 0 1 1n n n n n 96 1 0 0n n n n n 128 1 0 1n n n n n 160 1 1 0n n n n n 192 Network (Subnet) Addresses Each of these numbers becomes the Network Address of their subnet... 206.15.143.32 206.15.143.64 206.15.143.96 206.15.143.128 206.15.143.160 206.15.143.192 Network Layer

  46. The device assigned the first address will receive the first number AFTER the network address shown before. 206.15.143.33 or 32+1 0 0 10 0 0 0 1 And the last address in the Network will look like this: 206.15.143.62 0 0 11 1 1 1 0 *Remember, we cannot use all “1”s, that is the broadcast address (206.15.143.63) Node Addresses • The next network will start at 206.15.143.64 • The first IP address on this subnet network will receive: 206.15.143.65 0 1 00 0 0 0 1 And the last address in the Network will receive: 206.15.143.94 0 1 01 1 1 1 0 *Remember, the broadcast address (206.15.143.95) Network Layer

  47. Network: Host Range 206.15.143.32 206.15.143.33 to 206.15.143.62 206.15.143.64 206.15.143.65 to 206.15.143.94 206.15.143.96 206.15.143.128 206.15.143.160 206.15.143.192 Can you figure out the rest? 206.15.143.97 to 206.15.143.126 206.15.143.129 to 206.15.143.158 206.15.143.161 to 206.15.143.190 206.15.143.193 to 206.15.143.222 Network Layer

  48. 200.15.143.89 An address on the subnet 225.225.225.224 The new subnet mask When the computer does the Logical Bitwise AND Operation it will come up with the following Network Address (or Subnet Address): 11001000.00001111.10001111.01011001= 200.15.143.89 11111111.11111111.11111111.11100000 = 255.255.255.224 11001000.00001111.10001111.01000000 = 200.15.143.64 (Network) This address falls on our 2nd Subnet (Network) How the computer finds the Network Address Network Layer

  49. We have one class C license (206.15.143.0). We need to subnet that into 12 possible networks. Each network needs a maximum of 10 nodes. How many bits do we need to take? 24-2=14 4 bits need to be taken from the node portion and given to the network portion. Review • Will that leave enough bits for the node portion? We need a maximum of 10 on each network… 24-2=14 • If we take 4 away, that leaves us with 4. That is enough for our individual networks of 10 nodes each. • Our new subnet mask will look like this: 11111111.11111111.11111111.11110000 255.255.255.240 128+64+32+16= 240 • Our subnet, or network addresses will be: 206.15.143.16 206.15.143.32 206.15.143.48 206.15.143.64 206.15.143.80 206.15.143.96 206.15.143.112 206.15.143.128 206.15.143.144 206.15.143.160 206.15.143.176 206.15.143.192 206.15.143.208 206.15.143.224 Network Layer

  50. Class B Subnet Chart Class C Subnet Chart Review Network Layer

More Related