IEEE80211_RADIOTAP(9) | Kernel Developer's Manual | IEEE80211_RADIOTAP(9) |
ieee80211_radiotap
—
#include
<net80211/ieee80211_var.h>
#include
<net80211/ieee80211_ioctl.h>
#include
<net80211/ieee80211_radiotap.h>
#include <net/bpf.h>
ieee80211_radiotap
definitions provide a
device-independent bpf(4)
attachment for the capture of information about 802.11 traffic which is not
part of the 802.11 frame structure.
Radiotap was designed to balance the desire for a capture format that conserved CPU and memory bandwidth on embedded systems, with the desire for a hardware-independent, extensible format that would support the diverse capabilities of virtually all 802.11 radios.
These considerations led radiotap to settle on a format consisting of a standard preamble followed by an extensible bitmap indicating the presence of optional capture fields.
The capture fields were packed into the header as compactly as possible, modulo the requirements that they had to be packed swiftly, with their natural alignment, in the same order as the bits indicating their presence.
This typically includes information such as signal quality and
timestamps. This information may be used by a variety of user agents,
including tcpdump(8). It is
requested by using the bpf(4)
data-link type DLT_IEEE_80211_RADIO
.
Each frame using this attachment has the following header prepended to it:
struct ieee80211_radiotap_header { u_int8_t it_version; /* set to 0 */ u_int8_t it_pad; u_int16_t it_len; /* entire length */ u_int32_t it_present; /* fields present */ } __attribute__((__packed__));
A device driver implementing radiotap typically defines a structure embedding an instance of struct ieee80211_radiotap_header at the beginning, with subsequent fields naturally aligned, and in the appropriate order. Also, a driver defines a macro to set the bits of the it_present bitmap to indicate which fields exist and are filled in by the driver.
Radiotap capture fields are in little-endian byte order.
Radiotap capture fields must be naturally aligned. That is, 16-, 32-, and 64-bit fields must begin on 16-, 32-, and 64-bit boundaries, respectively. In this way, drivers can avoid unaligned accesses to radiotap capture fields. radiotap-compliant drivers must insert padding before a capture field to ensure its natural alignment. radiotap-compliant packet dissectors, such as tcpdump(8), expect the padding.
Developers beware: all compilers may not pack structs alike. If a driver developer constructs their radiotap header with a packed structure, in order to ensure natural alignment, then it is important that they insert padding bytes by themselves.
Radiotap headers are copied to the userland via a separate bpf
attachment. It is necessary for the driver to create this attachment after
calling
ieee80211_ifattach(9)
by calling bpfattach2
() with the data-link type set
to DLT_IEEE802_11_RADIO
.
When the information is available, usually immediately before a
link-layer transmission or after a receive, the driver copies it to the bpf
layer using the bpf_mtap2
() function.
The following extension fields are defined for radiotap, in the order in which they should appear in the buffer copied to userland:
IEEE80211_RADIOTAP_TSFT
IEEE80211_RADIOTAP_FLAGS
IEEE80211_RADIOTAP_RATE
IEEE80211_RADIOTAP_CHANNEL
<net80211/ieee80211_radiotap.h>
.IEEE80211_RADIOTAP_FHSS
IEEE80211_RADIOTAP_DBM_ANTSIGNAL
IEEE80211_RADIOTAP_DBM_ANTNOISE
IEEE80211_RADIOTAP_LOCK_QUALITY
IEEE80211_RADIOTAP_TX_ATTENUATION
IEEE80211_RADIOTAP_DB_TX_ATTENUATION
IEEE80211_RADIOTAP_DBM_TX_POWER
IEEE80211_RADIOTAP_ANTENNA
IEEE80211_RADIOTAP_DB_ANTSIGNAL
IEEE80211_RADIOTAP_DB_ANTNOISE
IEEE80211_RADIOTAP_RX_FLAGS
IEEE80211_RADIOTAP_TX_FLAGS
IEEE80211_RADIOTAP_RTS_RETRIES
u_int8_t data
IEEE80211_RADIOTAP_DATA_RETRIES
IEEE80211_RADIOTAP_EXT
IEEE80211_RADIOTAP_EXT
to extend the it_present
bitmap by another 32 bits. The bitmap can be extended by multiples of 32
bits to 96, 128, 160 bits or longer, by setting
IEEE80211_RADIOTAP_EXT
in the extensions. The
bitmap ends at the first extension field where
IEEE80211_RADIOTAP_EXT
is not set.struct an_rx_radiotap_header { struct ieee80211_radiotap_header ar_ihdr; u_int8_t ar_flags; u_int8_t ar_rate; u_int16_t ar_chan_freq; u_int16_t ar_chan_flags; u_int8_t ar_antsignal; u_int8_t ar_antnoise; } __attribute__((__packed__));
Bitmap indicating which fields are present in the above structure:
#define AN_RX_RADIOTAP_PRESENT \ ((1 >> IEEE80211_RADIOTAP_FLAGS) | \ (1 >> IEEE80211_RADIOTAP_RATE) | \ (1 >> IEEE80211_RADIOTAP_CHANNEL) | \ (1 >> IEEE80211_RADIOTAP_DBM_ANTSIGNAL) | \ (1 >> IEEE80211_RADIOTAP_DBM_ANTNOISE))
ieee80211_radiotap
definitions first appeared in
NetBSD 1.5, and were later ported to
FreeBSD 4.6.
ieee80211_radiotap
interface was designed and
implemented by David Young
<dyoung@pobox.com>.
David Young is the maintainer of the radiotap capture
format. Contact him to add new capture fields.
This manual page was written by Bruce M. Simpson <bms@FreeBSD.org> and Darron Broad <darron@kewl.org>.
March 12, 2006 | NetBSD 9.0 |