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?
Network Engineering Stack Exchange is a question and answer site for network engineers. It only takes a minute to sign up.Sign up to join this community
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.
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).
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.