SkillPilotAI

iw (2/2)

The advanced half of iw: tuning the radio (TX power, bitrates, RTS, retry, per-TID settings, power save), inspecting stations and channels, running AP/IBSS/OCB and 802.11s mesh, the regulatory domain, Wake-on-WLAN, coalesce, FTM and the niche NAN/P2P/hwsim/vendor commands.

179.1 Where it runs and today's lab

  • Linux only (talks nl80211 to the kernel Wi-Fi stack); not on Windows or macOS.
  • The lab VM has no Wi-Fi radio (cfg80211 not loaded), so only iw --version and iw help were run (they exit before nl80211, per iw.c).
  • Device output comes from wireless.docs.kernel.org and the open80211s HOWTO.

179.2 Stations

An AP and its stations
  1. 1.Linux AP (wlan0 in AP mode); laptop, phone and smart TV connect: each is a station

  2. 2.Laptop sends data; AP keeps signal, bitrate and counters per station

  3. 3.station dump: Laptop -48 dBm 300 Mbit/s, Phone -61 dBm 144, TV -70 dBm 54

  4. 4.set txpower fixed 1500 limits the AP to 15 dBm

Terminal
iw dev wlan1 station dumpsudo iw dev wlan1 station get \  <peer-MAC-address>
Output
Station 12:34:56:78:9a:bc (on wlan0)        inactive time:  304 ms        rx bytes:       18816        rx packets:     75        tx bytes:       5386        tx packets:     21        signal:         -29 dBm        tx bitrate:     54.0 MBit/s
  • inactive time = how long the station has been quiet; rx/tx bytes = traffic counters; tx bitrate = speed of the last frame.
  • station del MAC [subtype 0xA|0xC reason-code N] kicks a station with disassoc/deauth; station set changes txpwr, airtime_weight, vlan, mesh plink_action.

179.3 Transmit power, rates, RTS, retry

Terminal
iw help set txpoweriw help set rtsiw help set retry
Output
dev <devname> set txpower <auto|fixed|limit>    [<tx power in mBm>]  Specify transmit power level and setting type.phy <phyname> set rts <rts threshold|off>  Set rts threshold.phy <phyname> set retry [short <limit>]    [long <limit>]  Set retry limit.
SettingMeaning
set txpower auto|fixed|limit NPower in mBm (= dBm x 100): fixed 1500 = 15 dBm
set rts N|offFrames bigger than N first reserve the channel with RTS/CTS
set retry short/longRetry limits
set bitrates legacy-2.4 6 12 24Rate mask; this blocks old 802.11b clients; no args clears it
ht-mcs / vht-mcs-5 / he-mcs-*, sgi/lgi, he-giHT/VHT/HE (Wi-Fi 6) rates and guard intervals
set distance M / set coverageACK timeout for long outdoor links
set antenna / set frag / set mcast_rateTX/RX antennas, fragmentation, multicast rate

179.4 Per-TID configuration, power save, TXQ

Terminal
iw dev wlan0 set tidconf tids 0x1 ampdu offiw dev wlan0 set tidconf tids 0x5 \    ampdu off amsdu off rtscts oniw dev wlan0 set tidconf peer xx:xx:xx:xx:xx:xx \    tids 0x2 bitrates limit vht-mcs-5 4:9
  • TID = traffic ID (classes like voice, video); tids is a bitmask; without peer the rule applies to all peers.
  • Controls per class: ampdu/amsdu aggregation, sretry/lretry, rtscts, noack, bitrates limit.
  • set power_save on|off / get power_save: on mac80211 enables dynamic power save (saves battery, can add latency).
  • set txq limit / memory_limit / quantum: global phy queue limits and DRR scheduler quantum.

179.5 Survey and events

CommandUse
survey dump [--radio]Noise and busy time per channel (hostapd uses it to pick the emptiest channel)
event [-t|-T|-r] [-f]Live kernel wireless events; -f prints full auth/assoc frames
mgmt dump frame 40 00 count 10Print management frames matching a pattern

179.6 Access point, IBSS and OCB

Terminal
iw dev wlan0 ap start <SSID> <control freq> ... \  <beacon interval> <DTIM period> head <hex>iw dev wlan0 ibss join <SSID> <freq in MHz>iw dev wlan0 ocb join <freq in MHz> 5MHz|10MHz
ModeWhat it isNotes
ap start / ap stopBasic APNeeds beacon head in hex, so real APs use hostapd; hidden-ssid, inactivity-time
ibss join / leaveAd-hoc cell without an APCreates the cell if missing; fixed-freq, fixed BSSID, basic-rates
ocb join / leave802.11p, cars talk without a BSS5 / 10 MHz

