Wi-Fi MAC Layer: Scanning, Authentication, Association, and Data Transmission Processes

UsingWi‑Fias an example, theMAC layeris the "network access manager" that sits above the PHY/Baseband and decides how a device joins a network, gains access to the medium, exchanges frames, retries lost packets, and maintains connectivity.

A simplified Wi‑Fi stack looks like:

Application TCP/IP ↓ 802.11 MAC ↓ 802.11 PHY/Baseband ↓ RF ↓ Antenna

The MAC layer performs:

  • Scanning

  • Authentication

  • Association

  • Security key exchange

  • Data transmission

  • Retransmission

  • Roaming

  • Power saving

Let's walk through what happens when an ESP32-S31 connects to a Wi‑Fi AP.


Step 1: Scanning

Before connecting, the STA (station, e.g., ESP32) must discover available APs.

Passive Scan

The STA simply listens.

APs periodically send:

Beacon Frame

containing:

SSID Channel BSSID Security Mode Supported Rates Capabilities

Example:

SSID: HomeWiFi Channel: 6 Security: WPA2

Active Scan

The STA sends:

Probe Request

Example:

Who has SSID "HomeWiFi"?

AP replies:

Probe Response

At this stage, the MAC is handling management frames.

STA -------------------> Probe Request STA <------------------- Probe Response

Step 2: Authentication

Historically, 802.11 defined an authentication procedure before association.

Open System Authentication

Today this is the most common.

STA sends:

Authentication Request `

AP replies:

Authentication Response (Status = Success)
STA AP Authentication Request -----> <------- Authentication Response

This doesnotyet verify the Wi‑Fi password.

It simply says:

You may proceed to associate.

Step 3: Association

Now the station asks to join the AP.

Association Request

Contains:

SSID Supported Data Rates Capabilities QoS Features HT/VHT/HE Capabilities

Example:

I support: 802.11n MCS0~MCS7 WPA2 QoS

Association Response

AP replies:

Association ID (AID) Status Capabilities

Example:

AID = 0x0021 Status = Success

At this point:

STA is associated

but encrypted data is still unavailable.

STA AP Assoc Req -------------> <------- Assoc Resp

Step 4: WPA/WPA2/WPA3 Security

Now comes the real security process.

For WPA2-PSK the famous:

4-Way Handshake

occurs.


Goal

Both sides derive:

PTK (Pairwise Transient Key)

used to encrypt traffic.


Message 1

AP sends:

ANonce

Message 2

STA sends:

SNonce MIC

Message 3

AP sends:

Install Key GTK

Message 4

STA acknowledges.

AP STA M1 ANonce ------------> <---- M2 SNonce M3 GTK -------------> <---- M4 ACK

After this:

Encrypted traffic enabled

Now IP traffic can start.


Step 5: DHCP

This is above the MAC layer but happens immediately afterward.

DHCP Discover DHCP Offer DHCP Request DHCP ACK

Now the device obtains:

IP Address Gateway DNS

Example:

192.168.1.105

Step 6: Data Transmission

Once connected, the Wi‑Fi MAC handles frame delivery.

Example:

TCP Packet

becomes:

802.11 Data Frame

containing:

MAC Header Payload FCS

MAC Addressing

Each device has:

48-bit MAC Address

Example:

ESP32: 84:FC:E6:12:34:56 AP: 18:E8:29:AA:BB:CC

The MAC layer inserts source and destination addresses into every frame.


CSMA/CA

Wi‑Fi MAC must share the air with other devices.

Unlike Ethernet:

Can't detect collisions reliably

So Wi‑Fi uses:

CSMA/CA

Carrier Sense Multiple Access with Collision Avoidance.


Example:

Device A wants to send.

MAC first listens.

Channel Busy?

If yes:

Wait Random Backoff Retry

If no:

Transmit
Listen ↓ Busy? ↓ Wait ↓ Backoff ↓ Transmit

This logic is entirely MAC-level.


ACK and Retransmission

After every unicast frame:

Receiver sends ACK.
STA ---------- Data ----------> <------ ACK -----------

If no ACK arrives:

Retransmit `

The MAC maintains:

Retry Counter Sequence Number Duplicate Detection

This happens below TCP/IP.


Power Save

For battery devices, the MAC supports sleeping.

AP periodically indicates:

Buffered packets waiting.

through beacon information.

Station behavior:

Sleep Wake Check Beacon Retrieve Data Sleep Again

This is one reason Wi‑Fi IoT devices can save power.


Roaming

When signal quality drops:

RSSI ↓

the MAC scans for another AP.

Example:

AP1 -> AP2

The MAC performs:

Re-authentication Re-association Key Updates

while trying to keep connectivity.


Inside an ESP32-S31

Very roughly:

