Forwarding and Routing in Network Layer
Forwarding and Routing in Network Layer
The role of the network layer is thus deceptively simple – to move packets from a sending host to a receiving host. To do so, two important network-layer functions can be identified:
Forwarding
When a packet arrives at a router’s input link, the router must move the packet to the appropriate output link. For example, a packet arriving from Host H1 to Router R1 must be forwarded to the next router on a path to H2.
Routing
The network layer must determine the route or path taken by packets as they flow from a sender to a receiver. The algorithms that calculate these paths are referred to as routing algorithms. A routing algorithm would determine, for example, the path along which packets flow from H1 to H2.
The terms forwarding and routing are often used interchangeably by writers discussing network layers. We’ll use these terms more precisely in this book.
Forwarding refers to the router-local action of transferring packet from an input link interface to the appropriate output link interface.
Routing refers to the network-wide process that determines the end-to-end paths that packets take from source to destination.
Using a driving analogy, consider the trip from Pennsylvania to Florida undertaken by our traveller discussed earlier. During this trip, our driver passes through many interchanges en route to Florida. We can think of forwarding as the process of getting through a single interchange: A car enters the interchange from one road and determines which road it should take to leave the interchange. We think of routing as the process of planning the trip from Pennsylvania to Florida: Before embarking on the trip, the driver has consulted a map and chosen one of many paths possible, with each path consisting of a series of road segments connected at interchanges.
Every router has a forwarding table. A router forward a packet by examining the value of a field in the arriving packet’s header, and then using this header value to index into the router’s forwarding table. The value stored in the forwarding table entry for that header indicates the router’s outgoing link interface to which the packet is to be forwarded.
Depending on the network layer protocol, the header value could be the destination address of the packet or an indication of the connection to which the packet belongs.
Figure below provides an example.
In the above figure, a packet with a header field value of 0111 arrives to a router. The router indexes into its forwarding table and determines that the output link interface for this packet is interface 2. The router then internally forwards the packet to interface 2.
You might be wondering how the forwarding tables in the routers are configured. This is a critical issue, one that exposes the important interplay between routing and forwarding.
As shown in the figure above, the routing algorithm determines the values that are inserted into the routers’ forwarding tables. The routing algorithm may be centralized (e.g. with an algorithm executing on a central site and downloading routing information to each of the routers) or decentralized (i.e. with a piece of the distributed routing algorithm running in each router). In either case, a router receives routing protocol messages, which are used to configure its forwarding table. The distinct and different purposes of the forwarding and routing functions can be further illustrated by considering the hypothetical (and unrealistic, but technically feasible) case of a network in which all forwarding tables are configures directly by human operators physically present at the routers. In this case, no routing protocols would be required! Of course, the human operators would need to interact with each other to ensure that the forwarding tables were configured in such a way that packets reached their intended destinations. It’s also likely that human configuration would be more error-prone and much slower to respond to changes in the network topology than a routing protocol. We’re thus fortunate that all networks have both a forwarding and a routing function!
Connection Setup in Network Layer
We just said that the network layer has two important functions, forwarding and routing. But we’ll soon see that in some computer networks there is actually a third important network-layer function, namely, connection setup.
We know that in case of TCP, a three-way handshake is required before data can flow from sender to receiver. This allows the sender and receiver to set up the needed state information (for example, sequence number and initial flow-control window size). In an analogous manner, some network-layer architectures – for example, ATM, frame relay, and MPLS require the routers along the chosen path from source to destination to handshake with each other in order to set up state before network-layer data packets within a given source-to-destination connection can begin to flow. In the network layer, this process is referred to as connection setup.