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 #ifndef WIFI_MAC_HEADER_H
23 #define WIFI_MAC_HEADER_H
24 
25 #include "ns3/header.h"
26 #include "ns3/mac48-address.h"
27 #include "ns3/nstime.h"
28 #include <stdint.h>
29 
30 namespace ns3 {
31 
36 {
43 
57 
73 };
74 
80 class WifiMacHeader : public Header
81 {
82 public:
87  {
89  NO_ACK = 1,
91  BLOCK_ACK = 3,
92  };
93 
98  {
103  };
104 
105  WifiMacHeader ();
106  ~WifiMacHeader ();
107 
108  static TypeId GetTypeId (void);
109  virtual TypeId GetInstanceTypeId (void) const;
110  virtual void Print (std::ostream &os) const;
111  virtual uint32_t GetSerializedSize (void) const;
112  virtual void Serialize (Buffer::Iterator start) const;
113  virtual uint32_t Deserialize (Buffer::Iterator start);
114 
118  void SetAssocReq (void);
122  void SetAssocResp (void);
126  void SetProbeReq (void);
130  void SetProbeResp (void);
134  void SetBeacon (void);
139  void SetTypeData (void);
143  void SetAction ();
147  void SetBlockAckReq (void);
151  void SetBlockAck (void);
155  void SetMultihopAction ();
159  void SetDsFrom (void);
163  void SetDsNotFrom (void);
167  void SetDsTo (void);
171  void SetDsNotTo (void);
202  void SetType (enum WifiMacType type);
208  void SetRawDuration (uint16_t duration);
215  void SetDuration (Time duration);
221  void SetId (uint16_t id);
227  void SetSequenceNumber (uint16_t seq);
233  void SetFragmentNumber (uint8_t frag);
237  void SetNoMoreFragments (void);
241  void SetMoreFragments (void);
245  void SetRetry (void);
249  void SetNoRetry (void);
255  void SetQosTid (uint8_t tid);
259  void SetQosEosp ();
263  void SetQosNoEosp ();
269  void SetQosAckPolicy (enum QosAckPolicy policy);
273  void SetQosNormalAck (void);
277  void SetQosBlockAck (void);
281  void SetQosNoAck (void);
285  void SetQosAmsdu (void);
289  void SetQosNoAmsdu (void);
295  void SetQosTxopLimit (uint8_t txop);
299  void SetQosMeshControlPresent ();
307  void SetOrder (void);
311  void SetNoOrder (void);
312 
318  Mac48Address GetAddr1 (void) const;
324  Mac48Address GetAddr2 (void) const;
330  Mac48Address GetAddr3 (void) const;
336  Mac48Address GetAddr4 (void) const;
342  enum WifiMacType GetType (void) const;
346  bool IsFromDs (void) const;
350  bool IsToDs (void) const;
358  bool IsData (void) const;
365  bool IsQosData (void) const;
371  bool IsCtl (void) const;
377  bool IsMgt (void) const;
383  bool IsCfpoll (void) const;
389  bool IsRts (void) const;
395  bool IsCts (void) const;
401  bool IsAck (void) const;
407  bool IsBlockAckReq (void) const;
413  bool IsBlockAck (void) const;
419  bool IsAssocReq (void) const;
425  bool IsAssocResp (void) const;
431  bool IsReassocReq (void) const;
437  bool IsReassocResp (void) const;
443  bool IsProbeReq (void) const;
449  bool IsProbeResp (void) const;
455  bool IsBeacon (void) const;
461  bool IsDisassociation (void) const;
467  bool IsAuthentication (void) const;
473  bool IsDeauthentication (void) const;
479  bool IsAction () const;
486  bool IsMultihopAction () const;
492  uint16_t GetRawDuration (void) const;
498  Time GetDuration (void) const;
504  uint16_t GetSequenceControl (void) const;
510  uint16_t GetSequenceNumber (void) const;
516  uint16_t GetFragmentNumber (void) const;
522  bool IsRetry (void) const;
528  bool IsMoreFragments (void) const;
534  bool IsQosBlockAck (void) const;
540  bool IsQosNoAck (void) const;
546  bool IsQosAck (void) const;
552  bool IsQosEosp (void) const;
559  bool IsQosAmsdu (void) const;
565  uint8_t GetQosTid (void) const;
571  enum QosAckPolicy GetQosAckPolicy (void) const;
577  uint8_t GetQosTxopLimit (void) const;
584  uint32_t GetSize (void) const;
590  const char * GetTypeString (void) const;
591 
597  typedef void (* TracedCallback)(const WifiMacHeader &header);
598 
599 
600 private:
606  uint16_t GetFrameControl (void) const;
612  uint16_t GetQosControl (void) const;
618  void SetFrameControl (uint16_t control);
624  void SetSequenceControl (uint16_t seq);
630  void SetQosControl (uint16_t qos);
636  void PrintFrameControl (std::ostream &os) const;
637 
638  uint8_t m_ctrlType;
639  uint8_t m_ctrlSubtype;
640  uint8_t m_ctrlToDs;
641  uint8_t m_ctrlFromDs;
642  uint8_t m_ctrlMoreFrag;
643  uint8_t m_ctrlRetry;
644  uint8_t m_ctrlMoreData;
645  uint8_t m_ctrlWep;
646  uint8_t m_ctrlOrder;
647  uint16_t m_duration;
651  uint8_t m_seqFrag;
652  uint16_t m_seqSeq;
654  uint8_t m_qosTid;
655  uint8_t m_qosEosp;
656  uint8_t m_qosAckPolicy;
657  uint8_t m_amsduPresent;
658  uint16_t m_qosStuff;
659 };
660 
661 } //namespace ns3
662 
663 #endif /* WIFI_MAC_HEADER_H */
Protocol header serialization and deserialization.
Definition: header.h:42
bool IsBeacon(void) const
Return true if the header is a Beacon header.
void SetAction()
Set Type/Subtype values for an action header.
void SetRetry(void)
Set the Retry bit in the Frame Control field.
void SetMoreFragments(void)
Set the More Fragment bit in the Frame Control field.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
uint32_t GetSize(void) const
Return the size of the WifiMacHeader in octets.
uint16_t GetFragmentNumber(void) const
Return the fragment number of the header.
void SetQosAckPolicy(enum QosAckPolicy policy)
Set the QoS ACK policy in the QoS 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.
bool IsReassocResp(void) const
Return true if the header is a Reassociation Response header.
void SetProbeReq(void)
Set Type/Subtype values for a probe request header.
uint16_t GetRawDuration(void) const
Return the raw duration from the Duration/ID field.
void SetDuration(Time duration)
Set the Duration/ID field with the given duration (Time object).
bool IsAction() const
Return true if the header is an Action header.
def start()
Definition: core.py:1482
Forward calls to a chain of Callback.
Mac48Address m_addr2
Mac48Address GetAddr3(void) const
Return the address in the Address 3 field.
void SetNoMoreFragments(void)
Un-set the More Fragment bit in the Frame Control Field.
Mac48Address GetAddr4(void) const
Return the address in the Address 4 field.
enum WifiMacType GetType(void) const
Return the type (enum WifiMacType)
void SetId(uint16_t id)
Set the Duration/ID field with the given ID.
bool IsAssocReq(void) const
Return true if the header is an Association Request header.
uint16_t GetQosControl(void) const
Return the raw QoS Control field.
bool IsBlockAck(void) const
Return true if the header is a Block ACK header.
bool IsAssocResp(void) const
Return true if the header is an Association Response header.
void SetQosControl(uint16_t qos)
Set the QoS Control field with the given raw value.
uint16_t GetFrameControl(void) const
Return the raw Frame Control field.
bool IsCtl(void) const
Return true if the Type is Control.
void SetProbeResp(void)
Set Type/Subtype values for a probe response header.
void SetQosNoAck(void)
Set the QoS ACK policy in the QoS control field to no ACK.
bool IsQosAmsdu(void) const
Check if the A-MSDU present bit is set in the QoS control field.
bool IsProbeResp(void) const
Return true if the header is a Probe Response header.
Mac48Address m_addr1
Mac48Address m_addr3
iterator in a Buffer instance
Definition: buffer.h:98
bool IsCfpoll(void) const
Return true if the Type/Subtype is one of the possible CF-Poll headers.
bool IsMoreFragments(void) const
Return if the More Fragment bit is set.
Time GetDuration(void) const
Return the duration from the Duration/ID field (Time object).
uint8_t GetQosTid(void) const
Return the Traffic ID of a QoS header.
bool IsReassocReq(void) const
Return true if the header is a Reassociation Request header.
virtual uint32_t GetSerializedSize(void) const
uint8_t GetQosTxopLimit(void) const
Return the TXOP limit.
void SetAddr1(Mac48Address address)
Fill the Address 1 field with the given address.
void SetBeacon(void)
Set Type/Subtype values for a beacon header.
AddressType
Address types.
void SetDsNotTo(void)
Un-set the To DS bit in the Frame Control field.
void SetAddr3(Mac48Address address)
Fill the Address 3 field with the given address.
void SetAddr4(Mac48Address address)
Fill the Address 4 field with the given address.
WifiMacType
Combination of valid MAC header type/subtype.
uint16_t GetSequenceControl(void) const
Return the raw Sequence Control field.
bool IsProbeReq(void) const
Return true if the header is a Probe Request header.
virtual void Print(std::ostream &os) const
void SetOrder(void)
Set order bit in the frame control field.
bool IsAuthentication(void) const
Return true if the header is an Authentication header.
bool IsQosBlockAck(void) const
Return if the QoS ACK policy is Block ACK.
Mac48Address m_addr4
bool IsMgt(void) const
Return true if the Type is Management.
void SetAssocReq(void)
Set Type/Subtype values for an association request header.
void SetQosTid(uint8_t tid)
Set the TID for the QoS header.
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
void SetSequenceControl(uint16_t seq)
Set the Sequence Control field with the given raw value.
void SetNoRetry(void)
Un-set the Retry bit in the Frame Control field.
bool IsToDs(void) const
Every class exported by the ns3 library is enclosed in the ns3 namespace.
bool IsDisassociation(void) const
Return true if the header is a Disassociation header.
void SetAddr2(Mac48Address address)
Fill the Address 2 field with the given address.
QosAckPolicy
ACK policy for QoS frames.
an EUI-48 address
Definition: mac48-address.h:43
void SetBlockAck(void)
Set Type/Subtype values for a Block Ack header.
void PrintFrameControl(std::ostream &os) const
Print the Frame Control field to the output stream.
const char * GetTypeString(void) const
Return a string corresponds to the header type.
void SetAssocResp(void)
Set Type/Subtype values for an association response header.
void SetQosTxopLimit(uint8_t txop)
Set TXOP limit in the QoS control field.
void SetSequenceNumber(uint16_t seq)
Set the sequence number of the header.
bool IsData(void) const
Return true if the Type is DATA.
bool IsQosData(void) const
Return true if the Type is DATA and Subtype is one of the possible values for QoS DATA...
bool IsBlockAckReq(void) const
Return true if the header is a Block ACK Request header.
void SetQosNormalAck(void)
Set the QoS ACK policy in the QoS control field to normal ACK.
void SetTypeData(void)
Set Type/Subtype values for a data packet with no subtype equal to 0.
void SetQosNoAmsdu(void)
Set that A-MSDU is not present.
virtual void Serialize(Buffer::Iterator start) const
void SetDsTo(void)
Set the To DS bit in the Frame Control field.
bool IsFromDs(void) const
void SetQosEosp()
Set the end of service period (EOSP) bit in the QoS control field.
bool IsQosEosp(void) const
Return if the end of service period (EOSP) is set.
virtual 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 IsMultihopAction() const
Check if the header is a Multihop action header.
void SetType(enum WifiMacType type)
Set Type/Subtype values with the correct values depending on the given type.
bool IsCts(void) const
Return true if the header is a CTS header.
Mac48Address GetAddr1(void) const
Return the address in the Address 1 field.
tuple address
Definition: first.py:37
void SetQosMeshControlPresent()
Set the Mesh Control Present flag for the QoS header.
void SetQosNoMeshControlPresent()
Clear the Mesh Control Present flag for the QoS header.
void SetMultihopAction()
Set Type/Subtype values for a multihop action header.
bool IsDeauthentication(void) const
Return true if the header is a Deauthentication header.
bool IsRts(void) const
Return true if the header is a RTS header.
void SetQosNoEosp()
Un-set the end of service period (EOSP) bit in the QoS control field.
bool IsAck(void) const
Return true if the header is an ACK header.
static TypeId GetTypeId(void)
void SetFragmentNumber(uint8_t frag)
Set the fragment number of the header.
void SetBlockAckReq(void)
Set Type/Subtype values for a Block Ack Request header.
a unique identifier for an interface.
Definition: type-id.h:58
void SetQosAmsdu(void)
Set that A-MSDU is present.
enum QosAckPolicy GetQosAckPolicy(void) const
Return the QoS ACK Policy of a QoS header.
bool IsRetry(void) const
Return if the Retry bit is set.
Implements the IEEE 802.11 MAC header.
Mac48Address GetAddr2(void) const
Return the address in the Address 2 field.
bool IsQosNoAck(void) const
Return if the QoS ACK policy is No ACK.
void SetQosBlockAck(void)
Set the QoS ACK policy in the QoS control field to block ACK.
bool IsQosAck(void) const
Return if the QoS ACK policy is Normal ACK.
void SetDsNotFrom(void)
Un-set the From DS bit in the Frame Control field.
uint16_t GetSequenceNumber(void) const
Return the sequence number of the header.