To properly learn something, we have to start at the beginning. We will be learning one concept at a time, process it, and move to the next.

The goal is consistent learning and absorbing information while feeling engaged and not overwhelmed.

I have divided the network layer articles into six parts.

  1. Introduction to Network layer
  2. Addressing in Network layer
  3. Decoupling the Router
  4. Routing and Routing Protocols in Network Layer
  5. Internet Protocol
  6. DHCP and NAT in Network layer

Goal of this article

I will be decoupling the router and its functionalities in the network layer of the TCP/IP Five-layer network model.

The primary role of the network layer is deceptively simple—to move packets from a sending host to a receiving host. To achieve that, 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.

  • Forwarding is a function implemented in the data plane.

  • Forwarding refers to the router-local action of transferring a packet from an input link interface to the appropriate output link interface.

  • Forwarding takes place at very short timescales (typically a few nanoseconds) and thus is typically implemented in hardware.

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.

  • Routing refers to the network-wide process that determines the end-to-end paths that packets take from source to destination.

  • Routing takes place on much longer timescales (typically seconds), and as we will see is often implemented in software.

Forwarding table

  • A router forwards a packet by examining the value of one or more fields in the arriving packet’s header and then using these header values to index into its forwarding table.

  • The value stored in the forwarding table entry for those values indicates

the outgoing link interface at that router to which that packet is to be forwarded.

Inside Router

Let’s turn our attention to the forwarding function which does the actual transfer of packets from a router’s incoming links to the appropriate outgoing links at a router.

A high-level view of a generic router architecture is shown

Router architecture

  • Input Ports

    • It performs the physical layer function of terminating an incoming physical link at a router. This is shown in the leftmost box of an input port and the rightmost box of an output port.

    • An Input port also performs link-layer functions needed to interoperate with the link-layer at the other side of the incoming link. This is represented by the middleboxes in the input and output ports.

    • A lookup function is performed at the input port; this will occur in the rightmost box of the input port. It is here that the forwarding table is consulted to determine the router output port to which an arriving packet will be forwarded via the switching fabric.

    • Control packets (for example, packets carrying routing protocol information) are forwarded from an input port to the routing processor.

  • Switching Fabric

    • The switching fabric connects the router’s input ports to its output ports.

    • This switching fabric is completely contained within the router that is a network inside of a network router.

  • Output Ports

    • An output port stores packets received from the switching fabric and transmit these packets on the outgoing link by performing the necessary link-layer and physical-layer functions. This includes selecting and de-queuing packets for transmission and performing the needed link-layer and physical-layer transmission functions.

    • When a link is bidirectional (that is, carries traffic in both directions), an output port will typically be paired with the input port for that link on the same line card.

  • Routing Processor

    • Routing processor maintains routing tables and attached link-state information, and computes the forwarding table for the router.

Input Port Processing and Destination-based Forwarding

  • The input port’s line-termination function and link-layer processing implement the physical and link layers for that individual input link.

  • The lookup performed in the input port is central to the router’s operation—it is here that the router uses the forwarding table to look up the output port to which an arriving packet will be forwarded via the switching fabric.

  • The forwarding table is copied from the routing processor to the line cards over a separate bus indicated by the dashed line from the routing processor to the input line cards in router architecture. With such a shadow copy at each line card, forwarding decisions can be made locally, at each input port, without invoking the centralized routing processor on a per-packet basis and thus avoiding a centralized processing bottleneck.

  • Once a packet’s output port has been determined via the lookup, the packet can be sent into the switching fabric. In some designs, a packet may be temporarily blocked from entering the switching fabric if packets from other input ports are currently using the fabric. A blocked packet will be queued at the input port and then scheduled to cross the fabric at a later point in time.

Let’s close our discussion of input port processing by noting that the input port steps of looking up a destination IP address (“match”) and then sending the packet into the switching fabric to the specified output port (“action”) is a specific case of a more general “match plus action” abstraction that is performed in many networked devices, not just routers.

Switching Fabric and Switching

  • The switching fabric is at the very heart of a router, as it is through this fabric that the packets are switched (that is, forwarded) from an input port to an output port.

  • Switching can be accomplished in several ways:

    • Switching via memory
    • Switching via a bus
    • Switching via an interconnection network

Queuing

  • If we consider input and output port functionality, it’s clear that packet queues may form at both the input ports and the output ports.

  • The location and extent of queueing (either at the input port queues or the output port queues) will depend on the traffic load, the relative speed of the switching fabric, and the line speed.

  • Packet queues can form at the output ports even when the switching fabric is N times faster than the port line speeds.

  • As the queues grow large, the router’s memory can eventually be exhausted and packet loss will occur when no memory is available to store arriving packets.

  • Input Queueing: Consider a crossbar switching fabric and suppose that

    • All link speeds are identical
    • One packet can be transferred from any one input port to a given output port in the same amount of time it takes for a packet to be received on an input link.
    • Packets are moved from a given input queue to their desired output queue in an FCFS manner.
    • Multiple packets can be transferred in parallel, as long as their output ports are different.
    • If two packets at the front of two input queues are destined for the same output queue, then one of the packets will be blocked and must wait at the input queue.
    • The switching fabric can transfer only one packet to a given output port at a time.
  • Output Queuing:

    • When there is not enough memory to buffer an incoming packet, a decision must be made to either drop the arriving packet (a policy known as drop-tail) or remove one or more already-queued packets to make room for the newly arrived packet.
    • In some cases, it may be advantageous to drop (or mark the header of) a packet before the buffer is full to provide a congestion signal to the sender.

Packet Scheduling

Queueing disciplines commonly used in routers:

  • First-in-First-Out (FIFO)
  • Priority Queuing
  • Round Robin and Weighted Fair Queuing (WFQ)

Did you find this post useful?

I would be grateful if you let me know by sharing it on Twitter!

Follow me @ParthS0007 for more tech and blogging content :)