10

I have a relatively dumb question. Suppose the Switch just started, and it received a frame that contains a destination MAC address for a network device not in its MAC addresses table.

What happens then? Does it broadcast (MAC address ff:ff:ff:ff:ff:ff) and receive answers from connected devices, or is there a protocol dedicated for that which is used? I don't think the switch uses the ARP (Address Resolution Protocol)?

  • 1
    If you think about it, when a switch can't actually switch a frame (because it doesn't have the neccesary address in its table, for example), then it usually has to treat that frame as a hub would for compatibility reasons. – Todd Wilcox Apr 5 '16 at 18:53
  • Really thanks to everyone for the answers. – user30817 Sep 27 '16 at 11:01
23

Good question. I'll answer it with an animation:

enter image description here

When Host A sends the frame, the switch does not have anything in its MAC address table. Upon receiving the frame, it records Host A's MAC Address to Switch Port mapping. Since it doesn't know where the destination MAC address is, it floods the frame out all ports.

This assures that if host B exists (which at this point, the switch does not know yet), that it will receive it. Hopefully, upon receiving the frame, Host B will generate a response frame, which will allow the Switch to learn the MAC address mapping from the return frame.

You can read more about how a Switch works here (where I took the animation from). I would also suggest reading the entire article series for a closer look at how a packet moves through a network.

One last note regarding the terms Flooding vs Broadcast. A switch never broadcasts frames, a broadcast is not an action a switch can take. A switch can only flood a frame. A broadcast is simply a frame with a destination MAC address of ffff.ffff.ffff. This is often confused because the end effect is the same, but they are actually different.

  • The main difference between flooding and broadcasting is how the next node(s) will react – Ferrybig Apr 5 '16 at 20:47
  • 2
    @Ferrybig Correct. But I would phrase it slightly different...The main difference between a switch flooding a unicast frame, and a switch flooding a broadcast frame is how the next node(s) will react. There is no such thing as a switch broadcasting a frame. (This comment, and my answer, is speaking of transit traffic, not management traffic to/from the switch) – Eddie Apr 5 '16 at 21:16
4

When a switch receives a frame, it updates its MAC address table with the source MAC address and the port on which it received the frame. If the destination MAC address isn't in its MAC address table (unknown unicast), it floods the frame to all ports, except the port on which the frame was received.

  • Except when it floods, it does not flood the frame back to the port from which it received the frame, right? – Todd Wilcox Apr 5 '16 at 18:44
  • 1
    Right. it doesn't send it to the port from which the frame was received. – Ron Maupin Apr 5 '16 at 18:45
  • 3
    I'll just add that the switch doesn't learn the new (destination) MAC address until the device replies. – Ron Trunk Apr 5 '16 at 18:47
  • By flooding the frame to all the ports, there is security risk? – user24308 Apr 5 '16 at 18:51
  • 3
    It can be. And that's why some/many switches support disabling unicast flooding of unknown unicast (as well as multicast.) In three decades of networking, I've never had the need to use it. – Ricky Beam Apr 5 '16 at 19:45
4

The switch doesn't use ARP, but ARP can help in preventing this situation from occurring in the first place, for two reasons:

  1. If node A is sending an IP packet to node B which isn't in its ARP cache, it will first send an ARP request (which is a broadcast packet, and will automatically be flooded to all ports by the switch). When node B sends its ARP reply, the switch will learn its MAC address. So, by the time actual data transfer happens, the switch already knows the MAC addresses of the participants, and doesn't need to flood data packets.

  2. Many devices, when their link goes up, will send a gratuitous ARP packet. In addition to updating the ARP caches of other nodes on the network, the GARP will also fill the switch's MAC address table.

IPv6 doesn't use ARP, but NDP fulfills a similar purpose.

So overall, although switches certainly will flood frames to unicast addresses they haven't learned, it's not necessary as often as you might think, because it will usually have the opportunity to learn nodes' addresses from broadcast frames beforehand. However, you can definitely observe it with a switch that's had its MAC table overflowed or that has just rebooted.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy