Sub topic 13
Several switches: many MAC addresses behind one port
This chapter assumes you know how a single switch learns source addresses, looks up destinations, and floods unknown unicast frames. It also assumes you know what a VLAN is. Here we see what changes when switches connect to each other.
One port, many addresses
A MAC table maps an address to a port. It does not say that one port holds one host. When two switches are joined by an uplink, each switch learns every host on the far side through the uplink port. Switch SW1 therefore holds many entries that all point at the same port.
How the remote entries appear
SW1 has no knowledge of the topology beyond its own ports. It learns about C the same way it learns about A: by seeing a frame whose source address is C. That frame arrives on port 24, so SW1 records C on port 24. The same happens for D.
After A, B, C and D have each sent a frame, the tables look like this:
| Switch | MAC | Port |
|---|---|---|
| SW1 | A | 1 |
| SW1 | B | 2 |
| SW1 | C | 24 |
| SW1 | D | 24 |
| SW2 | A | 24 |
| SW2 | B | 24 |
| SW2 | C | 1 |
| SW2 | D | 2 |
Each switch decides only the next hop. SW1 sends a frame for C out port 24 and stops there. SW2 then does its own lookup and sends it out port 1.
Tracing a frame
Suppose A sends to C and neither switch knows C yet.
- SW1 learns A on port 1. C is unknown, so SW1 floods the frame out every port except port 1. This includes the uplink.
- SW2 receives the frame on port 24 and learns A on port 24. C is still unknown to SW2, so it floods out ports 1 and 2.
- C replies. SW2 learns C on port 1. It looks up A, finds port 24, and forwards only there.
- SW1 receives the reply on port 24, learns C on port 24, looks up A, and forwards out port 1.
From then on, traffic between A and C stays on the path between them. D never sees it.
Filtering across the uplink
The filtering rule from earlier chapters now has a practical use. If A sends to B, SW1 forwards out port 2 only. The frame never crosses the uplink, so SW2 and its hosts see no traffic. Without the table, every frame would cross the uplink.
Now suppose C sends to D. SW1 receives nothing from this, because SW2 forwards the frame from port 1 to port 2 and the uplink is not used. If SW2 had not yet learned D, it would flood, and SW1 would receive the frame on port 24. SW1 learns C on port 24, finds no entry for D, and floods it to ports 1 and 2.
Common problems
- Table size grows with the network. A switch at the top of a tree learns every host below it. Its table must be large enough for all of them.
- Per-VLAN entries. When the uplink is a trunk, the switch learns the same MAC separately in each VLAN that carries it.
- Loops. If two switches have two links between them, a flooded frame can return on the second link. SW1 would then see A's address arrive on a different port and move its entry back and forth. This is MAC flapping, and it signals a loop.
Exercise
SW1 has hosts A and B on ports 1 and 2 and an uplink on port 24 to SW2. SW1 has just learned A on port 1 and B on port 2. A frame arrives on port 24 with source C and destination B. What does SW1 learn, and where does it send the frame?
Show answer
SW1 learns C on port 24, because the source address is recorded against the ingress port. B is known on port 2, so SW1 forwards the frame out port 2 only.
Exercise
On SW2, the MAC address of host A is listed on port 24. Does this mean A is connected directly to port 24?
Show answer
No. It means the frame from A arrived on port 24. A can be any number of switches away, and the entry says only which port leads toward it.