How a switch learns, floods, forwards and filters

Four decisions

A switch looks at two addresses in every frame, and does one job with each:

StepUsesWhat the switch does
LearnSource MACRecords "this MAC lives on the port the frame came in on" in its MAC address table
FloodDestination MACBroadcast, multicast, or a unicast it hasn't learned: send out every port in the VLAN except the one it came in
ForwardDestination MACA known unicast: send out only the port in the table
FilterDestination MACThe destination is on the port the frame came in on: drop it

Unknown unicasts are flooded, which is why the very first frame to a new device reaches everyone. Once the reply comes back, the switch has learned both ends and forwards only where needed.

Watch it happen

SW1's table is empty when it starts. After PC1 pings PC3, SW1 knows PC1 is on Fa0/1 and PC3 is somewhere past Gi0/1 (the link to SW2). It doesn't know which port on SW2: it only knows its own way out.

In NetLab

▶ SW1
SW1>enable
SW1#show mac address-table
          Mac Address Table
-------------------------------------------

Vlan    Mac Address       Type        Ports
----    -----------       --------    -----
Total Mac Addresses for this criterion: 0
▶ PC1
NetLab Windows-style command prompt. Type help to see the commands.
C:\Users\student>ping -n 2 10.1.1.13

Pinging 10.1.1.13 with 32 bytes of data:
Reply from 10.1.1.13: bytes=32 time<1ms TTL=64
Reply from 10.1.1.13: bytes=32 time<1ms TTL=64

Ping statistics for 10.1.1.13:
    Packets: Sent = 2, Received = 2, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms
▶ SW1
SW1#show mac address-table
          Mac Address Table
-------------------------------------------

Vlan    Mac Address       Type        Ports
----    -----------       --------    -----
   1    001a.33d5.62b1    DYNAMIC     Fa0/1
   1    001a.dd6c.939f    DYNAMIC     Gi0/1
Total Mac Addresses for this criterion: 2
SW1#show mac address-table interface g0/1
          Mac Address Table
-------------------------------------------

Vlan    Mac Address       Type        Ports
----    -----------       --------    -----
   1    001a.dd6c.939f    DYNAMIC     Gi0/1
Total Mac Addresses for this criterion: 1
▶ SW2
SW2>enable
SW2#show mac address-table
          Mac Address Table
-------------------------------------------

Vlan    Mac Address       Type        Ports
----    -----------       --------    -----
   1    001a.33d5.62b1    DYNAMIC     Gi0/1
   1    001a.dd6c.939f    DYNAMIC     Fa0/1
Total Mac Addresses for this criterion: 2

Tip: Turn on Packet Walk in the Try-it panel and ping again: each switch shows whether it learned, flooded or forwarded the frame, and why.

Aging and clearing

Entries the switch learns are dynamic. If no frame from that MAC arrives for 300 seconds (the aging time), the entry is removed, so moved or unplugged devices don't leave stale entries. You can also clear them at once with clear mac address-table dynamic.

In NetLab

▶ PC1
NetLab Windows-style command prompt. Type help to see the commands.
C:\Users\student>ping -n 1 10.1.1.12

Pinging 10.1.1.12 with 32 bytes of data:
Reply from 10.1.1.12: bytes=32 time<1ms TTL=64

Ping statistics for 10.1.1.12:
    Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms
▶ SW1
SW1>enable
SW1#show mac address-table count
Mac Entries for Vlan 1:
---------------------------
Dynamic Address Count  : 2
Static  Address Count  : 0
Total Mac Addresses    : 2

Total Mac Address Space Available: 7998
SW1#show mac address-table aging-time
Global Aging Time:  300
Vlan    Aging Time
----    ----------
SW1#clear mac address-table dynamic
SW1#show mac address-table
          Mac Address Table
-------------------------------------------

Vlan    Mac Address       Type        Ports
----    -----------       --------    -----
Total Mac Addresses for this criterion: 0

Remember: Switches learn from the source MAC and forward by the destination MAC. Unknown destination = flood.

HOME LABS COMMUNITY DASHBOARD