35  Wi-Fi MAC Layer and IoT Applications

In 60 Seconds

Wi-Fi uses CSMA/CA (listen-before-talk) for channel access, with RTS/CTS handshakes to mitigate hidden terminal collisions in mesh and large deployments. QoS differentiation (802.11e) provides four priority levels (voice, video, best effort, background) to ensure time-sensitive IoT traffic gets preferred access. This chapter also covers real-world applications: 2.4 GHz for range-constrained sensors, 5 GHz for bandwidth-intensive cameras, and architecture selection between infrastructure, Wi-Fi Direct, and mesh modes.

35.1 Learning Objectives

By the end of this chapter, you will be able to:

  • Explain CSMA/CA Mechanisms: Describe how carrier sense, random backoff, and collision avoidance coordinate channel access among competing Wi-Fi stations
  • Evaluate MAC Performance: Analyze how contention window size, hidden terminals, and station density affect throughput and latency in dense IoT deployments
  • Configure QoS Differentiation: Map IoT traffic types to 802.11e access categories and justify priority assignments for latency-sensitive applications
  • Select Wi-Fi Architectures for IoT Use Cases: Recommend appropriate Wi-Fi configurations (infrastructure, Wi-Fi Direct, mesh) and frequency bands for smart home, industrial, agriculture, and healthcare deployments

The MAC (Media Access Control) layer is the traffic cop of Wi-Fi – it decides when each device gets to transmit. Without it, devices would all talk at once and create chaos. This chapter explains how Wi-Fi’s MAC layer manages access and how IoT applications use Wi-Fi for everything from smart thermostats to industrial sensors.

35.2 Prerequisites

Before diving into this chapter, you should be familiar with:

Key Concepts
  • CSMA/CA (Wi-Fi): Carrier Sense Multiple Access with Collision Avoidance; Wi-Fi devices listen before transmitting and use random backoff
  • DCF (Distributed Coordination Function): The fundamental MAC access method in 802.11; all devices contend equally for channel access
  • EDCA (Enhanced Distributed Channel Access): Wi-Fi 5/6 QoS extension prioritizing traffic into four access categories (VO, VI, BE, BK)
  • WMM (Wi-Fi Multimedia): Wi-Fi Alliance certification for EDCA/QoS; enables voice, video, best-effort, and background traffic prioritization
  • Power Save Mode: Client feature where device notifies AP it will sleep; AP buffers frames and delivers them on demand
  • Association Limit per AP: Practical maximum of 30-50 devices per AP for good performance; 802.11 supports up to 2007 associations
  • Block ACK: 802.11n feature aggregating acknowledgments for multiple frames, dramatically reducing ACK overhead
  • Frame Aggregation (A-MPDU/A-MSDU): Combining multiple frames in one transmission to reduce per-frame overhead

35.3 Key Takeaway

In one sentence: Wi-Fi uses CSMA/CA to share the medium, with hidden terminal mitigation via RTS/CTS, and QoS differentiation (802.11e) to prioritize time-sensitive traffic.

Remember this rule: Enable RTS/CTS for mesh networks with hidden terminals; use 5 GHz for high-bandwidth devices (cameras) and 2.4 GHz for range-constrained sensors.

35.4 MAC Layer and Channel Access

Wi-Fi uses CSMA/CA to share the medium. Hidden and exposed terminal problems can cause collisions or unnecessary backoff; RTS/CTS can mitigate hidden terminals. QoS and MAC performance depend on contention, interference, and client mix.

Wi-Fi Architecture Diagram 3

Wi-Fi Architecture Diagram 3
Figure 35.1: Wi-Fi CSMA/CA channel access with carrier sense and backoff

35.4.1 802.11 Channel Access Procedure

Flowchart showing 802.11 CSMA/CA channel access procedure with carrier sense, DIFS waiting, random backoff timer, frame transmission, and ACK receipt stages
Figure 35.2: IEEE 802.11 channel access mechanism using CSMA/CA for collision avoidance. The diagram shows a station sensing the channel carrier signal. If idle, the device waits for DIFS duration plus random backoff, then transmits the frame and waits for ACK acknowledgment. If busy, the station defers transmission and enters exponential backoff, preventing collisions through randomized retry timing.

Based on CP IoT System Design Guide, Chapter 4 – Networking.

35.4.2 Hidden Terminal Problem

