CCNA RnS #17: Switching Process


CCNA RnS #17: Switching Process

In this article, I am going to talk about the switching process which is a logic followed by the campus network switch to forward the frame to the destination.

The primary role of a switch is to forward the Ethernet frames. An Ethernet LAN consists of end-users, servers, and other devices connected to the switch and multiple switches connected to each other. To achieve this basic functionality, a switch uses forwarding logic that is based on the destination and the source MAC address field in the header. For more details on the Ethernet Frame format, please visit article CCNA RnS Article #9 – Ethernet UDP cable & Ethernet Frame

LAN Switch receives the frame and from this frame, it gets the source and the destination MAC address information. Once the source and the destination MAC addresses are determined it decides whether to forward the traffic or filter (ignore) the frame. A LAN switch performs 3 things to achieve correct frame forwarding –

  1. Determining when to forward a frame or when to drop based on the destination address
  2. Preparing the MAC address table by examining the source MAC address of the received frame
  3. Building the loop-free topology in the LAN environment and forwarding the single copy of the frame to ensure a frame don’t travel in the LAN segment infinitely

Forwarding frames to the Known Address

The LAN switch builds the MAC address table that contains MAC entries and the corresponding port/interface number. Based on the entries in this MAC table switch decide whether to forward the frame or ignore the frame. For example –

Figure 1: Simple Data forwarding to Known Unicast Address

In Figure 1, PC 1 with MAC address MAC:01 sends the frame to the switch using the frame destination address, switch decides that the destination MAC address (MAC:02) is connected to port Ethernet 0/2. In this case, the destination MAC address is known to the switch which is the single device, this type of communication is called the “Known Unicast MAC address forwarding”. In this communication, the frame is forwarded out to a single port that is Ethernet 0/2.

As you can see in an Ethernet LAN, the MAC address table plays a critical role. Just to tell you each switch in the network maintains an independent copy of the MAC address table. And when a frame is received switch performs the independent decision for forwarding.

Let’s see what happens when we have multiple switches in an environment with an example. Imaging PC 1 wants to communicate to PC 3 connected to another switch.

Figure 2: Known Unicast Forwarding Multi-switch environment

You can see both switches have independent views of the hosts connected to the LAN. Switch 1 MAC address has an entry for PC 3 MAC address MAC:03 through Gigabit 0/0. Once the frame is received on Switch 1 it sees the MAC:03 is reachable through the Gig0/0 interface and it sent out the frame to the Gig0/0 interface which is received by Switch 2 on Gig 0/0 port. Switch 2 reads the destination MAC address from the frame and consults the MAC address table. According to that PC 3 is connected to port Eth 0/3 and it sends the frame out only to Eth 0/3.

Building the MAC Address Table

 The second task that the switch performs is to build the MAC address table entries so it can perform the frame-forwarding decision effectively. MAC address table is built using the learning process.

LAN Switch listens to the incoming frames and from these frames, it reads the source MAC address field. Now two things happen, if the source MAC address is already listed in the MAC address table, it ignores the learning else it creates an entry for a new source address that is not known to this switch. Let’s try to understand the same with a simple example where a new PC 4 is added to the network and Switch 2 and Switch 1 are not aware of this PC MAC address.

Note: Things are not that simple in the actual network but just focus on the learning process for now –

Figure 3: Learning Process to build MAC Address Table

New PC, MAC:04 sends traffic to MAC:01. Frame received by local switch (Switch 2). Switch 2 reads the source address from the Ethernet frame and comes to know this is not already listed in the MAC address. It creates an entry for PC 4 with its MAC address and the port number where this frame was received.

Switch 2 also reads the destination field of the received frame from PC 4, this communication let’s say is for MAC:01. Switch 2 sees MAC:02 can be reached through the Gig 0/0 interface it sends the frame out to Gig 0/0 interface and it is received by Switch 1. Switch 1 reads the source MAC address from the frame and concludes it’s a new end-user connected to the network it is not aware of. It creates an entry for the PC 4 MAC address and the port where the frame was received is Gig 0/0.

Building the MAC address from scratch

Let’s say one of the switches in a network is rebooted and it doesn’t have any information about what end-points or devices are connected to the network. In this case, the switch simply performs the flooding.

Let’s try to understand with an example. PC 1 wants to send the traffic to PC 4 and switch 2 is just come up after the power cycle. The frame received by Switch 2 from Switch 1 but it doesn’t know where the PC 4 is located. In this case, Switch 2 will flood the frame to all the ports except the port where the frame is received. A frame sent to an unknown unicast address is known as an Unknown unicast frame which is not listed in the MAC address table – and this communication is always flooding.  

The switch also does the broadcast by sending a frame to the destination address FFFF.FFFF.FFFF. In this case, the switch creates multiple copies of the frame and sends to all ports except the one frame that was received.

This section now concludes the high-level learning process of MAC address for building the MAC address table and flooding.

The last step to successfully complete the logic of frame forwarding by the switch is to stop the Loop using Spanning Tree Protocol.

Spanning Tree Protocol (STP)

Spanning Tree Protocol is a loop prevention protocol used in Ethernet LAN. Loop means a packet travels in the network endlessly and finally consumes all the available bandwidth of the network. This situation in any network can bring the network down to its knees. STP ensures only one path exists in a network for a frame to send out.

Let’s try to understand the need of STP in a network using an example.

Figure 4: Network without STP

In Figure 4, let’s say PC 1 is not reachable for some time and in the meantime, PC 3 sends an unknown unicast frame for PC 1, this frame is received by SW 3 and it doesn’t know about PC1. SW 3  performs the flooding and sends the packet to SW 1 and SW 2. The same flooding process is performed by SW 1 and SW 2 and this unknown unicast frame is received by SW 3 again. This keeps continuing until it consumes all the available bandwidth. This is called the loop scenario in a segment where multiple paths exist for a destination.

STP avoids this loop by ensuring only 1 path towards the destination is in the forwarding state and the other path in the block state. A port in a forwarding state can send and receive data frames but a port in a blocking state means that port cannot forward or receive the data frames.

Figure 5: Network with STP

With STP enabled in Figure 5, only 1 forwarding path exists between SW 3 and SW 2 for PC 1 and traffic is not forwarded to SW 2 by SW 3. This prevents the loop in the network. Hope you find this informative!

 Continue Reading...