Skip to content
Tutorials Center
My learning

Topics

Lesson 59 of 79 ยท Wireless and Mobile Networks

Wi-Fi and 802.11

Learn how Wi-Fi works: SSIDs and BSSs, 2.4 and 5 GHz channels, CSMA/CA with RTS/CTS, association, frame types, roaming, and what Wi-Fi 6 and 7 changed.

Wi-Fi is the name for the IEEE 802.11 family of standards, and it is how most people reach the Internet today. It looks like Ethernet without the cable, but the radio medium forces very different rules: signals fade, neighbors interfere, and a station cannot listen while it transmits. Understanding those differences explains most Wi-Fi behavior, from slow speeds in a crowded apartment block to why your phone clings to a distant access point.

This lesson covers the building blocks (SSID, BSS, access points), how channels and bands work, how stations share the air with CSMA/CA, how a device joins a network and roams, and what the newest generations changed. It builds on medium access control and on the radio basics in signals and media.

Building blocks: stations, access points and BSS

A device with a Wi-Fi radio is a station (STA). Most home and office networks run in infrastructure mode: stations do not talk to each other directly but through an access point (AP), which also bridges the wireless network to a wired one.

  • A BSS (Basic Service Set) is one access point plus the stations associated with it. The AP's MAC address, called the BSSID, identifies the BSS.
  • An SSID is the human-readable network name, such as "HomeNet". Many APs can share one SSID. Several SSIDs can also be served by one AP, each with its own BSSID, for example "Staff" and "Guest".
  • An ESS (Extended Service Set) is a group of BSSs that share an SSID and are connected by a wired distribution system. This is what makes a whole campus look like one network, and it is what allows roaming.
flowchart TB
    SW["Wired switch / router"]
    AP1["AP 1<br/>BSSID aa:01"]
    AP2["AP 2<br/>BSSID aa:02"]
    SW --- AP1
    SW --- AP2
    L["Laptop"] -.-> AP1
    P["Phone"] -.-> AP1
    T["Tablet"] -.-> AP2

Two BSSs with the same SSID form one ESS. The dotted lines are radio links.

The other mode is ad hoc (IBSS), where stations talk to each other directly with no AP. It is rare today. Wi-Fi Direct and Bluetooth fill that role.

Bands and channels

Wi-Fi shares unlicensed radio spectrum. Anyone may transmit there, within power limits, which is why it is cheap and also why it gets crowded.

Band Typical channel width Notes
2.4 GHz 20 MHz (sometimes 40) Long range, good through walls, only three non-overlapping channels, shared with Bluetooth, microwave ovens and baby monitors.
5 GHz 20, 40, 80, 160 MHz Many more channels, shorter range, some channels require radar detection (DFS).
6 GHz 20 to 320 MHz Added by Wi-Fi 6E and 7. Lots of clean spectrum, only newer devices can use it.

On 2.4 GHz, channel numbers are spaced only 5 MHz apart, but each transmission is about 20 MHz wide. So channels 1 and 2 overlap almost completely, while channels 1, 6 and 11 are 25 MHz apart and do not overlap. That is why networks nearly always sit on one of those three. Putting your AP on channel 3 "to avoid the crowd" is worse than joining it: you collide with both channel 1 and channel 6 neighbors, and the radio cannot even decode their frames as normal traffic, it just hears noise.

On 5 GHz, channels are numbered in 5 MHz steps from 5,000 MHz too, but channels are defined at 20 MHz spacing (36, 40, 44, 48, ...), so neighbors do not overlap at 20 MHz width. Wider channels carry more data but use up more of the band, so fewer APs fit without interfering.

Python 2.4 GHz channel overlap calculator

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Sharing the air: CSMA/CA

On a wired Ethernet segment, a station can detect a collision while sending and abort (CSMA/CD). Radios cannot do that: the station's own transmission is billions of times stronger than anything it could hear arriving, so it is effectively deaf while sending. Wi-Fi therefore uses CSMA/CA, collision avoidance, together with acknowledgments.

