Router Architecture
Overview
A router is a networking device that forwards data packets between computer networks. There are three main components involved:
- input ports: take in packets from previous hop, send to switching fabric
- switching fabric: transfer packets from input port to output port
- output ports: take packets from switching fabric, send to next hop

Input Port
The input port is usually composed of three stages:
- Receive light / electronic signal from physical layer, decode the signal into bit stream
- Assemble bit stream into link layer frames, check for errors
- Decide the output port base on the forwarding table, and send the packet to switching fabric

Note
If data arrival rate switching fabric transfer rate, the input port need to buffer the incoming packets, which is what we call input port queuing
Switching Fabric
The switching fabric is responsible for transferring packets from input ports to output ports. There are three major types of switching fabric:
Memory Switching
In memory switching, packets are transferred from input port to output port via shared memory. The packet is copied into memory at the input port and then copied out from memory to the output port.

- Limited by memory bandwidth and processing power
- Packet-by-packet processing (no parallelism)
- Processing overhead of copying packets twice
Bus Switching
Bus switching uses a shared communication bus that all input and output ports connect to. Packets are placed on the bus and addressed to the appropriate output port.

- All ports share the same bus, need time-division multiplexing
- Only one packet can be transmitted on the bus at a time
- Bus speed limits total router throughput, if there are ports with link speed, then it requires bus speed of at least to keep up
Crossbar Switching
Crossbar switching uses a grid of input-output connections that can simultaneously connect multiple input ports to multiple output ports.

- Non-blocking architecture: real parallelism
- Each input can connect to any unused output simultaneously
- Does NOT scale up with the number of ports ( complexity growth)
Packet Scheduling
Priority Scheduling
The low priority queue will NEVER be served if there are packets in the high priority queue.

In the priority, scheduling, scheduler is NOT preemptive, meaning that if a low priority packet is being transmitted, and a high priority packet arrives, the high priority need to wait until the low priority packet is fully transmitted.
Round Robin Scheduling
Fair Round Robin
RR try to be fair, which will poll each queue in a circular manner, and transmit one packet from each queue in each round.

Weighted Fair Queuing (WFQ)
Each queue is assigned a weight , and in each round, the scheduler will transmit packets from queue .
