As described in Chapter 1, the Layer 2-specific PDU is a frame. The Data Link Layer created this new data unit by adding a Layer 2 frame header and trailer before passing it down to the Physical Layer. The most important information inside the frame header is the source and destination MAC addresses.
MAC Addresses
Layer 2 addresses are also called MAC (Media Access Control) addresses, physical addresses, or burned-in addresses (BIAs). These are assigned to NICs or device interfaces when they are manufactured.
MAC addresses are 48-bit values. The first 24 bits represent the Organizational Unique Identifier (OUI) code, which identifies the vendor of the device. The second-least significant bit in the OUI portion identifies whether the address has been locally (a bit value of 1) or universally (a bit value of 0) assigned, and the most significant bit identifies a Unicast MAC address (a bit value of 0) or a Multicast address (a bit value of 1). The last 24 bits form a unique value assigned to the specific interface so that each network interface can be identified in a unique way via the associated MAC address. This MAC address structure is illustrated in Figure 2.7 below:
Figure 2.7 – MAC Address Structure
| Note: Each NIC has a BIA (MAC address), so they could be considered both Layer 1 devices and Layer 2 devices.
|
Switches
Using hubs in medium-sized and large networks (or in any network for that matter) is not efficient. In order to improve performance, especially from a bandwidth and security standpoint, LANs are divided into multiple smaller LANs called collision domains and are interconnected by a LAN switch. When using switches, only the destination device in a communication flow receives the data sent by the source device, and multiple conversations between devices connected to a switch can happen simultaneously.
Switches have some intelligence, unlike hubs, because they send data to a port only if the data needs to reach that particular segment. This switching intelligence is based on a MAC table the switches keep in their memory. That table contains MAC address-to-port mappings and is populated in the following way: when a device sends data to a device located on another switch port, the switch learns the source MAC address (Layer 2 address) and its associated port. It then floods the received frames to all ports except the port on which it was received. This process continues until the MAC table is filled with entries for all of the devices in the network. When a switch must forward a frame with a destination MAC address that can be found in the MAC table, it forwards that frame only to that specific port.
The switching operation outlined above is exemplified in Figure 2.8 below; assume that the switch’s MAC address table is empty (i.e., the switch was just plugged in). When PC 1 sends a frame to PC 3, the switch does not know the port that PC 3 is connected to so it floods that frame out of all ports except the port on which it was received (port 1). At the same time, it records the source port and MAC address of that specific frame (port 1, with the MAC address of PC 1). When PC 3 responds and sends a frame back to PC 1, the switch does not have to flood that frame out of all ports because it now knows the port associated with PC 1. It forwards the frame just on port 1 to reach the destination. At the same time, it also records the port-MAC association for PC 3. If PC 1 sends a future frame to PC 3, the switch will forward it only on port 3 because it now knows where PC 3 is connected.
Figure 2.8 – Switching Operation (Building the MAC Address Table)
Special scenarios are those in which the destination Layer 2 field contains a Multicast or Broadcast address. In that case, the switch forwards the frame on multiple ports.
Devices connected to a switch port are in the same collision domains, while devices connected to different ports are in different collision domains. This is the most important feature of a switch: it separates collision domains. On the other hand, all devices connected to a switch are in the same broadcast domain.
Switches are considered Layer 2 devices because they make forwarding decisions based on Layer 2 (MAC) addresses.
| Note: A bridge is an old name for a switch. The bridge was the first step up from a hub and it offered limited switching capacities, usually containing two or four ports (while a switch commonly is equipped with up to 48 ports). Bridges use the same forwarding logic as switches do.
|
A special category of switches are Layer 3 switches, which have full Layer 3 capabilities, including routing. They are also called routing switches or, more often, multilayer switches, as they can make forwarding decisions at multiple layers.
Switching Logic
Switches are network devices that separate collision domains and process data at high rates, as the switching function is implemented in hardware using application-specific integrated circuits (ASICs). Networks are segmented by switches in order to provide more bandwidth per user by reducing the number of devices that share the same bandwidth. Switches forward traffic only on interfaces that need to receive the traffic. In the case of Unicast traffic, switches forward the frame on a single port rather than on all ports.
The bridge table is an internal data structure that records all the MAC address-to-interface pairs, whenever the switch receives a frame from a device. When the switch is first turned on, the bridge table (also called the switch table, the MAC address table, and the content addressable memory (CAM) table) contains no entries. When a frame enters an interface, the switch adds the source MAC address and the source port to its bridge table and then examines the destination MAC address. If this is a Broadcast, Multicast, or unknown Unicast address, the switch floods the frame out of all ports, except for the source port. If the source and the destination addresses are on the same interface, the frame is discarded. If the destination address is known (i.e., the switch has a valid entry in the bridge table), the switch forwards the frame out of the corresponding interface. This switching operation is summarized in Figure 2.9 below:
Figure 2.9 – Switching Operation (Flooding Frames)
In addition to flooding unknown Unicast frames, switches also flood two other frame types: Broadcast and Multicast. Various multimedia applications generate Multicast or Broadcast traffic that propagates throughout a switched network (i.e., the broadcast domain).
Switches learn source MAC addresses so they can send data to the appropriate destination segments. When a switch learns a source MAC address, it records the time of its entry. Every time the switch receives a frame from that source, it updates the timestamp. If a switch does not hear from that source before a predefined aging time expires, that entry is removed from the bridge table. The default aging time in Cisco access switches is five minutes. This behavior is outlined in Table 2.1 below (the sender workstation has the AAAA.AAAA.AAAA.AAAA MAC address):
Table 2.1 – Behavior of the Mac Address Table
| Reference Time |
Action |
Port |
MAC Address |
Age (sec) |
| 00:00 | Host A sends frame #1 |
Fa0/1 |
AAAA.AAAA.AAAA.AAAA |
0 |
| 00:30 | Age increases |
Fa0/1 |
AAAA.AAAA.AAAA.AAAA |
30 |
| 01:15 | Host A sends frame #2 |
Fa0/1 |
AAAA.AAAA.AAAA.AAAA |
0 |
| 06:14 | Age increases |
Fa0/1 |
AAAA.AAAA.AAAA.AAAA |
299 |
| 06:16 | Entry aged out (deleted) |
– |
– |
– |
| 06:30 | Host A sends frame #3 |
Fa0/1 |
AAAA.AAAA.AAAA.AAAA |
0 |
| 06:45 | Age increases |
Fa0/1 |
AAAA.AAAA.AAAA.AAAA |
15 |
MAC address table entries are removed when the aging time expires because switches have a finite amount of memory, limiting the number of addresses it can remember in its bridge table. If the MAC address table is full and the switch receives a frame from an unknown source, the switch floods that frame on all ports until an opening in the bridge table allows the bridge to learn about the station. Entries become available whenever the aging timer expires for an address. The aging timer helps to limit flooding by remembering the most active stations in the network. The aging timer can be adjusted if the total number of network devices is lower than the bridge table capacity. This allows the switch to remember the station longer and reduces flooding.
| Note: The process of flooding new, unknown frames when the MAC address table is full is a potential security risk because an attacker could take advantage of this behavior and overwhelm the bridge table. If the attacker is successful, all the ports (including the attacker port) will receive all the new frames, even if they are not destined for them.
|


