author | Vedran Miletić <rivanvx@gmail.com> |
Tue, 02 Aug 2011 17:42:33 -0400 | |
changeset 7385 | 10beb0e53130 |
parent 7256 | b04ba6772f8c |
child 10657 | 6531a8817def |
permissions | -rw-r--r-- |
7385
10beb0e53130
standardize emacs c++ mode comments
Vedran Miletić <rivanvx@gmail.com>
parents:
7256
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
6009 | 2 |
/* |
3 |
* Copyright (c) 2009 CTTC |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License version 2 as |
|
7 |
* published by the Free Software Foundation; |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Include., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 |
* |
|
18 |
* Author: Nicola Baldo <nbaldo@cttc.es> |
|
19 |
*/ |
|
20 |
||
21 |
#ifndef RADIOTAP_HEADER_H |
|
22 |
#define RADIOTAP_HEADER_H |
|
23 |
||
24 |
||
25 |
#include <ns3/header.h> |
|
26 |
||
27 |
namespace ns3 { |
|
7182
5ecfee5d17de
network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7027
diff
changeset
|
28 |
|
6009 | 29 |
/** |
30 |
* @brief Radiotap header implementation |
|
31 |
* |
|
32 |
* Radiotap is a de facto standard for 802.11 frame injection and reception. |
|
33 |
* The radiotap header format is a mechanism to supply additional information |
|
34 |
* about frames, from the driver to userspace applications such as libpcap, and |
|
35 |
* from a userspace application to the driver for transmission. |
|
36 |
* |
|
37 |
* @warning the radiotap header specification says that the fields included in |
|
38 |
* the header should be aligned to their natural ize (e.g., 16-bit fields |
|
39 |
* aligned to 16-bit boundaries, 32-bit fields aligned to 32-bit boundaries, |
|
40 |
* and so on. This implementation does not enforce this. However, the radiotap |
|
41 |
* specification enforces an order in which fields have to appear (if they |
|
42 |
* appear), and this ordering is such that, provided you don't leave gaps, all |
|
43 |
* fields will end up aligned without the need of inserting padding space. By |
|
44 |
* the term "gap" I mean not using a field which would appear between two used |
|
45 |
* fields. Moral: don't leave gaps, or if you do be careful about how you |
|
7182
5ecfee5d17de
network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7027
diff
changeset
|
46 |
* do it. |
6009 | 47 |
*/ |
48 |
class RadiotapHeader : public Header |
|
49 |
{ |
|
50 |
public: |
|
51 |
RadiotapHeader(); |
|
52 |
static TypeId GetTypeId (void); |
|
53 |
virtual TypeId GetInstanceTypeId (void) const; |
|
54 |
||
55 |
/** |
|
56 |
* This method is used by Packet::AddHeader to store the header into the byte |
|
57 |
* buffer of a packet. This method returns the number of bytes which are |
|
58 |
* needed to store the header data during a Serialize. |
|
59 |
* |
|
60 |
* @returns The expected size of the header. |
|
61 |
*/ |
|
62 |
virtual uint32_t GetSerializedSize (void) const; |
|
63 |
||
64 |
/** |
|
65 |
* This method is used by Packet::AddHeader to store the header into the byte |
|
66 |
* buffer of a packet. The data written is expected to match bit-for-bit the |
|
67 |
* representation of this header in a real network. |
|
68 |
* |
|
69 |
* @param start An iterator which points to where the header should |
|
70 |
* be written. |
|
71 |
*/ |
|
72 |
virtual void Serialize (Buffer::Iterator start) const; |
|
73 |
||
74 |
/** |
|
75 |
* This method is used by Packet::RemoveHeader to re-create a header from the |
|
76 |
* byte buffer of a packet. The data read is expected to match bit-for-bit |
|
77 |
* the representation of this header in real networks. |
|
78 |
* |
|
79 |
* @param start An iterator which points to where the header should |
|
80 |
* written. |
|
81 |
* @returns The number of bytes read. |
|
82 |
*/ |
|
83 |
virtual uint32_t Deserialize (Buffer::Iterator start); |
|
84 |
||
85 |
/** |
|
86 |
* This method is used by Packet::Print to print the content of the header as |
|
87 |
* ascii data to a C++ output stream. Although the header is free to format |
|
88 |
* its output as it wishes, it is recommended to follow a few rules to integrate |
|
89 |
* with the packet pretty printer: start with flags, small field |
|
90 |
* values located between a pair of parens. Values should be separated |
|
91 |
* by whitespace. Follow the parens with the important fields, |
|
92 |
* separated by whitespace. |
|
93 |
* |
|
94 |
* eg: (field1 val1 field2 val2 field3 val3) field4 val4 field5 val5 |
|
95 |
* |
|
96 |
* @param os The output stream |
|
97 |
*/ |
|
98 |
virtual void Print (std::ostream &os) const; |
|
7182
5ecfee5d17de
network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7027
diff
changeset
|
99 |
|
6009 | 100 |
/** |
101 |
* @brief Set the Time Synchronization Function Timer (TSFT) value. Valid for |
|
102 |
* received frames only. |
|
103 |
* |
|
104 |
* @param tsft Value in microseconds of the MAC's 64-bit 802.11 Time |
|
105 |
* Synchronization Function timer when the first bit of the MPDU |
|
106 |
* arrived at the MAC. |
|
107 |
*/ |
|
108 |
void SetTsft (uint64_t tsft); |
|
109 |
||
110 |
/** |
|
111 |
* @brief Get the Time Synchronization Function Timer (TSFT) value. Valid for |
|
112 |
* received frames only. |
|
113 |
* |
|
114 |
* @returns The value in microseconds of the MAC's 64-bit 802.11 Time |
|
115 |
* Synchronization Function timer when the first bit of the MPDU |
|
116 |
* arrived at the MAC. |
|
117 |
*/ |
|
118 |
uint64_t GetTsft (void) const; |
|
119 |
||
6041 | 120 |
enum { |
121 |
FRAME_FLAG_NONE = 0x00, /**< No flags set */ |
|
122 |
FRAME_FLAG_CFP = 0x01, /**< Frame sent/received during CFP */ |
|
123 |
FRAME_FLAG_SHORT_PREAMBLE = 0x02, /**< Frame sent/received with short preamble */ |
|
124 |
FRAME_FLAG_WEP = 0x04, /**< Frame sent/received with WEP encryption */ |
|
125 |
FRAME_FLAG_FRAGMENTED = 0x08, /**< Frame sent/received with fragmentation */ |
|
126 |
FRAME_FLAG_FCS_INCLUDED = 0x10, /**< Frame includes FCS */ |
|
127 |
FRAME_FLAG_DATA_PADDING = 0x20, /**< Frame has padding between 802.11 header and payload (to 32-bit boundary) */ |
|
128 |
FRAME_FLAG_BAD_FCS = 0x40, /**< Frame failed FCS check */ |
|
129 |
FRAME_FLAG_SHORT_GUARD = 0x80 /**< Frame used short guard interval (HT) */ |
|
130 |
}; |
|
6009 | 131 |
|
132 |
/** |
|
133 |
* @brief Set the frame flags of the transmitted or received frame. |
|
134 |
* @param flags flags to set. |
|
135 |
*/ |
|
136 |
void SetFrameFlags (uint8_t flags); |
|
137 |
||
138 |
/** |
|
139 |
* @brief Get the frame flags of the transmitted or received frame. |
|
140 |
* @returns The frame flags. |
|
141 |
* @see FrameFlags. |
|
142 |
*/ |
|
143 |
uint8_t GetFrameFlags (void) const; |
|
144 |
||
145 |
/** |
|
146 |
* @brief Set the transmit/receive channel frequency in units of megahertz |
|
147 |
* @param rate the transmit/receive channel frequency in units of megahertz. |
|
148 |
*/ |
|
149 |
void SetRate (uint8_t rate); |
|
150 |
||
151 |
/** |
|
152 |
* @brief Get the transmit/receive channel frequency in units of megahertz. |
|
153 |
* @returns The transmit/receive channel frequency in units of megahertz. |
|
154 |
*/ |
|
155 |
uint8_t GetRate (void) const; |
|
156 |
||
6041 | 157 |
enum { |
158 |
CHANNEL_FLAG_NONE = 0x0000, /**< No flags set */ |
|
159 |
CHANNEL_FLAG_TURBO = 0x0010, /**< Turbo Channel */ |
|
160 |
CHANNEL_FLAG_CCK = 0x0020, /**< CCK channel */ |
|
161 |
CHANNEL_FLAG_OFDM = 0x0040, /**< OFDM channel */ |
|
162 |
CHANNEL_FLAG_SPECTRUM_2GHZ = 0x0080, /**< 2 GHz spectrum channel */ |
|
163 |
CHANNEL_FLAG_SPECTRUM_5GHZ = 0x0100, /**< 5 GHz spectrum channel */ |
|
164 |
CHANNEL_FLAG_PASSIVE = 0x0200, /**< Only passive scan allowed */ |
|
165 |
CHANNEL_FLAG_DYNAMIC = 0x0400, /**< Dynamic CCK-OFDM channel */ |
|
166 |
CHANNEL_FLAG_GFSK = 0x0800 /**< GFSK channel (FHSS PHY) */ |
|
167 |
}; |
|
6009 | 168 |
|
169 |
/** |
|
170 |
* @brief Set the transmit/receive channel frequency and flags |
|
171 |
* @param frequency The transmit/receive data rate in units of 500 kbps. |
|
172 |
* @param flags The flags to set. |
|
173 |
* @see ChannelFlags |
|
174 |
*/ |
|
175 |
void SetChannelFrequencyAndFlags (uint16_t frequency, uint16_t flags); |
|
176 |
||
177 |
/** |
|
178 |
* @brief Get the transmit/receive data rate in units of 500 kbps. |
|
179 |
* @returns The transmit/receive data rate in units of 500 kbps. |
|
180 |
*/ |
|
181 |
uint16_t GetChannelFrequency (void) const; |
|
7182
5ecfee5d17de
network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7027
diff
changeset
|
182 |
|
6009 | 183 |
/** |
184 |
* @brief Get the channel flags of the transmitted or received frame. |
|
185 |
* @returns The frame flags. |
|
186 |
* @see ChannelFlags. |
|
187 |
*/ |
|
188 |
uint16_t GetChannelFlags (void) const; |
|
189 |
||
190 |
/** |
|
191 |
* @brief Set the RF signal power at the antenna as a decibel difference |
|
192 |
* from an arbitrary, fixed reference. |
|
193 |
* |
|
194 |
* @param signal The RF signal power at the antenna as a decibel difference |
|
195 |
* from an arbitrary, fixed reference; |
|
196 |
*/ |
|
197 |
void SetAntennaSignalPower (double signal); |
|
198 |
||
199 |
/** |
|
200 |
* @brief Get the RF signal power at the antenna as a decibel difference |
|
201 |
* from an arbitrary, fixed reference. |
|
202 |
* |
|
203 |
* @returns The RF signal power at the antenna as a decibel difference |
|
204 |
* from an arbitrary, fixed reference. |
|
205 |
*/ |
|
206 |
uint8_t GetAntennaSignalPower (void) const; |
|
207 |
||
208 |
/** |
|
209 |
* @brief Set the RF noise power at the antenna as a decibel difference |
|
210 |
* from an arbitrary, fixed reference. |
|
211 |
* |
|
212 |
* @param noise The RF noise power at the antenna as a decibel difference |
|
213 |
* from an arbitrary, fixed reference. |
|
214 |
*/ |
|
215 |
void SetAntennaNoisePower (double noise); |
|
216 |
||
217 |
/** |
|
218 |
* @brief Get the RF noise power at the antenna as a decibel difference |
|
219 |
* from an arbitrary, fixed reference. |
|
220 |
* |
|
221 |
* @returns The RF noise power at the antenna as a decibel difference |
|
222 |
* from an arbitrary, fixed reference. |
|
223 |
*/ |
|
224 |
uint8_t GetAntennaNoisePower (void) const; |
|
225 |
||
226 |
private: |
|
6041 | 227 |
enum { |
228 |
RADIOTAP_TSFT = 0x00000001, |
|
229 |
RADIOTAP_FLAGS = 0x00000002, |
|
230 |
RADIOTAP_RATE = 0x00000004, |
|
231 |
RADIOTAP_CHANNEL = 0x00000008, |
|
232 |
RADIOTAP_FHSS = 0x00000010, |
|
233 |
RADIOTAP_DBM_ANTSIGNAL = 0x00000020, |
|
234 |
RADIOTAP_DBM_ANTNOISE = 0x00000040, |
|
235 |
RADIOTAP_LOCK_QUALITY = 0x00000080, |
|
236 |
RADIOTAP_TX_ATTENUATION = 0x00000100, |
|
237 |
RADIOTAP_DB_TX_ATTENUATION = 0x00000200, |
|
238 |
RADIOTAP_DBM_TX_POWER = 0x00000200, |
|
239 |
RADIOTAP_ANTENNA = 0x00000400, |
|
240 |
RADIOTAP_DB_ANTSIGNAL = 0x00000800, |
|
241 |
RADIOTAP_DB_ANTNOISE = 0x00001000, |
|
242 |
RADIOTAP_EXT = 0x10000000 |
|
243 |
}; |
|
6009 | 244 |
|
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7182
diff
changeset
|
245 |
void CheckAddChannelField (); |
7182
5ecfee5d17de
network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7027
diff
changeset
|
246 |
|
5ecfee5d17de
network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7027
diff
changeset
|
247 |
uint16_t m_length; |
5ecfee5d17de
network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7027
diff
changeset
|
248 |
uint32_t m_present; |
5ecfee5d17de
network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7027
diff
changeset
|
249 |
|
5ecfee5d17de
network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7027
diff
changeset
|
250 |
uint64_t m_tsft; |
5ecfee5d17de
network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7027
diff
changeset
|
251 |
uint8_t m_flags; |
5ecfee5d17de
network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7027
diff
changeset
|
252 |
uint8_t m_rate; |
5ecfee5d17de
network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7027
diff
changeset
|
253 |
uint16_t m_channelFreq; |
5ecfee5d17de
network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7027
diff
changeset
|
254 |
uint16_t m_channelFlags; |
5ecfee5d17de
network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7027
diff
changeset
|
255 |
int8_t m_antennaSignal; |
5ecfee5d17de
network coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7027
diff
changeset
|
256 |
int8_t m_antennaNoise; |
6009 | 257 |
}; |
258 |
||
259 |
} // namespace ns3 |
|
260 |
||
261 |
#endif /* RADIOTAP_HEADER_H */ |