There are 4 key router components:
- Input Ports:
- This is the physical entry point (port) where a network cable plugs into a router, so it receives the raw electrical/radio/light signals from the physical cable and converts them back into binary bits. A router port (physical hardware) are different from software ports (e.g. Port 80 for HTTP, using sockets).
- It also performs a link-layer function, meaning it decodes the link-layer protocol (e.g. Ethernet) to extract the IP packet from its outer frame.
- Finally, it reads the packet’s destination address, check’s the router’s forwarding table, and determines which output port the packet should be sent to via the router’s internal switching fabric.
- Switching Fabric
- The switching fabric connects the router’s input ports to its output ports.
- Output Ports
- An output port stores packets received from the switching fabric and transmits these packets on the outgoing links by performing the necessary link-layer and physical-layer functions
- When a link is bidirectional (i.e. carries traffic in both directions), the output port will also be paid with an import port for that link.
- Routing Processor
- This performance the control-plane functions i.e. it’s the router’s central brain
- Unlike the input ports (which handle individual packets moving at high speed), the routing processor doesn’t touch everyday data packets. Instead, it manages high-level path planning and network administration.
- In traditional routers, the routing processor does its own thinking. It speaks directly to other routers across the internet to exchange path information, runs algorithms internally to figure out the best route, and builds the forwarding table itself and copies it to the input ports.
- In SDN routers, the routing processor doesn’t calculate routes on its own. Instead, it listens to a remote central controller (the master software brain) and takes the forwarding tables received from that controller and installs them into the router’s input ports. More notes on this here.
- Besides setting up forwarding tables, the routing processor also handles network management – tasks like checking system health, monitoring performance, and allowing network admins to log in remotely.

Roundabout Analogy
- We can use the analogy of a traffic roundabout to explain how routers process packets, how they make routing decisions and whee physical traffic jams occur inside router hardware
| Roundabout Feature | Router Component | What It Does |
|---|---|---|
| Entry Road & Attendant Station | Input Port | Receives incoming packets and looks up where they should go. |
| The Roundabout Itself | Switch Fabric | The internal hardware “lanes” that transfer packets from entry to exit. |
| Exit Road | Output Port | Sends outgoing packets down the next cable toward their destination. |
- Now imagine an attendant standing at the entrance of the roundabout inspecting each car to explain the difference between traditional and modern forwarding:
- Destination-based forwarding (traditional): the attendant asks where you’re going. The decision is based only on the destination IP address e.g. if you’re going to London, take Exit 3
- Generalised forwarding (modern/SDN): the attendant looks at multiple pieces of information, not just the destination (e.g. the origin, the car type, licence plate, safety rules, etc.). For example, sports cars take a priority road, unsafe cars (suspicious packets) are blocked, lorries from France (specific source IP) must take Exit 1.
- By thinking of a router as a roundabout, router engineers can pinpoint where data backs up:
- Input Port Jam: Cars arrive at 100 mph, but the attendant checks tickets slowly. Packets pile up on the entry road waiting for a lookup.
- Switch Fabric Jam: The attendant works fast, but the roundabout itself is narrow or slow. Packets get stuck inside the internal transfer machinery.
- Output Port Jam: Everything moves fast, but cars from every entry road all want to take Exit 2 at the exact same time. Packets pile up waiting to squeeze onto that single physical exit wire.
Input Port Processing and Destination-Based Forwarding
- Before a router can read where a packet needs to go, the input port has to capture the raw signal off the cable and unwrap its outer packaging. It does this in two steps:
- Line-Termination (Physical Layer): Plugs directly into the physical cable (fiber, copper, or wireless). It catches incoming pulses of light or electricity and translates them into raw 1s and 0s.
- Link-Layer Processing (Link Layer): Takes those 1s and 0s, checks them for transmission errors, and strips off the temporary outer wrapper (like the Ethernet frame) so the router can access the actual IP packet inside.
- The lookup then performed in the input port is central to the router’s operation – it’s where the router uses the forwarding table to look up the correct output port to which an arriving packet will be forwarded via the switching fabric.
- The forwarding table is computed by the routing processor or is received from a remote SDN controller.
- This forwarding table is copied across to each line card at every input port. Each input port stores its own local copy of this table right on its own memory chip. When a packet arrives, the input port looks up the destination on its own local table in nanoseconds.

