Summary
Highlights
The network layer is responsible for encapsulating segments from the transport layer into packets. Its four basic operations include addressing (assigning source and destination IP addresses), encapsulation (wrapping layer four segments into a packet), routing (finding the best path to the destination), and decapsulation (unwrapping the frame to retrieve the packet).
IP, operating at Layer 3, has three main characteristics: connectionless (sends data without verifying the destination's availability), best-effort (attempts to find the best route but doesn't guarantee delivery), and media independent (can travel over any media type as it's encapsulated in frames that are media-dependent).
The IPv4 header includes fields like version (IPv4), source and destination IP addresses, and the Time to Live (TTL) number. The TTL is crucial; it decrements by one at each hop, and if it reaches zero before reaching the destination, the packet is dropped, often resulting in a ping timeout.
IPv6 addresses the limitations of IPv4 by offering a vast number of addresses (128 bits) and simplifying packet handling with fewer header fields. A significant improvement is the elimination of Network Address Translation (NAT), allowing direct internet access for every device with an IPv6 address, which benefits real-time communications.
Routing involves finding the quickest path to a destination. Communication can be loopback (to oneself), local (within the LAN), or remote (outside the LAN via a router). The default gateway is critical; if a destination is not in the local LAN, traffic is sent to the default gateway to reach the outside world. Without a correct gateway IP, external communication fails.
When a packet reaches a router, the router decapsulates the packet from its frame, reads the destination IP, consults its routing table, and re-encapsulates the packet into a new frame for the next hop. Routing tables contain different types of routes: directly connected (automatically added), static (manually configured by an administrator), and dynamic (learned from other routers through routing protocols like OSPF, EIGRP, or RIP). A default route sends packets to a specific interface if no other match is found in the routing table.