|
|
|
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 |
/* |
| 3 |
* Copyright (c) 2018 Sébastien Deronne |
| 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, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 |
* |
| 18 |
* Author: Sébastien Deronne <sebastien.deronne@gmail.com> |
| 19 |
*/ |
| 20 |
|
| 21 |
#ifndef WIFI_PLCP_HEADER_H |
| 22 |
#define WIFI_PLCP_HEADER_H |
| 23 |
|
| 24 |
#include "ns3/header.h" |
| 25 |
|
| 26 |
namespace ns3 { |
| 27 |
|
| 28 |
/** |
| 29 |
* \ingroup wifi |
| 30 |
* |
| 31 |
* Implements the IEEE 802.11b SIG PLCP header |
| 32 |
*/ |
| 33 |
class DsssSigHeader : public Header |
| 34 |
{ |
| 35 |
public: |
| 36 |
DsssSigHeader (); |
| 37 |
virtual ~DsssSigHeader (); |
| 38 |
|
| 39 |
/** |
| 40 |
* \brief Get the type ID. |
| 41 |
* \return the object TypeId |
| 42 |
*/ |
| 43 |
static TypeId GetTypeId (void); |
| 44 |
TypeId GetInstanceTypeId (void) const; |
| 45 |
void Print (std::ostream &os) const; |
| 46 |
uint32_t GetSerializedSize (void) const; |
| 47 |
void Serialize (Buffer::Iterator start) const; |
| 48 |
uint32_t Deserialize (Buffer::Iterator start); |
| 49 |
|
| 50 |
/** |
| 51 |
* Fill the RATE field of L-SIG (in bit/s). |
| 52 |
* |
| 53 |
* \param rate the RATE field of L-SIG expressed in bit/s |
| 54 |
*/ |
| 55 |
void SetRate (uint64_t rate); |
| 56 |
/** |
| 57 |
* Return the RATE field of L-SIG (in bit/s). |
| 58 |
* |
| 59 |
* \return the RATE field of L-SIG expressed in bit/s |
| 60 |
*/ |
| 61 |
uint64_t GetRate (void) const; |
| 62 |
/** |
| 63 |
* Fill the LENGTH field of L-SIG (in bytes). |
| 64 |
* |
| 65 |
* \param length the LENGTH field of L-SIG expressed in bytes |
| 66 |
*/ |
| 67 |
void SetLength (uint16_t length); |
| 68 |
/** |
| 69 |
* Return the LENGTH field of L-SIG (in bytes). |
| 70 |
* |
| 71 |
* \return the LENGTH field of L-SIG expressed in bytes |
| 72 |
*/ |
| 73 |
uint16_t GetLength (void) const; |
| 74 |
|
| 75 |
|
| 76 |
private: |
| 77 |
uint8_t m_rate; ///< RATE field |
| 78 |
uint16_t m_length; ///< LENGTH field |
| 79 |
}; |
| 80 |
|
| 81 |
|
| 82 |
/** |
| 83 |
* \ingroup wifi |
| 84 |
* |
| 85 |
* Implements the IEEE 802.11 L-SIG PLCP header |
| 86 |
*/ |
| 87 |
class LSigHeader : public Header |
| 88 |
{ |
| 89 |
public: |
| 90 |
LSigHeader (); |
| 91 |
virtual ~LSigHeader (); |
| 92 |
|
| 93 |
/** |
| 94 |
* \brief Get the type ID. |
| 95 |
* \return the object TypeId |
| 96 |
*/ |
| 97 |
static TypeId GetTypeId (void); |
| 98 |
TypeId GetInstanceTypeId (void) const; |
| 99 |
void Print (std::ostream &os) const; |
| 100 |
uint32_t GetSerializedSize (void) const; |
| 101 |
void Serialize (Buffer::Iterator start) const; |
| 102 |
uint32_t Deserialize (Buffer::Iterator start); |
| 103 |
|
| 104 |
/** |
| 105 |
* Fill the RATE field of L-SIG (in bit/s). |
| 106 |
* |
| 107 |
* \param rate the RATE field of L-SIG expressed in bit/s |
| 108 |
*/ |
| 109 |
void SetRate (uint64_t rate); |
| 110 |
/** |
| 111 |
* Return the RATE field of L-SIG (in bit/s). |
| 112 |
* |
| 113 |
* \return the RATE field of L-SIG expressed in bit/s |
| 114 |
*/ |
| 115 |
uint64_t GetRate (void) const; |
| 116 |
/** |
| 117 |
* Fill the LENGTH field of L-SIG (in bytes). |
| 118 |
* |
| 119 |
* \param length the LENGTH field of L-SIG expressed in bytes |
| 120 |
*/ |
| 121 |
void SetLength (uint16_t length); |
| 122 |
/** |
| 123 |
* Return the LENGTH field of L-SIG (in bytes). |
| 124 |
* |
| 125 |
* \return the LENGTH field of L-SIG expressed in bytes |
| 126 |
*/ |
| 127 |
uint16_t GetLength (void) const; |
| 128 |
|
| 129 |
|
| 130 |
private: |
| 131 |
uint8_t m_rate; ///< RATE field |
| 132 |
uint16_t m_length; ///< LENGTH field |
| 133 |
}; |
| 134 |
|
| 135 |
|
| 136 |
/** |
| 137 |
* \ingroup wifi |
| 138 |
* |
| 139 |
* Implements the IEEE 802.11n HT-SIG PLCP header |
| 140 |
*/ |
| 141 |
class HtSigHeader : public Header |
| 142 |
{ |
| 143 |
public: |
| 144 |
HtSigHeader (); |
| 145 |
virtual ~HtSigHeader (); |
| 146 |
|
| 147 |
/** |
| 148 |
* \brief Get the type ID. |
| 149 |
* \return the object TypeId |
| 150 |
*/ |
| 151 |
static TypeId GetTypeId (void); |
| 152 |
TypeId GetInstanceTypeId (void) const; |
| 153 |
void Print (std::ostream &os) const; |
| 154 |
uint32_t GetSerializedSize (void) const; |
| 155 |
void Serialize (Buffer::Iterator start) const; |
| 156 |
uint32_t Deserialize (Buffer::Iterator start); |
| 157 |
|
| 158 |
/** |
| 159 |
* Fill the MCS field of HT-SIG. |
| 160 |
* |
| 161 |
* \param length the MCS field of HT-SIG |
| 162 |
*/ |
| 163 |
void SetMcs (uint8_t mcs); |
| 164 |
/** |
| 165 |
* Return the MCS field of HT-SIG. |
| 166 |
* |
| 167 |
* \return the MCS field of HT-SIG |
| 168 |
*/ |
| 169 |
uint8_t GetMcs (void) const; |
| 170 |
/** |
| 171 |
* Fill the channel width field of HT-SIG (in MHz). |
| 172 |
* |
| 173 |
* \param width the channel width (in MHz) |
| 174 |
*/ |
| 175 |
void SetChannelWidth (uint16_t width); |
| 176 |
/** |
| 177 |
* Return the channel width (in MHz). |
| 178 |
* |
| 179 |
* \return the channel width (in MHz) |
| 180 |
*/ |
| 181 |
uint16_t GetChannelWidth (void) const; |
| 182 |
/** |
| 183 |
* Fill the aggregation field of HT-SIG . |
| 184 |
* |
| 185 |
* \param aggregation whether the PSDU contains A-MPDU or not |
| 186 |
*/ |
| 187 |
void SetAggregation (bool aggregation); |
| 188 |
/** |
| 189 |
* Return the aggregation field of HT-SIG. |
| 190 |
* |
| 191 |
* \return the aggregation field of HT-SIG |
| 192 |
*/ |
| 193 |
bool GetAggregation (void) const; |
| 194 |
/** |
| 195 |
* Fill the short guard interval field of HT-SIG. |
| 196 |
* |
| 197 |
* \param sgi whether short guard interval is used or not |
| 198 |
*/ |
| 199 |
void SetShortGuardInterval (bool sgi); |
| 200 |
/** |
| 201 |
* Return the short guard interval field of HT-SIG. |
| 202 |
* |
| 203 |
* \return the short guard interval field of HT-SIG |
| 204 |
*/ |
| 205 |
bool GetShortGuardInterval (void) const; |
| 206 |
/** |
| 207 |
* Fill the HT length field of HT-SIG (in bytes). |
| 208 |
* |
| 209 |
* \param length the HT length field of HT-SIG (in bytes) |
| 210 |
*/ |
| 211 |
void SetLength (uint16_t length); |
| 212 |
/** |
| 213 |
* Return the HT length field of HT-SIG (in bytes). |
| 214 |
* |
| 215 |
* \return the HT length field of HT-SIG (in bytes) |
| 216 |
*/ |
| 217 |
uint16_t GetLength (void) const; |
| 218 |
|
| 219 |
|
| 220 |
private: |
| 221 |
uint8_t m_mcs; ///< Modulation and Coding Scheme index |
| 222 |
uint8_t m_cbw20_40; ///< CBW 20/40 |
| 223 |
uint16_t m_length; ///< HT length |
| 224 |
uint8_t m_aggregation; ///< Aggregation |
| 225 |
uint8_t m_sgi; ///< Short Guard Interval |
| 226 |
}; |
| 227 |
|
| 228 |
/** |
| 229 |
* \ingroup wifi |
| 230 |
* |
| 231 |
* Implements the IEEE 802.11ac VHT-SIG-A1 PLCP header |
| 232 |
*/ |
| 233 |
class VhtSigA1Header : public Header |
| 234 |
{ |
| 235 |
public: |
| 236 |
VhtSigA1Header (); |
| 237 |
virtual ~VhtSigA1Header (); |
| 238 |
|
| 239 |
/** |
| 240 |
* \brief Get the type ID. |
| 241 |
* \return the object TypeId |
| 242 |
*/ |
| 243 |
static TypeId GetTypeId (void); |
| 244 |
TypeId GetInstanceTypeId (void) const; |
| 245 |
void Print (std::ostream &os) const; |
| 246 |
uint32_t GetSerializedSize (void) const; |
| 247 |
void Serialize (Buffer::Iterator start) const; |
| 248 |
uint32_t Deserialize (Buffer::Iterator start); |
| 249 |
|
| 250 |
/** |
| 251 |
* Fill the channel width field of VHT-SIG-A1 (in MHz). |
| 252 |
* |
| 253 |
* \param width the channel width (in MHz) |
| 254 |
*/ |
| 255 |
void SetChannelWidth (uint16_t width); |
| 256 |
/** |
| 257 |
* Return the channel width (in MHz). |
| 258 |
* |
| 259 |
* \return the channel width (in MHz) |
| 260 |
*/ |
| 261 |
uint16_t GetChannelWidth (void) const; |
| 262 |
/** |
| 263 |
* Fill the number of streams field of VHT-SIG-A1. |
| 264 |
* |
| 265 |
* \param nStreams the number of streams |
| 266 |
*/ |
| 267 |
void SetNStreams (uint8_t nStreams); |
| 268 |
/** |
| 269 |
* Return the number of streams. |
| 270 |
* |
| 271 |
* \return the number of streams |
| 272 |
*/ |
| 273 |
uint8_t GetNStreams (void) const; |
| 274 |
|
| 275 |
private: |
| 276 |
uint8_t m_bw; ///< BW |
| 277 |
uint8_t m_nsts; ///< NSTS |
| 278 |
}; |
| 279 |
|
| 280 |
|
| 281 |
/** |
| 282 |
* \ingroup wifi |
| 283 |
* |
| 284 |
* Implements the IEEE 802.11ac VHT-SIG-A2 PLCP header |
| 285 |
*/ |
| 286 |
class VhtSigA2Header : public Header |
| 287 |
{ |
| 288 |
public: |
| 289 |
VhtSigA2Header (); |
| 290 |
virtual ~VhtSigA2Header (); |
| 291 |
|
| 292 |
/** |
| 293 |
* \brief Get the type ID. |
| 294 |
* \return the object TypeId |
| 295 |
*/ |
| 296 |
static TypeId GetTypeId (void); |
| 297 |
TypeId GetInstanceTypeId (void) const; |
| 298 |
void Print (std::ostream &os) const; |
| 299 |
uint32_t GetSerializedSize (void) const; |
| 300 |
void Serialize (Buffer::Iterator start) const; |
| 301 |
uint32_t Deserialize (Buffer::Iterator start); |
| 302 |
|
| 303 |
/** |
| 304 |
* Fill the short guard interval field of VHT-SIG-A2. |
| 305 |
* |
| 306 |
* \param sgi whether short guard interval is used or not |
| 307 |
*/ |
| 308 |
void SetShortGuardInterval (bool sgi); |
| 309 |
/** |
| 310 |
* Return the short GI field of VHT-SIG-A2. |
| 311 |
* |
| 312 |
* \return the short GI field of VHT-SIG-A2 |
| 313 |
*/ |
| 314 |
bool GetShortGuardInterval (void) const; |
| 315 |
/** |
| 316 |
* Fill the SU VHT MCS field of VHT-SIG-A2. |
| 317 |
* |
| 318 |
* \param length the SU VHT MCS field of VHT-SIG-A2 |
| 319 |
*/ |
| 320 |
void SetSuMcs (uint8_t mcs); |
| 321 |
/** |
| 322 |
* Return the SU VHT MCS field of VHT-SIG-A2. |
| 323 |
* |
| 324 |
* \return the SU VHT MCS field of VHT-SIG-A2 |
| 325 |
*/ |
| 326 |
uint8_t GetSuMcs (void) const; |
| 327 |
|
| 328 |
|
| 329 |
private: |
| 330 |
uint8_t m_sgi; ///< Short GI |
| 331 |
uint8_t m_suMcs; ///< SU VHT MCS |
| 332 |
}; |
| 333 |
|
| 334 |
|
| 335 |
/** |
| 336 |
* \ingroup wifi |
| 337 |
* |
| 338 |
* Implements the IEEE 802.11ac VHT-SIG-B PLCP header |
| 339 |
*/ |
| 340 |
class VhtSigBHeader : public Header |
| 341 |
{ |
| 342 |
public: |
| 343 |
VhtSigBHeader (); |
| 344 |
virtual ~VhtSigBHeader (); |
| 345 |
|
| 346 |
/** |
| 347 |
* \brief Get the type ID. |
| 348 |
* \return the object TypeId |
| 349 |
*/ |
| 350 |
static TypeId GetTypeId (void); |
| 351 |
TypeId GetInstanceTypeId (void) const; |
| 352 |
void Print (std::ostream &os) const; |
| 353 |
uint32_t GetSerializedSize (void) const; |
| 354 |
void Serialize (Buffer::Iterator start) const; |
| 355 |
uint32_t Deserialize (Buffer::Iterator start); |
| 356 |
}; |
| 357 |
|
| 358 |
|
| 359 |
/** |
| 360 |
* \ingroup wifi |
| 361 |
* |
| 362 |
* Implements the IEEE 802.11ax HE-SIG-A1 PLCP header |
| 363 |
*/ |
| 364 |
class HeSigA1Header : public Header |
| 365 |
{ |
| 366 |
public: |
| 367 |
HeSigA1Header (); |
| 368 |
virtual ~HeSigA1Header (); |
| 369 |
|
| 370 |
/** |
| 371 |
* \brief Get the type ID. |
| 372 |
* \return the object TypeId |
| 373 |
*/ |
| 374 |
static TypeId GetTypeId (void); |
| 375 |
TypeId GetInstanceTypeId (void) const; |
| 376 |
void Print (std::ostream &os) const; |
| 377 |
uint32_t GetSerializedSize (void) const; |
| 378 |
void Serialize (Buffer::Iterator start) const; |
| 379 |
uint32_t Deserialize (Buffer::Iterator start); |
| 380 |
|
| 381 |
/** |
| 382 |
* Fill the MCS field of HE-SIG-A1. |
| 383 |
* |
| 384 |
* \param length the MCS field of HE-SIG-A1 |
| 385 |
*/ |
| 386 |
void SetMcs (uint8_t mcs); |
| 387 |
/** |
| 388 |
* Return the MCS field of HE-SIG-A1. |
| 389 |
* |
| 390 |
* \return the MCS field of HE-SIG-A1 |
| 391 |
*/ |
| 392 |
uint8_t GetMcs (void) const; |
| 393 |
/** |
| 394 |
* Fill the BSS Color field of HE-SIG-A1. |
| 395 |
* |
| 396 |
* \param bssColor the BSS Color value |
| 397 |
*/ |
| 398 |
void SetBssColor (uint8_t bssColor); |
| 399 |
/** |
| 400 |
* Return the BSS Color field in the HE-SIG-A1. |
| 401 |
* |
| 402 |
* \return the BSS Color field in the HE-SIG-A1 |
| 403 |
*/ |
| 404 |
uint8_t GetBssColor (void) const; |
| 405 |
/** |
| 406 |
* Fill the channel width field of HE-SIG-A1 (in MHz). |
| 407 |
* |
| 408 |
* \param width the channel width (in MHz) |
| 409 |
*/ |
| 410 |
void SetChannelWidth (uint16_t width); |
| 411 |
/** |
| 412 |
* Return the channel width (in MHz). |
| 413 |
* |
| 414 |
* \return the channel width (in MHz) |
| 415 |
*/ |
| 416 |
uint16_t GetChannelWidth (void) const; |
| 417 |
/** |
| 418 |
* Fill the GI + LTF size field of HE-SIG-A1. |
| 419 |
* |
| 420 |
* \param gi the guard interval (in nanoseconds) |
| 421 |
* \param ltf the number of HE-LTF |
| 422 |
*/ |
| 423 |
void SetGuardIntervalAndLtfSize (uint16_t gi, uint8_t ltf); |
| 424 |
/** |
| 425 |
* Return the guard interval (in nanoseconds). |
| 426 |
* |
| 427 |
* \return the guard interval (in nanoseconds) |
| 428 |
*/ |
| 429 |
uint16_t GetGuardInterval (void) const; |
| 430 |
/** |
| 431 |
* Fill the number of streams field of HE-SIG-A1. |
| 432 |
* |
| 433 |
* \param nStreams the number of streams |
| 434 |
*/ |
| 435 |
void SetNStreams (uint8_t nStreams); |
| 436 |
/** |
| 437 |
* Return the number of streams. |
| 438 |
* |
| 439 |
* \return the number of streams |
| 440 |
*/ |
| 441 |
uint8_t GetNStreams (void) const; |
| 442 |
|
| 443 |
|
| 444 |
private: |
| 445 |
//TODO: add boolean to know whether this is part of a HE SU or HE MU PPDU (fields and positions are different! We currently only support HE SU) |
| 446 |
uint8_t m_format; ///< Format bit |
| 447 |
uint8_t m_bssColor; ///< BSS color field |
| 448 |
uint8_t m_ul_dl; ///< UL/DL bit |
| 449 |
uint8_t m_mcs; ///< MCS field |
| 450 |
uint8_t m_spatialReuse; ///< Spatial Reuse field |
| 451 |
uint8_t m_bandwidth; ///< Bandwidth field |
| 452 |
uint8_t m_gi_ltf_size; ///< GI+LTF Size field |
| 453 |
uint8_t m_nsts; ///< NSTS |
| 454 |
}; |
| 455 |
|
| 456 |
|
| 457 |
/** |
| 458 |
* \ingroup wifi |
| 459 |
* |
| 460 |
* Implements the IEEE 802.11ax HE-SIG-A2 PLCP header |
| 461 |
*/ |
| 462 |
class HeSigA2Header : public Header |
| 463 |
{ |
| 464 |
public: |
| 465 |
HeSigA2Header (); |
| 466 |
virtual ~HeSigA2Header (); |
| 467 |
|
| 468 |
/** |
| 469 |
* \brief Get the type ID. |
| 470 |
* \return the object TypeId |
| 471 |
*/ |
| 472 |
static TypeId GetTypeId (void); |
| 473 |
TypeId GetInstanceTypeId (void) const; |
| 474 |
void Print (std::ostream &os) const; |
| 475 |
uint32_t GetSerializedSize (void) const; |
| 476 |
void Serialize (Buffer::Iterator start) const; |
| 477 |
uint32_t Deserialize (Buffer::Iterator start); |
| 478 |
}; |
| 479 |
|
| 480 |
|
| 481 |
/** |
| 482 |
* \ingroup wifi |
| 483 |
* |
| 484 |
* Implements the IEEE 802.11ax HE-SIG-B PLCP header |
| 485 |
*/ |
| 486 |
class HeSigBHeader : public Header |
| 487 |
{ |
| 488 |
public: |
| 489 |
HeSigBHeader (); |
| 490 |
virtual ~HeSigBHeader (); |
| 491 |
|
| 492 |
/** |
| 493 |
* \brief Get the type ID. |
| 494 |
* \return the object TypeId |
| 495 |
*/ |
| 496 |
static TypeId GetTypeId (void); |
| 497 |
TypeId GetInstanceTypeId (void) const; |
| 498 |
void Print (std::ostream &os) const; |
| 499 |
uint32_t GetSerializedSize (void) const; |
| 500 |
void Serialize (Buffer::Iterator start) const; |
| 501 |
uint32_t Deserialize (Buffer::Iterator start); |
| 502 |
}; |
| 503 |
|
| 504 |
} //namespace ns3 |
| 505 |
|
| 506 |
#endif /* WIFI_PLCP_HEADER_H */ |