36
How does a switch operate?
A Layer 2 switch uses some features of the Data Link layer in OSI model to
forward the packet to destination port(s). Here we introduce some important
features of a switch and how they work.
MAC address table
When a packet is received on a port, the switch first checks if the packet is
good or bad and extracts the source MAC address (SA) and destination MAC
address (DA) to find 1) if SA exists in the MAC address table, if it does not, the
switch will put it in the MAC address table; if it does, 2) the switch looks up DA and
its associated port to which the traffic is forwarded. If DA does not exist, the switch
will broadcast the packet.
Due to the limitation to the size of a MAC address, the MAC address aging
function is applied. When the MAC address has resided and no updates been
refreshed in the table for a long time, this means the traffic using that entry has not
come for a while. If this time period is more than the aging time, the entry will be
marked invalid. The vacancy is now available for other new MAC.
Both learning and forwarding are the most important functions in a switch.
Besides that, VLAN can be one of the rules to forward packets. There are ingress
rule and egress rule applied. The ingress rule is used to filter the incoming packet
by VLAN ID and so on and to decide whether the packet is allowed to enter the
switch or not. The egress rule is used to forward the packet to the proper port.
Fig. 3-6