- Let’s consider the simplest case of an incoming packet is switched to its output port based on its destination IP address.
- There are over 4 billion possible IPv4 addresses, so if a router had a forwarding table with 4 billion individual entries, it would take too much memory and be too slow to search through for every single packet.
- So, instead, it uses IP prefixes (which work like post/zip codes)
- Instead of listing individual addresses, routers group them by their starting bits, known as a prefix.
- This is exactly how postal zip codes work in America: a sorting facility doesn’t need a bin for every house in California. It just sends all mail starting with “9” to the West Coast truck.

- As shown in this image, the router condenses massive ranges of IP addresses into a few simple prefixes (in blue).
- If the beginning of an incoming packet’s IP address matches a prefix in the table, it is forwarded out of that specific link interface.
- If it doesn’t match any of the specific rules, it gets pushed out of a “catch-all” default door, which is Interface 3 in this example.
- Because prefixes can overlap, an incoming IP address might actually match two different entries in the table.
- To solve this, the rule is that the router must always choose the longest prefix match, meaning the match that has the highest number of identical bits.
- This is because the longest match is the most specific e.g. if a post office has one sorting rule for “New York State” (a short prefix) and a different rule for “New York City” (a longer, more specific prefix), a letter to Manhattan will match both. The system uses the longer, more specific rule to ensure the letter goes to the exact right city, not just the general state.
- The forwarding table makes this lookup pretty simple – hardware logic searches through the forwarding table looking for the longest prefix match.
- Then, once the packet’s output port is determined via this lookup, the packet can be sent into the switching fabric.
- In some designs, a packet can be temporarily blocked from entering the switching fabric if it’s busy handling packets from other inputs. It’s then queued at the input port and scheduled to cross the fabric at a later point.
Switching
- The switching fabric is where packets are forwarded to an output port.
- Switching can be done in a few different ways:
- Switching via memory: method routers use to physically move a packet from an input port to an output port by temporarily storing it in RAM
- Early routers were just standard computers. When a packet arrived, it interrupted the main CPU. The CPU copied the packet into central memory, figured out its destination, and then copied it out to the correct exit port.
- Because every single packet had to be written into memory and then read out of memory over a single shared wire (the system bus), the router could only move one packet at a time.
- So to switch a packet via memory, the data had to travel across this exact same bus twice – once to be written from the input port into memory, and a second time to be read from memory out to the output port.
- Therefore, if the memory could handle B data transfers per second, the router’s maximum forwarding speed was exactly half of that (B/2).
- Switching via a bus: where an input port sends a packet directly to an output port over a single shared communication wire, completely bypassing the router’s main central CPU
- When a packet arrives, the input port gives a temporary, internal label to it that identifies the correct output port.The packet is sent down the shared bus. Because all output ports are connected to this same bus, every output port sees the packet go by.
- Only the output port that matches the temporary label grabs the packet. It then rips off the internal label and sends the bare packet on its way.
- Because all ports share one single wire, only one packet can cross the bus at a time. If multiple packets arrive at different input ports at the exact same millisecond, they have to wait in line.
- Switching via an interconnection network: this solves the one-at-a-time speed limit of a single shared bus by using a grid of intersecting wires, allowing multiple packets to cross the router simultaneously.
- Where every horizontal and vertical wire crosses is a crosspoint – a microscopic electronic bridge. When Input 2 needs to send a packet to Output 2, the router’s hardware controller snaps that specific bridge closed, creating a dedicated, direct path.
- Because the wires are physically separate, Input 2 can send a packet to Output 2 at the exact same time Input 1 sends a packet to Output 1.
- This design is considered non-blocking. A packet will never get stuck waiting just because the router’s internal machinery is busy handling other traffic. If your specific exit is clear, you can go.
- The only time a packet is forced to wait is if Input 1 and Input 2 both try to send packets to Output 2 at the exact same millisecond. Because a single output wire can only carry one packet at a time, one of the packets must wait at its input port until the destination is free.
- Switching via memory: method routers use to physically move a packet from an input port to an output port by temporarily storing it in RAM

