Routers

Why
Routers are important because they faciliate the traffic in the internet and other packet switched networks

What
A router is a device that serves as a packet switch. It takes incoming packets and looks up their end destination in their forwarding table and sends that packet to the correct next packet switch.

How
Routers move packets by looking information from the network layer rather than from the link layer

Driving Example
The routing process works in a very similar to how a driver from Philadelphia tries to drive to Orlando without a map or GPS. He would:
 * 1) Start at Philadelphia and stop at a local gas station and ask for directions to Florida. The guy would tell him to get to I-95 South
 * 2) When he gets to Florida, he stops at Jacksonville to ask for directions again.
 * etc

Input Ports
The router must be able to perform lookups at the speed that physical bits are flowing in, otherwise, we will create blockages in the input ports. This can be done in a couple of ways:
 * Line termination function performs physical layer functionality
 * Data link processing function performs link layer functionality
 * Performs routing function and forwarding and if necessary, the packet is stored in a queue if the switching fabric is too busy
 * 1) Keep local copy of forwarding table at each input port
 * 2) Keep forwarding information in a tree data structure to improve lookup

Switching Fabric
The switching fabric is at the heart of the router and is responsible for driving data inside of the router. There are a few primary ways that routers use to switch their packets
 * Connects input and output ports
 * 1) Switch by Memory - In this scheme, the packet is copied into memory when it arrives from the input port and then copied to the correct output port once the table lookup is complete (this could have already been done at the input port)
 * 2) Switch via Bus
 * 3) Switch via an interconnected network - more advanced version of switch via Bus that overcomes the bus bandwidth by connecting 2n buses together

Output Ports
One important factor in all of this is the switching speed. That is, how many packets can the switching fabric handle each time unit. We note that if the switching speed is $$n \times line speed$$, then we cannot experience any queuing at the input ports
 * Stores packets that have been forwarded to it
 * Data link processing function performs link layer functionality
 * Line termination function performs physical layer functionality

However, under the assumption that the switching speed is the same as above, if all of the input ports are driving traffic through the output port, then we will naturally experience queuing since only one packet can leave the ouput port at each time unit

Therefore, there are a few important considerations that must be addressed:
 * 1) Size of buffers? We need to know how to design our buffers to absorb heavy amounts of traffic
 * 2) Which packet to remove from the queue first? This service is called the packet scheduler and there are a couple of schemes in place. We could either use the standard FIFO queue strategy, or we could have some sort of weighting mechanism. Packet scheduling plays a big role in quality of service guarantees
 * 3) Which packets should we drop? When the queue is full or is in danger of filling up, we must use some strategy to figure out which packets we want to drop. When the queue is simply full, we must make the choice to drop the arriving packet (drop-tail) or one of the packets that are already in our queue. We could also use a strategy called Random Early Detection in which we drop packets according to a probabilistic model based on how many elements are already in our queue
 * 4) Dealing with Head of Line Blocking - If a packet in the input port is waiting for another packet on the input port, then every packet behind the initial packet will end up waiting even if the destination for those packets are not the same as the initial packet

Routing Processor
This is the part of router that handles the routing protocol and performs the operations required for the routing protocol