Switch – How does Ethernet Switch ensures the validity of the MAC address table

ethernetlanswitch

Let us say I have switch S with 4 ports, PA, PB, PC, and PD, to which I have connected 4 hosts, A, B, C and D with the MAC addresses AA:AA:AA:AA:AA:AA, BB:BB:BB:BB:BB:BB, CC:CC:CC:CC:CC:CC and DD:DD:DD:DD:DD:DD respectively, in the same order.
Now let us say switch, S has got the MAC address table created after packets been transmitted between the host.

The MAC address table would look somewhat like this-


AA:AA:AA:AA:AA:AA -----> PA

BB:BB:BB:BB:BB:BB -----> PB

CC:CC:CC:CC:CC:CC -----> PC

DD:DD:DD:DD:DD:DD -----> PD

Now let us say, i swap the hosts C and D. So after swapping, host C connects to port PD and host D connects to port PC. But the MAC address table with the switch remains the same; (assumption: there are no frames transmitted from either hosts, C and D to rebuild the MAC address table)

Now, if host A wants to send data to host C, then data transmitted by host A would reach the switch, S and then switch looks up its MAC address table and figures out that the destination MAC address in the frame is CC:CC:CC:CC:CC:CC (of host C) is connected to port PC and forwards the frame on its PC port.
But once the frame reaches the host connected to port PC, which is host D (since we had swapped) would reject the frame. Since its NIC card compares its own MAC address DD:DD:DD:DD:DD:DD with that of the destination MAC address CC:CC:CC:CC:CC:CC. And packet would get dropped.

  1. Please confirm me if my understanding of this scenario is correct.

  2. Secondly, if the packet was reached to a wrong host and got dropped. And the source host things that i had sent the data to the intended host. How does this problem be addressed in networking.

Best Answer

Your understanding is correct, but your assumption that "no frames transmitted from either hosts, C and D." is likely wrong.

Gratuitious ARP precisely address this concern. From Wireshark.org:

The networking stack in many operating systems will issue a gratuitous ARP if the IP or MAC address of a network interface changes, to inform other machines on the network of the change so they can report IP address conflicts, to let other machines update their ARP tables, and to inform switches of the MAC address of the machine.

Even without Gratuitous ARP

  • if the machine is set to DHCP, then the DHCP request will triger the update
  • even if set to static, most operating systems tend to send many, many kind of traffic even when not solicited, like automatic updates for example.