Application ↓ TCP/IP Stack ↓ Wi-Fi MAC ├─ Scanning ├─ Authentication ├─ Association ├─ Security ├─ ACK ├─ Retries ├─ Power Save └─ Roaming ↓ Wi-Fi Baseband ├─ OFDM ├─ Modulation ├─ Encoding └─ Synchronization ↓ RF ├─ 2.4 GHz LO ├─ PA ├─ LNA └─ Antenna

A useful rule of thumb

  • MACdecideswho can talk, when to talk, and who we're talking to.

  • Basebandconverts packets into Wi‑Fi symbols and vice versa.

  • RFconverts those symbols into actual 2.4 GHz radio waves.

So when you see logs like:

wifi: scan start wifi: authentication success wifi: association success wifi: connected

those events are primarily being driven by theWi‑Fi MAC layer, while the baseband and RF are the engines that physically move the bits through the air.

相关新闻

ROS2笔记1

ROS2笔记1

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

2026/10/21 2:25:53 阅读更多 →
26 精武杯手机部分复盘

26 精武杯手机部分复盘

【简要案情】 近期&#xff0c;某市反诈部门接到多名群众报案&#xff0c;均遭遇“投资理财”类电信网络诈骗&#xff0c;指向的犯罪团伙涉案资金巨大、作案链条隐蔽。办案单位迅速成立专案组开展电子数据取证工作。经初查&#xff0c;该犯罪团伙搭建虚假投资平台&#xff0c;通…

2026/10/21 2:25:53 阅读更多 →
PHP安全漏洞修复指南:防SQL注入与XSS

PHP安全漏洞修复指南:防SQL注入与XSS

一、为什么 PHP 项目总被盯上做 PHP 开发这些年&#xff0c;我见过太多项目上线后被黑的情况。说句实话&#xff0c;大部分漏洞并不是什么高深的技术&#xff0c;翻来覆去就是 SQL 注入和 XSS 这两类。很多新手写代码的时候图省事&#xff0c;直接把用户输入拼进 SQL 语句&…

2026/10/21 2:25:53 阅读更多 →

最新新闻

无人机航拍小目标检测数据集构建:从场景设计到智慧交通与应急救援落地

无人机航拍小目标检测数据集构建:从场景设计到智慧交通与应急救援落地

我做无人机视觉落地也有几年了&#xff0c;今年被问得最多的问题不是“模型怎么调”&#xff0c;而是“模型怎么到了现场就不灵”。很多朋友拿着公开的航拍检测模型&#xff0c;在桌面演示上mAP能到七八十个点&#xff0c;可一部署到国内的十字路口、老小区、城乡结合部&#x…

2026/10/21 3:07:07 阅读更多 →
Seay源代码审计系统实战:PHP漏洞扫描与规则扩展

Seay源代码审计系统实战:PHP漏洞扫描与规则扩展

简介&#xff1a;Seay源代码审计系统是一款基于C#开发的PHP代码安全审计工具&#xff0c;主要运行于Windows平台&#xff0c;面向网络安全初学者、CTF/AWD参赛选手及渗透测试人员&#xff0c;用于快速定位PHP项目中的安全隐患。它能够识别SQL注入、代码执行、命令执行、文件包含…

2026/10/21 3:07:07 阅读更多 →
Seay源代码审计系统实战:PHP静态代码审计与AWD快速排查指南

Seay源代码审计系统实战:PHP静态代码审计与AWD快速排查指南

简介&#xff1a;Seay源代码审计系统是一款基于C#开发的PHP代码安全审计工具&#xff0c;主要运行于Windows平台&#xff0c;面向网络安全初学者、CTF/AWD参赛选手及渗透测试人员&#xff0c;用于快速定位PHP项目中的安全隐患。它可检测SQL注入、代码执行、命令执行、文件包含、…

2026/10/21 3:07:07 阅读更多 →
程序员 AI 出图避坑:椒图 AI 与 Nano Banana Pro 实战指南

程序员 AI 出图避坑:椒图 AI 与 Nano Banana Pro 实战指南

如果你也是那种被拉去“顺带做个图”就浑身难受的程序员&#xff0c;这篇文章应该能帮你省下不少救心丸。我自己的本职是写后端&#xff0c;大部分时间对着终端和接口文档&#xff0c;但只要涉及方案评审、产品汇报、开源项目宣传&#xff0c;就逃不开一个尴尬任务&#xff1a;…

2026/10/21 3:07:07 阅读更多 →
从能生成到有质感:Seedance 2.0镜头语言全解析

从能生成到有质感:Seedance 2.0镜头语言全解析

先说一个我自己的真实感受&#xff1a;第一次用 Seedance 2.0 生成视频时&#xff0c;我很兴奋&#xff0c;因为画面真的“能动了”。但等我把五六段素材拼到一起&#xff0c;越看越不对劲——画面在动&#xff0c;情绪却没动&#xff1b;每个镜头单拎出来都不差&#xff0c;连…

