15.4 HOW ROUTERS FORWARD PACKETS
The primary role of a router is to forward packets between independent networks. Unlike an Ethernet switch, which forwards frames according to MAC addresses within a single LAN, a router examines the destination IP address and determines the most appropriate path toward the destination network. This process, known as packet forwarding, enables information to travel across many interconnected networks while preserving a common network-layer protocol.
15.4.1 Packet Encapsulation
As information passes through an internetwork, the network-layer packet remains largely unchanged, but the data-link frame surrounding it is replaced at every network boundary.
For example, a packet transmitted from a computer on an Ethernet LAN may be encapsulated within an Ethernet frame. When that frame reaches a router, the router removes the Ethernet header and trailer, examines the IP packet, determines the appropriate outgoing interface, and then encapsulates the same IP packet within a new frame suitable for the next network. The outgoing frame may again be Ethernet, or it may use Wi-Fi, fiber-optic Ethernet, a point-to-point link, or another Layer-2 technology. This process is illustrated conceptually in Figure 15.5 illustrates this process schematically.

The distinction between Layer 2 and Layer 3 is fundamental. Ethernet, Wi-Fi, and other local networking technologies provide communication only within a single network segment. The Internet Protocol provides the common addressing system that allows packets to move between those networks.
Back to reading