Modern wireless networks are built on complex protocols, with each layer responsible for its own area of work, ensuring stable data transmission. When you send a message or play a video, the signal goes through numerous processing stages before being converted into radio waves. A special place in this hierarchy is occupied by the wireless network. data link layer, which directly controls access to the physical medium and guarantees the integrity of transmitted frames.
It is here, at the boundary between the software and the radio part of the device, that the magic of converting data into a format understandable to the wireless interface occurs. Media Access Control MAC (Media Access Control) is a key sublayer that determines the rules of the game for all devices within the router's coverage area. Understanding its operation is essential not only for network engineers but also for advanced users looking to optimize their home network.
In this article, we will examine in detail what tasks this mechanism solves, how it prevents collisions, and why the operation of the family of standards is impossible without it. IEEE 802.11You will learn how devices are addressed and how data is fragmented for efficient transmission over the air.
Structure of the data link layer and the place of MAC
The OSI model's data link layer in Wi-Fi networks is divided into two logical parts, each of which performs a strictly defined set of functions. The upper part is called LLC (Logical Link Control) and is responsible for interaction with the network layer, providing protocol multiplexing. The lower part is MAC, which directly interacts with the physical layer (PHY), managing the radio channel.
Separation is necessary so that changes in the physical layer (for example, switching from 2.4 GHz to 5 GHz) do not require a complete redesign of the network's software logic. MAC sublayer acts as a universal translator that takes data packets from the upper layers and packages them into frames for transmission over the air.
- 📡 Access control: Determines when a particular device can transmit data so as not to interfere with others.
- 🛡️ Error control: checks the integrity of received frames and requests retransmission if damaged.
- 🏷️ Addressing: uses unique MAC addresses to deliver information to the exact recipient over the air.
⚠️ Warning: Some older network adapter drivers may have implemented MAC and PHY functions in software, which could create a high load on the computer's CPU.
CSMA/CA
Wired Ethernet networks use a collision detection method (CSMA/CD), but it's not applicable in wireless environments due to the nature of radio wave propagation. A device can't simultaneously transmit and listen on the same frequency, so a mechanism was developed for Wi-Fi. CSMA/CA (Carrier Sense Multiple Access with Collision Avoidance). This means that before sending data, a node first "listens" to the air.
If the channel is clear, the device waits for a short interval, called DIFS (Distributed Inter-Frame Space), before transmitting. If another client or access point is already transmitting, your device enters sleep mode and starts a random countdown timer. This approach minimizes the likelihood of two devices talking at the same time.
The collision avoidance process is closely tied to the acknowledgement system (ACK). After successfully receiving a frame, the receiver is required to send a short acknowledgement frame. If the sender does not receive an ACK within a certain time, it assumes a collision or data loss has occurred and retransmits.
802.11 Addressing and Framing
One of the main functions of the MAC layer is correct addressing. Unlike wired networks, where there are typically only two recipients (sender and recipient), in Wi-Fi, a frame must contain up to four addresses. This is due to the need to support bridging (WDS) mode and roaming between access points.
A standard frame contains fields for the address of the recipient (DA), sender (SA), receiver (RA), and transmitter (TA). MAC header It also includes a frame control field, which tells the device what type of frame it is (control, management, or data) and whether the transmission should be fragmented.
Each frame is equipped with a checksum (FCS), which is calculated based on the packet's contents. If interference occurs during transmission and bits are altered, the receiving end will detect a checksum mismatch and simply discard the corrupted frame without forwarding it further over the network.
| Frame field | Function Description | Size (bytes) |
|---|---|---|
| Frame Control | Frame type, protocol version, flags | 2 |
| Duration/ID | Channel busy time or frame ID | 2 |
| Address 1-4 | Addresses of the recipient, sender, and intermediate nodes | 6-24 |
| Sequence Control | Sequence and fragment number | 2 |
Data fragmentation and collection
Wireless environments are extremely unstable, and transmitting large amounts of data in one chunk often leads to errors. If a long packet is corrupted by interference, it must be retransmitted in its entirety, reducing overall throughput. To avoid this, MAC layer Performs fragmentation - breaks large data packets (MSDUs) into smaller fragments.
Each fragment is numbered and transmitted separately, receiving its own acknowledgement (ACK). This allows only the damaged fragment to be retransmitted, rather than the entire original packet. The reassembly (defragmentation) process occurs on the receiver side, which waits for all the pieces before sending the data up the protocol stack.
The Fragmentation Threshold can be configured in the router interface. Too small a value will increase header overhead, while too large a value will result in frequent retransmissions in noisy environments.
⚠️ Note: Changing the fragmentation threshold only makes sense in environments with severe radio interference. In a clean environment, it may even reduce speed due to increased service traffic.
Energy saving and sleep modes
For battery-powered mobile devices, energy conservation is critical. The 802.11 MAC layer provides special power-saving mechanisms (Power Save Mode). The device can periodically put its Wi-Fi module into sleep mode, disabling the receiver.
Before going to sleep, the client notifies the access point of its status. The access point buffers incoming packets for this client. To determine whether there is data available, the device periodically wakes up and listens for special beacon frames containing a traffic indication map (TIM).
What happens if the device does not wake up on time?
If a client misses several beacon intervals, the access point may consider it disconnected and flush the buffer, resulting in data loss or connection failure.
There are various versions of this mechanism, including U-APSD, which allows the device to sleep for longer periods and wake up only when it plans to send or receive data. This significantly extends the battery life of smartphones and laptops.
MAC-level security and encryption
Although encryption is often associated with the upper layers, the basic security of a wireless network is implemented at the MAC sublayer. Security protocols such as WPA2 And WPA3, use encryption mechanisms (AES-CCMP) integrated into the framing process. Data is encrypted before adding a checksum and being transmitted over the air.
Furthermore, the MAC layer is responsible for authentication and association. Before exchanging data, a device must complete a four-way handshake, during which security keys are verified. Without successful completion of this process at the MAC layer, further transmission of user data is impossible.
- 🔐 Encryption: converting the frame payload into an unreadable format.
- 🔑 Key management: generation and rotation of temporary encryption keys.
- 🚫 Filtration: discard frames from unauthorized senders.
☑️ Wi-Fi Security Check
The Impact of MAC Configuration on Network Speed
Configuring MAC layer parameters can significantly impact the actual connection speed. For example, using short interframe intervals (Short GI) allows for more data to be transmitted per unit of time, but requires good signal quality. In long-range or interference-intensive environments, it's better to use standard intervals.
Another important parameter is the RTS/CTS (Request to Send / Clear to Send) mechanism. It is designed to solve the hidden node problem, where two clients cannot "hear" each other but interfere with the access point. Enabling RTS/CTS adds overhead frames before each data transmission, which reduces the speed in clear air but saves the network in difficult conditions.
Network optimization often begins with log analysis and understanding how devices communicate at the data link layer. Excessive retries indicate signal problems or interference, which is directly related to the operation of MAC mechanisms.
⚠️ Note: Advanced MAC settings (RTS threshold, Fragmentation threshold) are often hidden in the standard firmware of home routers and are only accessible in expert mode or via the command line.
Frequently Asked Questions (FAQ)
Is it possible to change the MAC address of a network card?
Yes, this process is called MAC spoofing. It can be performed through the operating system's driver settings or with specialized utilities. It is often used to bypass address filtering or to enhance privacy on public networks.
Does the number of connected devices affect the operation of the MAC layer?
Absolutely. The more devices compete for the channel, the more frequent collisions occur and the more time devices spend waiting (backoff). This leads to increased latency and a reduction in the effective throughput for each client.
Why do we need fragmentation if we have high-speed internet?
Fragmentation is needed not for speed, but for reliability. In a wireless environment with its constant interference from microwaves, Bluetooth devices, and neighboring networks, transmitting small chunks of data is more efficient than constantly retransmitting huge, lost packets.
Does WPA3 encryption work at the MAC level?
Yes, WPA3 (SAE protocol) security mechanisms are implemented at the junction of the MAC and physical layers, providing stronger protection against password brute-force attacks compared to previous versions of the security standard.