Suggest an editImprove this articleRefine the answer for “What does the OSI network layer do?”. Your changes go to moderation before they’re published.Approval requiredContentWhat you’re changing🇺🇸EN🇺🇦UAPreviewTitle (EN)Short answer (EN)**The network layer (Network Layer)** is responsible for *delivering packets between different networks* and for *routing*: choosing the path the data will take. **Key point:** the network layer provides logical addressing (IP addresses) and routes packets between networks - it is the layer that decides where to send a packet next, which node becomes the next "hop".Shown above the full answer for quick recall.Answer (EN)Image**The network layer (Network Layer)** is responsible for *delivering packets between different networks* and for *routing*: choosing the path the data will take. Short formulation for an interview: > **The network layer provides logical addressing (IP addresses) and routes packets between networks. It is the layer that decides where to send a packet next - which node becomes the next "hop".** --- ## Main functions of the network layer ### 1. Routing: the main function The network layer: - decides "where to send the packet" - chooses the optimal path (route) - passes the packet to the next router (next-hop) This is implemented using: - routing tables - route lookup algorithms - static/dynamic routes --- ### 2. Logical addressing (IP addressing) Layer 3 uses **IP addresses**, which: - are unique within the network - are independent of MAC addresses - allow packets to be delivered across multiple networks Main addressing protocols: - IPv4 - IPv6 --- ### 3. Packet encapsulation and decapsulation On the way in, the network layer: - receives a segment from L4 (TCP/UDP) - wraps it into a packet (IP header + payload) On the way out: - passes the packet to the data link layer (L2) --- ### 4. Packet fragmentation and reassembly If a packet exceeds the link's MTU, the network layer can: - **fragment** it into smaller pieces (in IPv4) - **reassemble** the fragments at the destination device IPv6 does not support fragmentation by routers, only by the sender. --- ### 5. Determining packet lifetime (TTL/Hop Limit) Every IP packet contains: - **TTL (IPv4)** - **Hop Limit (IPv6)** Every router decrements the TTL by 1. If TTL=0, the packet is dropped and an ICMP "Time Exceeded" message is sent. This protects the internet from infinite loops. --- ### 6. Handling ICMP messages ICMP works *on top of IP* and is used for: - transmission errors - diagnostics - `ping` and `traceroute` --- ## Routers operate at the network layer **Switch = L2** **Router = L3** A router: - reads the destination IP address - checks the routing table - forwards the packet to the correct subnet Without the network layer, it is impossible to deliver packets: - to other subnets - to the internet - between offices/branches --- ## Network layer protocols #### Addressing protocols: - IPv4 - IPv6 #### Diagnostic and service protocols: - ICMP - ICMPv6 #### Routing protocols: - OSPF - BGP - RIP - IS-IS --- ## What the network layer does NOT do It's important not to confuse these: The network layer is **not** responsible for: - delivering frames within a LAN - MAC addresses - TCP/UDP ports - reliable delivery That is the job of L2 and L4. --- ## Example of the network layer at work If a computer with the address **192.168.1.5** sends a packet to **8.8.8.8**: 1. L4 creates a segment (TCP/UDP). 2. L3 wraps it into an IP packet and checks the destination IP. 3. It realizes the address is on a different network. 4. It sends the packet to the router (gateway). 5. The router determines the best path and forwards it further.For the reviewerNote to the moderator (optional)Visible only to the moderator. Helps review go faster.