A Discrete-Event Network Simulator
API
wifi-mac-header.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2006, 2009 INRIA
3  * Copyright (c) 2009 MIRKO BANCHI
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: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  * Author: Mirko Banchi <mk.banchi@gmail.com>
20  */
21 
22 #ifndef WIFI_MAC_HEADER_H
23 #define WIFI_MAC_HEADER_H
24 
25 #include "ns3/header.h"
26 #include "ns3/mac48-address.h"
27 
28 namespace ns3
29 {
30 
31 class Time;
32 
37 {
48 
58 
72 
88 
90 };
91 
97 class WifiMacHeader : public Header
98 {
99  public:
104  {
106  NO_ACK = 1,
109  };
110 
115  {
119  ADDR4
120  };
121 
122  WifiMacHeader();
129  ~WifiMacHeader() override;
130 
135  static TypeId GetTypeId();
136 
137  TypeId GetInstanceTypeId() const override;
138  void Print(std::ostream& os) const override;
139  uint32_t GetSerializedSize() const override;
140  void Serialize(Buffer::Iterator start) const override;
141  uint32_t Deserialize(Buffer::Iterator start) override;
142 
146  void SetDsFrom();
150  void SetDsNotFrom();
154  void SetDsTo();
158  void SetDsNotTo();
191  virtual void SetType(WifiMacType type, bool resetToDsFromDs = true);
197  void SetRawDuration(uint16_t duration);
204  void SetDuration(Time duration);
210  void SetId(uint16_t id);
216  void SetSequenceNumber(uint16_t seq);
222  void SetFragmentNumber(uint8_t frag);
226  void SetNoMoreFragments();
230  void SetMoreFragments();
234  void SetRetry();
238  void SetNoRetry();
242  void SetPowerManagement();
246  void SetNoPowerManagement();
252  void SetQosTid(uint8_t tid);
256  void SetQosEosp();
260  void SetQosNoEosp();
266  void SetQosAckPolicy(QosAckPolicy policy);
270  void SetQosAmsdu();
274  void SetQosNoAmsdu();
280  void SetQosTxopLimit(uint8_t txop);
286  void SetQosQueueSize(uint8_t size);
298  void SetOrder();
302  void SetNoOrder();
303 
309  Mac48Address GetAddr1() const;
315  Mac48Address GetAddr2() const;
321  Mac48Address GetAddr3() const;
327  Mac48Address GetAddr4() const;
333  virtual WifiMacType GetType() const;
337  bool IsFromDs() const;
341  bool IsToDs() const;
349  bool IsData() const;
356  bool IsQosData() const;
363  bool HasData() const;
369  bool IsCtl() const;
375  bool IsMgt() const;
381  bool IsCfPoll() const;
387  bool IsCfAck() const;
393  bool IsCfEnd() const;
399  bool IsPsPoll() const;
405  bool IsRts() const;
411  bool IsCts() const;
417  bool IsAck() const;
423  bool IsBlockAckReq() const;
429  bool IsBlockAck() const;
435  bool IsTrigger() const;
441  bool IsAssocReq() const;
447  bool IsAssocResp() const;
453  bool IsReassocReq() const;
459  bool IsReassocResp() const;
465  bool IsProbeReq() const;
471  bool IsProbeResp() const;
477  bool IsBeacon() const;
483  bool IsDisassociation() const;
489  bool IsAuthentication() const;
495  bool IsDeauthentication() const;
501  bool IsAction() const;
507  bool IsActionNoAck() const;
514  bool IsMultihopAction() const;
520  uint16_t GetRawDuration() const;
526  Time GetDuration() const;
532  uint16_t GetSequenceControl() const;
538  uint16_t GetSequenceNumber() const;
544  uint8_t GetFragmentNumber() const;
550  bool IsRetry() const;
556  bool IsPowerManagement() const;
562  bool IsMoreData() const;
568  bool IsMoreFragments() const;
574  bool IsQosBlockAck() const;
580  bool IsQosNoAck() const;
586  bool IsQosAck() const;
592  bool IsQosEosp() const;
599  bool IsQosAmsdu() const;
605  uint8_t GetQosTid() const;
617  uint8_t GetQosQueueSize() const;
624  virtual uint32_t GetSize() const;
630  virtual const char* GetTypeString() const;
631 
637  typedef void (*TracedCallback)(const WifiMacHeader& header);
638 
639  protected:
645  virtual uint16_t GetFrameControl() const;
651  virtual uint16_t GetQosControl() const;
657  virtual void SetFrameControl(uint16_t control);
663  void SetSequenceControl(uint16_t seq);
669  virtual void SetQosControl(uint16_t qos);
675  void PrintFrameControl(std::ostream& os) const;
676 
677  uint8_t m_ctrlType;
678  uint8_t m_ctrlSubtype;
679  uint8_t m_ctrlToDs;
680  uint8_t m_ctrlFromDs;
681  uint8_t m_ctrlMoreFrag;
682  uint8_t m_ctrlRetry;
684  uint8_t m_ctrlMoreData;
685  uint8_t m_ctrlWep;
686  uint8_t m_ctrlOrder;
689  uint16_t m_duration;
693  uint8_t m_seqFrag;
694  uint16_t m_seqSeq;
696  uint8_t m_qosTid;
697  uint8_t m_qosEosp;
698  uint8_t m_qosAckPolicy;
699  uint8_t m_amsduPresent;
700  uint8_t m_qosStuff;
701 };
702 
703 } // namespace ns3
704 
705 #endif /* WIFI_MAC_HEADER_H */
iterator in a Buffer instance
Definition: buffer.h:100
Protocol header serialization and deserialization.
Definition: header.h:44
virtual uint32_t Deserialize(Buffer::Iterator start)=0
Deserialize the object from a buffer iterator.
an EUI-48 address
Definition: mac48-address.h:46
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition: type-id.h:59
Implements the IEEE 802.11 MAC header.
uint8_t GetQosTid() const
Return the Traffic ID of a QoS header.
bool IsCfAck() const
Return true if the header is a CF-Ack header.
uint8_t m_qosEosp
QoS EOSP.
uint8_t m_ctrlRetry
control retry
uint8_t m_qosTid
QoS TID.
uint8_t m_ctrlPowerManagement
control power management
bool IsAssocReq() const
Return true if the header is an Association Request header.
bool IsCfPoll() const
Return true if the Type/Subtype is one of the possible CF-Poll headers.
void SetQosAckPolicy(QosAckPolicy policy)
Set the QoS Ack policy in the QoS control field.
bool IsAck() const
Return true if the header is an Ack header.
AddressType
Address types.
uint16_t GetRawDuration() const
Return the raw duration from the Duration/ID field.
void SetRawDuration(uint16_t duration)
Set the Duration/ID field with the given raw uint16_t value.
bool IsProbeReq() const
Return true if the header is a Probe Request header.
bool IsBlockAckReq() const
Return true if the header is a BlockAckRequest header.
bool IsQosAmsdu() const
Check if the A-MSDU present bit is set in the QoS control field.
bool IsCts() const
Return true if the header is a CTS header.
Mac48Address GetAddr3() const
Return the address in the Address 3 field.
void SetQosAmsdu()
Set that A-MSDU is present.
virtual uint16_t GetFrameControl() const
Return the raw Frame Control field.
Mac48Address GetAddr4() const
Return the address in the Address 4 field.
virtual void SetFrameControl(uint16_t control)
Set the Frame Control field with the given raw value.
bool IsBeacon() const
Return true if the header is a Beacon header.
uint32_t GetSerializedSize() const override
bool IsAssocResp() const
Return true if the header is an Association Response header.
Mac48Address GetAddr1() const
Return the address in the Address 1 field.
uint16_t GetSequenceNumber() const
Return the sequence number of the header.
bool IsDisassociation() const
Return true if the header is a Disassociation header.
Mac48Address m_addr1
address 1
uint16_t m_seqSeq
sequence sequence
bool IsMoreFragments() const
Return if the More Fragment bit is set.
void SetRetry()
Set the Retry bit in the Frame Control field.
uint16_t GetSequenceControl() const
Return the raw Sequence Control field.
bool IsTrigger() const
Return true if the header is a Trigger header.
void SetQosTxopLimit(uint8_t txop)
Set TXOP limit in the QoS control field.
virtual WifiMacType GetType() const
Return the type (WifiMacType)
void SetNoMoreFragments()
Un-set the More Fragment bit in the Frame Control Field.
bool IsRetry() const
Return if the Retry bit is set.
bool IsActionNoAck() const
Return true if the header is an Action No Ack header.
bool IsMgt() const
Return true if the Type is Management.
bool IsCtl() const
Return true if the Type is Control.
Time GetDuration() const
Return the duration from the Duration/ID field (Time object).
virtual void SetQosControl(uint16_t qos)
Set the QoS Control field with the given raw value.
uint8_t m_ctrlSubtype
control subtype
void SetSequenceNumber(uint16_t seq)
Set the sequence number of the header.
void SetNoOrder()
Unset order bit in the frame control field.
virtual uint32_t GetSize() const
Return the size of the WifiMacHeader in octets.
uint8_t m_amsduPresent
A-MSDU present.
bool IsCfEnd() const
Return true if the header is a CF-End header.
void SetDsNotFrom()
Un-set the From DS bit in the Frame Control field.
virtual uint16_t GetQosControl() const
Return the raw QoS Control field.
bool IsProbeResp() const
Return true if the header is a Probe Response header.
bool IsAction() const
Return true if the header is an Action header.
void SetMoreFragments()
Set the More Fragment bit in the Frame Control field.
bool IsQosEosp() const
Return if the end of service period (EOSP) is set.
Mac48Address m_addr4
address 4
Mac48Address m_addr2
address 2
void SetAddr1(Mac48Address address)
Fill the Address 1 field with the given address.
void SetOrder()
Set order bit in the frame control field.
void SetSequenceControl(uint16_t seq)
Set the Sequence Control field with the given raw value.
void SetQosQueueSize(uint8_t size)
Set the Queue Size subfield in the QoS control field.
void SetQosNoAmsdu()
Set that A-MSDU is not present.
bool IsBlockAck() const
Return true if the header is a BlockAck header.
virtual void SetType(WifiMacType type, bool resetToDsFromDs=true)
Set Type/Subtype values with the correct values depending on the given type.
void SetAddr4(Mac48Address address)
Fill the Address 4 field with the given address.
uint8_t m_ctrlOrder
control order (set to 1 for QoS Data and Management frames to signify that HT/VHT/HE control field is...
uint8_t m_ctrlFromDs
control from DS
Mac48Address GetAddr2() const
Return the address in the Address 2 field.
uint16_t m_duration
duration
virtual const char * GetTypeString() const
Return a string corresponds to the header type.
uint8_t m_ctrlWep
control WEP
bool HasData() const
Return true if the header type is DATA and is not DATA_NULL.
bool IsReassocReq() const
Return true if the header is a Reassociation Request header.
void SetQosTid(uint8_t tid)
Set the TID for the QoS header.
QosAckPolicy GetQosAckPolicy() const
Return the QoS Ack policy in the QoS control field.
void SetDuration(Time duration)
Set the Duration/ID field with the given duration (Time object).
bool IsData() const
Return true if the Type is DATA.
void SetQosNoEosp()
Un-set the end of service period (EOSP) bit in the QoS control field.
uint8_t m_seqFrag
sequence fragment
uint8_t m_ctrlMoreData
control more data
bool IsReassocResp() const
Return true if the header is a Reassociation Response header.
bool IsRts() const
Return true if the header is a RTS header.
static TypeId GetTypeId()
Get the type ID.
bool IsQosAck() const
Return if the QoS Ack policy is Normal Ack.
void Print(std::ostream &os) const override
bool IsMoreData() const
Return if the More Data bit is set.
void SetQosNoMeshControlPresent()
Clear the Mesh Control Present flag for the QoS header.
void SetDsFrom()
Set the From DS bit in the Frame Control field.
bool IsQosNoAck() const
Return if the QoS Ack policy is No Ack.
uint8_t m_qosStuff
QoS stuff.
void SetDsTo()
Set the To DS bit in the Frame Control field.
void PrintFrameControl(std::ostream &os) const
Print the Frame Control field to the output stream.
uint8_t m_ctrlType
control type
void SetAddr2(Mac48Address address)
Fill the Address 2 field with the given address.
void SetId(uint16_t id)
Set the Duration/ID field with the given ID.
bool IsQosBlockAck() const
Return if the QoS Ack policy is Block Ack.
bool IsPsPoll() const
Return true if the header is a PS-POLL header.
uint8_t GetFragmentNumber() const
Return the fragment number of the header.
bool IsQosData() const
Return true if the Type is DATA and Subtype is one of the possible values for QoS Data.
void SetQosEosp()
Set the end of service period (EOSP) bit in the QoS control field.
void Serialize(Buffer::Iterator start) const override
uint8_t GetQosQueueSize() const
Get the Queue Size subfield in the QoS control field.
void SetAddr3(Mac48Address address)
Fill the Address 3 field with the given address.
void SetDsNotTo()
Un-set the To DS bit in the Frame Control field.
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
void SetFragmentNumber(uint8_t frag)
Set the fragment number of the header.
void SetQosMeshControlPresent()
Set the Mesh Control Present flag for the QoS header.
Mac48Address m_addr3
address 3
bool IsPowerManagement() const
Return if the Power Management bit is set.
void SetPowerManagement()
Set the Power Management bit in the Frame Control field.
uint8_t m_ctrlMoreFrag
control more fragments
QosAckPolicy
Ack policy for QoS frames.
bool IsMultihopAction() const
Check if the header is a Multihop action header.
void SetNoRetry()
Un-set the Retry bit in the Frame Control field.
bool IsDeauthentication() const
Return true if the header is a Deauthentication header.
~WifiMacHeader() override
uint8_t m_ctrlToDs
control to DS
bool IsAuthentication() const
Return true if the header is an Authentication header.
void SetNoPowerManagement()
Un-set the Power Management bit in the Frame Control field.
uint8_t m_qosAckPolicy
QoS Ack policy.
address
Definition: first.py:47
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
Definition: nstime.h:839
Every class exported by the ns3 library is enclosed in the ns3 namespace.
WifiMacType
Combination of valid MAC header type/subtype.
@ WIFI_MAC_QOSDATA_NULL_CFACK_CFPOLL
@ WIFI_MAC_EXTENSION_DMG_BEACON
@ WIFI_MAC_CTL_TRIGGER
@ WIFI_MAC_CTL_DMG_SSW_ACK
@ WIFI_MAC_MGT_PROBE_REQUEST
@ WIFI_MAC_CTL_END_ACK
@ WIFI_MAC_DATA_CFACK
@ WIFI_MAC_CTL_BACKREQ
@ WIFI_MAC_DATA_NULL
@ WIFI_MAC_CTL_PSPOLL
@ WIFI_MAC_CTL_DMG_POLL
@ WIFI_MAC_CTL_DMG_GRANT_ACK
@ WIFI_MAC_CTL_RTS
@ WIFI_MAC_CTL_DMG_CTS
@ WIFI_MAC_CTL_CTS
@ WIFI_MAC_MGT_AUTHENTICATION
@ WIFI_MAC_MGT_MULTIHOP_ACTION
@ WIFI_MAC_CTL_CTLWRAPPER
@ WIFI_MAC_QOSDATA_CFACK_CFPOLL
@ WIFI_MAC_MGT_BEACON
@ WIFI_MAC_CTL_DMG_GRANT
@ WIFI_MAC_MGT_ACTION
@ WIFI_MAC_MGT_ASSOCIATION_RESPONSE
@ WIFI_MAC_CTL_DMG_SPR
@ WIFI_MAC_CTL_ACK
@ WIFI_MAC_MGT_DISASSOCIATION
@ WIFI_MAC_QOSDATA_NULL_CFPOLL
@ WIFI_MAC_MGT_ASSOCIATION_REQUEST
@ WIFI_MAC_DATA_NULL_CFACK_CFPOLL
@ WIFI_MAC_MGT_REASSOCIATION_REQUEST
@ WIFI_MAC_QOSDATA_CFACK
@ WIFI_MAC_CTL_BACKRESP
@ WIFI_MAC_DATA_CFACK_CFPOLL
@ WIFI_MAC_DATA_CFPOLL
@ WIFI_MAC_CTL_END
@ WIFI_MAC_DATA_NULL_CFACK
@ WIFI_MAC_MGT_ACTION_NO_ACK
@ WIFI_MAC_MGT_DEAUTHENTICATION
@ WIFI_MAC_QOSDATA_NULL
@ WIFI_MAC_CTL_DMG_DTS
@ WIFI_MAC_DATA_NULL_CFPOLL
@ WIFI_MAC_MGT_PROBE_RESPONSE
@ WIFI_MAC_QOSDATA_CFPOLL
@ WIFI_MAC_DATA
@ WIFI_MAC_CTL_DMG_SSW
@ WIFI_MAC_MGT_REASSOCIATION_RESPONSE
@ WIFI_MAC_CTL_DMG_SSW_FBCK
@ WIFI_MAC_QOSDATA