A Discrete-Event Network Simulator
API
wifi-mac-header.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2006, 2009 INRIA
4  * Copyright (c) 2009 MIRKO BANCHI
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation;
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
20  * Author: Mirko Banchi <mk.banchi@gmail.com>
21  */
22 
23 #ifndef WIFI_MAC_HEADER_H
24 #define WIFI_MAC_HEADER_H
25 
26 #include "ns3/header.h"
27 #include "ns3/mac48-address.h"
28 
29 namespace ns3 {
30 
31 class Time;
32 
37 {
47 
61 
77 };
78 
84 class WifiMacHeader : public Header
85 {
86 public:
91  {
93  NO_ACK = 1,
95  BLOCK_ACK = 3,
96  };
97 
102  {
107  };
108 
109  WifiMacHeader ();
115  WifiMacHeader (WifiMacType type);
116  virtual ~WifiMacHeader ();
117 
122  static TypeId GetTypeId (void);
123  TypeId GetInstanceTypeId (void) const;
124  void Print (std::ostream &os) const;
125  uint32_t GetSerializedSize (void) const;
126  void Serialize (Buffer::Iterator start) const;
128 
132  void SetDsFrom (void);
136  void SetDsNotFrom (void);
140  void SetDsTo (void);
144  void SetDsNotTo (void);
177  void SetType (WifiMacType type, bool resetToDsFromDs = true);
183  void SetRawDuration (uint16_t duration);
190  void SetDuration (Time duration);
196  void SetId (uint16_t id);
202  void SetSequenceNumber (uint16_t seq);
208  void SetFragmentNumber (uint8_t frag);
212  void SetNoMoreFragments (void);
216  void SetMoreFragments (void);
220  void SetRetry (void);
224  void SetNoRetry (void);
230  void SetQosTid (uint8_t tid);
234  void SetQosEosp ();
238  void SetQosNoEosp ();
244  void SetQosAckPolicy (QosAckPolicy policy);
248  void SetQosAmsdu (void);
252  void SetQosNoAmsdu (void);
258  void SetQosTxopLimit (uint8_t txop);
264  void SetQosQueueSize (uint8_t size);
268  void SetQosMeshControlPresent ();
276  void SetOrder (void);
280  void SetNoOrder (void);
281 
287  Mac48Address GetAddr1 (void) const;
293  Mac48Address GetAddr2 (void) const;
299  Mac48Address GetAddr3 (void) const;
305  Mac48Address GetAddr4 (void) const;
311  WifiMacType GetType (void) const;
315  bool IsFromDs (void) const;
319  bool IsToDs (void) const;
327  bool IsData (void) const;
334  bool IsQosData (void) const;
341  bool HasData (void) const;
347  bool IsCtl (void) const;
353  bool IsMgt (void) const;
359  bool IsCfPoll (void) const;
365  bool IsCfAck (void) const;
371  bool IsCfEnd (void) const;
377  bool IsRts (void) const;
383  bool IsCts (void) const;
389  bool IsAck (void) const;
395  bool IsBlockAckReq (void) const;
401  bool IsBlockAck (void) const;
407  bool IsTrigger (void) const;
413  bool IsAssocReq (void) const;
419  bool IsAssocResp (void) const;
425  bool IsReassocReq (void) const;
431  bool IsReassocResp (void) const;
437  bool IsProbeReq (void) const;
443  bool IsProbeResp (void) const;
449  bool IsBeacon (void) const;
455  bool IsDisassociation (void) const;
461  bool IsAuthentication (void) const;
467  bool IsDeauthentication (void) const;
473  bool IsAction (void) const;
480  bool IsMultihopAction (void) const;
486  uint16_t GetRawDuration (void) const;
492  Time GetDuration (void) const;
498  uint16_t GetSequenceControl (void) const;
504  uint16_t GetSequenceNumber (void) const;
510  uint8_t GetFragmentNumber (void) const;
516  bool IsRetry (void) const;
522  bool IsMoreFragments (void) const;
528  bool IsQosBlockAck (void) const;
534  bool IsQosNoAck (void) const;
540  bool IsQosAck (void) const;
546  bool IsQosEosp (void) const;
553  bool IsQosAmsdu (void) const;
559  uint8_t GetQosTid (void) const;
565  QosAckPolicy GetQosAckPolicy (void) const;
571  uint8_t GetQosQueueSize (void) const;
578  uint32_t GetSize (void) const;
584  const char * GetTypeString (void) const;
585 
591  typedef void (* TracedCallback)(const WifiMacHeader &header);
592 
593 
594 private:
600  uint16_t GetFrameControl (void) const;
606  uint16_t GetQosControl (void) const;
612  void SetFrameControl (uint16_t control);
618  void SetSequenceControl (uint16_t seq);
624  void SetQosControl (uint16_t qos);
630  void PrintFrameControl (std::ostream &os) const;
631 
632  uint8_t m_ctrlType;
633  uint8_t m_ctrlSubtype;
634  uint8_t m_ctrlToDs;
635  uint8_t m_ctrlFromDs;
636  uint8_t m_ctrlMoreFrag;
637  uint8_t m_ctrlRetry;
638  uint8_t m_ctrlMoreData;
639  uint8_t m_ctrlWep;
640  uint8_t m_ctrlOrder;
641  uint16_t m_duration;
645  uint8_t m_seqFrag;
646  uint16_t m_seqSeq;
648  uint8_t m_qosTid;
649  uint8_t m_qosEosp;
650  uint8_t m_qosAckPolicy;
651  uint8_t m_amsduPresent;
652  uint8_t m_qosStuff;
653 };
654 
655 } //namespace ns3
656 
657 #endif /* WIFI_MAC_HEADER_H */
uint8_t m_ctrlMoreData
control more data
Protocol header serialization and deserialization.
Definition: header.h:42
bool IsRetry(void) const
Return if the Retry bit is set.
void SetRetry(void)
Set the Retry bit in the Frame Control field.
bool IsCfEnd(void) const
Return true if the header is a CF-End header.
bool IsDisassociation(void) const
Return true if the header is a Disassociation header.
void SetMoreFragments(void)
Set the More Fragment bit in the Frame Control field.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
uint16_t GetFrameControl(void) const
Return the raw Frame Control field.
void SetRawDuration(uint16_t duration)
Set the Duration/ID field with the given raw uint16_t value.
void SetFrameControl(uint16_t control)
Set the Frame Control field with the given raw value.
void SetDuration(Time duration)
Set the Duration/ID field with the given duration (Time object).
bool IsCtl(void) const
Return true if the Type is Control.
uint8_t m_ctrlType
control type
def start()
Definition: core.py:1855
Forward calls to a chain of Callback.
Mac48Address m_addr2
address 2
uint32_t GetSize(void) const
Return the size of the WifiMacHeader in octets.
void SetNoMoreFragments(void)
Un-set the More Fragment bit in the Frame Control Field.
uint8_t m_qosAckPolicy
QoS Ack policy.
Mac48Address GetAddr1(void) const
Return the address in the Address 1 field.
bool IsQosEosp(void) const
Return if the end of service period (EOSP) is set.
uint8_t m_qosEosp
QoS EOSP.
void Print(std::ostream &os) const
void SetId(uint16_t id)
Set the Duration/ID field with the given ID.
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
Definition: nstime.h:813
WifiMacType GetType(void) const
Return the type (enum WifiMacType)
void SetQosControl(uint16_t qos)
Set the QoS Control field with the given raw value.
void SetQosQueueSize(uint8_t size)
Set the Queue Size subfield in the QoS control field.
const char * GetTypeString(void) const
Return a string corresponds to the header type.
bool IsCfPoll(void) const
Return true if the Type/Subtype is one of the possible CF-Poll headers.
uint8_t m_seqFrag
sequence fragment
bool IsTrigger(void) const
Return true if the header is a Trigger header.
Mac48Address m_addr1
address 1
AddressType
Address types.
Mac48Address m_addr3
address 3
iterator in a Buffer instance
Definition: buffer.h:98
bool IsMultihopAction(void) const
Check if the header is a Multihop action header.
bool IsBlockAck(void) const
Return true if the header is a BlockAck header.
bool IsBlockAckReq(void) const
Return true if the header is a BlockAckRequest header.
bool IsAction(void) const
Return true if the header is an Action header.
void SetAddr1(Mac48Address address)
Fill the Address 1 field with the given address.
uint8_t m_ctrlToDs
control to DS
bool IsQosNoAck(void) const
Return if the QoS Ack policy is No Ack.
void SetDsNotTo(void)
Un-set the To DS bit in the Frame Control field.
uint8_t GetQosQueueSize(void) const
Get the Queue Size subfield in the QoS control field.
bool IsQosAmsdu(void) const
Check if the A-MSDU present bit is set in the QoS control field.
void SetAddr3(Mac48Address address)
Fill the Address 3 field with the given address.
bool IsBeacon(void) const
Return true if the header is a Beacon header.
void SetAddr4(Mac48Address address)
Fill the Address 4 field with the given address.
WifiMacType
Combination of valid MAC header type/subtype.
void SetOrder(void)
Set order bit in the frame control field.
bool IsFromDs(void) const
Mac48Address GetAddr3(void) const
Return the address in the Address 3 field.
uint8_t GetQosTid(void) const
Return the Traffic ID of a QoS header.
bool IsCts(void) const
Return true if the header is a CTS header.
void Serialize(Buffer::Iterator start) const
uint8_t m_amsduPresent
A-MSDU present.
Mac48Address m_addr4
address 4
uint8_t m_ctrlMoreFrag
control more fragments
uint8_t m_ctrlFromDs
control from DS
bool IsAssocResp(void) const
Return true if the header is an Association Response header.
bool IsQosAck(void) const
Return if the QoS Ack policy is Normal Ack.
bool IsAssocReq(void) const
Return true if the header is an Association Request header.
Mac48Address GetAddr2(void) const
Return the address in the Address 2 field.
uint8_t m_ctrlOrder
control order (set to 1 for QoS Data and Management frames to signify that HT/VHT/HE control field is...
void SetQosTid(uint8_t tid)
Set the TID for the QoS header.
Mac48Address GetAddr4(void) const
Return the address in the Address 4 field.
void SetSequenceControl(uint16_t seq)
Set the Sequence Control field with the given raw value.
bool IsCfAck(void) const
Return true if the header is a CF-Ack header.
void SetNoRetry(void)
Un-set the Retry bit in the Frame Control field.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint16_t GetSequenceNumber(void) const
Return the sequence number of the header.
bool IsData(void) const
Return true if the Type is DATA.
address
Definition: first.py:44
uint16_t m_seqSeq
sequence sequence
uint8_t m_qosStuff
QoS stuff.
void SetAddr2(Mac48Address address)
Fill the Address 2 field with the given address.
Time GetDuration(void) const
Return the duration from the Duration/ID field (Time object).
bool IsProbeReq(void) const
Return true if the header is a Probe Request header.
an EUI-48 address
Definition: mac48-address.h:43
TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
QosAckPolicy
Ack policy for QoS frames.
bool IsMoreFragments(void) const
Return if the More Fragment bit is set.
uint16_t m_duration
duration
uint16_t GetRawDuration(void) const
Return the raw duration from the Duration/ID field.
void SetType(WifiMacType type, bool resetToDsFromDs=true)
Set Type/Subtype values with the correct values depending on the given type.
uint8_t m_ctrlRetry
control retry
bool IsQosBlockAck(void) const
Return if the QoS Ack policy is Block Ack.
uint16_t GetQosControl(void) const
Return the raw QoS Control field.
bool IsDeauthentication(void) const
Return true if the header is a Deauthentication header.
void SetQosTxopLimit(uint8_t txop)
Set TXOP limit in the QoS control field.
bool IsMgt(void) const
Return true if the Type is Management.
void SetSequenceNumber(uint16_t seq)
Set the sequence number of the header.
bool IsProbeResp(void) const
Return true if the header is a Probe Response header.
uint32_t GetSerializedSize(void) const
void SetQosNoAmsdu(void)
Set that A-MSDU is not present.
bool IsReassocReq(void) const
Return true if the header is a Reassociation Request header.
void SetDsTo(void)
Set the To DS bit in the Frame Control field.
void SetQosEosp()
Set the end of service period (EOSP) bit in the QoS control field.
bool IsRts(void) const
Return true if the header is a RTS header.
uint32_t Deserialize(Buffer::Iterator start)
void SetDsFrom(void)
Set the From DS bit in the Frame Control field.
void SetNoOrder(void)
Unset order bit in the frame control field.
bool IsQosData(void) const
Return true if the Type is DATA and Subtype is one of the possible values for QoS Data...
bool IsAck(void) const
Return true if the header is an Ack header.
uint8_t m_qosTid
QoS TID.
void SetQosMeshControlPresent()
Set the Mesh Control Present flag for the QoS header.
void SetQosNoMeshControlPresent()
Clear the Mesh Control Present flag for the QoS header.
uint8_t m_ctrlSubtype
control subtype
void SetQosNoEosp()
Un-set the end of service period (EOSP) bit in the QoS control field.
uint8_t GetFragmentNumber(void) const
Return the fragment number of the header.
static TypeId GetTypeId(void)
Get the type ID.
bool IsAuthentication(void) const
Return true if the header is an Authentication header.
void SetFragmentNumber(uint8_t frag)
Set the fragment number of the header.
a unique identifier for an interface.
Definition: type-id.h:58
void SetQosAmsdu(void)
Set that A-MSDU is present.
void PrintFrameControl(std::ostream &os) const
Print the Frame Control field to the output stream.
Implements the IEEE 802.11 MAC header.
bool IsToDs(void) const
uint8_t m_ctrlWep
control WEP
bool IsReassocResp(void) const
Return true if the header is a Reassociation Response header.
bool HasData(void) const
Return true if the header type is DATA and is not DATA_NULL.
QosAckPolicy GetQosAckPolicy(void) const
Return the QoS Ack policy in the QoS control field.
uint16_t GetSequenceControl(void) const
Return the raw Sequence Control field.
void SetDsNotFrom(void)
Un-set the From DS bit in the Frame Control field.
void SetQosAckPolicy(QosAckPolicy policy)
Set the QoS Ack policy in the QoS control field.