Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Consider a standard GigE network switch. In order to do the switching, presumably it needs to maintain a map of MAC addresses of all things that exist on the network to its (switch's) port numbers.

  • How does it maintain such a map?
  • What are the protocols involved?
  • If I change the topology of one part of the network, does the entire network get notified or do things get discovered "lazily" (i.e. on first need)?
share|improve this question
up vote 8 down vote accepted

The switch learns the MAC-port mapping by looking at the source mac address of each incoming packet. So, the switch can build the mac table gradually.

When it needs to forward a packet, it looks at the destination mac address and forwards it to the appropriate port according to the mac table. If it did not find any entry, it will sent the packet to all ports (except the sending port).

To keep only valid entries in the mac table, the switch flushes the unused entries after a specific timeout.

When network topology changes, the switch can learn the new location of the mac address when it receives a new packet. It will overwrite the old mapping of this mac address.

For more info, look at this link.

share|improve this answer
(+1) Nice! Simple and effective. – NPE Dec 21 '10 at 16:10
Well, all ports except the ingress port, typically. – Vatine Dec 22 '10 at 11:44
@Vatine: yes, it should be :) – Khaled Dec 22 '10 at 11:57

It is called MAC address table and it contains the port, the MAC address and a timestamp. If you change the topology, because you will disconnect some cables, at that time all entries that contain the ports involved will be discarded from the MAC address table. The new entries are learned after each first packet gets received from equipments. Some entries will remain for the wrong port, if the equipment is not directly attached, but, usually, it will be learned soon because of the broadcasts. If there is no traffic from an equipment, then it must pass the timeout until its entry gets discarded. The timeout is usually 120 seconds.

share|improve this answer

taken this scenario:

host_a - port 1 host_b - port 2

when host_a wants to send a packet to host_b then will hit the switch which will record the mac address of host_a and because host_b didn't send anything yet will broadcast the frame on all the ports - host_b will notice that is sent to him and respond on port b.

at this moment the switch knows that host_a has mac1 on port 1 and host_b has mac2 on port 2. any further communication it will be done just trough this ports instead of broadcasting.

  • how does maintain the map is vendor specific but it comes down to a list of mac and their associated ports.
  • in the simplest model there is no protocol really except that all it happens at level 2 OSI
  • if you change the topology the switch will delete the old entry and update it with the new one (as host_1 mac1 is on port 10 instead of 1).

what i said apply to unmanaged switches and could apply to managed switches as well but there things get more complicated. for example cisco can configure what mac comes to what port, they run proprietary protocols as ISL or the open dot1q text

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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