Switch Traffic

Last Update By Kim - June 21, 2020

As covered in the article Network Devices, a switch's primary purpose is to facilitate communication within networks. It does this by maintaining what is known as a MAC Address table. This is a table which maps the MAC addresses of devices plugged into the switch, to each of its interfaces. Switches operate at layer 2 of the OSI model, where they work with layer 2 headers to enable hop-to-hop delivery.

Switch Example

When you connect a switch to a new network, the first thing it does is that it creates a new entry in its MAC address table for any incoming traffic. Let’s say you have a very simple network with a switch and 4 hosts connected to it, as follows:

The switch has just been connected and receives traffic from 2 of the hosts. It would then populate its MAC address table as follows:

Vlan ID MAC Address Located on Port
10 A4:08:F5:1E:DE:0B Fa0/1
10 60:02:B4:BB:01:FC Fa0/2

For some reason it has not received any traffic from hosts C and D. What would happen if host A tries to communicate with host C? Firstly, the switch would look at the frame it has received from Host A, and look at the destination Mac Address (to Host C). It would then perform a lookup in its MAC address table to determine whether it knows which port to send traffic to. Since no matching entries exist in the switch's tables, it would flood (or, in other words, broadcast) the frame out from all of its interfaces (except the receiving port).

When the switch does this, all hosts connected to it will respond and send a new frame back towards the switch. The switch would then create new entries for all the hosts who responded and populate its MAC address table with this new information:

Vlan ID MAC Address Located on Port
10 A4:08:F5:1E:DE:0B Fa0/1
10 60:02:B4:BB:01:FC Fa0/2
20 30:9C:22:B0:D4:9E Fa0/7
20 28:A1:2B:E6:3B:42 Fa0/8

When host A tries to communicate with host C again, the switch would look at the frame’s source and destination MAC addresses, and compare them to its own MAC address table. This time, it knows where to send this frame, and host A can now successfully communicate with host C. It’s important to understand that MAC addresses are the lifeblood of the switch. If it weren|t for MAC addresses, the switch would not know where to send or respond to traffic.

Side note: Don't get confused with VLAN IDs - that's a topic for another time and will be covered in a future article.

Comments: