Function Of Switches
An Ethernet switch is a device that is used at the Access Layer. Like a hub, a switch connects multiple hosts to the network. Unlike a hub, a switch can forward a message to a specific host. When a host sends a message to another host on the switch, the switch accepts and decodes the frames to read the physical (MAC) address portion of the message.
A table on the switch, called a MAC address table, contains a list of all of the active ports and the host MAC addresses that are attached to them. When a message is sent between hosts, the switch checks to see if the destination MAC address is in the table. If it is, the switch builds a temporary connection, called a circuit, between the source and destination ports. This new circuit provides a dedicated channel over which the two hosts can communicate. Other hosts attached to the switch do not share bandwidth on this channel and do not receive messages that are not addressed to them. A new circuit is built for every new conversation between hosts. These separate circuits allow many conversations to take place at the same time, without collisions occurring.
What happens when the switch receives a frame addressed to a new host that is not yet in the MAC address table? If the destination MAC address is not in the table, the switch does not have the necessary information to create an individual circuit. When the switch cannot determine where the destination host is located, it uses a process called flooding to forward the message out to all attached hosts. Each host compares the destination MAC address in the message to its own MAC address, but only the host with the correct destination address processes the message and responds to the sender.
How does the MAC address of a new host get into the MAC address table? A switch builds the MAC address table by examining the source MAC address of each frame that is sent between hosts. When a new host sends a message or responds to a flooded message, the switch immediately learns its MAC address and the port to which it is connected. The table is dynamically updated each time a new source MAC address is read by the switch. In this way, a switch quickly learns the MAC addresses of all attached hosts.
Sometimes, it is necessary to connect another networking device, like a hub, to a switch port. This is done to increase the number of hosts that can be connected to the network. When a hub is connected to a switch port, the switch associates the MAC addresses of all hosts connected to that hub with the single port on the switch. Occasionally, one host on the attached hub sends a message to another host attached to the same hub. In this case, the switch receives the frame and checks the table to see where the destination host is located. If both the source and destination hosts are located on the same port, the switch discards the message.
When a hub is connected to a switch port, collisions can occur on the hub. The hub forwards to all ports the damaged messages resulting from a collision. The switch receives the garbled message, but, unlike a hub, a switch does not forward the damaged messages caused by collisions. As a result, every switch port creates a separate collision domain. This is a good thing. The fewer hosts contained in a collision domain, the less likely it is that a collision will occur.