Net802.11

This page documents bits of the net80211 framework used in FreeBSD. It’s intended for Kernel developers to help them understand how to use/update/write a driver that makes use of the framework. It was developed whilst I learnt about net80211 whilst writing the wpi driver.

The Concept / Background

When wireless networking was first being adopted by the various open source operating systems things were a little adhoc. Each wireless driver needed to implement code to handle many of the same things, such as station scanning, rate control and all things wireless to support 802.11 networking.

Over time it became apparent that much of functionality that was being implemented in each and every driver was being duplicated. Hence the birth of net80211.

net80211 is a subsystem that implements a state machine to deal with the various states of a wireless connection as well as a set of api’s to assist drivers to every aspect of wireless network communications.

Some of the features the subsystem provides are:

  • Wireless Connection State Control
  • Wireless Node Management
  • Hooks for drivers to override default net80211 functionality
  • Background scanning support
  • Automatic rate control
  • Plugable authentication (wep, wpa)
  • Host Access Point support

In the future, multiple ssid support for host access points is planned.

Wireless Connection State Diagram

At the center of net80211 is the Wireless Connection State Diagram.

FIXME: PUT DIAGRAM

This diagram indicates the main states that the net80211 state machine can be in. Each one of these states relates to a particular action that net80211 expects the driver to be doing. Internally net80211 uses these states to manage the subsystem.

The states can be summarized as following:

  • INIT
    No wireless connection exists, No Scanning is in progress
    SCAN
    A Scan for nearby stations is in progress
    ASSOC
    A 802.11 connection is being established to a nearby station
    AUTH
    Connection credentials are being established with a nearby station
    RUN
    A valid connection to a nearby station exists and network traffic should pass normally

Interfacing to net80211

A driver interfaces to net80211 via function pointers.

TODO:

Scanning

  • BG Scanning
  • FG Scanning

State Transitions

  • newstate

Writing a driver

TODO:

  • attach
    • set capabilities (ic->ic_caps)
    • override default states (ic->ic_newstate, ic->scan_start, etc)
    • media_init (ieee80211_media_init)
    • rate control init (ieee80211_amrr_init)
    • bpfattach2 for radio frames
    • setup channels (ic->ic_nchans, ic->channels, A,B,G,etc)
    • announce support ( iee80211_announce)
  • newstate
    • Handle state transitions based on hardware
    • fallthrough to orig_newstate
    • Don’t hold sleep locks!
  • ioctl
    • Nothing special for net80211
  • scan_start
  • scan_end
  • set_channel
  • scan_curchan
  • scan_mindwell
    • Tell hardware to perform relevant action
    • Can’t sleep mutex

Locking

TODO

Finding Information

The net80211 subsystem lives in src/sys/net80211 of the FreeBSD source tree[1].

Within this directory there are a number of critically important files that if your writing a wireless driver, will become invaluable for understanding what is happening.

  • ieee80211.h
    The 802.11 protocol definitions
    ieee80211.c
    functions available to drivers (look here or apis).
    ieee80211_input.c
    The code path for any frame into the system
    ieee80211_regdomain.c
    Presets for valid regulatory information, used if the driver does not provide it’s own channel setup
    ieee80211_proto.h
    The Defined Connection States & other 802.11 protocol implementation definitinos
    ieee80211_crypto_*: Various encryption implementations
    .. Many others

Acronyms

AMSDU; (11n): Multiple 802.3 frames in an 802.11 frame
AMDPU; (11n): A low-level TCP-like mechanism whereby you can pipeline up to 64K of data in a sliding window and ACK multiple frames at once.
CCK ; Complementary code keying Modulation Technique used by 802.11b
DYN ;
IBSS ;
HOSTAP; Host access point
HT  ;
OFDM ; orthogonal frequency-division multiplexing Modulation technique used by 802.11g
STA ; Station Mode
TSF ;
WME ; Wireless Multimedia Extensions (11e)

Standards

802.11a ; 5Ghz, OFDM, 6Mb - 54Mb
802.11b ; 2.4 Ghz, CCK, 1Mb - 11Mb
802.11e ; QOS, WME
802.11g ; 2.4 Ghz, CCK+OFDM, 11b + 11a xmit rates
802.11h ; Spectrum Transmit Power Extension
802.11i ; WPA2/RSN
802.11n ; 2.4/5Ghz, 802.11g coexist, CCK+OFDM, MMIO 802.11e, beacon forming, block acks
802.11s ; Mesh Networks
802.1x ; Authentication

References

  1. http://cvsweb.freebsd.org/src/sys/net80211

External Links