Switch Lookup Table

mac addressswitchswitching

HeadFirst Networking Exercise Solution

I was just reading a book called HeadFirst Networking and I'm a bit confused about something. I am attaching an image from the book. The page says that the direction of the frames as maintained in the switch lookup table should be a mapping between MAC address and the ports. But I'm not sure whether the address is that of the source or destination.

Best Answer

It remembers the MAC of the computer attached to that port.

if you have four computers connected to a switch:

PC1 with MAC1 connected to PORT1
PC2 with MAC2 connected to PORT2
PC3 with MAC3 connected to PORT3
PC4 with MAC4 connected to PORT4

Imagine you just turned the switch on, and the MAC table is empty.

When you send a packet from PC1 to PC2, the switch doesnt yet know where the PC with MAC2 is (on which port), but it knows that it recieved a packet from MAC1 on PORT1 (and it adds this entry to the MAC table). Since it doesnt know where PC2 is, it sends the packet to all ports (except PORT1, since the packet came from there.

All three other PCs get the packet, PC3 and PC4 ignore it, but PC2 probably replies. Since the switch just recieved a packet from a PC with MAC2 on PORT2, it adds this entry to the MAC table. Since it also has an entry for MAC1 on PORT1, it sends the packet there (and only there).

After such a packet exchange (eg. ping), the state of the MAC table would be:

a device with MAC1 is located on PORT1
a device with MAC2 is located on PORT2