A Discrete-Event Network Simulator
API
wifi-phy-header.h
Go to the documentation of this file.
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_PHY_HEADER_H
22 #define WIFI_PHY_HEADER_H
23 
24 #include "ns3/header.h"
25 
26 namespace ns3 {
27 
34 class DsssSigHeader : public Header
35 {
36 public:
37  DsssSigHeader ();
38  virtual ~DsssSigHeader ();
39 
44  static TypeId GetTypeId (void);
45  TypeId GetInstanceTypeId (void) const;
46  void Print (std::ostream &os) const;
47  uint32_t GetSerializedSize (void) const;
48  void Serialize (Buffer::Iterator start) const;
50 
56  void SetRate (uint64_t rate);
62  uint64_t GetRate (void) const;
68  void SetLength (uint16_t length);
74  uint16_t GetLength (void) const;
75 
76 
77 private:
78  uint8_t m_rate;
79  uint16_t m_length;
80 };
81 
82 
89 class LSigHeader : public Header
90 {
91 public:
92  LSigHeader ();
93  virtual ~LSigHeader ();
94 
99  static TypeId GetTypeId (void);
100  TypeId GetInstanceTypeId (void) const;
101  void Print (std::ostream &os) const;
102  uint32_t GetSerializedSize (void) const;
103  void Serialize (Buffer::Iterator start) const;
105 
111  void SetRate (uint64_t rate, uint16_t channelWidth = 20);
117  uint64_t GetRate (uint16_t channelWidth = 20) const;
123  void SetLength (uint16_t length);
129  uint16_t GetLength (void) const;
130 
131 
132 private:
133  uint8_t m_rate;
134  uint16_t m_length;
135 };
136 
137 
144 class HtSigHeader : public Header
145 {
146 public:
147  HtSigHeader ();
148  virtual ~HtSigHeader ();
149 
154  static TypeId GetTypeId (void);
155  TypeId GetInstanceTypeId (void) const;
156  void Print (std::ostream &os) const;
157  uint32_t GetSerializedSize (void) const;
158  void Serialize (Buffer::Iterator start) const;
160 
166  void SetMcs (uint8_t mcs);
172  uint8_t GetMcs (void) const;
178  void SetChannelWidth (uint16_t channelWidth);
184  uint16_t GetChannelWidth (void) const;
190  void SetAggregation (bool aggregation);
196  bool GetAggregation (void) const;
202  void SetShortGuardInterval (bool sgi);
208  bool GetShortGuardInterval (void) const;
214  void SetHtLength (uint16_t length);
220  uint16_t GetHtLength (void) const;
221 
222 
223 private:
224  uint8_t m_mcs;
225  uint8_t m_cbw20_40;
226  uint16_t m_htLength;
227  uint8_t m_aggregation;
228  uint8_t m_sgi;
229 };
230 
237 class VhtSigHeader : public Header
238 {
239 public:
240  VhtSigHeader ();
241  virtual ~VhtSigHeader ();
242 
247  static TypeId GetTypeId (void);
248  TypeId GetInstanceTypeId (void) const;
249  void Print (std::ostream &os) const;
250  uint32_t GetSerializedSize (void) const;
251  void Serialize (Buffer::Iterator start) const;
253 
259  void SetMuFlag (bool mu);
260 
266  void SetChannelWidth (uint16_t channelWidth);
272  uint16_t GetChannelWidth (void) const;
278  void SetNStreams (uint8_t nStreams);
284  uint8_t GetNStreams (void) const;
285 
291  void SetShortGuardInterval (bool sgi);
297  bool GetShortGuardInterval (void) const;
303  void SetShortGuardIntervalDisambiguation (bool disambiguation);
309  bool GetShortGuardIntervalDisambiguation (void) const;
315  void SetSuMcs (uint8_t mcs);
321  uint8_t GetSuMcs (void) const;
322 
323 
324 private:
325  //VHT-SIG-A1 fields
326  uint8_t m_bw;
327  uint8_t m_nsts;
328 
329  //VHT-SIG-A2 fields
330  uint8_t m_sgi;
332  uint8_t m_suMcs;
333 
335  bool m_mu;
336  };
337 
338 
344 class HeSigHeader : public Header
345 {
346 public:
347  HeSigHeader ();
348  virtual ~HeSigHeader ();
349 
354  static TypeId GetTypeId (void);
355  TypeId GetInstanceTypeId (void) const;
356  void Print (std::ostream &os) const;
357  uint32_t GetSerializedSize (void) const;
358  void Serialize (Buffer::Iterator start) const;
360 
366  void SetMuFlag (bool mu);
367 
373  void SetMcs (uint8_t mcs);
379  uint8_t GetMcs (void) const;
385  void SetBssColor (uint8_t bssColor);
391  uint8_t GetBssColor (void) const;
397  void SetChannelWidth (uint16_t channelWidth);
403  uint16_t GetChannelWidth (void) const;
410  void SetGuardIntervalAndLtfSize (uint16_t gi, uint8_t ltf);
416  uint16_t GetGuardInterval (void) const;
422  void SetNStreams (uint8_t nStreams);
428  uint8_t GetNStreams (void) const;
429 
430 
431 private:
432  //HE-SIG-A1 fields
433  uint8_t m_format;
434  uint8_t m_bssColor;
435  uint8_t m_ul_dl;
436  uint8_t m_mcs;
437  uint8_t m_spatialReuse;
438  uint8_t m_bandwidth;
439  uint8_t m_gi_ltf_size;
440  uint8_t m_nsts;
441 
443  bool m_mu;
444 };
445 
446 } //namespace ns3
447 
448 #endif /* WIFI_PHY_HEADER_H */
Protocol header serialization and deserialization.
Definition: header.h:42
uint16_t GetChannelWidth(void) const
Return the channel width (in MHz).
void Print(std::ostream &os) const
void Print(std::ostream &os) const
uint8_t m_bandwidth
Bandwidth field.
uint8_t m_sgi
Short Guard Interval.
uint8_t m_spatialReuse
Spatial Reuse field.
uint8_t m_cbw20_40
CBW 20/40.
void SetMcs(uint8_t mcs)
Fill the MCS field of HT-SIG.
uint16_t m_htLength
HT length.
uint8_t m_format
Format bit.
void SetChannelWidth(uint16_t channelWidth)
Fill the channel width field of VHT-SIG-A1 (in MHz).
uint8_t m_ul_dl
UL/DL bit.
uint16_t GetChannelWidth(void) const
Return the channel width (in MHz).
void SetMuFlag(bool mu)
Set the Multi-User (MU) flag.
uint8_t m_mcs
MCS field.
void SetNStreams(uint8_t nStreams)
Fill the number of streams field of HE-SIG-A1.
def start()
Definition: core.py:1858
static TypeId GetTypeId(void)
Get the type ID.
Implements the IEEE 802.11ac PHY header (VHT-SIG-A1/A2/B).
void Print(std::ostream &os) const
void Serialize(Buffer::Iterator start) const
uint8_t m_gi_ltf_size
GI+LTF Size field.
uint16_t GetChannelWidth(void) const
Return the channel width (in MHz).
TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
void SetShortGuardIntervalDisambiguation(bool disambiguation)
Fill the short GI NSYM disambiguation field of VHT-SIG-A2.
void SetRate(uint64_t rate, uint16_t channelWidth=20)
Fill the RATE field of L-SIG (in bit/s).
uint8_t m_nsts
NSTS.
void SetBssColor(uint8_t bssColor)
Fill the BSS Color field of HE-SIG-A1.
void SetRate(uint64_t rate)
Fill the RATE field of L-SIG (in bit/s).
STL namespace.
uint8_t m_nsts
NSTS.
uint32_t Deserialize(Buffer::Iterator start)
uint8_t GetMcs(void) const
Return the MCS field of HE-SIG-A1.
uint16_t GetLength(void) const
Return the LENGTH field of L-SIG (in bytes).
uint16_t m_length
LENGTH field.
uint32_t Deserialize(Buffer::Iterator start)
iterator in a Buffer instance
Definition: buffer.h:98
TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
static TypeId GetTypeId(void)
Get the type ID.
TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
void Serialize(Buffer::Iterator start) const
uint32_t GetSerializedSize(void) const
void SetMcs(uint8_t mcs)
Fill the MCS field of HE-SIG-A1.
uint8_t m_rate
RATE field.
void SetNStreams(uint8_t nStreams)
Fill the number of streams field of VHT-SIG-A1.
void Print(std::ostream &os) const
uint32_t GetSerializedSize(void) const
void SetSuMcs(uint8_t mcs)
Fill the SU VHT MCS field of VHT-SIG-A2.
bool m_mu
This is used to decide whether MU SIG-B should be added or not.
uint32_t GetSerializedSize(void) const
bool GetShortGuardInterval(void) const
Return the short guard interval field of HT-SIG.
uint16_t GetLength(void) const
Return the LENGTH field of L-SIG (in bytes).
Implements the IEEE 802.11 OFDM and ERP OFDM L-SIG PHY header.
void SetMuFlag(bool mu)
Set the Multi-User (MU) flag.
uint8_t GetNStreams(void) const
Return the number of streams.
void SetLength(uint16_t length)
Fill the LENGTH field of L-SIG (in bytes).
uint8_t GetNStreams(void) const
Return the number of streams.
void SetAggregation(bool aggregation)
Fill the aggregation field of HT-SIG.
void Serialize(Buffer::Iterator start) const
void SetChannelWidth(uint16_t channelWidth)
Fill the channel width field of HE-SIG-A1 (in MHz).
uint16_t m_length
LENGTH field.
uint8_t m_rate
RATE field.
static TypeId GetTypeId(void)
Get the type ID.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void Print(std::ostream &os) const
uint32_t Deserialize(Buffer::Iterator start)
uint32_t Deserialize(Buffer::Iterator start)
bool GetAggregation(void) const
Return the aggregation field of HT-SIG.
uint8_t m_sgi_disambiguation
Short GI NSYM Disambiguation.
void Serialize(Buffer::Iterator start) const
uint8_t GetMcs(void) const
Return the MCS field of HT-SIG.
uint8_t m_suMcs
SU VHT MCS.
uint8_t m_sgi
Short GI.
void SetChannelWidth(uint16_t channelWidth)
Fill the channel width field of HT-SIG (in MHz).
uint64_t GetRate(void) const
Return the RATE field of L-SIG (in bit/s).
void Serialize(Buffer::Iterator start) const
Implements the IEEE 802.11n PHY header (HT-SIG1/2).
bool m_mu
This is used to decide whether MU SIG-B should be added or not.
static TypeId GetTypeId(void)
Get the type ID.
void SetHtLength(uint16_t length)
Fill the HT length field of HT-SIG (in bytes).
uint8_t GetSuMcs(void) const
Return the SU VHT MCS field of VHT-SIG-A2.
bool GetShortGuardInterval(void) const
Return the short GI field of VHT-SIG-A2.
Implements the IEEE 802.11ax HE-SIG PHY header (HE-SIG-A1/A2/B)
Implements the IEEE 802.11 DSSS SIG PHY header.
uint16_t GetHtLength(void) const
Return the HT length field of HT-SIG (in bytes).
void SetGuardIntervalAndLtfSize(uint16_t gi, uint8_t ltf)
Fill the GI + LTF size field of HE-SIG-A1.
void SetLength(uint16_t length)
Fill the LENGTH field of L-SIG (in bytes).
TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
void SetShortGuardInterval(bool sgi)
Fill the short guard interval field of VHT-SIG-A2.
uint32_t Deserialize(Buffer::Iterator start)
uint16_t GetGuardInterval(void) const
Return the guard interval (in nanoseconds).
uint32_t GetSerializedSize(void) const
uint64_t GetRate(uint16_t channelWidth=20) const
Return the RATE field of L-SIG (in bit/s).
uint8_t m_mcs
Modulation and Coding Scheme index.
uint8_t GetBssColor(void) const
Return the BSS Color field in the HE-SIG-A1.
static TypeId GetTypeId(void)
Get the type ID.
void SetShortGuardInterval(bool sgi)
Fill the short guard interval field of HT-SIG.
uint32_t GetSerializedSize(void) const
a unique identifier for an interface.
Definition: type-id.h:58
uint8_t m_aggregation
Aggregation.
bool GetShortGuardIntervalDisambiguation(void) const
Return the short GI NSYM disambiguation field of VHT-SIG-A2.
TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
uint8_t m_bssColor
BSS color field.