Routers

A router is an operates at the network layer of the OSI reference model. Routers are used to connect two or more IP networks.

A router consists of a computer with at least two network interface cards supporting the IP protocol. The router receives packets from each interface via a network interface and forwards the received packets to an appropriate output network interface. The key points here are that routers in the network have a perspective of the correct path to use to reach a destination.

A router receives packets from each interface via a network interface. Received packets have all link protocol headers removed.

The router uses the information in the IP header to decide whether and where to forward each received packet, and which network interface to use to send the packet. Most packets are forwarded based on the packet's IP destination address, along with routing information held within the router in a routing table.

A router does not by default forward a packet with an IP broadcast address. Protocols using broadcast packets normally only operate within a single broadcast domain. (Routers can sometimes be specifically configured to support this.)

Once the transmit interface is selected, the router checks the Maximum Transfer Unit (MTU) of the interface. If the packet size is less than or equal to the MTU, the processing continues. All IP packets contain a TTL value that determines the number of router hops that a packet may be routed, this is decremented by most routers (although routers can be configured to reduce the value by more than 1) It is used to prevent routing loops, and ensures topologies with loops do not result in packets that circulate indefinitely.

At the output interface, the packet (together with a new link layer header) is placed into a transmit queue until the link layer processor is ready to transmit the packet. This, like the receive queue. Each out-going packet requires a new link layer protocol header to be added (encapsulation) with the destination address set to the next system to the receive the packet. The link protocol controller also maintains the hardware address table associated with the interface. This usually involves using the Address ReResit Exam Solution Protocol (arp) to find out the hardware (MAC) addresses of other computers or routers directly connected to the same cable (or LAN). The packet is finally sent using the media interface with the hardware address set to the next hop system. In this way, transmitted packets have a new link protocol header added prior to transmission of each packet.

IPv4 Packets larger than the interface MTU cannot be sent. They can be fragmented by the router into two or more smaller packets. If an IPv4 packet is received which has the Don't Fragment (DF) bit set in the packet header or uses IPv6, the packet is not fragmented, but is instead discarded. In this case, an ICMP error message is returned to the sender (i.e. to the original packet's IP source address) informing it of the interface's MTU size. This forms the basis for Path MTU discovery (PMTU).

Routing and Filter Tables

The routing and filter tables resemble similar tables in link layer bridges and switches. Except, that instead of specifying link hardware addresses (MAC addresses), the router table sepcify network (IP addresses). The routing table lists known IP destination addresses with the appropraite network interface to be used to reach that destiantion. A default entry may be specified to be used for all addresses not explicitly defined in the table (this is very common in routers close to the edge of the networ, where the default routes packets towards the Internet backbone).

A filter table may also be used to ensure that unwanted packets are discarded. The filter may be used to deny access to particular protocols or to prevent unauthorised access from remote computers by discarding packets to a specified destination address. Routers at the edge of ISP networks also often perform filtering of the IP source address, as a way to prevent "spoofing" of addresses belonging to other networks.

A router forwards packets from one IP network to another IP network. Like other systems, it routes based on the longest-prefxi match of the IP addresss in the routing table.

One exception to this rule is when a router receives an IP packet to a network broadcast address. In this case, the router will process the packet internally (to see if it needs to respond) and then discards the packet. Forwarding a broadcast packet can lead to severe storms of packets, and if uncontrolled could lead to network overload.

At the output interface, the packet (together with a new link layer header) is placed into a transmit queue until the link layer processor is ready to transmit the packet. This, like the receive queue. Each out-going packet requires a new link layer protocol header to be added (encapsulation) with the destination address set to the next system to the receive the packet. The link protocol controller also maintains the hardware address table associated with the interface. This usually involves using the Address ReResit Exam Solution Protocol (arp) to find out the hardware (MAC) addresses of other computers or routers directly connected to the same cable (or LAN). The packet is finally sent using the media interface with the hardware address set to the next hop system.

Latency

A router introduces delay (latency) as it processes the packets it receives. The total delay observed is the sum of many components including:

The router queue of packets waiting to be sent also introduces a potential cause of packet loss. Since the router has a finite amount of buffer memory to hold the queue, a router which receives packets at too high a rate may experience a full queue. In this case, the router ahs no other option than to simply discard excess packets. If required, these may later be retransmitted by a transport protocol.

Architecture of a router

Routers are often used to connect together networks which use different types of links. The optimum (and maximum) packet lengths (i.e. the maximum transmission unit (MTU)) is different for different types of network. A router may therefore uses IP to provide segmentation of packets into a suitable size for transmission on a network.

IP routers allow alternate paths to be dynamically selected when routers forward packets. Adding parallel paths through the network adds robustness to failure - if one link, interface (or router) fails, an alternate path may be selected restoring end-to-end connectivity. All IP packets contain a TTL value that determines the number of router hops that a packet may be routed. A router decrements the hop count (IPv4 TTL or IPv6 HopCount) field each time it forwards a packet. If a packet gets stuck in a loop the TTL counts down to zero - at which point the packet is automatically discarded.

Associated protocols perform network error reporting (ICMP), communication between routers (to determine appropriate routes to each destination) and remote monitoring of the router operation (network management).

The operation of a simple modern router is described on a separate page.


See also

Operation of a Router


Gorry Fairhurst - Date: 10/01/2020