The network layer is responsible for the source- to-destination delivery of a packet, possibly across multiple networks (links). Whereas the data link layer oversees the delivery of the packet between two systems on the same network (links), the network layer ensures that each packet gets from its point of origin to its final destination. Cont.. The TCP/IP network layer (Layer 3) defines how to deliver IP packets over the entire trip, from the original device that creates the packet to the device that needs to receive the packet. That process requires cooperation between several different jobs and concepts on a number of devices. This chapter begins with an overview of all these cooperating functions, and then it dives into more detail about each area. Two Key Network-Layer Functions forwarding: move packets from router’s input to appropriate router output routing: determine route taken by packets from source to destination. – routing algorithms NIC addressing Network Interface Card (NIC) is a hardware component that is present on the computer. It is used to connect different networking devices such as computers and servers to share data over the connected network. It provides functionality such as support for I/O interrupt, Direct Memory Access (DMA) interfaces, partitioning, and data transmission. NIC is important for us to establish a wired or wireless connection over the network. Network Interface Card is also known as Network Interface Controller, Network Adapter, Ethernet card, Connection card, and LAN (Local Area Network) Adapter. Cont.. Functions of the Network Interface Card o NIC is used to convert data into a digital signal. o In the OSI model, NIC uses the physical layer to transmit signals and the network layer to transmit data packets. o NIC offers both wired (using cables) and wireless (using Wi-Fi) data communication techniques. o NIC is a middleware between a computer/server and a data network. o NIC operates on both physical as well as the data link layer of the OSI model. Cont.. Layer 3 network addressing is one of the major tasks of Network Layer. Network Addresses are always logical i.e. these are software based addresses which can be changed by appropriate configurations. A network address always points to host / node / server or it can represent a whole network. Network address is always configured on network interface card and is generally mapped by system with the MAC address (hardware address or layer-2 address) of the machine for Layer-2 communication. Cont.. IP addressing provides mechanism to differentiate between hosts and network. Because IP addresses are assigned in hierarchical manner, a host always resides under a specific network. The host which needs to communicate outside its subnet, needs to know destination network address, where the packet/data is to be sent. Hosts in different subnet need a mechanism to locate each other. This task can be done by DNS. Cont.. DNS is a server which provides Layer-3 address of remote
host mapped with its domain name or FQDN.
When a host acquires the Layer-3 Address (IP Address) of the
remote host, it forwards all its packet to its gateway.
A gateway is a router equipped with all the information which
leads to route packets to the destination host.
Routers take help of routing tables, which has the following information: – Address of destination network – Method to reach the network Packetizing Packetizing refers to the process of encapsulating data received from the payload, which is the upper layer of the network, in a Network layer at the source, and then decapsulating it at the destination. The host adds a header that includes the source and the destination addresses alongside other relevant information that is required in the process of packetizing. The receiver host receives the network layer packet from the Data Link layer, decapsulates it, and sends the payload to the upper layer protocol. The routers cannot change the header or the address. IP addressing An IP address is a unique address that identifies a device on the internet or a local network. IP stands for "Internet Protocol," which is the set of rules governing the format of data sent via the internet or local network. The internet needs a way to differentiate between different computers, routers, and websites. IP addresses provide a way of doing so and form an essential part of how the internet works Cont.. There are two versions of IP that currently coexist in the global Internet: IP version 4 (IPv4) and IP version 6 (IPv6). IPv4 addresses are 32 bits long, and Pv6 addresses 128 bits long. An IP address is a string of numbers separated by periods. IP addresses are expressed as a set of four numbers. an example 192.158.1.38. Each number in the set can range from 0 to 255. So, the full IP addressing range goes from 0.0.0.0 to 255.255.255.255. Internet Protocol Version 4 (IPv4) An IPv4 address is a 32-bit address that uniquely and universally defines the connection of a device (for example, a computer or a router) to the Internet. IPv4 addresses are unique. They are unique in the sense that each address defines one, and only one, connection to the Internet. Two devices on the Internet can never have the same address at the same time. The IPv4 addresses are universal in the sense that the addressing system must be accepted by any host that wants to be connected to the Internet. Address Space A protocol such as IPv4 that defines addresses has an address space. An address space is the total number of addresses used by the protocol. If a protocol uses N bits to define an address, the address space is 2N because each bit can have two different values (0 or 1) and N bits can have 2N values. IPv4 uses 32-bit addresses, which means that the address space is 232 or 4,294,967,296 (more than 4 billion). This means that, theoretically, if there were no restrictions, more than 4 billion devices could be connected to the Internet. Types of IPv4 Addressing Schemes There are two types of IPv4 addressing schemes: Classful Addressing Classless Addressing Classful addressing IPv4 addressing, at its inception, used the concept of classes. This architecture is called classful addressing. In classful addressing, the address space is divided into five classes: A, B, C, D, and E. Each class occupies some part of the address space. We can find the class of an address when given the address in binary notation or dotted-decimal notation. If the address is given in binary notation, the first few bits can immediately tell us the class of the address. If the address is given in decimal-dotted notation, the first byte defines the class. Both methods are shown in Figure below. Cont.. Cont.. One problem with classful addressing is that each class is divided into a fixed number of blocks with each block having a fixed size as shown in Table Net id (Network Id) and Host id In classful addressing, an IP address in class A, B, or C is divided into netid and hostid. These parts are of varying lengths, depending on the class of the address. Note that the concept does not apply to classes D and E. In class A, one byte defines the netid and three bytes define the hostid. In class B, two bytes define the netid and two bytes define the hostid. In class C, three bytes define the netid and one byte defines the hostid. Cont.. Subnet Masks A mask (also called the default mask) is a 32-bit number made of contiguous 1s followed by contiguous 0s. For the subnet address scheme to work, every machine on the network must know which part of the host address will be used as the subnet address. This is accomplished by assigning a subnet mask to each machine. A subnet mask is a 32-bit value that allows the recipient of IP packets to distinguish the network portion of the IP address from the host portion of the IP address A subnet mask is composed of 1s and 0s where: The 1s in the subnet mask represent the positions that refer to the network or subnet addresses The 0s in the subnet mask represent the positions that refer to the host address Default subnet masks Not all networks need subnets, meaning they use the default subnet mask. This is basically the same as saying that a network doesn’t have a subnet address. Here is default subnet mask for Classes A, B, and C Class A - network.node.node.node Subnet mask: 255.0.0.0 Class B network.network.node.node Subnet mask:255.255.0.0 Class C- network.network.network.node Subnet mask: 255.255.255.0 These default subnet masks show the minimum number of 1’s you can have in a subnet mask for each class. Address Depletion Problem The fast growth of the Internet led to the near depletion of the available addresses in classful addressing scheme. Yet the number of devices on the Internet is much less than the 232 address space. We have run out of class A and B addresses, and a class C block is too small for most midsize organizations. One solution that has alleviated the problem is the idea of classless addressing. Classful addressing, which is almost obsolete, is replaced with classless addressing. Classless Inter Domain Routing (CIDR) CIDR combines several IP address ranges into one network or route. To overcome address depletion and give more organizations access to the Internet, classless addressing was designed and implemented. In this scheme, there are no classes, but the addresses are still granted in blocks. In classless addressing, when an entity, small or large, needs to be connected to the Internet, it is granted a block (range) of addresses. The size of the block (the number of addresses) varies based on the nature and size of the entity. Classless Addressing To overcome address depletion and give more organizations access to the Internet, classless addressing was designed and implemented. In this scheme, there are no classes, but the addresses are still granted in blocks. Address Blocks In classless addressing, when an entity, small or large, needs to be connected to the Internet, it is granted a block (range) of addresses. The size of the block (the number of addresses) varies based on the nature and size of the entity. For example, a household may be given only two addresses; a large organization may be given thousands of addresses. Mask A better way to define a block of addresses is to select any address in the block and the mask. As we discussed before, a mask is a 32-bit number in which the n leftmost bits are 1s and the 32 - n rightmost bits are 0s. However, in classless addressing the mask for a block can take any value from 0 to 32. It is very convenient to give just the value of n preceded by a slash (CIDR notation). In IPv4 addressing, a block of addresses can be defined as x.y.z.t/n in which x.y.z.t defines one of the addresses and the /n defines the mask. The address and the /n notation completely define the whole block (the first address, the last address, and the number of addresses). Cont.. First Address: The first address in the block can be found by setting the 32 - n rightmost bits in the binary notation of the address to 0s. Last Address: The last address in the block can be found by setting the 32 - n rightmost bits in the binary notation of the address to 1s. Number of Addresses: The number of addresses in the block is the difference between the last and first address. It can easily be found using the formula 2 32- n. Cont.. Example. A block of addresses is granted to a small organization. We know that one of the addresses is 205.16.37.39/28. A. What is the first address in the block? B. Find the last address for the block? C. Find the number of addresses Solution. A. The binary representation of the given address is 11001101 00010000 00100101 00100111. If we set 32 - 28 rightmost bits to 0, we get 11001101 00010000 01001010 00100000 or 205.16.37.32. B. The binary representation of the given address is 11001101 00010000 00100101 00100111. If we set 32 - 28 rightmost bits to 1, we get 11001101 00010000 00100101 00101111 or 205.16.37.47. C. The value of n is 28, which means that number of addresses is 232- 28 or 16. Cont.. Example Another way to find the first address, the last address, and the number of addresses is to represent the mask as a 32-bit binary (or 8-digit hexadecimal) number. This is particularly useful when we are writing a program to find these pieces of information. In Example previous above /28 can be represented as 11111111 11111111 11111111 11110000 (twenty-eight 1s and four 0s). Find a. The first address b. The last address c. The number of addresses Solution a. The first address can be found by ANDing the given addresses with the mask. ANDing here is done bit by bit. The result of ANDing 2 bits is 1 if both bits are 1s; the result is 0 otherwise. Address: 11001101 00010000 00100101 00100111 Mask: 11111111 11111111 11111111 11110000 First address: 11001101 00010000 0010010100100000 Cont.. b. The last address can be found by ORing the given addresses with the complement of the mask. ORing here is done bit by bit. The result of ORing 2 bits is 0 if both bits are 0s; the result is 1 otherwise. The complement of a number is found by changing each 1 to 0 and each 0 to 1. Address: 11001101 00010000 00100101 00100111 Mask complement: 00000000 00000000 00000000 00001111 Last address: 11001101 00010000 00100101 00101111 c. The number of addresses can be found by complementing the mask, interpreting it as a decimal number, and adding 1 to it. Mask complement: 000000000 00000000 00000000 00001111 Number of addresses: 15 + 1 =16 Sub netting Subnetting is extending the network portion and reducing the host portion. Advantage of Subnetting is that helps a network admin to efficiently use the network IPs. To create the sub network structure, host bits must be reassigned as network bits which is often referred to as borrowing bits. The starting point for this process is always the leftmost bit of the host. That is the one closest to the last network octet. Total number of subnets is 2^bits borrowed Total number of hosts is 2^remaining host bits Cont.. Example. Let us subnet the network address 192.168.10.0 with a subnet mask 255.255.255.192 or in slash format /26 1. How many subnets do we have? 2. How many hosts per subnet do we have? 3. What are the subnet IDs? 4. What’s the broadcast address for the each subnets? 5. What are the valid hosts? Cont.. 1. Since 192 is 2 bits on (11000000), the answer would be 2^2 = 4 2. We have 6 host bits off (11000000), so the answer would be 2^6 – 2 = 62 hosts 3. We vary the borrowed bits (00, 01, 10, 11). So the subnets ID are 192.168.10.0, 192.168.10.64, 192.168.10.128, 192.168.10.192. 4. 5. Sub netting class A and B networks The Class A and B sub netting procedure is identical to the process for Class C, except there may be significantly more bits involved. Assigning 12 bits of a Class B address to the subnet field creates a subnet mask of 255.255.255.240 or /28. All eight bits were assigned in the third octet resulting in 255, the total value of all eight bits. Four bits were assigned in the fourth octet resulting in 240. Cont.. Example 1 172.16.0.0 = Network address 255.255.192.0 = Subnet mask Calculate How many Subnets? How many Hosts per subnet? Subnet IDs of valid subnets? Broadcast address for each subnet and valid hosts? Private and Public IP addresses. An IP address is a unique numerical ID assigned to each device on the Internet. A private IP address, also known as the local IP address, is the IP address your network router allocates to your device. This address is only visible within your network, so it is unavailable on the Internet. Each device on the same network is assigned a unique private IP address that allows them to communicate with other devices. The device in your home can have the same private IP address as your neighbors' device or anyone else's all over the world, with private IP addresses. Cont.. A public IP address is an address provided that is provided by your internet service provider (ISP) to your network. The internet is accessed through your router's public IP address. Public IP addresses are commonly used by publicly accessible enterprises such as websites, DNS, and VPN servers because they can be accessed from anywhere in the world. You can not go online without having your public IP address, which identifies your device on the internet. Your router is an intermediate between your computer and the internet on a typical home network. NAT To access the Internet, one public IP address is needed, but we can use a private IP address in our private network. The idea of NAT is to allow multiple devices to access the Internet through a single public address. To achieve this, the translation of a private IP address to a public IP address is required. Network Address Translation (NAT) is a process in which one or more local IP address is translated into one or more Global IP address and vice versa in order to provide Internet access to the local hosts. Cont.. Also, it does the translation of port numbers i.e. masks the port number of the host with another port number, in the packet that will be routed to the destination. It then makes the corresponding entries of IP address and port number in the NAT table. NAT generally operates on a router or firewall. Network Address Translation (NAT) Types – There are 3 ways to configure NAT: Static NAT Dynamic NAT Port Address Translation (PAT) Static NAT In this, a single unregistered (Private) IP address is mapped with a legally registered (Public) IP address i.e one-to-one mapping between local and global addresses. This is generally used for Web hosting. These are not used in organizations as there are many devices that will need Internet access and to provide Internet access, a public IP address is needed. Suppose, if there are 3000 devices that need access to the Internet, the organization has to buy 3000 public addresses that will be very costly. Dynamic NAT While static NAT is a constant mapping between inside local and global addresses, dynamic network address translation allows you to automatically map inside local and global addresses (which are usually public IP addresses). Dynamic NAT uses a group or pool of public IPv4 addresses for translation. Dynamic NAT used to translate a set of unregistered IP addresses to a smaller set of registered addresses. Dynamic NAT enables you to connect to a large number of hosts to the public Internet using a limited number of registered addresses. Cont.. To configure dynamic NAT, the following steps are required: 1. configure the router’s inside interface using the ip nat inside command 2. configure the router’s outside interface using the ip nat outside command 3. configure an ACL that has a list of the inside source addresses that will be translated 4. configure a pool of global IP addresses using the ip nat pool NAME FIRST_IP_ADDRESS LAST_IP_ADDRESS netmask SUBNET_MASK command 5. enable dynamic NAT with the ip nat inside source list ACL_NUMBER pool NAME global configuration command PAT Port Address Translation (PAT) is an extension of Network Address Translation (NAT) that permits multiple devices on a LAN to be mapped to a single public IP address to conserve IP addresses. PAT is actually a modified version of dynamic NAT in which the number of inside local addresses is greater than the number of inside global addresses. There is generally one single inside global IP address providing Internet access to all inside hosts. NAT Overloading is the only version of NAT that actually conserves IP addresses and it is also the most popular form of NAT as well. PAT is often most cost-effective when many users are connected to the internet through just one public IP address. Address Mapping Address mapping is a process of determining a logical address knowing the physical address of the device and determining the physical address by knowing the logical address of the device. Address mapping is required when a packet is routed from source host to destination host in the same or different network. Address Mapping ONLY – Logical Address to Physical/Local Address – e.ge, IP to MAC address (ARP) – Local Address to Logical Address – MAC to IP address (RARP) Logical to Physical Address Mapping – ARP When a source host wants to send a packet to the destination host it obtains the logical address of the destination host from the DNS (Domain Name Server). If the packet is at any intermediatory router in the network the logical address of the next-hop router is obtained using the routing table. Now the packet to be sent is encapsulated in the frame at the data link layer as it has to travel through the physical network and at the physical level the sender would require the physical address of the receiver. So, the source host broadcasts the ARP query packet to all the hosts in the network. Physical to Logical Address Mapping –RARP To map a physical address of a device to its logical address there are protocols such as RARP, BOOT, DHCP. Reverse mapping, or mapping a physical address to a logical address, is occasionally necessary. RARP is a request and reply protocol used to find the IP address from the MAC address. The physical machine address is also known as a media access control (MAC) address. Routing Routing refers to determining the route taken by packets from source to destination, and is implemented in the control plane. Routing is the process of moving data from one device to another device. In most cases, routing is performed by a networking device called a router. Additionally, a router can forward two or more connections to other networks. Furthermore, we can use routers to create and manage networks. They’re responsible for moving data from one device to another within networks. Additionally, in some cases, it’s also possible to transmit data in different networks using routers. Forwarding Forwarding refers to moving packets from a router's input to appropriate router output, and is implemented in the data plane. Forwarding is the process of collecting data from one device and sending it to another device. This process differs from routing because it doesn’t manage moving data from one device to another. Unlike the routing process, forwarding performs some actions and simply forwards the packets which arrive in intermediate routers. It’s not responsible for deciding the path. In the forwarding process, we only forward the packets to another attached network Encapsulation Data is encapsulated with protocol information at each layer when it is transmitted across a network. As data moves through the layers, communication occurs within the peer layer before moving to the next layer. One important piece of information to keep in mind is that data flows two ways in the OSI model, DOWN (data encapsulation) and UP (data decapsulation). An ARP packet is encapsulated directly into a data link frame.