Switching and Bridging
Networking and internetworking devices are commonly classified into four categories: repeaters, bridges, routers, and gateways. This chapter focuses on bridging and switching in local area networks (LANs): how bridges learn and forward frames, how switches relate to bridges, and how loops are prevented using the spanning tree algorithm.
Bridges and LAN Switches
A bridge is a device that connects two or more LAN segments and forwards Ethernet frames between them based on MAC (hardware) addresses. Each connection of a bridge to a LAN is called a port. When multiple LAN segments are connected by bridges, the combined network is called an extended LAN.
Bridges operate at the data-link layer (Layer 2) of the OSI model. They inspect frame headers to determine the source and destination MAC addresses and decide whether to forward, filter, or flood frames. Modern multiport bridges are commonly known as switches. A switch is effectively a multiport bridge implemented in hardware for higher performance.
Basic forwarding behaviour
- If a frame's destination MAC address is known in the bridge's forwarding table, the bridge forwards the frame only to the corresponding port.
- If the destination MAC address is unknown, the bridge floods the frame: it forwards the frame out on every active port except the port on which the frame was received.
- If the destination MAC address equals the source port's segment (i.e., the destination is on the same LAN segment as the source), the bridge filters the frame and does not forward it to other segments.
Learning Bridges
A learning bridge builds and maintains a forwarding table (also called a MAC table) automatically. The forwarding table maps MAC addresses to bridge ports. Maintenance of this table is performed by the bridge itself; human configuration of each host entry is not required.
Learning is performed by inspecting the source MAC address of every frame that the bridge receives. When a frame arrives on a port, the bridge records that the source address is reachable via that port. Entries in the forwarding table are associated with an ageing timeout. If an entry is not refreshed within the timeout period, the bridge removes (ages out) that entry to accommodate moves and topology changes.
Typical behaviour summary:
- The bridge records the source MAC address and the port on which the frame arrived.
- When a later frame arrives with that destination MAC, the bridge forwards it only to the learned port.
- If the destination is unknown, the bridge floods the frame to all other ports.
Switch versus Bridge
- A bridge historically refers to a device connecting two LAN segments; a switch is a multiport bridge with many ports implemented in high-speed hardware.
- Switches typically use ASICs (hardware) to forward frames at wire speed; bridges were originally implemented in software or low-speed hardware.
- Both maintain a MAC forwarding table and perform learning and ageing; switches add features such as VLAN support and advanced filtering.
Spanning Tree Algorithm
When LANs are interconnected with multiple bridges, redundant paths are often present to improve reliability. Redundant paths cause loops, which lead to problems such as continuous frame replication and broadcast storms. Bridges must prevent indefinite looping of frames. The standard solution is the Spanning Tree Algorithm.
The spanning tree algorithm enables bridges to discover the network topology and to disable just enough ports so that the interconnection forms a loop-free spanning tree. The algorithm was originally developed by Digital Equipment Corporation and later standardised by IEEE as IEEE 802.1D.
High-level steps of the algorithm:
- Each bridge has a unique bridge identifier (Bridge ID).
- All bridges exchange configuration messages containing three key pieces of information: the sending bridge's ID, the ID of the root bridge as believed by the sender, and the distance (measured in hops or path cost) from the sender to that root.
- Using these messages, the bridges elect one bridge as the root bridge (the bridge with the lowest Bridge ID).
- Each non-root bridge selects a single root port, the port that gives the shortest path toward the root bridge.
- For each LAN segment, the bridges connected to that segment select one bridge as the designated bridge for that segment; the designated bridge is responsible for forwarding frames toward the root on behalf of that LAN. The designated bridge is the bridge on that LAN that has the shortest path to the root bridge; ties are broken by lower Bridge ID.
- Ports that are neither root ports nor designated ports are placed into a blocking state so that they do not forward user frames, thereby eliminating loops. The blocking state still permits the exchange of control messages needed to maintain the spanning tree.
Example from the simple labelling used earlier (bridges labelled B1, B2, B3, ...):
- If B1 has the smallest Bridge ID, B1 becomes the root bridge and forwards out all its ports.
- If B3 and B5 are both connected to LAN A, the bridge closer to the root becomes the designated bridge; if both are equally close, the bridge with the smaller Bridge ID is chosen.
- Similarly, if B5 and B7 are connected to LAN B and both are equally close to the root, the one with the smaller Bridge ID (B5) is the designated bridge.
Configuration messages exchanged by bridges are used to propagate root selection and path information. The configuration message fields are:
- The ID of the sending bridge.
- The ID of what the sending bridge believes to be the root bridge.
- The distance (in hops or path cost) from the sending bridge to the root bridge.
When a bridge receives a configuration message, it updates its view of the root and path if the received information is superior. A configuration message is considered superior if it:
- identifies a root with a smaller Bridge ID,
- identifies the same root but with a shorter distance to the root, or
- identifies the same root and equal distance, but the sending bridge has a smaller Bridge ID (tie-breaker).
In IEEE 802.1D terminology, the control messages used by STP are called BPDUs (Bridge Protocol Data Units).
Broadcast and Multicast
Most LANs support both broadcast and multicast addressing. Bridges and switches must handle these appropriately:
- For a broadcast frame (destination broadcast address), a bridge forwards the frame out on every active port except the ingress port so that all segments receive the broadcast.
- For multicast frames, hosts determine whether to accept a multicast frame. Bridges historically treated multicast like broadcast and flooded it. Modern switches can implement multicast filtering mechanisms (for example, IGMP snooping) to limit multicast forwarding only to ports where group members are present.
Switching Techniques
Switches may use different internal forwarding techniques; the common methods are:
- Store-and-forward: The switch receives the entire frame, checks it for errors (CRC), and then forwards it. This method avoids forwarding corrupted frames but introduces greater latency.
- Cut-through: The switch begins forwarding a frame as soon as it has read the destination MAC address (after the first 6+6+2 bytes); this reduces latency but forwards frames even if they are later found to be corrupted.
- Fragment-free (modified cut-through): The switch waits for the first 64 bytes (which typically contain collision fragments) and then begins forwarding; this represents a compromise between cut-through and store-and-forward.
Practical notes and applications
- Bridging and switching are essential for scaling LANs: learning and selective forwarding reduce unnecessary traffic on segments and improve overall network performance.
- Spanning Tree Protocol (STP) is essential in networks with redundancy; without STP or an equivalent protocol, loops will cause broadcast storms and eventual network failure.
- Modern Ethernet networks use switches rather than simple bridges. Switches provide higher port density, better performance, VLANs, QoS features, and fast hardware learning of MAC addresses.
Key terms: bridge, switch, MAC address, forwarding table, learning bridge, ageing timeout, root bridge, designated bridge, blocking state, BPDU, IEEE 802.1D, store-and-forward, cut-through, multicast, broadcast.