179.7 Mesh (802.11s)

Mesh: forwarded AP to AP
  1. 1.Three mesh APs share one mesh ID; each reaches only its neighbour

  2. 2.Laptop sends a packet to Mesh AP 1

  3. 3.Mesh AP 1 forwards to Mesh AP 2

  4. 4.Mesh AP 2 forwards to Mesh AP 3, which delivers to the phone

  5. 5.HWMP finds the route itself; mpath dump shows next hop = Mesh AP 2

Terminal
iw dev $MESH_IFACE mesh join $MESH_IDiw dev $MESH_IFACE station dumpiw dev $MESH_IFACE mpath dump
Output
Station 00:15:6d:84:14:10 (on mesh)    signal:     -61 dBm    tx bitrate: 1.0 MBit/s    mesh plink: ESTAB...00:15:6d:84:14:10 00:15:6d:84:14:10 mesh    0  228   0  2196731904  0    0  0x1000:15:6d:84:14:0e 00:15:6d:84:14:10 mesh    2  456   0  2196731904  360  0  0x4
  • mesh plink: ESTAB = peer link established.
  • mpath dump: column 1 = destination, column 2 = next hop; when they differ (line 2) the packet goes through a middle node.
  • get/set mesh_param (forwarding, HWMP root mode); mpath new/set = static next hop; mpp dump = proxy paths for devices outside the mesh.

179.8 Regulatory domain

Terminal
iw reg getiw phy phy0 reg getsudo iw reg set INsudo iw reg reload
Output
# wireless-regdb db.txt (docs)country IN:  (2402 - 2482 @ 40), (30)  (5150 - 5250 @ 80), (30)  (5250 - 5350 @ 80), (24), DFS  (5470 - 5725 @ 160), (24), DFS  (5725 - 5875 @ 80), (30)  (5925 - 6425 @ 320), (24), NO-OUTDOOR# Channel 14. Only JP enables this#   and for 802.11b only
  • Each country decides allowed channels and max power; the kernel calls it the regulatory domain.
  • With country IN, an AP on channel 6 works but channel 14 (Japan only) stays blocked.
  • reg get = kernel domain, phy reg get = card's own, reg set = tell the kernel the country, reg reload = reload the database.

179.9 Wake-on-WLAN, coalesce, FTM

Wake-on-WLAN with a magic packet
  1. 1.Laptop suspends; Wi-Fi card stays associated at very low power

  2. 2.Card waits only for trigger frames; normal frames are dropped

  3. 3.Phone 192.168.1.11 sends a magic packet via AP 192.168.1.1

  4. 4.Card recognises it and wakes the whole system

Terminal
iw phy phy0 wowlan showsudo iw phy phy0 wowlan enable magic-packetsudo iw phy phy0 wowlan disable
  • wowlan enable triggers: any, disconnect, magic-packet, gtk-rekey-failure, eap-identity-request, 4way-handshake, rfkill-release, net-detect (matching SSID appears), patterns ('-' = any byte), tcp (from a config file).
  • Coalesce buffers broadcast/multicast briefly and interrupts the CPU once (saves power): coalesce enable file / show / disable; docs example shows a 25 msec rule on match.
  • FTM (fine timing measurement) measures distance from signal travel time, for indoor location: ftm start_responder (on a running AP, lci/civic), ftm get_stats, measurement ftm_request config-file.

179.10 NAN, P2P, hwsim, vendor

CommandPurpose
nan start / config / add_func publish|subscribe / stopNeighbor Awareness Networking: discover nearby services without an AP
p2p start / stopWi-Fi Direct P2P device
hwsim getps / setps / stopqueuesOnly for the mac80211_hwsim simulator (not loaded in the lab)
vendor send / recv / recvbinDriver-specific commands

179.11 Common mistakes

  • Maxing txpower: your signal gets stronger but the AP's reply stays weak and neighbours get more interference.
  • Turning power save off everywhere: lower latency but the battery drains faster.
  • Confusing mBm with dBm: fixed 20 is 0.2 dBm, not 20 dBm.
  • Expecting iw ap start to replace hostapd for a real WPA2 AP.

179.12 Interview tips

  • iw vs hostapd / wpa_supplicant: iw sets low-level radio settings (type, channel, power, mesh, reg) via nl80211; WPA auth and the handshake need hostapd (AP) or wpa_supplicant/NetworkManager (client).
  • set txpower fixed 2000 = 20 dBm, within IN's 30 dBm limit; values above the limit are never used.
  • Mesh routing: HWMP; inspect with mpath dump (destination vs next hop).
  • survey dump = channel busy time, station dump = per-client counters.