Many of us use switches every day but never really think about how they work. Whether you are studying to become a CCNA or just want to learn more about how a switch really functions, this article is for you.
Hubs vs. Switches
Prior to switches, Hubs were the standard for connecting devices on a local area network (LAN). The problem with hubs was that everything that went through them had to share the bandwidth of the link, bandwidth was wasted because all traffic was sent to all devices, and there were a lot of collisions because the hub didn’t do anything to prevent them. A switch fixes these problems.
What do switches do?
Here are some facts about switches that you should know:
Switches work at Layer 2 of the OSI model, not Layer 1 like a hub
Switches switch Ethernet frames
Switches don’t look at IP address information, only Ethernet MAC addresses
Switches keeps a table of all MAC addresses traversing the switch and what port they are on (this table is called the bridge forwarding table or CAM table)
Switches only sends traffic to the devices that are the destination for that traffic, saving bandwidth
Each device connected to the switch gets the full bandwidth of the switch port because the switch prevents collisions
Now that you know that the switch has the bridge forwarding table and uses that to intelligently send traffic, a common question is, “what if the destination MAC address for the traffic that the switch receives is not in the bridge forwarding table?” What does the switch do with that Ethernet frame? The answer is that the switch will flood that frame out all ports on the switch. The switch will then monitor the traffic for the response from that frame and see what device, on what port, responded to that flooded frame. That information will be put in the bridge forwarding table so that, next time, the switch won’t have to flood that traffic.
Bridge forwarding table
To see the bridge forwarding table on a Cisco switch, just type show mac-address-table, like this:
Port speed & Duplex
Of particular importance when it comes to switches are port speed and duplex. The speed of a port can be set to 10Mb, 100Mb, or 1000Mb (1GB), or Auto negotiate, depending on what the switch and the connecting device offers. Most switch ports and devices use auto negotiate to find the best speed and duplex available. However, this doesn’t always work. Some devices have trouble with this and you may have to go in to the switch and hardcode the speed or duplex.
Speaking of duplex, what is duplex? Duplex is set to either half, full, or is auto negotiated. A half duplex connection is where only one device can send or receive at a time. A full duplex connection is where both devices can send and receive at the same time.
Thus, if you have a 100Mb half-duplex connection, only sending at 100Mb OR receiving at 100Mb can happen at the same time. If you have a 100Mb full duplex connection, you can effectively get 200Mb out of the link because you could be sending 100Mb and receiving 100Mb at the same time.
Here is how you see the current speed and duplex of a switch port using the show interface command:
Most administrators will hard-code the port speed and duplex of servers to prevent auto negotiation. You don’t want your switch to reboot one night and, in the morning, have the email server connecting to the network at 10Mb half-duplex. You want the email server to either run at 1GB full duplex (for example) or not work at all.
Types of Switches
There are a number of different types of switches. You can buy a “dumb” switch for about $10 these days. It has no manageability and probably only 4-8 ports. From there, you can go up to an unmanaged 24 or 48 port switch.
However, most business users prefer a managed switch so that you can get statistics on switch traffic, see your bridge forwarding table, troubleshoot connections, and hard-code port speeds and duplex.
There are many brands of managed switches including, of course, Cisco. These managed switches come in sizes from just a few ports, all the way up to over 96 ports. You can even buy chassis-based switches, costing tens of thousands of dollars, like a Cisco Catalyst 6500 series switch. The chassis-based switches can have blades (cards) that perform not just switching but also routing, intrusion detection, and other services.
Another type of switch is called a Layer 3 switch. A Layer 3 switch is a switch that also has the routing functionality of a router but no WAN ports. Layer 3 switches are used primarily when a large company wants to use VLAN’s to segregate their network into logical networks.
Here is what we have learned:
Switches work at Layer 2 of the OSI model, data-link
Switches switch Ethernet frames
Flooding is when a switch doesn’t have a destination MAC in its bridge forwarding table and it has to send that frame out to all ports
Port speed and duplex are critical settings when it comes to connecting devices.
There are many types of switches, managed, unmanaged, chassis-based, and layer 3.
You might also want to read the following related articles: