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.

  • I am not sure we can reproduce and host the image from that book on the site... I need to check Commented Oct 7, 2013 at 12:42
  • IANAL but this is fair use.
    – Ron Trunk
    Commented Jul 2, 2014 at 19:39

4 Answers 4


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

The switch maps the device that is connected to that port in its table. It does this when it learns a new MAC for the port automatically.

Take a look at (2min20s):


This explains it a bit more in depth.

When computer 1 sends data to computer 3, the switch analyses the destination and source MAC address and adds it both to the table. (unless it is already known of course) The source MAC isn't hard to add to the table. However, the destination MAC if not known is first flooded by the switch to all ports. If a response follows, the switch can add this address as well.


The switch learns from the source address field so future frames that contain that learned address as a destination can be forwarded out the port it learned it from earlier. If the switch hasn't yet learned the address in the destination address it "floods" the frame out all ports except the port the frame arrived on.


The mac-address table maintained on the switch is the source mac-address of packets received on that interface.

The destination mac-address has nothing to do with the device attached to that port so the switch has no need to associate that mac-address with the ingress port.

Cisco Press has an online article that covers this topic.

(Late reply due to comment...)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.