A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
33 {
39 
53 
69 };
70 
76 class WifiMacHeader : public Header
77 {
78 public:
80  {
82  NO_ACK = 1,
84  BLOCK_ACK = 3,
85  };
86 
88  {
93  };
94 
95  WifiMacHeader ();
96  ~WifiMacHeader ();
97 
98  static TypeId GetTypeId (void);
99  virtual TypeId GetInstanceTypeId (void) const;
100  virtual void Print (std::ostream &os) const;
101  virtual uint32_t GetSerializedSize (void) const;
102  virtual void Serialize (Buffer::Iterator start) const;
103  virtual uint32_t Deserialize (Buffer::Iterator start);
104 
105 
106  void SetAssocReq (void);
107  void SetAssocResp (void);
108  void SetProbeReq (void);
109  void SetProbeResp (void);
110  void SetBeacon (void);
111  void SetTypeData (void);
112  void SetAction ();
113  void SetBlockAckReq (void);
114  void SetBlockAck (void);
115  void SetMultihopAction ();
116  void SetDsFrom (void);
117  void SetDsNotFrom (void);
118  void SetDsTo (void);
119  void SetDsNotTo (void);
120  void SetAddr1 (Mac48Address address);
121  void SetAddr2 (Mac48Address address);
122  void SetAddr3 (Mac48Address address);
123  void SetAddr4 (Mac48Address address);
124  void SetType (enum WifiMacType type);
125  void SetRawDuration (uint16_t duration);
126  void SetDuration (Time duration);
127  void SetId (uint16_t id);
128  void SetSequenceNumber (uint16_t seq);
129  void SetFragmentNumber (uint8_t frag);
130  void SetNoMoreFragments (void);
131  void SetMoreFragments (void);
132  void SetRetry (void);
133  void SetNoRetry (void);
134  void SetQosTid (uint8_t tid);
135  void SetQosEosp ();
136  void SetQosNoEosp ();
137  void SetQosAckPolicy (enum QosAckPolicy);
138  void SetQosNormalAck (void);
139  void SetQosBlockAck (void);
140  void SetQosNoAck (void);
141  void SetQosAmsdu (void);
142  void SetQosNoAmsdu (void);
143  void SetQosTxopLimit (uint8_t txop);
144 
145 
146  Mac48Address GetAddr1 (void) const;
147  Mac48Address GetAddr2 (void) const;
148  Mac48Address GetAddr3 (void) const;
149  Mac48Address GetAddr4 (void) const;
150  enum WifiMacType GetType (void) const;
151  bool IsFromDs (void) const;
152  bool IsToDs (void) const;
153  bool IsData (void) const;
154  bool IsQosData (void) const;
155  bool IsCtl (void) const;
156  bool IsMgt (void) const;
157  bool IsCfpoll (void) const;
158  bool IsRts (void) const;
159  bool IsCts (void) const;
160  bool IsAck (void) const;
161  bool IsBlockAckReq (void) const;
162  bool IsBlockAck (void) const;
163  bool IsAssocReq (void) const;
164  bool IsAssocResp (void) const;
165  bool IsReassocReq (void) const;
166  bool IsReassocResp (void) const;
167  bool IsProbeReq (void) const;
168  bool IsProbeResp (void) const;
169  bool IsBeacon (void) const;
170  bool IsDisassociation (void) const;
171  bool IsAuthentication (void) const;
172  bool IsDeauthentication (void) const;
173  bool IsAction () const;
174  bool IsMultihopAction () const;
175  uint16_t GetRawDuration (void) const;
176  Time GetDuration (void) const;
177  uint16_t GetSequenceControl (void) const;
178  uint16_t GetSequenceNumber (void) const;
179  uint16_t GetFragmentNumber (void) const;
180  bool IsRetry (void) const;
181  bool IsMoreFragments (void) const;
182  bool IsQosBlockAck (void) const;
183  bool IsQosNoAck (void) const;
184  bool IsQosAck (void) const;
185  bool IsQosEosp (void) const;
186  bool IsQosAmsdu (void) const;
187  uint8_t GetQosTid (void) const;
188  enum QosAckPolicy GetQosAckPolicy (void) const;
189  uint8_t GetQosTxopLimit (void) const;
190 
191  uint32_t GetSize (void) const;
192  const char * GetTypeString (void) const;
193 
194 
195 private:
196  uint16_t GetFrameControl (void) const;
197  uint16_t GetQosControl (void) const;
198  void SetFrameControl (uint16_t control);
199  void SetSequenceControl (uint16_t seq);
200  void SetQosControl (uint16_t qos);
201  void PrintFrameControl (std::ostream &os) const;
202 
203  uint8_t m_ctrlType;
204  uint8_t m_ctrlSubtype;
205  uint8_t m_ctrlToDs;
206  uint8_t m_ctrlFromDs;
207  uint8_t m_ctrlMoreFrag;
208  uint8_t m_ctrlRetry;
209  uint8_t m_ctrlPwrMgt;
210  uint8_t m_ctrlMoreData;
211  uint8_t m_ctrlWep;
212  uint8_t m_ctrlOrder;
213  uint16_t m_duration;
217  uint8_t m_seqFrag;
218  uint16_t m_seqSeq;
220  uint8_t m_qosTid;
221  uint8_t m_qosEosp;
222  uint8_t m_qosAckPolicy;
223  uint8_t m_amsduPresent;
224  uint16_t m_qosStuff;
225 };
226 
227 } // namespace ns3
228 
229 
230 
231 #endif /* WIFI_MAC_HEADER_H */