The network layer is the third layer (layer 3) of the seven-layer OSI model.
The network layer is directly above the data link layer and is concerned with getting data from one node to another, even if the target system is located on a remote network, unlike the data link layer which is concerned with local (same subnet) deliver of data.
The network layer provides routing and creating logical paths for transmitting data from node to node.
Some of the functions of this layer include logical addressing, routing and forwarding, datagram encapsulation, and connection management.
- Logical Addressing: Every device that communicates over a TCP/IP network has a logical address assigned to it. This address is known as an IP address. This address is not to be confused with a NIC’s physical address which is the
MAC addressed discussed in the previous article. IP addresses are unique within the network.
- Routing: IP packets may need to be routed between subnets before the data reaches the target system. It is the network layer that handles incoming packets from various sources. Routers are a good example of systems
that depend on the network layer to forward traffic to the correct destination.
- Data Encapsulation: The network layer encapsulates data received from transport layer into datagrams, also known as packets and adds a network layer header.
- Fragmentation and Reassembly: The network layer fragments the data if the packets are too large for the data link layer. Packets are reassembled at the target node.
- Connection Management: Protocols that function at this layer are used to manage some aspects of the network connection between nodes.
Anything that has to do with logical addressing (IP Addresses) works at the OSI Network layer. The network device that heavily depends on the network layer for routing traffic between subnets is the router.
Every TCP/IP device, including computers, depends on the network layer. Anytime your computer needs to communicate with another host, the network layer decides where the packet needs to be sent to. TCP/IP nodes have local routing tables just like routers do.
From your computer, open a command prompt and type
ROUTE PRINT then hit enter.
Routers use their routing tables to decide what port to forward IP traffic on based on the destination IP address found in the packet. While routing may seem complicated, the concept is quite simple.
In the case of a router, when it receives a packet on one interface, the packet is brought up through the network stack and the headers are analyzed. The router will look at the destination information and determine, based on its routing tables, what to do with the packet. Either the router will drop the packet, or place it on one of its interfaces.
If the packet is destined for a node on a local subnet that the router is connected to, the router will deliver the packet using layer 2 methods. If the packet is destined for a remote network, the router will send the packet to the next gateway where the process starts all over again.
It is crucial that you understand how IP addressing works to fully understand routing. We will be covering IP addressing in more detail in the upcoming articles in this series.