2026/10/21 3:07:07 阅读更多 →
RAG效果差?问题多半出在知识库管理:清洗、分块与治理实战

RAG效果差?问题多半出在知识库管理:清洗、分块与治理实战

先说明一点&#xff1a;这个标题我深有同感。做了大半年RAG相关的东西&#xff0c;见过不少团队把精力全压在召回链路调参上&#xff0c;结果效果上不去&#xff0c;最后排查一圈&#xff0c;问题全出在知识库本身——脏数据、错分块、无版本、无评测&#xff0c;源头一乱&…

2026/10/21 3:06:07 阅读更多 →

日新闻

统一内存+量化:锐龙AI Max PRO 400如何本地跑320B大模型

统一内存+量化:锐龙AI Max PRO 400如何本地跑320B大模型

这段时间硬件圈和AI圈都在传一个事&#xff1a;AMD锐龙AI Max PRO 400系列把最高192GB统一内存搬进了PC形态的产品里&#xff0c;按宣传口径&#xff0c;本地跑320B参数的大家伙不再是纸面概念。我第一反应倒不是“内存真大”&#xff0c;而是这话背后的含金量——它把过去只能…

2026/10/21 0:00:11 阅读更多 →
AI助手深度使用体验:对话质量、长文本处理与指令遵循如何留住用户

AI助手深度使用体验:对话质量、长文本处理与指令遵循如何留住用户

1. 从“封号重开”这个行为说起&#xff1a;用户到底在追求什么“封号重开”这四个字&#xff0c;放在任何产品语境里都带着一股决绝的味道。一个账号从零开始积累使用记录、调教偏好、沉淀工作流&#xff0c;背后是大量的时间和精力成本。正常情况下&#xff0c;没有人愿意主动…

2026/10/21 0:00:11 阅读更多 →
ROS中YOLOv3工程落地:通信同步、坐标变换与性能调优

ROS中YOLOv3工程落地:通信同步、坐标变换与性能调优

1. 为什么在ROS里硬刚YOLOv3不是“炫技”&#xff0c;而是工程落地的必经之路我第一次在某高校机器人实验室看到那台搭载Jetson TX2的移动底盘原地打转、反复识别错垃圾桶时&#xff0c;就意识到&#xff1a;单纯跑通darknet_ros demo和真正让YOLOv3在ROS里“干活”&#xff0c…

2026/10/21 0:00:11 阅读更多 →

周新闻

基于GMM的语音识别系统原理与MATLAB实现详解

基于GMM的语音识别系统原理与MATLAB实现详解

说到基于高斯混合模型&#xff08;GMM&#xff09;的语音识别系统&#xff0c;很多人第一反应就是一堆数学公式&#xff0c;觉得门槛很高。但如果你真的在MATLAB里把它落地跑通&#xff0c;会发现核心其实就是三件事&#xff1a;把声音变成特征向量&#xff0c;用GMM给每个类别…

2026/10/20 10:02:13 阅读更多 →
数字图像处理入门:反白、灰度化、调色板修改与导出txt实践

数字图像处理入门:反白、灰度化、调色板修改与导出txt实践

数字图像处理这四个字听起来挺唬人&#xff0c;但落到具体操作上&#xff0c;无非就是让计算机按你的想法“摆弄”像素。我在一个模拟项目X里用了一套特别经典的基础处理流程&#xff1a;对图像做反白、改调色板、彩色转灰度&#xff0c;最后把像素数据导出成txt文件。单看每一…

2026/10/20 20:43:59 阅读更多 →
机器人大脑技术盘点:具身智能的感知、决策与数据闭环

机器人大脑技术盘点:具身智能的感知、决策与数据闭环

如果你的信息流最近也天天刷到“机器人大脑”这个词&#xff0c;你会发现一个很有意思的现象&#xff1a;每个人说的“大脑”根本不是同一个东西。有人指的是大语言模型&#xff0c;有人指的是运动控制系统&#xff0c;还有人指的是能理解物理世界的端到端模型。在2026年这个时…

2026/10/20 2:50:50 阅读更多 →

月新闻

我发现了一个新思路:用 Remotion + Claude Code 像写代码一样自动化生成短视频

我发现了一个新思路:用 Remotion + Claude Code 像写代码一样自动化生成短视频

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

2026/10/20 10:02:08 阅读更多 →
Windows下 Codex 中 Chrome 和 Computer Use 插件不可用问题排查及解决参考方式:TaoToken 统一 Key 配置与验证

Windows下 Codex 中 Chrome 和 Computer Use 插件不可用问题排查及解决参考方式:TaoToken 统一 Key 配置与验证

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

2026/10/20 9:50:17 阅读更多 →
黑夜航拍船只数据集训练YOLOV5模型全流程解析

黑夜航拍船只数据集训练YOLOV5模型全流程解析

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

2026/10/20 9:50:45 阅读更多 →