Course contentsShow
← Embedded Systems & Computer Architecture
Lesson 875 of 93612. IoT Connectivity and SecurityFree lesson

Implementing Wi-Fi Data Link Frame Structures

Examine the MAC layer frame formats and access control mechanisms required to manage reliable data transmission over shared Wi-Fi channels.

In this lesson, you will learn how the IEEE 802.11 MAC layer structures data frames to facilitate reliable communication over a shared, contention-based wireless medium.

Anatomy of the 802.11 MAC Frame

Unlike Ethernet frames, which have a simple header, Wi-Fi frames must handle the complexities of wireless transmission, such as mobility and potential interference. A standard Wi-Fi data frame consists of a MAC Header, a Frame Body (the payload), and a Frame Check Sequence (FCS) for error detection.

The most critical component is the Frame Control field, which identifies the frame type (Management, Control, or Data) and handles flow control bits like Retry and More Data. Because Wi-Fi is a shared medium, the frame includes four different address fields. While wired Ethernet only needs a Source and Destination, Wi-Fi frames use these four fields to distinguish between the transmitter, receiver, and the ultimate source/destination addresses when traffic passes through a wireless Access Point (AP).

Access Control: CSMA/CA

Since multiple devices cannot transmit simultaneously without causing collisions, we use Carrier Sense Multiple Access with Collision Avoidance (CSMA/CA). Before sending a frame, the embedded network controller performs a "clear channel assessment":

// Simplified logic for channel access
if (check_clear_channel() == CHANNEL_IDLE) {
    transmit_frame(data_frame);
} else {
    // Implement random backoff to avoid collision
    wait_random_interval(CW_MIN, CW_MAX);
    retry_transmission();
}

By utilizing a Network Allocation Vector (NAV)—a timer value embedded in the frame header—other stations are informed of how long the channel will be occupied. This mechanism acts as a "virtual carrier sense," preventing nodes from attempting to transmit during a frame exchange. The receiver must then acknowledge the frame (using an ACK frame) for the transaction to be considered successful. If the sender does not receive an ACK, the MAC layer assumes a collision or interference occurred, increments the retry count, and re-queues the frame.

Key Takeaway: Wi-Fi frame structures leverage a multi-address header and the CSMA/CA algorithm to manage shared medium access and ensure reliable delivery in an inherently noisy wireless environment.