Network diagram showing hidden terminal problem with two stations A and B on opposite sides of access point, both transmitting simultaneously, causing collision at AP because A and B cannot hear each other
Figure 35.3: Hidden terminal problem where two stations cannot sense each other’s transmissions (due to distance, obstacles, or low SNR) but both can reach the same access point. If they transmit at the same time, their frames can collide at the AP, causing retransmissions and wasted airtime.

35.4.3 Exposed Terminal Problem

Network topology showing exposed terminal problem where Node B unnecessarily defers transmission because it senses Node A transmitting, even though B's transmission to Node C would not cause interference
Figure 35.4: Exposed terminal problem where a node unnecessarily defers transmission. Node B is within range of transmitting Node A and detects A’s transmission. B defers its own transmission to Node C even though B to C transmission would not interfere with A’s transmission to the AP. This reduces network efficiency as B unnecessarily waits when parallel transmissions are possible. Occurs when CSMA sensing is overly conservative.

35.4.4 RTS/CTS Handshake

Sequence diagram of RTS/CTS handshake showing four-step process: RTS request, CTS broadcast, NAV timer setting, and protected data transmission
Figure 35.5: RTS/CTS handshake mechanism for collision avoidance in Wi-Fi. The four-way handshake prevents hidden terminal collisions: (1) Sender transmits Request-To-Send with duration, (2) Receiver responds with Clear-To-Send heard by all nearby nodes, (3) Other nodes set NAV timer and defer transmission, (4) Sender transmits data frame safely. CTS broadcast alerts hidden terminals to wait, reducing collisions at the cost of additional overhead. Essential for mesh networks with multi-hop hidden terminals.

35.4.5 MAC Performance Characteristics

Performance graph showing 802.11 MAC throughput vs number of stations, with curves for saturation throughput, collision rate, and average delay as node count increases from 1 to 100
Figure 35.6: 802.11 MAC layer performance characteristics and metrics. The figure illustrates that as the number of contending stations increases (often modeled under saturation assumptions), collision probability and backoff overhead rise and effective throughput per station decreases. Exact curves depend on PHY rate, frame sizes, retry limits, and traffic patterns.

Based on CP IoT System Design Guide, Chapter 4 – Networking.

35.5 Wi-Fi Architecture for IoT

~20 min | Intermediate | P08.C33.U01

35.5.1 Infrastructure Mode (Most Common)

Wi-Fi Architecture Diagram 4

Wi-Fi Architecture Diagram 4
Figure 35.7: Wi-Fi infrastructure mode with access point connecting devices to Internet

This variant shows the same three Wi-Fi architectures from a spatial coverage perspective - emphasizing how each mode extends or limits coverage area.

Diagram: INFRA

Diagram: INFRA
Figure 35.8: Wi-Fi architectures compared by coverage area: Infrastructure (single room), Direct (two devices), Mesh (whole building)

Key Insight: Choose architecture based on coverage needs: Infrastructure for single room with good AP placement, Wi-Fi Direct for temporary device-to-device links, Mesh for large areas with multiple rooms or floors. Mesh eliminates dead zones through overlapping coverage.

Characteristics:

Detailed 802.11 frame structure diagram showing MAC header fields including frame control, duration, three address fields, sequence control, frame body payload section, and 4-byte FCS checksum
Figure 35.9: IEEE 802.11 frame structure showing MAC header, frame body, and FCS components. The frame consists of three main parts: (1) MAC Header with frame control, duration, addresses (source, destination, BSSID), and sequence control totaling 24-30 bytes, (2) Frame Body containing 0-2312 bytes of payload data with encryption if enabled, (3) Frame Check Sequence (FCS) providing 4-byte CRC32 checksum for error detection. Key header fields include frame type (management, control, data), fragmentation bits, retry flag, power management bit, and QoS priority fields.

Based on CP IoT System Design Guide, Chapter 4 – Networking.

  • Centralized access point (AP) or router
  • All devices connect to AP
  • AP provides DHCP, routing, internet access
  • Most common for home/office IoT

35.5.2 Wi-Fi Direct (Peer-to-Peer)

Diagram: PHONE

Diagram: PHONE
Figure 35.10: Wi-Fi Direct peer-to-peer connections with smartphone as group owner

Characteristics:

  • Direct device-to-device connection
  • No router required
  • One device acts as soft AP
  • Use cases: Camera to phone, phone to printer

35.5.3 Wi-Fi Mesh Networks

Diagram: GATEWAY

Diagram: GATEWAY
Figure 35.11: Wi-Fi mesh network with gateway and satellite nodes extending coverage

