Switching is the process of using the physical address of devises to perform forwarding decisions. Switches use application specific integrated circuits (ASICs) to perform their switching function. As a consequence, amazingly fast switching speeds are accomplished. Today I will explain how switches learn the hardware address of hosts attached to them and how they use this information to perform their tasks. I will focus on the protocol designed for preventing broadcast loop existence.
For those of you that are new to this field, what I am talking about is the Spanning Tree Protocol (STP); I will describe its operation in details and use examples when necessary, so you can get a clear understanding of how it functions.
Switches are very important networking devices; they’re used to terminate hosts on the LAN. They consist of multiple Ethernet/Fast Ethernet/Gigabit Ethernet interfaces with adjustable throughput rates.
They can be seen as multi lane highways with a lot of exit points. Each host is assigned a separate lane on the highway, therefore collision domains are separated per each individual switch port. No bandwidth sharing takes place and each individual host on each port is provided with independent, dedicated bandwidth. The benefits of all these are:
- Low Latency
- Thunder Speed
- Low Cost
Why low cost? Well the answer is quite simple. Imagine having a LAN of fifty hosts. All the hosts need access to the Internet; therefore they should be connected to a router somehow. Having 50 interfaces on a router to terminate client links is inefficient and wasteful.
By incorporating a switch in the network, the router needs only a single interface to connect to the switch and all users reach the router’s exit point with the help of the switch’s ASIC electronics. The diagram below shows a typical LAN connection.
As already mentioned, switches operate at layer 2 (the data-link layer) of the OSI model. They do not need special configuration to operate; they are simple plug and play devices. You can expect a new switch out of the box to work instantly when it is powered up. Later on we’ll take a look at just how this is accomplished.
A layer 2 switch deals with three functions:
- Address learning — When a switch is first switched on, it learns the MAC address of hosts attached to it and stores the MAC address and interface port association into its MAC table.
- Forwarding — Based on the MAC address table, the switch is able to forward frames out the appropriate interfaces.
- Loop prevention — Multiple connections between switches may exist for redundancy purposes. However these multiple connections may lead to network loops without the use of a sophisticated protocol to prevent their existence. STP is the protocol running on the switch ports to eliminate data flooding as a consequence of loops while at the same time maintaining redundancy.
How Does the Switch Find Host MACs?
Let’s use the diagram below to help us understand how address learning process takes place.
Let’s assume that we have just powered on the switch. It has nothing in its MAC table. We connect the cables from the hosts on the switch interfaces as shown in the diagram. Host A initiates a connection towards Host D, and the following takes place:
- Host A (interface fe0/0) sends a frame to Host D (MAC address:0000.43c5.334c).
- The switch inspects the Source Address in the frame and notes in its table the MAC address of Host A along with the Interface number from which the frame originated.
- The switch inspects the Destination Address in the frame. Since it does not have Hosts D MAC address in its table, it constructs a broadcast frame and forwards out all interfaces except the interface from where the original frame arrived.
- Host D identifies itself as the expected recipient and responds back to Host A. The switch receives the respond frame on interface fe0/11 and places the SA in its table along with the interface number where the frame came from.
- From now on, further communication between the two hosts will be switched to the appropriate interfaces based on the MAC tables entries.
This process takes place every time a new host is attached on the switch and initiates traffic. The switch tries to keep its MAC table up-to-date, therefore if some hosts do not initiate traffic for a certain amount of time, the switch removes them from its table and reinserts them when they begin sending traffic.
Spanning Tree Protocol (STP) Operations
The Spanning Tree Protocol (STP) is responsible for identifying links in the network and shutting down the redundant ones, preventing possible network loops. In order to do so, all switches in the network exchange BPDU messages between them to agree upon the root bridge. Once they elect the root bridge, every switch has to determine which of its ports will communicate with the root port.
If more than one link connects to the root bridge, then one is elected as the forwarding port (Designated Port) and the others are blocked. Let us see the operation of STP with the use of an example. We will use the topology shown below to help us understand how STP operates.
- The root bridge needs to be elected. Two fields combined together identify the root bridge: MAC address and Priority value. Without manual configuration all switches have the same priority therefore it is up to the MAC address to decide upon the root bridge. The switch with the lowest MAC address value is elected as the root bridge. In the diagram above Switch C is the elected root bridge.
- Once the root bridge is elected, each switch needs to identify a single root port – the port closest to the route bridge. This port will always be in the forwarding state. By default all ports of the route bridge are in the forwarding state. Moreover, one port per segment (called designated port) is allowed to be in the forwarding state.
- In our example we have 2 ports on switch A and two ports on switch B that belong to the same segment. Therefore, two of them need to be blocked to avoid loops. Since switch B has higher MAC address value (hence lower priority), its designated ports need to be blocked.
- The result of all this is that only one path from one switch to any other switch exists. Mission accomplished!
Things to Keep in Mind About STP
- The Spanning Tree Protocol is a link management protocol that is designed to support redundant links while at the same time preventing switching loops in the network. It is quite useful and should be enabled on the switch interfaces.
- STP has high convergence time; it can take up to one minute to converge and provide redundancy. A newer development is implemented to the STP protocol, called the Rapid Spanning Tree Protocol (RSTP). The latter retains all the tasks of STP whilst minimizing convergence time significantly.
More Related Posts
- Scaling IP Addresses with NAT (Network Address Translation) and PAT (Port Address Translation)
- Session Initiation Protocol: the Right Choice for VoIP
- A Short Guide to Internet Control Protocols
- New Training Release: Cisco CCNP BCMSN Training
- How to Troubleshoot Your Connections with Ping and Traceroute