The rules of the basic DCF (Distributed Coordination Function) are:

  1. Listen first. If the medium has been idle for a short gap (DIFS), the station may send.
  2. If it is busy, wait until it becomes idle, then wait a random backoff: pick a number of time slots from a contention window and count down only while the medium stays idle. Randomness makes it unlikely that two waiting stations start at the same slot.
  3. Send the frame. The receiver, after a very short gap (SIFS), replies with an ACK. Because the SIFS is shorter than the DIFS, the ACK always wins the medium.
  4. No ACK means a collision or loss. The sender doubles its contention window (binary exponential backoff) and tries again.

This is why Wi-Fi throughput is always well below the "link rate" printed on the box. Every frame pays for waiting, backoff, headers and an ACK, and one slow device occupies the air for longer per byte than a fast one, dragging everyone down.

The hidden terminal problem

Two stations may both be in range of the AP but not of each other. Neither hears the other, both see an idle medium, and both transmit: the AP receives a collision. This is the hidden terminal problem. The optional RTS/CTS handshake reduces it:

sequenceDiagram
    participant A as Station A
    participant AP as Access point
    participant B as Station B (hidden from A)
    A->>AP: RTS (reserve the air for N microseconds)
    AP->>A: CTS (heard by A and B)
    Note over B: B hears the CTS and stays quiet
    A->>AP: Data frame
    AP->>A: ACK

The CTS is broadcast, so even a station that cannot hear A learns that the medium is reserved.

Every frame carries a duration field, and stations that overhear it set a NAV (Network Allocation Vector), a virtual "medium busy" timer. RTS/CTS costs extra airtime, so it is normally used only for frames above a size threshold or on networks with known hidden nodes.

Joining a network: scan, authenticate, associate

A station goes through these steps to join a BSS:

  1. Scanning. The AP sends beacon frames, roughly ten per second, announcing the SSID, supported rates, channel and security capabilities. A station can listen passively or send a probe request and wait for a probe response (active scanning).
  2. Authentication. In modern networks the old 802.11 "open authentication" step is just a formality. The real security handshake happens next.
  3. Association. The station sends an association request and the AP answers with an association ID. The station is now part of the BSS.
  4. Security handshake. With WPA2 or WPA3, a 4-way handshake proves both sides know the key and derives fresh per-session encryption keys. WPA3 replaces the pre-shared-key exchange with SAE, which resists offline password guessing.
  5. Getting an IP address. Only now does the device send a DHCP request over the new link.

Frame types

802.11 frames come in three families:

  • Management frames set up and tear down the relationship: beacon, probe request/response, authentication, association, reassociation, disassociation, deauthentication.
  • Control frames help deliver data: RTS, CTS, ACK.
  • Data frames carry the payload, which is the same IP packet you would see on Ethernet.