Characteristics:

  • Multiple access points form a mesh
  • Self-healing, automatic routing
  • Extended coverage for large areas
  • Standards/implementations: IEEE 802.11s, vendor mesh systems, ESP32 frameworks (ESP-IDF ESP-Wi-Fi-MESH, Arduino painlessMesh)

35.6 QoS and Traffic Differentiation

QoS traffic differentiation diagram showing four access categories (Voice, Video, Best Effort, Background) with different AIFS waiting periods and contention window ranges, illustrating priority-based channel access in 802.11e
Figure 35.12: Statistical traffic differentiation for QoS in Wi-Fi networks. The diagram shows how 802.11e QoS assigns different priority levels to traffic types using four Access Categories (AC): (1) AC_VO (Voice) highest priority with shortest wait times for VoIP calls, (2) AC_VI (Video) second priority for streaming video with bounded latency, (3) AC_BE (Best Effort) standard priority for web browsing and file transfer, (4) AC_BK (Background) lowest priority for bulk data transfers and backups. Each category uses different AIFS (Arbitration Inter-Frame Space) and contention window sizes - higher priority classes wait shorter AIFS before transmitting, increasing their probability of channel access.

Quick Check: A smart factory has IP cameras streaming at 4 Mbps and temperature sensors sending 200-byte readings every 60 seconds. Which Wi-Fi architecture and QoS mapping would you recommend?

The cameras need 5 GHz band for bandwidth and should be mapped to AC_VI (Video) for bounded latency. The temperature sensors use 2.4 GHz for better range through metal shelving and can use AC_BE (Best Effort) since their data is small and not time-critical. A mesh topology would extend coverage across the factory floor, and RTS/CTS should be enabled if metal obstructions create hidden terminals.

35.7 Videos

Wi-Fi and the Protocol Stack
Wi-Fi and the Protocol Stack
Lesson 4 — layering fundamentals that underpin 802.11 networking.

35.8 Real-World IoT Applications

35.8.1 Smart Home Automation

Diagram: BAND_24

Diagram: BAND_24
Figure 35.13: Smart home dual-band Wi-Fi with 2.4 GHz and 5 GHz device separation

Use Case: Wi-Fi connects all smart home devices to central hub - Lights: 2.4 GHz (low bandwidth, range important) - Cameras: 5 GHz (high bandwidth video streaming) - Sensors: 2.4 GHz (battery-powered, need range)

35.8.2 Industrial IoT Monitoring

Application: Factory sensor network - Devices: 100+ sensors monitoring machines - Network: Wi-Fi 6 with OFDMA for dense deployment - Security: WPA2-Enterprise with 802.1X authentication - Topology: Mesh network for large facility coverage

35.8.3 Smart Agriculture

Application: Greenhouse monitoring - Sensors: Soil moisture, temperature, humidity (ESP32) - Power: Deep sleep mode, wake every 15 minutes - Connectivity: Wi-Fi 4 (2.4 GHz for range) - Data: MQTT over Wi-Fi to cloud platform

35.8.4 Healthcare Wearables

Application: Patient monitoring devices - Devices: Wearable sensors (heart rate, SpO2) - Connection: Wi-Fi Direct to smartphone gateway - Security: WPA3 with end-to-end encryption - Power: Wi-Fi modem sleep when idle

35.10 Worked Example: Hidden Terminal Impact on a Warehouse IoT Deployment

A warehouse deploys 80 Wi-Fi temperature sensors across 4,000 m^2 of shelving. Each sensor transmits a 200-byte reading every 60 seconds. The warehouse has one centrally placed AP. Steel shelving creates significant RF shadowing.

Problem Setup:

  • 80 sensors, each within range of the AP but many hidden from each other
  • Without RTS/CTS, hidden terminals cause collisions at the AP
  • Sensor radio: 802.11n at 2.4 GHz, 6.5 Mbps PHY rate

Without RTS/CTS (Hidden Terminals Present):

Assume 30% of sensor pairs are hidden from each other (common with steel shelving):

  • Collision probability per transmission: ~18% (measured via simulation for 80 nodes, 30% hidden)
  • Each collision wastes both frames + ACK timeout: ~2 ms per collision
  • Retransmissions needed: average 1.22 attempts per frame (18% first-attempt failure)
  • Effective throughput per sensor: 200 bytes / 1.22 = 164 useful bytes per attempt
  • Aggregate wasted airtime: 80 sensors x 0.22 retransmissions x 2 ms = 35.2 ms/minute wasted

