Computer Networks — From Flooding to Spanning Tree Protocol (STP) & Distance Vector Routing (DVR)
It can be some challenge to toggle the concepts between switching and routing. In this article, we will focus on the evolution of interconnecting from basic hubs to switching and routing with detailed discussions of two distributed algorithms.
We take the modern network infrastructure for granted. To help understand different architectures of interconnecting computers, we start with the simplest setting: Suppose we have two computers in a local area, how do we connect them? — We simply use a single Ethernet cable to plug into the Ethernet ports of two computers, easy! there are connected.
How do we connect to the third computer and scale such interconnection? Taking another Ethernet cable to connect to the third one. Every time we add a new Ethernet cable, we take in total two ports on two computers, eventually, it does not scale because we simply run out of Ethernet ports on the computers. Hence we need a device with a lot of ports — Then that is Network Hub.
1. Network Hub
By definition, a Network Hub is a common connection point for devices in a Local Area Network (LAN). It is also called repeater because it repeats the data signals from one port to all other ports. In the networking terminology, it is called flooding — flooding the message to all the other ports. Due to its simple architecture, network hubs have the following characteristics:
- Flooding & Collision: Repeating messages for all incoming traffic. Think about a noisy classroom, every student is talking at the same time, which causes confusion and loss of messages. In the networking term, it is commonly referred to as a collision.
- Collision Avoidance: When such collision happens, just like multiple persons speaking all at the same time, the natural resolution is taking turns to speak. So someone has to back off and wait for the chance to speak. In the technical term, it is called collision avoidance.
- Unwanted Message: Even if the collision can be avoided, it still creates a lot of redundancy as everybody is listening to the messages even if they are not the targeted audience. Illustrated in the graph below, though PC1 intends to send a message to PC4, the hubs in the LAN repeat and send the messages to every PCs in the network.
2. Network Switch
To address the limitations above, the solution is to direct the message only to the target audience instead of flooding (broadcasting). Such a device is the network switch. In simple terms: a network switch is a smarter repeater that knows the right port to forward the message. In technical terms: network switches create partitions of the collision domain, hence enforce isolation and break the network into multiple LAN segments. Illustrated below, PC1–PC3 connected with Switch2 can be regarded as one LAN segment and PC4–PC6 connected with Switch3 as another LAN segment. As switches know which ports to send the message, the message only gets delivered to PC4.
A network switch looks like a box with lots of Ethernet ports and looks similar to a consumer router (just without the wifi antenna and WAN port). In fact, a home wifi router is a combination of a router and a switch (though conventionally we refer them as the router and technically we can use it sorely as a switch). The ports on the switch are labeled with numerical numbers 1–8 below.
2.1 Forwarding Table
Mentioned earlier, a switch shall know which ports to forward the message, but how does it acquire such knowledge in the first place? — At a high-level, by remembering the ports it receives packets historically from network hosts, the switch knows which port to forward the traffic if a known host becomes the target recipient at next time. This process constructs a forwarding table. The connected hosts are identified using the unique id — MAC address (You can find MAC address of your PC/Mac and other devices on device labels or though system settings).