6

I was wondering if there is a possibility that a switch won't get the needed MAC address to it's CAM.

For example, if the used protocol is UDP, where the sender doesn't need an answer back from the receiver?

Thank you

Ron Maupin
  • 98,218
  • 26
  • 115
  • 191
  • So, I don't work with networking, but for some reason when this question appeared in the sidebar, I momentarily wondered - Why in the name of god would a switch always get a MAC(intosh) address from a PC(Windows). I usually don't like to make irrelevant comments, but the thought just made me chuckle so I figured i'd share. – Ryan Feb 08 '18 at 19:23

3 Answers3

12

A switch learns the source MAC from the sender. If the destination is not in the CAM table, the switch floods the frame out all ports. So if the receiver never responds, the switch will never learn the receiver's MAC and it will always flood the frame.

Ron Trunk
  • 66,852
  • 5
  • 65
  • 126
  • Hi, thank you for answer. So in case the frame is received by PC with the destination MAC address it always sends the answer back so switch can add this mac into CAM table ? Or how the switch knows that the frame was received ? – Lukáš Stacke Feb 05 '18 at 19:19
  • The switch doesn't know or care if it was received. It only learns MAC addresses fro the source address of frames. – Ron Trunk Feb 05 '18 at 21:11
3

Whether you use UDP, TCP or any other transport protocol, the underlying IP layer uses an IP address. When the sender (or the router for that matter) attempts to send the IP packet over the local segment it has to discover the MAC address first.

For this, IPv4 uses ARP, IPv6 uses NDP. Both protocols require the destination to send either an ARP response or a Neighbor Advertisement message. This will tell the switch the destination's MAC address and the port in any case.

As Ron Trunk has pointed out, even if the switch didn't know where the MAC address is located (when not using IP or another protocol requiring a response) the switch would emulate a repeater and broadcast the frame to all ports (except the source port).

Zac67
  • 81,287
  • 3
  • 67
  • 131
  • 1
    nick-picking but the switch will flood the frame, not broadcast it. A broadcast is a type or frame, while flooding is a switch behavior. – JFL Feb 05 '18 at 21:08
  • so that means the only mac address which will goes into CAM is always only source mac. – Lukáš Stacke Feb 05 '18 at 22:00
  • @JFL Agreed - I wasn't using the noun though but the verb, and flooding vs broadcasting doesn't make too much of a difference. ;-) – Zac67 Feb 05 '18 at 22:03
  • @LukášStacke Yes - the source MAC/port combination is stored in the SAT and the destination MAC is used for forwarding. – Zac67 Feb 05 '18 at 22:05
2

An ethernet switch will get the source MAC address from the frame as it enters the switch. A MAC address is a data-link address on the frame. UDP is a transport protocol, encapsulated in the network protocol, which is encapsulated in the data-link protocol. The switch has no idea what protocols are encapsulated inside the data-link frame.

Ron Maupin
  • 98,218
  • 26
  • 115
  • 191
  • Great, thank you for answer ! but how the switch knows that the frame was really received by someone ? I suppose PC with destination mac address has to send back some reply, but is it always sent or there can occur some cases when the reply isn't sent back. – Lukáš Stacke Feb 05 '18 at 19:26
  • The switch has no idea if the frame is received. The switch simply doesn't care; it is a transparent device. Replies are the responsibility of upper-layer protocols, and not all protocols require a response. – Ron Maupin Feb 05 '18 at 19:28