At low load (80 sensors, 60s interval), this is manageable. But during a cold chain alert where 40 sensors exceed threshold and switch to 5-second reporting:

  • 40 sensors x 12 transmissions/minute = 480 transmissions/minute
  • Collisions: 480 x 0.18 = 86 collisions/minute
  • Wasted airtime: 86 x 2 ms = 172 ms/minute
  • Alert delivery latency: P95 rises from 50 ms to 800 ms due to exponential backoff after collisions

With RTS/CTS Enabled:

  • RTS/CTS overhead: 44 bytes (RTS) + 38 bytes (CTS) = 82 bytes per exchange
  • Data efficiency drops: 200 / (200 + 82) = 71% (29% protocol overhead)
  • But collision probability drops to ~2% (only RTS frames can collide, and they are shorter)
  • Alert delivery P95: 120 ms (6.7x improvement over no RTS/CTS during burst)

Decision Framework:

Scenario RTS/CTS? Reason
< 20 sensors, open floor Off Low collision probability, RTS/CTS overhead not justified
20-50 sensors, some obstructions Optional Enable if retransmission rate exceeds 10%
50+ sensors, metal shelving On Hidden terminal collisions degrade P95 latency significantly
Time-critical alerts (cold chain) On Predictable latency more important than throughput efficiency

The key insight: RTS/CTS costs 29% throughput overhead but delivers 6.7x better worst-case latency. For IoT alarm systems where P95 latency matters more than aggregate throughput, always enable RTS/CTS in environments with metal obstructions.

35.11 Concept Relationships

Concept Relationship Key Insight
CSMA/CA ↔︎ Collisions Listen-before-talk prevents some Hidden terminals still cause collisions at AP
RTS/CTS ↔︎ Overhead Reserves channel at 29% cost Reduces collisions from 18% to 2% in dense deployments
QoS Priority ↔︎ Latency AC_VO gets shortest wait Voice: P95 50ms, Best Effort: P95 800ms under load
Hidden Terminals ↔︎ Mesh Metal/walls block line-of-sight 30% hidden pairs = 18% collision rate without RTS/CTS

Common Pitfalls

Industrial cameras, VoIP intercoms, and real-time monitoring applications suffer severe quality degradation without WMM QoS prioritization. If WMM is disabled, all traffic — including video streams — competes equally with background data. Always enable WMM when deploying latency-sensitive IoT applications.

While an AP can technically associate 2007 devices, performance degrades significantly beyond 30-50 associations. Each additional device increases channel contention. Deployments with 100+ IoT sensors per AP will experience severe throughput degradation. Distribute IoT devices across multiple APs.

Wi-Fi power save mode (U-APSD or legacy PS) introduces variable latency for downlink frames (up to one DTIM interval, typically 100-300 ms). For remote control or real-time monitoring applications, this latency is unacceptable. Disable power save mode for latency-critical IoT devices.

A single 802.11b client on an AP forces protection mechanisms (CTS-to-self) that dramatically reduce throughput for all connected devices. Disable 802.11b data rates (1/2/5.5/11 Mbps) in AP configuration to prevent legacy client degradation.

35.12 Summary

This chapter covered Wi-Fi MAC layer and IoT applications:

  • CSMA/CA Channel Access: Carrier Sense Multiple Access with Collision Avoidance prevents simultaneous transmissions through listen-before-talk, but hidden terminals cause collisions without RTS/CTS
  • RTS/CTS Handshake: Request To Send / Clear To Send mitigates hidden terminal collisions by reserving airtime (other nodes defer), improving reliability at the cost of additional overhead
  • QoS Differentiation: 802.11e provides four access categories (Voice, Video, Best Effort, Background) with different AIFS and contention windows
  • Smart Home: Use 2.4 GHz for range-constrained sensors, 5 GHz for bandwidth-intensive cameras
  • Industrial IoT: Wi-Fi 6 with OFDMA handles dense sensor deployments; mesh extends coverage
  • Agriculture: Deep sleep + periodic wake works for low-data sensors; consider LPWAN for outdoor range
  • Healthcare: Wi-Fi Direct to smartphone gateway; WPA3 security essential

35.13 See Also

35.14 What’s Next

Next Topic Description
Wi-Fi Design Exercises Hands-on deployment pitfalls, roaming configuration, backhaul planning, and hidden terminal analysis labs
Wi-Fi Architecture Fundamentals Review infrastructure, Wi-Fi Direct, and mesh architecture foundations
Wi-Fi Fundamentals and Standards Revisit 802.11 standards, frequency bands, and PHY layer details