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.
Unlike physical MAC addresses, which are tied to specific hardware, logical addresses (IP Addresses) are hierarchical and assigned by the network you connect to.
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.
192.168.1.5To 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.
2001:0db8:85a3:0000:0000:8a2e:0370:7334A 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.
255.255.255.0 (indicates the first 24 bits are the network, and the last 8 bits identify the specific computer).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.
Routers must constantly communicate with each other to discover the most efficient paths through the Internet.