Ethernet

Ethernet Switching

How Ethernet switches learn MAC addresses and forward frames in modern networks.

From Hubs to Switches: Limits of a Shared Medium

To understand an Ethernet switch, first consider the limitations of its predecessor, the hub. A hub is a simple device that operates at the Physical Layer (Layer 1). It receives an electrical signal on one port, regenerates it, and broadcasts it to every other port. This creates a "logical bus," where all connected devices share a single communication channel.

The shared medium produced three problems:

  • Collisions: When two devices tried to transmit simultaneously, their signals corrupted each other, forcing them to stop and retransmit.
  • Shared bandwidth: The total bandwidth of the medium was shared among all devices, so performance degraded as more devices became active.
  • Easier traffic capture: Every device connected to a hub received traffic from the other ports, making frame capture easier.

An Ethernet switch limits these problems by forwarding frames to selected ports and separating collision domains.

What is an Ethernet Switch? The Device's Role

A typical Ethernet switch operates at Layer 2 (the Data Link Layer) of the OSI model. Unlike a hub, it processes Ethernet frames and reads their addresses. Multilayer switches can also perform Layer 3 functions.

The primary job of a switch is to receive frames and select an output port using the destination address. For a known unicast, it sends the frame to the port leading to the destination instead of flooding all ports like a hub. Separating collision domains at the ports is called microsegmentation. In half-duplex operation, each port forms a separate collision domain; in full-duplex operation, collisions do not occur.

The Switch's MAC Address Table

An Ethernet switch stores a MAC address tablecontaining entries used to select output ports. An entry associates a device's hardware address with a port and, in a VLAN network, with a VLAN context.

The table is sometimes called a CAM (Content-Addressable Memory) table because some devices implement it with content-addressable memory. A dynamic entry is created from frames received on a port, while a static entry follows administrator configuration. A typical MAC address table contains entries with the following information:

ColumnDescription
MAC AddressThe 48-bit MAC address of the connected interface.
PortThe physical port through which the device with this MAC address is reachable.
TypeIndicates how the entry was learned. Dynamic entries are learned automatically, while Static entries are manually configured by an administrator.
VLAN (optional)The VLAN identifier associated with the address and port entry.

MAC address learning

A new switch has an empty MAC address table when it starts. It builds the table dynamically through a passive learning process.

The process relies on this principle: every Ethernet frame has a source MAC address. The switch uses the source address and ingress VLAN to learn entries. The process is as follows:

  1. Frame Arrival:An Ethernet frame arrives on one of the switch's ports (e.g., Port Fa0/1).
  2. Inspect Source MAC Address: The switch examines the header of the frame and reads the source MAC address. Let's say the source is 0030.a3cb.87c5.
  3. Consult MAC Address Table: The switch looks in its table to see if it already has an entry for 0030.a3cb.87c5.
  4. Learn or Refresh:
    • If the address is NOT in the table: The switch concludes, "A device with MAC address 0030.a3cb.87c5 is located on the other end of Port Fa0/1." It then creates a new dynamic entry in its table, associating that MAC address with that port number.
    • If the address IS already in the table: The switch knows the device's location. It refreshes an internal aging timer for that entry. This timer ensures that entries for devices that are no longer on the network are eventually removed, while a topology change or port shutdown can clear dynamic entries.

The switch repeats this process for every frame that enters it. As devices communicate, it automatically populates the table with learned addresses and ports without manually entering every association. An entry is usually scoped to a VLAN and can be removed after its aging time expires. A topology change or port shutdown can also remove dynamic entries, depending on the implementation.

The Forwarding Decision: Filter, Forward, or Flood

After learning the source address, the switch examines the frame's destination MAC address and selects one of three actions:

1. Forwarding (Known Unicast)

This is the ideal and most common scenario. The switch receives a frame destined for a known MAC address.

  1. A frame arrives on Port Fa0/1, destined for a device with MAC 00d0.bab8.8516.
  2. The switch performs a lookup in its MAC address table.
  3. It finds an entry: 00d0.bab8.8516 is located on Port Fa0/4.
  4. The switch then transmits the frame only out of Port Fa0/4. No other ports receive the frame.

For this frame, the switch selects one output port using the MAC entry for the current VLAN. This does not create a permanent connection or guarantee confidentiality; other ports can handle other frames at the same time.

2. Flooding (Unknown Unicast)

This occurs when the switch receives a frame destined for a MAC address that is not yet in its MAC address table. Since the switch does not know which port to send the frame to, it floods the frame within the current VLAN using a method similar to a hub.

  1. A frame arrives on Port Fa0/1, destined for MAC 00e0.f9cd.3908.
  2. The switch performs a lookup in its table and finds no entry for this address.
  3. The switch then floods the frame: it makes copies and sends them through eligible ports in the same VLAN, except for the ingress port.

The intended recipient will receive the frame and likely send a reply. When that reply comes back, the switch will learn the location of 00e0.f9cd.3908 from its source MAC address, and future frames to that device will be forwarded. Broadcast frames (destination FF:FF:FF:FF:FF:FF) and unknown multicast frames are usually flooded within the VLAN, unless configuration limits that traffic. Multicast forwarding can also be constrained by features such as IGMP snooping.

3. Filtering (Same-Port Destination)

This is a less common but logical scenario. The switch receives a frame where the destination MAC address is located on the same port that the frame arrived on.

  1. A frame arrives on Port Fa0/3 from a device connected to a hub, which is then connected to the switch. The frame is destined for another device on the same hub.
  2. The switch inspects the destination MAC and finds in its table that this MAC is also reachable via Port Fa0/3.
  3. The switch knows there is no need to transmit the frame back out the same port it came from. It simply filters, or discards, the frame.

Effects of Ethernet switching

Frame forwarding by switches limits the problems of hubs and improves link utilization. The security impact depends on network configuration.

Collision-domain separation

Switching segments collision domains. In half-duplex operation, a 24-port switch can form 24 separate collision domains. Collisions occur on a half-duplex link when the device and switch transmit at the same time. Modern switch links usually operate in full-duplex mode, so collisions do not occur.

Full-duplex communication

In full-duplex operation, a device can send and receive data simultaneously. In 100BASE-TX the directions use separate pairs, while 1000BASE-T uses all four pairs in both directions; neither full-duplex case uses CSMA/CD. A 100 Mbps link provides 100 Mbps in each direction, or up to 200 Mbps aggregate throughput when both directions carry traffic.

Per-port link capacity

Unlike a hub, a switch provides each port with its link rate unless the switching fabric, uplink, or oversubscription limits it. When Host A communicates with Server C through a 1 Gbps port, that pair can use up to 1 Gbps on the link. At the same time, Host B can communicate with Server D through other ports, subject to the switch resources.

Reduced traffic visibility

For known unicast, a switch normally does not send the frame to other ports, which limits casual capture with a packet sniffer compared with a hub. This does not replace access controls, because flooding, monitoring ports, and misconfiguration can expose traffic.

Related articles