01023762c2d9c9b959abd82c02e6ff793b5563d4
[dragonfly.git] / share / man / man9 / ieee80211_radiotap.9
1 .\"
2 .\" Copyright (c) 2004  Bruce M. Simpson <bms@spc.org>,
3 .\"                     Darron Broad <darron@kewl.org>,
4 .\"                     David Young <dyoung@pobox.com>.
5 .\" All rights reserved.
6 .\"
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
9 .\" are met:
10 .\" 1. Redistributions of source code must retain the above copyright
11 .\"    notice, this list of conditions and the following disclaimer.
12 .\" 2. Redistributions in binary form must reproduce the above copyright
13 .\"    notice, this list of conditions and the following disclaimer in the
14 .\"    documentation and/or other materials provided with the distribution.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 .\" SUCH DAMAGE.
27 .\"
28 .\" $FreeBSD: src/share/man/man9/ieee80211_radiotap.9,v 1.7 2009/09/18 00:33:47 brueffer Exp $
29 .\"
30 .Dd April 28, 2010
31 .Dt IEEE80211_RADIOTAP 9
32 .Os
33 .Sh NAME
34 .Nm ieee80211_radiotap
35 .Nd 802.11 device packet capture support
36 .Sh SYNOPSIS
37 .In netproto/802_11/ieee80211_var.h
38 .\"
39 .Pp
40 .Ft void
41 .Fo ieee80211_radiotap_attach
42 .Fa "struct ieee80211com *"
43 .Fa "struct ieee80211_radiotap_header *th"
44 .Fa "int tlen"
45 .Fa "uint32_t tx_radiotap"
46 .Fa "struct ieee80211_radiotap_header *rh"
47 .Fa "int rlen"
48 .Fa "uint32_t rx_radiotap"
49 .Fc
50 .\"
51 .Ft int
52 .Fn ieee80211_radiotap_active_vap "struct ieee80211vap *"
53 .\"
54 .Ft int
55 .Fn ieee80211_radiotap_active "struct ieee80211com *"
56 .\"
57 .Ft void
58 .Fn ieee80211_radiotap_tx "struct ieee80211vap *" "struct mbuf *"
59 .Sh DESCRIPTION
60 The
61 .Nm net80211
62 layer used by 802.11 drivers includes support for a device-independent
63 packet capture format called
64 .Nm radiotap
65 that is understood by tools such as
66 .Xr tcpdump 1 .
67 This facility is designed for capturing 802.11 traffic,
68 including information that is not part of the normal 802.11 frame structure.
69 .Pp
70 Radiotap was designed to balance the desire for a hardware-independent,
71 extensible capture format against the need to
72 conserve CPU and memory bandwidth on embedded systems.
73 These considerations led to a format consisting of
74 a standard preamble followed by an extensible bitmap indicating the
75 presence of optional capture fields.
76 A
77 .Nm net80211
78 device driver supporting
79 .Vt radiotap
80 defines two packed structures that it shares with
81 .Nm net80211 .
82 These structures embed an instance of a
83 .Vt ieee80211_radiotap_header
84 structure at the beginning,
85 with subsequent fields in the appropriate order,
86 and macros to set the bits of the
87 .Va it_present
88 bitmap to indicate which fields exist and are filled in by the driver.
89 This information is then supplied through the
90 .Fn ieee80211_radiotap_attach
91 call after a successful
92 .Fn ieee80211_ifattach
93 request.
94 .Pp
95 With radiotap setup, drivers just need to fill in per-packet
96 capture state for frames sent/received and dispatch capture state
97 in the transmit path (since control is not returned to the
98 .Nm net80211
99 layer before the packet is handed to the device).
100 To minimize overhead this work should be done only when one
101 or more processes are actively capturing data;
102 this is checked with one of
103 .Fn ieee80211_radiotap_active_vap
104 and
105 .Fn ieee80211_radiotap_active .
106 In the transmit path capture work looks like this:
107 .Bd -literal -offset indent
108 if (ieee80211_radiotap_active_vap(vap)) {
109         ... /* record transmit state */
110         ieee80211_radiotap_tx(vap, m); /* capture transmit event */
111 }
112 .Ed
113 .Pp
114 While in the receive path capture is handled in
115 .Nm net80211
116 but state must be captured before dispatching a frame:
117 .Bd -literal -offset indent
118 if (ieee80211_radiotap_active(ic)) {
119         ... /* record receive state */
120 }
121 \&...
122 ieee80211_input(...);   /* packet capture handled in net80211 */
123 .Ed
124 .Pp
125 .\"
126 The following fields are defined for
127 .Vt radiotap ,
128 in the order in which they should appear in the buffer supplied
129 to
130 .Nm net80211 .
131 .Bl -tag -width indent
132 .It Dv IEEE80211_RADIOTAP_TSFT
133 This field contains the unsigned 64-bit value, in microseconds,
134 of the MAC's 802.11 Time Synchronization Function (TSF).
135 In theory, for each received frame, this value is recorded
136 when the first bit of the MPDU arrived at the MAC.
137 In practice, hardware snapshots the TSF otherwise and one cannot assume
138 this data is accurate without driver adjustment.
139 .It Dv IEEE80211_RADIOTAP_FLAGS
140 This field contains a single unsigned 8-bit value, containing one or
141 more of these bit flags:
142 .Bl -tag -width indent
143 .It Dv IEEE80211_RADIOTAP_F_CFP
144 Frame was sent/received during the Contention Free Period (CFP).
145 .It Dv IEEE80211_RADIOTAP_F_SHORTPRE
146 Frame was sent/received with short preamble.
147 .It Dv IEEE80211_RADIOTAP_F_WEP
148 Frame was encrypted.
149 .It Dv IEEE80211_RADIOTAP_F_FRAG
150 Frame was an 802.11 fragment.
151 .It Dv IEEE80211_RADIOTAP_F_FCS
152 Frame contents includes the FCS.
153 .It Dv IEEE80211_RADIOTAP_F_DATAPAD
154 Frame contents potentially has padding between the 802.11 header and the
155 data payload to align the payload to a 32-bit boundary.
156 .It Dv IEEE80211_RADIOTAP_F_BADFCS
157 Frame was received with an invalid FCS.
158 .It Dv IEEE80211_RADIOTAP_F_SHORTGI
159 Frame was sent/received with Short Guard Interval.
160 .El
161 .It Dv IEEE80211_RADIOTAP_RATE
162 This field contains a single unsigned 8-bit value that is the data rate.
163 Legacy rates are in units of 500Kbps.
164 MCS rates (used on 802.11n/HT channels) have the high bit set and
165 the MCS in the low 7 bits.
166 .It Dv IEEE80211_RADIOTAP_CHANNEL
167 This field contains two unsigned 16-bit values.
168 The first value is the center frequency for the channel
169 the frame was sent/received on.
170 The second value is a bitmap containing flags that specify channel properties.
171 .Pp
172 This field is deprecated in favor of
173 .Dv IEEE80211_RADIOTAP_XCHANNEL
174 but may be used to save space in the capture file for legacy devices.
175 .\".It Dv IEEE80211_RADIOTAP_FHSS
176 .\"This field contains two 8-bit values.
177 .\"This field should be present only for frequency-hopping radios.
178 .\"The first byte is the hop set.
179 .\"The second byte is the pattern in use.
180 .It Dv IEEE80211_RADIOTAP_DBM_ANTSIGNAL
181 This field contains a single signed 8-bit value that indicates the
182 RF signal power at the antenna, in decibels difference from 1mW.
183 .It Dv IEEE80211_RADIOTAP_DBM_ANTNOISE
184 This field contains a single signed 8-bit value that indicates the
185 RF noise power at the antenna, in decibels difference from 1mW.
186 .\".It Dv IEEE80211_RADIOTAP_LOCK_QUALITY
187 .\"This field contains a single unsigned 16-bit value, indicating the
188 .\"quality of the Barker Code lock.
189 .\"No unit is specified for this field.
190 .\"There does not appear to be a standard way of measuring this at this time;
191 .\"this quantity is often referred to as
192 .\".Dq "Signal Quality"
193 .\"in some datasheets.
194 .\".It Dv IEEE80211_RADIOTAP_TX_ATTENUATION
195 .\"This field contains a single unsigned 16-bit value, expressing transmit
196 .\"power as unitless distance from maximum power set at factory calibration.
197 .\"0 indicates maximum transmit power.
198 .\"Monotonically nondecreasing with lower power levels.
199 .\".It Dv IEEE80211_RADIOTAP_DB_TX_ATTENUATION
200 .\"This field contains a single unsigned 16-bit value, expressing transmit
201 .\"power as decibel distance from maximum power set at factory calibration.
202 .\"0 indicates maximum transmit power.
203 .\"Monotonically nondecreasing with lower power levels.
204 .It Dv IEEE80211_RADIOTAP_DBM_TX_POWER
205 Transmit power expressed as decibels from a 1mW reference.
206 This field is a single signed 8-bit value.
207 This is the absolute power level measured at the antenna port.
208 .It Dv IEEE80211_RADIOTAP_ANTENNA
209 This field contains a single unsigned 8-bit value that specifies
210 which antenna was used to transmit or receive the frame.
211 Antenna numbering is device-specific but typically the primary antenna has
212 the lowest number.
213 On transmit a value of zero may be seen which typically means
214 antenna selection is left to the device.
215 .It Dv IEEE80211_RADIOTAP_DB_ANTSIGNAL
216 This field contains a single unsigned 8-bit value that indicates the
217 RF signal power at the antenna, in decibels difference from an
218 arbitrary, fixed reference.
219 .It Dv IEEE80211_RADIOTAP_DB_ANTNOISE
220 This field contains a single unsigned 8-bit value that indicates the
221 RF noise power at the antenna, in decibels difference from an
222 arbitrary, fixed reference.
223 .It Dv IEEE80211_RADIOTAP_XCHANNEL
224 This field contains four values: a 32-bit unsigned bitmap of
225 flags that describe the channel attributes, a 16-bit unsigned
226 frequency in MHz (typically the channel center), an 8-bit
227 unsigned IEEE channel number, and a signed 8-bit value that
228 holds the maximum regulatory transmit power cap in .5 dBm
229 (8 bytes total).
230 Channel flags are defined in:
231 .In netproto/802_11/_ieee80211.h
232 (only a subset are found in
233 .In netproto/802_11/ieee80211_radiotap.h ).
234 This property supersedes
235 .Dv IEEE80211_RADIOTAP_CHANNEL
236 and is the only way to completely express all
237 channel attributes and the
238 mapping between channel frequency and IEEE channel number.
239 .El
240 .Sh EXAMPLES
241 Radiotap receive definitions for the Intersil Prism driver:
242 .Bd -literal -offset indent
243 #define WI_RX_RADIOTAP_PRESENT \\
244         ((1 << IEEE80211_RADIOTAP_TSFT) \\
245          (1 << IEEE80211_RADIOTAP_FLAGS) | \\
246          (1 << IEEE80211_RADIOTAP_RATE) | \\
247          (1 << IEEE80211_RADIOTAP_CHANNEL) | \\
248          (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL) | \\
249          (1 << IEEE80211_RADIOTAP_DB_ANTNOISE))
250
251 struct wi_rx_radiotap_header {
252         struct ieee80211_radiotap_header wr_ihdr;
253         uint64_t       wr_tsf;
254         uint8_t        wr_flags;
255         uint8_t        wr_rate;
256         uint16_t       wr_chan_freq;
257         uint16_t       wr_chan_flags;
258         uint8_t        wr_antsignal;
259         uint8_t        wr_antnoise;
260 } __packed;
261 .Ed
262 .Pp
263 and transmit definitions for the Atheros driver:
264 .Bd -literal -offset indent
265 #define ATH_TX_RADIOTAP_PRESENT (               \\
266         (1 << IEEE80211_RADIOTAP_TSFT)          | \\
267         (1 << IEEE80211_RADIOTAP_FLAGS)         | \\
268         (1 << IEEE80211_RADIOTAP_RATE)          | \\
269         (1 << IEEE80211_RADIOTAP_DBM_TX_POWER)  | \\
270         (1 << IEEE80211_RADIOTAP_ANTENNA)       | \\
271         (1 << IEEE80211_RADIOTAP_XCHANNEL)      | \\
272         0)
273
274 struct ath_tx_radiotap_header {
275         struct ieee80211_radiotap_header wt_ihdr;
276         uint64_t       wt_tsf;
277         uint8_t        wt_flags;
278         uint8_t        wt_rate;
279         uint8_t        wt_txpower;
280         uint8_t        wt_antenna;
281         uint32_t       wt_chan_flags;
282         uint16_t       wt_chan_freq;
283         uint8_t        wt_chan_ieee;
284         int8_t         wt_chan_maxpow;
285 } __packed;
286 .Ed
287 .Sh SEE ALSO
288 .Xr tcpdump 1 ,
289 .Xr bpf 4 ,
290 .Xr ieee80211 9
291 .Sh HISTORY
292 The
293 .Nm
294 definitions first appeared in
295 .Nx 1.5 .
296 .\"
297 .Sh AUTHORS
298 .An -nosplit
299 The original version of this manual page was written by
300 .An Bruce M. Simpson Aq bms@FreeBSD.org
301 and
302 .An Darron Broad Aq darron@kewl.org .