An 802.11 data frame has up to four address fields, not two. In a typical station-to-AP frame these are the receiver (the AP's BSSID), the transmitter (the station), and the final destination, so the AP knows where to forward it on the wired side. This is also why you cannot simply treat captured Wi-Fi frames as Ethernet frames.

Management frames were historically unauthenticated, so anyone could forge a deauthentication frame and knock a device off the network. WPA3 and 802.11w "protected management frames" close that hole. We return to attacks like this in common attacks and defenses.

Roaming

When you walk through a building, your device moves from one AP's coverage to another's while staying in the same ESS. Because both APs share the SSID and sit on the same wired network, the device can keep its IP address. The process:

  1. The client notices the signal (RSSI) from its current AP dropping below a threshold.
  2. It scans for other APs with the same SSID.
  3. It sends a reassociation request to the better AP, which tells the old AP over the wired side that the client has moved.

The decision is made by the client, not the network, and many devices are "sticky": they hold on to a weak AP long after a stronger one is available. Standards help the network nudge clients: 802.11k gives a client a list of neighbor APs, 802.11v lets the AP suggest a move, and 802.11r (fast transition) shortens the security handshake so a voice call does not drop during the switch.

Python Roaming with a signal threshold and hysteresis

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Wi-Fi generations

Since 2018 the Wi-Fi Alliance uses simple numbers for the generations:

Name Standard Bands Key ideas
Wi-Fi 4 802.11n 2.4 and 5 GHz MIMO (several antennas), 40 MHz channels, frame aggregation
Wi-Fi 5 802.11ac 5 GHz 80 and 160 MHz channels, 256-QAM, downlink MU-MIMO
Wi-Fi 6 / 6E 802.11ax 2.4, 5 (and 6 GHz) OFDMA, 1024-QAM, uplink MU-MIMO, BSS coloring, target wake time
Wi-Fi 7 802.11be 2.4, 5, 6 GHz 320 MHz channels, 4096-QAM, multi-link operation

The theme of recent generations is efficiency in crowded places, not just peak speed. OFDMA (from Wi-Fi 6) splits a channel into small resource units so one transmission can serve several stations at once, which suits many small packets such as chat and sensor traffic. BSS coloring tags frames with a color so a station can tell "this is a neighbor's network, I may transmit anyway" instead of always deferring. Target wake time lets battery devices sleep until a scheduled moment. Multi-link operation in Wi-Fi 7 lets a device use several bands at once, for lower latency and better reliability.

Headline rates (several gigabits per second) assume wide channels, many antennas and a short distance. Real throughput depends on distance, walls, interference and how many devices share the air.

Older standards, router bands and WLAN trade-offs

The numbered generations began with Wi-Fi 4. Before that, the standards had letter names, and you still meet them in old equipment and exams:

Standard Year Band Maximum rate Note
802.11 1997 2.4 GHz 2 Mbit/s The original
802.11b 1999 2.4 GHz 11 Mbit/s Long range, crowded band
802.11a 1999 5 GHz 54 Mbit/s First OFDM standard, shorter range
802.11g 2003 2.4 GHz 54 Mbit/s OFDM on 2.4 GHz, compatible with b

Routers are sold by how many bands they can use at the same time. A single-band router uses only 2.4 GHz: long range and good wall penetration, but crowded and slow. A dual-band router adds 5 GHz, which is faster and less crowded but covers a shorter distance, so devices that are close pick 5 GHz and distant ones keep 2.4 GHz. A tri-band router has a second 5 GHz radio (or a 6 GHz one), which gives more capacity for many devices and for the link between mesh nodes.

Types and security of a WLAN

A WLAN can be an infrastructure network (stations talk through an access point) or an ad hoc network (stations talk directly). A large site adds controllers and many access points in one ESS. For protection, WEP is broken and must never be used. WPA2/WPA3-Personal (often called WPA-PSK, pre-shared key) uses one passphrase for everyone, which suits homes and small shops; the weakness is that anybody who knows the passphrase can join, and WPA2-PSK can be attacked offline if the passphrase is weak. WPA2/WPA3-Enterprise uses 802.1X with a RADIUS server, so every user has their own credentials that can be revoked one by one.

Why choose a WLAN? It is easy to install and expand (no cable to pull), cheaper than wiring a whole building, and gives mobility, which is why it dominates homes, offices, schools and campuses, hospitals, cafes and airports. The limits are real: performance varies with distance, walls and interference, speeds are shared by everyone on the channel, signals can be intercepted and so must be encrypted, and latency is less predictable than on a cable.

MAC filtering and port security

MAC filtering lets an access point (or a router) admit only devices whose MAC address is on an allow list, or reject those on a block list. Admins like it because it is easy to understand: "only these laptops may join".

It does little for security. A MAC address is not a secret. It travels unencrypted in every 802.11 frame header, so anyone listening on the air can see which addresses are allowed, and copying one onto another device (MAC spoofing) takes one command. The list also does not encrypt anything, so it is no substitute for WPA2 or WPA3 (see security fundamentals). It is also a maintenance burden, and modern phones and laptops use randomized (private) MAC addresses per network, which breaks allow lists unless you turn the feature off for that network. The one reasonable use is as an extra convenience filter (keep the neighbor's smart TV off your guest network), never as the lock on the door.

Port security on switches

The wired counterpart is port security, a feature of managed switches (the name is Cisco's, but similar features exist elsewhere). Instead of trusting a list of Wi-Fi clients, it controls which MAC addresses may appear on each switch port:

  • A maximum number of MAC addresses per port, often 1 for a desktop and 2 for a desktop behind a phone.
  • Static addresses typed by the admin, dynamic ones learned (and forgotten at reboot), or sticky ones learned once and saved in the configuration.
  • A violation mode when an unauthorized address shows up: protect silently drops its frames, restrict drops and logs, and shutdown puts the port in an err-disabled state until an admin re-enables it.

This stops a user from plugging a small switch or hub into a wall socket to hide several devices, and it limits MAC flooding attacks that fill the switch's address table with bogus entries to force it to broadcast like a hub. Like Wi-Fi filtering, it can be defeated by spoofing a MAC address that is legitimately allowed on that port, so serious networks use IEEE 802.1X, which makes the device (or user) authenticate with credentials or a certificate before the port forwards anything.

Run the simulation of a port with a maximum of one MAC address in two violation modes.

Python Switch port security in miniature

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The second port shows the harsh behavior of shutdown mode: after one violation even the legitimate device loses its connection, until an admin recovers the port. The last two lines are the reason MAC filtering is not authentication: the attacker only has to repeat what was seen.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. Why does Wi-Fi use collision avoidance (CSMA/CA) instead of collision detection?

    A transmitting station drowns out everything it could hear, so it cannot detect a collision. Wi-Fi avoids collisions with random backoff and relies on ACKs to learn when a frame was lost.
  2. 2. Which set of 2.4 GHz channels does not overlap?

    Each transmission is about 20 MHz wide, but channel numbers are only 5 MHz apart. Channels 1, 6 and 11 are 25 MHz apart, so they do not overlap.
  3. 3. What problem does the RTS/CTS handshake mainly address?

    This is the hidden terminal problem. The CTS from the access point is heard by stations that cannot hear the sender, and they set their NAV and stay quiet.
  4. 4. Who normally decides when a Wi-Fi device roams to another access point?

    Roaming is client-driven. 802.11k and 802.11v let the network give hints, but the device chooses when to send a reassociation request.
  5. 5. What is the main idea of OFDMA in Wi-Fi 6?

    OFDMA divides a channel into smaller units that can be assigned to different stations in the same transmission, which makes many small packets much more efficient.

Summary

  • Wi-Fi (802.11) connects stations to an access point; an AP and its stations form a BSS, and BSSs with the same SSID joined by a wired network form an ESS.
  • On 2.4 GHz only channels 1, 6 and 11 are free of overlap; 5 and 6 GHz offer many more, wider channels at shorter range.
  • CSMA/CA uses carrier sensing, random backoff and ACKs; RTS/CTS and the NAV counter the hidden terminal problem.
  • A device scans (beacons, probes), associates, completes the WPA2/WPA3 handshake and then asks for an IP address by DHCP.
  • Roaming is decided by the client; 802.11k, v and r help. Wi-Fi 6 and 7 improve efficiency with OFDMA, BSS coloring and multi-link operation.
  • MAC filtering is a weak access control, because MAC addresses are visible and easily copied; switch port security (limit and learn MAC addresses per port) stops flooding and rogue devices on wired ports, and 802.1X or WPA3 give real authentication.

Next, leave the building and look at wide-area wireless: cellular networks.