codingstuff.io
ExploreTutorialsProblemsCS Subjects
Get Started
ExploreTutorialsProblemsCS Subjects
Get Started
codingstuff.io

Master the art of building software through interactive tutorials, real-world problems, and guided projects.

Pune, Maharashtra, India

codingstuffmail@gmail.com

Product

  • Explore
  • Tutorials
  • Problems
  • CS Subjects

Company

  • About
  • Contact
  • Privacy Policy
  • Terms & Conditions
  • Sitemap

© 2026 codingstuff.io. All rights reserved.

Built with ❤️ for developers everywhere

/
/
All Subjects
🌐

Computer Networks

26 chapters

1Network Topologies & LAN/WAN2Network Devices (Hub, Switch, Router)3OSI Reference Model4OSI Model & TCP/IP Suite5TCP/IP Protocol Suite6Switching Techniques (Circuit, Packet)7Data Link: Framing & Error Detection8Error Correction (Hamming Code)9Flow Control (Stop-and-Wait, Sliding Window)10MAC: CSMA/CD & CSMA/CA11Network Layer & Routing12IP Addressing (IPv4, IPv6)13Subnetting & CIDR14Routing Algorithms (Distance Vector, Link State)15ARP, ICMP, and NAT16DHCP Protocol17Transport Layer Services18Transport Layer: UDP19Transport Layer: TCP & 3-Way Handshake20TCP Congestion Control21Application Layer: DNS & HTTP22Application Layer: SMTP & FTP23Socket Programming Basics24Wireless Networks & Wi-Fi Standards25VLANs & Spanning Tree Protocol26Network Security & Cryptography
SubjectsComputer Networks

Network Layer & Routing

Updated 2026-05-06
2 min read

Network Layer & Routing

The Network Layer (Layer 3 of the OSI model) is responsible for the source-to-destination delivery of a packet across multiple networks. If the Data Link layer is like navigating the streets of your neighborhood, the Network Layer is like the highway system connecting different cities.

1. Logical Addressing (IP Addresses)

Unlike physical MAC addresses, which are tied to specific hardware, logical addresses (IP Addresses) are hierarchical and assigned by the network you connect to.

IPv4

An IPv4 address is a 32-bit address that uniquely and universally defines the connection of a device to the Internet. It is typically written in dotted-decimal notation.

  • Example: 192.168.1.5
  • The 32 bits allow for approximately 4.3 billion unique addresses. Because the world ran out of IPv4 addresses, mechanisms like NAT (Network Address Translation) were invented to allow entire home networks to share a single public IPv4 address.

IPv6

To solve the address exhaustion problem, IPv6 was introduced. It uses 128-bit addresses, allowing for $3.4 \times 10^38$ unique addresses—enough to assign an IP address to every atom on the surface of the Earth.

  • Example: 2001:0db8:85a3:0000:0000:8a2e:0370:7334

2. Subnetting

A large organization might be assigned a block of thousands of IP addresses. Instead of having all thousands of computers on a single massive network (which would cause massive broadcast storms and congestion), the network administrator will divide the large network into smaller, logical sub-networks called Subnets.

Subnetting is achieved using a Subnet Mask, which tells the computer which part of the IP address represents the Network ID, and which part represents the Host ID.

  • Example Subnet Mask: 255.255.255.0 (indicates the first 24 bits are the network, and the last 8 bits identify the specific computer).

3. Routing

When a packet needs to be sent to a computer on a different network, it is sent to a Router. The router's job is to look at the destination IP address in the packet header, consult its internal map (Routing Table), and forward the packet closer to its final destination.

Routing Algorithms

Routers must constantly communicate with each other to discover the most efficient paths through the Internet.

  1. Distance-Vector Routing: Each router periodically shares its knowledge of the entire network with its immediate neighbors. (e.g., RIP Protocol).
  2. Link-State Routing: Each router shares knowledge of its immediate neighbors with the entire network. Every router builds a complete topological map of the entire network and runs Dijkstra's Shortest Path algorithm to find the best routes. (e.g., OSPF Protocol).


PreviousMAC: CSMA/CD & CSMA/CANextIP Addressing (IPv4, IPv6)

Recommended Gear

MAC: CSMA/CD & CSMA/CAIP Addressing (IPv4, IPv6)