Output Port Processing
- Output port processing takes packets stored in the output port’s memory and sends them over the output link.
- This includes selecting (i.e. scheduling) and de-queuing packets for transmission, and performing the needed link-layer and physical-layer transmission functions.

When Does Queuing Happen?
- Packet queues can occur at both the input and output ports.
- The location and extent of this queuing depends on traffic load, the speed of the switching fabric and the line speed
- If the queues get too large, the router’s memory can get exhausted resulting in packet loss (as there’ll be no memory to store arriving packets).
- The location of these traffic jams then depends on two speeds:
- Rline (Cable Speed): How fast packets arrive at the router from the outside world.
- Rswitch (Internal Speed): How fast the router’s internal hardware moves packets from an entrance to an exit.
- To guarantee that a traffic jam never happens at the input ports, the router’s internal speed (Rswitch) must be exactly N times faster than the cable speed (Rline), where N is the total number of ports.
- If a router has 10 input ports (N=10), the worst possible situation is all 10 ports receiving a packet at the exact same millisecond, with all 10 packets needing to go to the exact same output port. But if the internal switch is 10 times faster than the incoming cable, it can sweep all 10 packets out of the entryways before the next batch arrives.
Input Queuing
- If the switch fabric isn’t fast enough to move all the packets through it without a delay then the packets will start queuing at the input ports
- Packets need to join input port queues to wait their turn to be transferred through the switching fabric to the output port.

- In this image, two packets are at the front of their input queue (input 1 and input 3) and are destined for the same output port (output 1).
- If the switching fabric chooses to transfer the packet from the front of input 1, then the first packet in input 3 must wait.
- In fact, not only does this first packet at input 3 wait, but so too does the second packet that is queued behind that packet in input 3 (even though that packet wants to go to output 2, where no other packet wants to go).
- This situation is known as head-of-the-line (HOL) blocking in an input-queue switch – a queued packet in an input queue must wait for transfer through the fabric (even though its output port is free) because it’s blocked by another packet at the head of the line.
Output Queuing
- Now suppose Rswitch (the router’s internal speed) is N times faster than Rline (the speed packets arrive at the router). And imagine the router has 10 input ports (N=10), but they all want to exit through the same output port.
- If T is the exact time it takes for a physical cable to transmit a single packet, determined by the cable speed (Rline)
- The output port spends the entirety of time T pushing exactly one packet out onto its departing cable.
- During that exact same time T, the 10 incoming cables each finish receiving one new packet.
- Because the internal switch speed (Rswitch) is exactly 10 times faster than the cable speed (Rline), the internal machinery takes all 10 of those newly arrived packets and transfers them across the router to the output port before time T is up.
- Since the output port can only transmit a single packet in a single unit of time (i.e. the packet transmission time), the N arriving packets will have to queue (wait) from transmission over the outgoing link.
- Eventually, there can be so many queued packets that it exhausts all available memory at the output port.

- When an output port’s waiting line (buffer) gets completely full, the router is forced to throw data away, but it uses specific rules to manage how and when this happens.
- The “Full Line” Problem (Drop-Tail): If the memory is 100% full and a new packet arrives, the simplest thing a router can do is just delete the new arrival. This basic rule is called drop-tail. Alternatively, it might delete an already-waiting packet to make room for the new one.
- Early Warning Systems (AQM): Instead of waiting for a catastrophic overflow, modern routers use Active Queue Management (AQM) algorithms (with names like RED, PIE, or CoDel). These systems proactively drop or mark a few packets before the line is totally full. This acts as a warning flare, signaling the computers sending the data to slow down before a massive traffic jam occurs.
- Because the internal switch drops packets at the exit door much faster than the physical cable can send them away, a line constantly builds up. To manage this growing line, the output port uses a packet scheduler- essentially a bouncer at the exit door who decides exactly which waiting packet gets to leave next.
How Much Buffering is “Enough”?
- tbc