Switches operate at layer 2 of the OSI model (Data Link). It sends frames based on destination MAC addresses (Media Access Control) found within the same frame based on its CAM table (Content Addressable Table).
Each switch port is a collision domain, the bandwidth is not shared, and they work in full-duplex or half-duplex.
The size of the broadcast domains can be limited through vlan segmentation, and communication between vlans is possible through a layer3 device such as a router or a multilayer switch.
When the frames arrive at the switch, the source MAC addresses are learned, placed in the CAM table with the port and VLAN through which they arrived, and are also added along with a timestamp, by default 300 seconds. If the destination MAC is not found in the MAC Address Table, it sends Unknown Unicast flooding to all ports belonging to the same vlan. The computers in the same vlan receive the Unknown Unicast, and the computer with the destination MAC address replies to the switch for the switch registers its MAC and vlan with the destination port. Finally, the switch sends the frames to the destination based on the information learned.
Broadcast and multicast MAC addresses also generate flooding:
- ffff.ffff.ffff – Broadcast
- 01xx.xxxx.xxxx – Multicast IPv4
- 3333.xxxx.xxxx – Multicast IPv6
CAM Table (Content-Addressable Memory)
Switches can hold many MAC addresses in their CAM table, but they are limited.
The CAM table stores a MAC entry by default is 300 seconds. If, after 300 seconds, no other frame is detected on that port, the MAC is removed from the CAM table.
If the MAC address is detected on a different port, the switch creates a new record with the new port, vlan and a new timestamp; then the previous entry is deleted. In case the switch receives a frame from a source MAC address already in the CAM, only its timestamp is updated.
View all MAC addresses in the CAM table:
Switch#show mac address-table Legend: * - primary entry age - seconds since last seen n/a - not available vlan mac address type learn age ports ------+----------------+--------+-----+----------+-------------------------- * 8 1cc1.de3f.71b6 dynamic Yes 105 Fa9/5 * 5 0017.a477.0004 dynamic Yes 20 Po10 * 115 0038.dfa3.a55d dynamic Yes 30 Fa9/9 * 8 0015.60de.08e6 dynamic Yes 10 Fa9/5 * 2312 3333.0000.000d static Yes - Gi1/1,Gi1/3,Gi1/4,Gi1/5
Find a specific MAC address:
# show mac address-table address <dirección mac> !Example: Switch#show mac address-table address 0017.a477.0004 Legend: * - primary entry age - seconds since last seen n/a - not available vlan mac address type learn age ports ------+----------------+--------+-----+----------+-------------------------- Supervisor: * 5 0017.a477.0004 dynamic Yes 135 Po10 Switch#
View all MAC addresses learned by an interface:
# show mac address-table dynamic interface <tipo numero> !Example: Switch#sh mac address-table interface f9/9 Legend: * - primary entry age - seconds since last seen n/a - not available vlan mac address type learn age ports ------+----------------+--------+-----+----------+-------------------------- * 115 0038.dfa3.a55d dynamic Yes 5 Fa9/9 * 4 0023.18bc.5482 dynamic Yes 0 Fa9/9 Switch#
Display the current CAM table size:
# show mac address-table count !Example 1: Switch2#show mac address-table count Mac Entries for Vlan 1: --------------------------- Dynamic Address Count : 0 Static Address Count : 0 Total Mac Addresses : 0 Mac Entries for Vlan 10: --------------------------- Dynamic Address Count : 3 Static Address Count : 0 Total Mac Addresses : 3 Mac Entries for Vlan 20: --------------------------- Dynamic Address Count : 3 Static Address Count : 0 Total Mac Addresses : 3 Total Mac Address Space Available: 70013688 Switch# !Example 2: Switch#show mac-address-table count MAC Entries for all vlans : Dynamic Address Count: 235 Static Address (User-defined) Count: 203 Total MAC Addresses In Use: 438 Total MAC Addresses Available: 65536 Switch#
Add a static MAC address in the CAM table.
# (config)# mac address-table static <xxx.xxxx.xxxx> vlan <vlan-id> { drop | interface type number} !Example Switch1(config)# mac address-table static 1111.2222.3333 vlan 10 interface g1/1ddress-table static 1111.2222.3333 vlan 10 interface g1/1
Statically entered MACs are not deleted from the table regardless of whether they are active or not; they are stored in the configuration file.
Clear the CAM table (Dynamic entries only):
# clear mac address-table dynamic [ address mac-address | interface type number | vlan vlan-id ]
Modify CAM timestamp
Switch(config)# mac address-table aging-time 120
View the timestamp value of the CAM table
Switch1# sh mac add aging Global Aging Time: 120 Vlan Aging Time ---- ---------- Switch1#
Be careful with filling the CAM table because if it fills up, the switch works as a Hub; it just floods the frames through all ports.
The video is in Spanish only