Example: Switch Operation on a Local Network

A switch uses a routing table to associate the switch’s port number with the MAC address connected at the other end of the wire. The following steps will show how the switch’s routing table is populated.

  1. PC Sends a Frame to the Switch
  2. Switch Receives Frame
  3. Switch Broadcasts Frame to all Nodes
  4. Router Sends Reply to PC
  5. Switch Forwards Frame to PC
switch_table.png
Click image to enlarge.

1 PC Sends a Frame to the Switch

When a host first connects to a network, it attempts to communicate with a router to obtain an IP addresses.

It creates a packet with a broadcast IP address, then encapsulates the packet into a frame with a broadcast MAC address. This frame is then sent to all hosts.

switch_table_1.png

The MAC address used to broadcast a frame to all hosts is all ones (FF:FF:FF:FF:FF:FF).

2 Switch Receives Frame

When the switch receives this frame, it uses its routing table to associate the host's MAC address with the interface that received the frame.

switch_table_2.png

Remember the frame sent to the Dynamic Host Configuration Protocol (DHCP) server in the router contains the source MAC address.

3 Switch Broadcasts Frame to all Nodes

The MAC in the switch sees this is a broadcast frame, so the switch forwards the frame to all hosts connected to it.

switch_table_3.png

4 Router Sends Reply to PC

When the switch receives the reply from the router, it associates the router’s MAC address with the interface that received the frame.

switch_table_4.png

5 Switch Forwards Frame to PC

The switch looks at this frame to find the destination MAC address and sees that it is already in its routing table. The frame is then forwarded to the appropriate port. No other port will see this frame.

switch_table_5.png
© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.