1.\" $NetBSD: ieee80211_radiotap.9,v 1.8 2005/12/13 16:15:10 explorer Exp $ 2.\" 3.\" Copyright (c) 2004 Bruce M. Simpson <bms@spc.org>, 4.\" Darron Broad <darron@kewl.org>, 5.\" David Young <dyoung@pobox.com>. 6.\" All rights reserved. 7.\" 8.\" Redistribution and use in source and binary forms, with or without 9.\" modification, are permitted provided that the following conditions 10.\" are met: 11.\" 1. Redistributions of source code must retain the above copyright 12.\" notice, this list of conditions and the following disclaimer. 13.\" 2. Redistributions in binary form must reproduce the above copyright 14.\" notice, this list of conditions and the following disclaimer in the 15.\" documentation and/or other materials provided with the distribution. 16.\" 17.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27.\" SUCH DAMAGE. 28.\" 29.\" $FreeBSD: src/share/man/man9/ieee80211_radiotap.9,v 1.3 2004/07/07 12:59:39 ru Exp $ 30.\" 31.Dd July 11, 2005 32.Dt IEEE80211_RADIOTAP 9 33.Os 34.Sh NAME 35.Nm ieee80211_radiotap 36.Nd software 802.11 stack packet capture definitions 37.Sh SYNOPSIS 38.In net80211/ieee80211_var.h 39.In net80211/ieee80211_ioctl.h 40.In net80211/ieee80211_radiotap.h 41.In net/bpf.h 42.\" 43.Sh DESCRIPTION 44The 45.Nm 46definitions provide a device-independent 47.Xr bpf 4 48attachment for the 49capture of information about 802.11 traffic which is not part of 50the 802.11 frame structure. 51.Pp 52Radiotap was designed to balance the desire for a capture format 53that conserved CPU and memory bandwidth on embedded systems, 54with the desire for a hardware-independent, extensible format 55that would support the diverse capabilities of virtually all 56802.11 radios. 57.Pp 58These considerations led radiotap to settle on a format consisting of 59a standard preamble followed by an extensible bitmap indicating the 60presence of optional capture fields. 61.Pp 62The capture fields were packed into the header as compactly as possible, 63modulo the requirements that they had to be packed swiftly, 64with their natural alignment, 65in the same order as the bits indicating their presence. 66.Pp 67This typically includes information such as signal quality and 68timestamps. 69This information may be used by a variety of user agents, including 70.Xr tcpdump 8 . 71It is requested by using the 72.Xr bpf 4 73data-link type 74.Dv DLT_IEEE_80211_RADIO . 75.Pp 76.\" 77Each frame using this attachment has the following header prepended to it: 78.Bd -literal -offset indent 79struct ieee80211_radiotap_header { 80 u_int8_t it_version; /* set to 0 */ 81 u_int8_t it_pad; 82 u_int16_t it_len; /* entire length */ 83 u_int32_t it_present; /* fields present */ 84} __attribute__((__packed__)); 85.Ed 86.Pp 87.\" 88A device driver implementing 89.Vt radiotap 90typically defines a structure embedding an instance of 91.Vt "struct ieee80211_radiotap_header" 92at the beginning, 93with subsequent fields naturally aligned, 94and in the appropriate order. Also, a driver defines 95a macro to set the bits of the 96.Va it_present 97bitmap to indicate which fields exist and are filled in by the driver. 98.\" 99.Pp 100Radiotap capture fields 101.Em must be naturally aligned . 102That is, 16-, 32-, and 64-bit fields must begin on 16-, 32-, and 10364-bit boundaries, respectively. 104In this way, drivers can avoid unaligned accesses to radiotap 105capture fields. 106radiotap-compliant drivers must insert padding before a capture 107field to ensure its natural alignment. 108radiotap-compliant packet dissectors, such as 109.Xr tcpdump 8 , 110expect the padding. 111.Pp 112Developers beware: all compilers may not pack structs alike. 113If a driver developer constructs their radiotap header with a packed 114structure, in order to ensure natural alignment, then it is important 115that they insert padding bytes by themselves. 116.Pp 117Radiotap headers are copied to the userland via a separate bpf attachment. 118It is necessary for the driver to create this attachment after calling 119.Xr ieee80211_ifattach 9 120by calling 121.Fn bpfattach2 122with the data-link type set to 123.Dv DLT_IEEE802_11_RADIO . 124.Pp 125.\" 126When the information is available, 127usually immediately before a link-layer transmission or after a receive, 128the driver copies it to the bpf layer using the 129.Fn bpf_mtap2 130function. 131.Pp 132.\" 133The following extension fields are defined for 134.Vt radiotap , 135in the order in which they should appear in the buffer copied to userland: 136.Bl -tag -width indent 137.It Dv IEEE80211_RADIOTAP_TSFT 138This field contains the unsigned 64-bit value, in microseconds, 139of the MAC's 802.11 Time Synchronization Function timer, 140when the first bit of the MPDU arrived at the MAC. 141This field should be present for received frames only. 142.It Dv IEEE80211_RADIOTAP_FLAGS 143This field contains a single unsigned 8-bit value, containing a bitmap 144of flags specifying properties of the frame being transmitted or received. 145.It Dv IEEE80211_RADIOTAP_RATE 146This field contains a single unsigned 8-bit value, which is the data rate in 147use in units of 500Kbps. 148.It Dv IEEE80211_RADIOTAP_CHANNEL 149This field contains two unsigned 16-bit values. 150The first value is the frequency upon which this PDU was transmitted 151or received. 152The second value is a bitmap containing flags which specify properties of 153the channel in use. 154These are documented within the header file, 155.In net80211/ieee80211_radiotap.h . 156.It Dv IEEE80211_RADIOTAP_FHSS 157This field contains two 8-bit values. 158This field should be present for frequency-hopping radios only. 159The first byte is the hop set. 160The second byte is the pattern in use. 161.It Dv IEEE80211_RADIOTAP_DBM_ANTSIGNAL 162This field contains a single signed 8-bit value, which indicates the 163RF signal power at the antenna, in decibels difference from 1mW. 164.It Dv IEEE80211_RADIOTAP_DBM_ANTNOISE 165This field contains a single signed 8-bit value, which indicates the 166RF noise power at the antenna, in decibels difference from 1mW. 167.It Dv IEEE80211_RADIOTAP_LOCK_QUALITY 168This field contains a single unsigned 16-bit value, indicating the 169quality of the Barker Code lock. 170No unit is specified for this field. 171There does not appear to be a standard way of measuring this at this time; 172this quantity is often referred to as 173.Dq "Signal Quality" 174in some datasheets. 175.It Dv IEEE80211_RADIOTAP_TX_ATTENUATION 176This field contains a single unsigned 16-bit value, expressing transmit 177power as unitless distance from maximum power set at factory calibration. 1780 indicates maximum transmit power. 179Monotonically nondecreasing with lower power levels. 180.It Dv IEEE80211_RADIOTAP_DB_TX_ATTENUATION 181This field contains a single unsigned 16-bit value, expressing transmit 182power as decibel distance from maximum power set at factory calibration. 1830 indicates maximum transmit power. 184Monotonically nondecreasing with lower power levels. 185.It Dv IEEE80211_RADIOTAP_DBM_TX_POWER 186Transmit power expressed as decibels from a 1mW reference. 187This field is a single signed 8-bit value. 188This is the absolute power level measured at the antenna port. 189.It Dv IEEE80211_RADIOTAP_ANTENNA 190For radios which support antenna diversity, this field contains a single 191unsigned 8-bit value specifying which antenna is being used to transmit 192or receive this frame. 193The first antenna is antenna 0. 194.It Dv IEEE80211_RADIOTAP_DB_ANTSIGNAL 195This field contains a single unsigned 8-bit value, which indicates the 196RF signal power at the antenna, in decibels difference from an 197arbitrary, fixed reference. 198.It Dv IEEE80211_RADIOTAP_DB_ANTNOISE 199This field contains a single unsigned 8-bit value, which indicates the 200RF noise power at the antenna, in decibels difference from an 201arbitrary, fixed reference. 202.It Dv IEEE80211_RADIOTAP_EXT 203This bit is reserved for any future extensions to the 204.Vt radiotap 205structure. 206A driver sets 207.Dv IEEE80211_RADIOTAP_EXT 208to extend the it_present bitmap by another 64 bits. 209The bitmap can be extended by multiples of 32 bits to 96, 128, 160 210bits or longer, by setting 211.Dv IEEE80211_RADIOTAP_EXT 212in the extensions. 213The bitmap ends at the first extension field where 214.Dv IEEE80211_RADIOTAP_EXT 215is not set. 216.El 217.Sh EXAMPLES 218Radiotap header for the Cisco Aironet driver: 219.Bd -literal -offset indent 220struct an_rx_radiotap_header { 221 struct ieee80211_radiotap_header ar_ihdr; 222 u_int8_t ar_flags; 223 u_int8_t ar_rate; 224 u_int16_t ar_chan_freq; 225 u_int16_t ar_chan_flags; 226 u_int8_t ar_antsignal; 227 u_int8_t ar_antnoise; 228} __attribute__((__packed__)); 229.Ed 230.Pp 231Bitmap indicating which fields are present in the above structure: 232.Bd -literal -offset indent 233#define AN_RX_RADIOTAP_PRESENT \\ 234 ((1 \*[Gt]\*[Gt] IEEE80211_RADIOTAP_FLAGS) | \\ 235 (1 \*[Gt]\*[Gt] IEEE80211_RADIOTAP_RATE) | \\ 236 (1 \*[Gt]\*[Gt] IEEE80211_RADIOTAP_CHANNEL) | \\ 237 (1 \*[Gt]\*[Gt] IEEE80211_RADIOTAP_DBM_ANTSIGNAL) | \\ 238 (1 \*[Gt]\*[Gt] IEEE80211_RADIOTAP_DBM_ANTNOISE)) 239.Ed 240.Sh SEE ALSO 241.Xr bpf 4 , 242.Xr ieee80211 9 243.Sh HISTORY 244The 245.Nm 246definitions first appeared in 247.Nx 1.5 , 248and were later ported to 249.Fx 4.6 . 250.\" 251.Sh AUTHORS 252.An -nosplit 253The 254.Nm 255interface was designed and implemented by 256.An David Young Aq dyoung@pobox.com . 257.An David Young 258is the maintainer of the radiotap capture format. 259Contact him to add new capture fields. 260.Pp 261This manual page was written by 262.An Bruce M. Simpson Aq bms@FreeBSD.org 263and 264.An Darron Broad Aq darron@kewl.org . 265