< Home

Layer 2 Switching

A Layer 2 device works at the second layer of the OSI model and forwards data packets based on media access control (MAC) addresses. Ports on a Layer 2 device send and receive data independently and belong to different collision domains. Collision domains are isolated at the physical layer so that collisions will not occur between hosts (or networks) connected through this Layer 2 device due to uneven traffic rates on these hosts (or networks).

A Layer 2 device parses and learns source MAC addresses of Ethernet frames and maintains a mapping table of MAC addresses and ports. This table is called a MAC address table. When receiving an Ethernet frame, the device searches for the destination MAC address of the frame in the MAC table to determine through which port to forward this frame.

  1. When the Layer 2 device receives an Ethernet frame, it records the source MAC address and the inbound port of the frame in the MAC address table to guide Layer 2 forwarding. If the same MAC address entry exists in the MAC address table, the device resets the aging time of the entry. An aging mechanism is used to maintain entries in the MAC address table. Entries that are not updated within the aging time are deleted from the MAC address table.
  2. The device determines whether the destination MAC address is a broadcast address.
    1. If the destination MAC address is a broadcast address, the device forwards the frame to all its ports except the port from which the frame is received.
    2. If the destination MAC address is not a broadcast address, the device looks up the MAC address table based on the destination MAC address of the Ethernet frame. If a matching entry is found in the MAC address table, the device forwards the frame to the port specified in the entry. If no matching entry is found, the device forwards the frame to all its ports except the port from which the frame is received.

According to the preceding forwarding process, a Layer 2 device maintains a MAC address table and forwards Ethernet frames based on destination MAC addresses. This forwarding mechanism fully uses network bandwidth and improves network performance. Figure 1 shows an example of Layer 2 switching

Figure 1 Layer 2 switching example

Although Layer 2 devices can isolate collision domains, they cannot isolate broadcast domains. As described in the Layer 2 forwarding process, broadcast packets and packets that do not match nay entry in the MAC address table are forwarded to all ports (except the port from which the frame is received). Packet broadcasting consumes much bandwidth on network links and brings security issues. Routers can isolate broadcast domains, but high costs and low forwarding performance of routers limit the application of routers in Layer 2 forwarding. The virtual local area network (VLAN) technology is introduced to solve this problem in Layer 2 switching.

Copyright © Huawei Technologies Co., Ltd.
Copyright © Huawei Technologies Co., Ltd.
Next topic >