But what if your phone in Lucknow wants to send data to a server located in another city or another country?
The data may have to cross many routers and many different networks before reaching its destination.
This is where the Network Layer becomes important.
The Network Layer is the third layer of the OSI model. Its main job is to deliver packets from a source device to a destination device even when both devices are located on different networks.
It performs important tasks such as logical addressing, routing, forwarding, internetworking, fragmentation, congestion handling and Quality of Service.
In the Internet, the most important Network Layer protocol is IP — Internet Protocol.
What Is the Network Layer?
The Network Layer is responsible for moving data from the source host to the destination host across one or more networks.
It sits between the Transport Layer and the Data Link Layer.
Its most important question is very simple:
The Network Layer therefore deals with addressing and path selection.
Network Layer Position in the OSI Model
What Is the PDU of Network Layer?
The Protocol Data Unit of the Network Layer is generally called a:
The Transport Layer gives its data to the Network Layer.
The Network Layer adds its own header containing information such as source and destination logical addresses.
Why Do We Need the Network Layer?
Suppose Computer A and Computer B are directly connected through one LAN.
The Data Link Layer can help them communicate inside that local network.
Now suppose Computer B is located on another network.
The packet may need to travel through:
Source Host
Creates data that must be sent to another network.
Default Router
Receives the packet and decides where it should go next.
Intermediate Routers
Forward the packet from one network toward another.
Destination Network
Final router delivers the packet toward the destination host.
Without the Network Layer, communication would mostly remain limited to directly connected local networks.
Main Functions of the Network Layer
Logical Addressing
Gives source and destination hosts logical addresses such as IP addresses.
Routing
Determines a suitable path from source network to destination network.
Forwarding
Moves an incoming packet to the correct outgoing interface.
Internetworking
Connects different networks into a larger network system.
Fragmentation
Handles packet-size differences when a packet must cross a network with a smaller MTU.
Congestion Handling
Helps deal with situations where too much traffic enters the network.
Quality of Service
Supports performance requirements such as delay, bandwidth and packet-loss needs.
Error Reporting
Network-control mechanisms can report certain delivery or routing problems.
Loop Prevention
Fields such as TTL or Hop Limit prevent packets from circulating forever.
Logical Addressing
A network may contain millions of devices.
Each device therefore needs an address that can identify its network and its position within the internetwork.
The Network Layer mainly uses:
IP address is called a logical address.
It is different from the MAC address used at the Data Link Layer.
IP: 192.168.1.10
Checks destination IP
IP: 10.10.1.20
Why Is IP Called a Logical Address?
Because it is assigned according to network organization rather than being permanently tied to the hardware interface in the same way a MAC address normally is.
Routing
Routing means selecting a path through the network.
When multiple paths exist between sender and receiver, routers and routing mechanisms decide which route should be used.
A route may be selected according to factors such as:
- Hop count
- Link cost
- Bandwidth
- Delay
- Administrative policy
- Network reachability
Forwarding
Forwarding is the actual movement of a packet inside a router.
When a router receives a packet:
Routing vs Forwarding
Routing
Routing decides which paths should exist.
It builds or updates information used to reach different networks.
Think: “Which path should be used?”
Forwarding
Forwarding handles each arriving packet.
It sends that packet through the selected outgoing interface.
Think: “Where should this packet go now?”
Internetworking
Internetworking means connecting multiple individual networks so they can communicate as one larger system.
The Internet itself is the biggest example.
Different networks may use different:
- Physical media
- Data rates
- Local technologies
- Frame formats
The Network Layer provides a common logical delivery mechanism above those local differences.
Fragmentation and Reassembly
Not every network can carry packets of the same maximum size.
Suppose one network supports a packet of 4000 bytes but the next network can carry only 1500 bytes.
In IPv4, fragmentation may be needed when permitted.
First part
Middle part
Final part
Reassembly
The fragments must eventually be combined again to recover the original IP datagram.
In IP, reassembly takes place at the destination host.
Congestion Control
Congestion happens when the network receives more traffic than it can comfortably handle.
Imagine a road designed for 500 vehicles suddenly receiving 5000 vehicles.
The same kind of problem can occur inside a network.
Increased delay, queue overflow and packet loss.
Causes of Congestion
- Too many packets arriving at the same time
- Slow outgoing links
- Insufficient router buffer
- Poor routing decisions
- Sudden traffic bursts
Quality of Service — QoS
Different applications have different network requirements.
For example:
- Email can tolerate some delay.
- Voice calls are sensitive to delay.
- Video streaming needs reasonable bandwidth.
- Interactive games are sensitive to latency and jitter.
Error Reporting and Diagnostics
The Network Layer is not responsible for correcting every transmission error.
However, network-control protocols can report certain delivery problems.
In the Internet architecture, ICMP is used for control and diagnostic messages associated with IP.
Examples include:
- Destination unreachable
- Time exceeded
- Diagnostic echo request and reply
TTL and Hop Limit
Routing problems can sometimes create loops.
Without a protection mechanism, a packet could keep circulating between routers.
IPv4 uses:
IPv6 uses a similar field called:
Every router that forwards the packet reduces the value.
When the value reaches zero, the packet is discarded.
Services Provided by Network Layer to Transport Layer
The Transport Layer uses the Network Layer to send data toward another host.
A good Network Layer service should hide unnecessary details of the underlying networks from the Transport Layer.
Classic design goals include:
- Services should be independent of router technology.
- The Transport Layer should not need to know the number or type of routers used.
- Network addressing should provide a consistent way to identify destinations.
- Communication should work across different interconnected networks.
Two Basic Service Approaches
- Connectionless service
- Connection-oriented service
Connectionless Network Service
In a connectionless service, no dedicated logical path is established before sending packets.
Each packet can be treated independently.
Every packet normally carries enough destination information to be routed.
Packet 1
Packet 2
Two packets belonging to the same communication may theoretically travel through different routes.
Connection-Oriented Network Service
In a connection-oriented approach, a logical path is established before data packets are transferred.
The communication usually has three phases:
- Connection setup
- Data transfer
- Connection release
Logical Path
Once the path is established, packets associated with that virtual connection normally follow that logical route.
Datagram Network
A datagram network implements connectionless packet delivery.
Each packet is called a datagram and is handled independently.
Important Features
- No connection setup is required before transmission.
- Each packet contains destination information.
- Routers make forwarding decisions packet by packet.
- Packets may use different paths.
- Packets may arrive out of order.
- Router state for each end-to-end connection is not required in the same way as a virtual-circuit network.
Virtual Circuit Network
A virtual circuit is a logical connection created through a packet-switched network.
Before data transfer, the path is established.
Routers or switches along the selected path maintain information about the virtual connection.
Main Stages
Setup
Establish the virtual route.
Data Transfer
Packets use the established logical path.
Release
Connection information is removed after communication finishes.
Datagram Network vs Virtual Circuit Network
| Point | Datagram Network | Virtual Circuit Network |
|---|---|---|
| Service Type | Connectionless | Connection-oriented |
| Setup | No prior connection setup | Connection setup required |
| Routing | Packet may be routed independently | Logical path selected during setup |
| Packet Header | Usually carries full destination address | May carry a shorter virtual-circuit identifier |
| Router State | Less connection-specific state | Virtual-circuit state maintained |
| Packet Order | Packets can arrive out of order | Normally follow same logical path |
| Failure Effect | Later packets may find another route | Existing virtual circuit may need rebuilding |
| Example Concept | Internet IP model | Virtual-circuit packet-switching model |
Major Network Layer Design Issues
When designing the Network Layer, engineers must decide much more than simply how to place an address inside a packet.
Service Type
Should the network provide connectionless or connection-oriented service?Routing
How should packets find a suitable path?Forwarding
How should routers move packets to the next hop efficiently?Addressing
How should hosts and networks be uniquely identified?Packet Size
What happens when different networks support different MTUs?Congestion
How should the network behave under heavy traffic?Quality of Service
How should different performance requirements be handled?Internetworking
How should different networks communicate through one common layer?Failure Handling
What happens if a route, link or router becomes unavailable?Store-and-Forward Packet Switching
In packet-switched networks, a router generally receives a packet before forwarding it toward the next hop.
Sends packet
Receives, examines and forwards
Receives packet
The router examines header information and decides which outgoing interface should be used.
Important Service Design Principles
A well-designed Network Layer should make communication easy for upper layers.
The Transport Layer should not need to understand every internal detail of each router or physical network.
Routing Table
A router needs information about reachable networks.
This information is stored in a routing or forwarding table.
Default Route
The route:
is commonly used as an IPv4 default route.
It can be chosen when no more specific route matches the destination.
Longest Prefix Matching
Sometimes more than one routing-table entry matches the destination IP address.
The router normally selects the most specific matching prefix.
Example
Suppose the table contains:
Destination:
All three prefixes may be related, but:
Static Routing and Dynamic Routing
Static Routing
Routes are manually configured by an administrator.
Advantages:
- Simple in small networks
- No routing-protocol overhead
- Predictable configuration
Limitations:
- Difficult to maintain in large networks
- Does not automatically adapt to many failures
Dynamic Routing
Routers exchange information through routing protocols and can adapt routes when network conditions change.
Examples include:
- RIP
- OSPF
- BGP
Important Information Carried in a Network Packet
The exact fields depend on the protocol, but an IP packet header contains information needed for network delivery.
What Is MTU?
MTU stands for:
It is the maximum packet or payload size a particular link-layer technology can carry in one frame according to its rules.
A common Ethernet IP MTU is:
If an IPv4 datagram is larger than the outgoing link MTU, fragmentation may be required unless fragmentation is prohibited.
Solved IPv4 Fragmentation Numerical
Suppose:
Step 1: Find Original Data Size
Step 2: Maximum Data Per Fragment
1480 is divisible by 8, which is useful because the IPv4 fragment offset is measured in units of 8 bytes.
Fragments
| Fragment | Data Bytes | Total Length | Offset | MF |
|---|---|---|---|---|
| 1 | 1480 | 1500 | 0 | 1 |
| 2 | 1480 | 1500 | 185 | 1 |
| 3 | 1020 | 1040 | 370 | 0 |
Offset Calculation
IPv4 vs IPv6 Fragmentation
| Point | IPv4 | IPv6 |
|---|---|---|
| Router Fragmentation | Can occur when allowed | Routers do not fragment transit packets |
| Who Fragments? | Source or router may fragment in relevant cases | Fragmentation is performed by the source using the Fragment extension header |
| Path MTU Importance | Important | Very important |
| Reassembly | Destination | Destination |
Flow Control vs Congestion Control
Students often confuse these two terms.
| Point | Flow Control | Congestion Control |
|---|---|---|
| Main Problem | Fast sender may overwhelm receiver | Too much traffic may overwhelm the network |
| Focus | Sender and receiver relationship | Overall network load |
| Typical Concern | Receiver capacity | Router queues, links and traffic level |
| Example | Sliding Window flow control | Traffic management and congestion mechanisms |
Important Network Layer and Related Routing Protocols
Role of a Router at the Network Layer
A router is the main device associated with the Network Layer.
Its basic work is:
- Receive a frame on an interface.
- Remove the local Data Link Layer framing.
- Examine the destination Network Layer address.
- Search forwarding information.
- Select the next hop or outgoing interface.
- Create suitable Data Link Layer framing for the next link.
- Forward the packet.
Real-Life Example: Opening a Website
Suppose you enter a website address on your laptop.
After the destination IP is known, your device needs to send packets toward that server.
Your Laptop
Creates an IP packet containing source and destination addresses.
Home or Campus Router
Checks the destination and forwards the packet toward the next network.
ISP Routers
Multiple routers may forward the packet according to their routing information.
Destination Network
Packet reaches the network containing the web server.
Server
The destination host receives the packet and passes its contents upward to the correct transport process.
Network Layer vs Data Link Layer
| Point | Data Link Layer | Network Layer |
|---|---|---|
| OSI Layer | Layer 2 | Layer 3 |
| Main Unit | Frame | Packet |
| Address | MAC address | IP address |
| Delivery | Link-to-link or local delivery | Host-to-host delivery across networks |
| Main Device | Switch / bridge | Router |
| Major Concern | Framing, MAC access, link errors | Routing, forwarding and logical addressing |
Network Layer vs Transport Layer
| Point | Network Layer | Transport Layer |
|---|---|---|
| OSI Layer | Layer 3 | Layer 4 |
| Main Delivery | Host-to-host | Process-to-process |
| Main Address | IP address | Port number |
| Main Task | Routing and packet forwarding | End-to-end transport service |
| Common Protocols | IP | TCP, UDP |
Common Exam Mistakes
Network Layer routing mainly uses logical addresses such as IP addresses.
Routing decides or learns paths. Forwarding handles an individual packet using that information.
A router's key forwarding function is associated with the Network Layer, although real devices also interact with lower layers.
Flow control protects the receiver from a fast sender. Congestion control deals with excessive traffic inside the network.
Packets can be routed independently and may take different paths.
IPv6 routers do not fragment transit packets. Fragmentation, when needed, is handled by the source.
In practical forwarding, routers decrement TTL as packets pass through hops.
It commonly stores network prefixes and associated next-hop or interface information.
Longest prefix means the matching route with the greatest prefix length, such as /25 being more specific than /24.
Standard IP service is generally best effort and does not itself guarantee reliable delivery.
40 Important Network Layer Questions With Answers
20 Network Layer MCQs With Answers
A. Layer 1
B. Layer 2
C. Layer 3
D. Layer 4
A. Bit
B. Frame
C. Packet
D. Segment only
A. IP address
B. MAC address only
C. Port number
D. Process ID
A. Router
B. Keyboard
C. Repeater only
D. Printer
A. Framing
B. Routing
C. Encoding
D. Multiplexing
A. Forwarding
B. Encryption
C. Sampling
D. Modulation
A. Connectionless best-effort service
B. Guaranteed end-to-end delivery
C. Circuit switching only
D. Application encryption
A. 0.0.0.0/0
B. 255.255.255.255/32 only
C. 127.0.0.1/8
D. 1.1.1.1/32 always
A. Most specific matching route
B. Shortest IP address
C. Largest packet
D. Lowest MAC address
A. Maximum Transmission Unit
B. Minimum Transfer Utility
C. Main Transport User
D. Maximum TCP Usage
A. More Fragments
B. Maximum Frame
C. Main Forwarder
D. Multiple Flow
A. 8 bytes
B. 1 bit
C. 100 bytes
D. 1024 bytes
A. TTL
B. Port number
C. MAC CRC
D. Sequence window
A. Hop Limit
B. Frame Limit
C. Window Limit
D. Route ID
A. ICMP
B. HTML
C. CSS
D. SMTP only
A. Connectionless
B. Always connection-oriented
C. Circuit switched only
D. Application layer only
A. Setup before data transfer
B. No path information
C. No forwarding
D. No routers
A. OSPF
B. HTML
C. ARP table entry only
D. JPEG
A. Network traffic exceeds available resources
B. A user changes font size
C. A monitor turns off
D. A keyboard disconnects
A. Transport Layer
B. Network Layer
C. Physical Layer
D. Data Link Layer
Frequently Asked Questions
What is the Network Layer in simple words?
The Network Layer is the OSI layer responsible for sending packets from one host to another host across different networks using logical addresses and routers.
What are the main functions of the Network Layer?
Its main functions include logical addressing, routing, forwarding, internetworking, fragmentation handling, congestion management, QoS support and network-control functions.
Why is IP address called a logical address?
An IP address identifies a host and its network logically and can change when the device moves to another network or receives another network configuration.
What is the difference between routing and forwarding?
Routing determines paths or learns reachability information, while forwarding sends each arriving packet through the selected outgoing interface.
What is a datagram network?
A datagram network is a connectionless packet-switched network where each packet can be processed and routed independently.
What is a virtual circuit?
A virtual circuit is a logical path established through a packet-switched network before data transfer.
What is MTU?
MTU means Maximum Transmission Unit and represents the maximum packet size that can be carried through a link according to that link's technology and configuration.
Does IPv6 router fragmentation work like IPv4?
No. IPv6 routers do not fragment packets in transit. The source is responsible for fragmentation when it is required.
What is longest prefix matching?
It is the rule where a router chooses the matching routing entry with the greatest prefix length because that route is the most specific.
What is the main device used at the Network Layer?
A router is the main device associated with Network Layer packet forwarding between networks.
Quick Network Layer Revision
Final Memory Line:
IP identifies the destination → Routing finds the direction → Forwarding moves the packet → Routers repeat this process until the packet reaches the destination network.
