15.12.4 How Does a Router Know Where to Send a Packet?
- What Is a Router?
- Why Can't Ethernet Switches Perform This Job?
- What Is Inside an IP Packet?
- What Is a Routing Table?
- What Is the "Next Hop"?
- Does the Router Change the Packet?
- How Does the Router Find the Correct Local Device?
- How Do Routers Learn Routes?
- Is the Shortest Route Always Chosen?
- What Happens If a Router Fails?
- How Many Routers Does a Packet Usually Cross?
- Why Is Routing Such an Elegant Solution?
- What Should You Remember?
Short Answer
A router forwards information by examining the destination Internet Protocol (IP) address contained within every packet. It compares this address with the entries in its routing table and determines the most appropriate next step toward the destination. The router does not need to know the packet's complete journey—it simply forwards the packet to the next router, which repeats the process. By making millions of these simple decisions every second, routers collectively enable information to travel across the global Internet.
What Is a Router?
A router is a communication device that connects two or more independent networks.
Unlike an Ethernet switch, which forwards information only within a single Local Area Network (LAN), a router forwards packets between different networks. For example, a packet sent from a computer in Australia to a server in Europe may pass through dozens of routers before reaching its destination.
Each router is responsible for only one small part of that journey.
Why Can't Ethernet Switches Perform This Job?
Ethernet switches make forwarding decisions using Media Access Control (MAC) addresses.
MAC addresses identify devices within a local network but provide no indication of where those devices are located within the wider Internet. A switch therefore works very efficiently inside a LAN but cannot determine how to reach computers located in distant networks. Routers solve this problem by using IP addresses, which contain a hierarchical structure identifying both:
- the destination network; and
- the individual device within that network.
This allows routers to direct packets toward the correct network regardless of where it is located.
What Is Inside an IP Packet?
Every IP packet contains several pieces of information, including:
- the source IP address;
- the destination IP address;
- control information; and
- the user data being transmitted.
The destination IP address is the most important piece of information for the router. Rather than examining the contents of the message itself, the router simply determines where the packet needs to go next.
This separation between addressing and user data allows routers to operate extremely quickly.
What Is a Routing Table?
Every router maintains a routing table. A routing table is simply a list of destination networks together with information describing how those networks can be reached. A typical routing table contains entries describing:
- destination networks;
- network prefixes;
- the next router (next hop);
- the outgoing network interface; and
- a measure of the preferred route.
When a packet arrives, the router compares the destination IP address with the entries in this table and selects the most appropriate route.
What Is the "Next Hop"?
One of the most important ideas in routing is the concept of the next hop.
A router does not normally know every detail of the complete journey. Instead, it asks a much simpler question: "Which neighbouring router should receive this packet next?"
After forwarding the packet, the neighbouring router asks exactly the same question. Each router therefore contributes only one step of the overall route. This process continues until the packet finally reaches its destination network.
The approach is very similar to a relay race, where each runner carries the baton only part of the total distance before passing it to the next runner.
Does the Router Change the Packet?
Not significantly.
The IP packet itself remains largely unchanged as it travels through the Internet. However, the Layer-2 frame surrounding the packet changes every time the packet crosses into a new network. For example, a packet might:
- leave a home computer inside an Ethernet frame;
- travel across a fibre-optic backbone using a different framing technology;
- cross an ISP network;
- arrive at another Ethernet network; and
- finally reach a Wi-Fi access point before being delivered to the destination device.
At every stage, the router removes the incoming Layer-2 frame and creates a new one appropriate for the outgoing network.
The IP packet itself continues its journey unchanged.
How Does the Router Find the Correct Local Device?
Although routers use IP addresses to move packets between networks, local communication technologies such as Ethernet require MAC addresses.
When a packet reaches the destination network, the router determines the MAC address corresponding to the destination IP address. In IPv4 networks this mapping is performed using the Address Resolution Protocol (ARP). IPv6 performs the same function using the Neighbor Discovery Protocol (NDP).
These processes occur automatically and are normally invisible to users.
How Do Routers Learn Routes?
Small networks may use static routing, where a network administrator manually enters routing information.
Larger networks usually employ dynamic routing. In dynamic routing, neighbouring routers exchange information about the networks they can reach. As network conditions change—for example, if a communication link fails—routers automatically update their routing tables and begin forwarding packets along alternative paths.
This ability to adapt is one of the reasons why the Internet is so resilient.
Is the Shortest Route Always Chosen?
Not necessarily.
Routers generally select the best route rather than the physically shortest one. Depending on the network, routing decisions may consider factors such as:
- available bandwidth;
- communication delay;
- reliability;
- network policies; and
- current operating conditions.
Consequently, the route taken by a packet today may differ from the route taken by another packet tomorrow, even if both packets have the same destination.
What Happens If a Router Fails?
One of the strengths of the Internet is that there is rarely only one possible path.
If a router or communication link fails, neighbouring routers usually discover the problem automatically. They then update their routing tables and begin forwarding packets along alternative routes. Most users never notice these changes because they occur very quickly. This distributed approach means that no single router controls the entire Internet.
Instead, every router cooperates with neighbouring routers to provide reliable worldwide communication.
How Many Routers Does a Packet Usually Cross?
The answer depends upon the destination.
A packet sent to another computer in the same building may not pass through any routers at all. A packet sent to another country may pass through:
- the home router;
- an Internet Service Provider (ISP);
- several regional routers;
- international backbone networks;
- additional ISP routers; and
- the destination network.
Even so, the forwarding process remains exactly the same at every step.
Each router simply forwards the packet toward its next destination.
Why Is Routing Such an Elegant Solution?
One of the remarkable features of the Internet is that extremely complex communication emerges from a series of very simple decisions.
No router needs to understand the complete structure of the Internet. Each router only needs sufficient information to decide where the packet should go next. When millions of routers apply this same principle simultaneously, they collectively create a communication system capable of connecting billions of devices throughout the world.
This distributed architecture has allowed the Internet to grow continuously for more than four decades while remaining remarkably reliable.
What Should You Remember?
Routers are the devices that make internetworking possible.
They examine the destination IP address of every packet, consult their routing tables, and forward the packet toward the next network on its journey. Although a packet may pass through many routers before reaching its destination, each router performs exactly the same simple task—determining the best next hop.
This combination of logical IP addressing, routing tables, and distributed forwarding is one of the fundamental architectural principles upon which the modern Internet is built.
Back to reading