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
29namespace ns3 {
30
31class Time;
32
37{
47
61
77};
78
84class WifiMacHeader : public Header
85{
86public:
91 {
93 NO_ACK = 1,
96 };
97
102 {
106 ADDR4
107 };
108
109 WifiMacHeader ();
116 virtual ~WifiMacHeader ();
117
122 static TypeId GetTypeId (void);
123
124 TypeId GetInstanceTypeId (void) const override;
125 void Print (std::ostream &os) const override;
126 uint32_t GetSerializedSize (void) const override;
127 void Serialize (Buffer::Iterator start) const override;
129
133 void SetDsFrom (void);
137 void SetDsNotFrom (void);
141 void SetDsTo (void);
145 void SetDsNotTo (void);
178 void SetType (WifiMacType type, bool resetToDsFromDs = true);
184 void SetRawDuration (uint16_t duration);
191 void SetDuration (Time duration);
197 void SetId (uint16_t id);
203 void SetSequenceNumber (uint16_t seq);
209 void SetFragmentNumber (uint8_t frag);
213 void SetNoMoreFragments (void);
217 void SetMoreFragments (void);
221 void SetRetry (void);
225 void SetNoRetry (void);
231 void SetQosTid (uint8_t tid);
235 void SetQosEosp ();
239 void SetQosNoEosp ();
245 void SetQosAckPolicy (QosAckPolicy policy);
249 void SetQosAmsdu (void);
253 void SetQosNoAmsdu (void);
259 void SetQosTxopLimit (uint8_t txop);
265 void SetQosQueueSize (uint8_t size);
277 void SetOrder (void);
281 void SetNoOrder (void);
282
288 Mac48Address GetAddr1 (void) const;
294 Mac48Address GetAddr2 (void) const;
300 Mac48Address GetAddr3 (void) const;
306 Mac48Address GetAddr4 (void) const;
312 WifiMacType GetType (void) const;
316 bool IsFromDs (void) const;
320 bool IsToDs (void) const;
328 bool IsData (void) const;
335 bool IsQosData (void) const;
342 bool HasData (void) const;
348 bool IsCtl (void) const;
354 bool IsMgt (void) const;
360 bool IsCfPoll (void) const;
366 bool IsCfAck (void) const;
372 bool IsCfEnd (void) const;
378 bool IsRts (void) const;
384 bool IsCts (void) const;
390 bool IsAck (void) const;
396 bool IsBlockAckReq (void) const;
402 bool IsBlockAck (void) const;
408 bool IsTrigger (void) const;
414 bool IsAssocReq (void) const;
420 bool IsAssocResp (void) const;
426 bool IsReassocReq (void) const;
432 bool IsReassocResp (void) const;
438 bool IsProbeReq (void) const;
444 bool IsProbeResp (void) const;
450 bool IsBeacon (void) const;
456 bool IsDisassociation (void) const;
462 bool IsAuthentication (void) const;
468 bool IsDeauthentication (void) const;
474 bool IsAction (void) const;
481 bool IsMultihopAction (void) const;
487 uint16_t GetRawDuration (void) const;
493 Time GetDuration (void) const;
499 uint16_t GetSequenceControl (void) const;
505 uint16_t GetSequenceNumber (void) const;
511 uint8_t GetFragmentNumber (void) const;
517 bool IsRetry (void) const;
523 bool IsMoreFragments (void) const;
529 bool IsQosBlockAck (void) const;
535 bool IsQosNoAck (void) const;
541 bool IsQosAck (void) const;
547 bool IsQosEosp (void) const;
554 bool IsQosAmsdu (void) const;
560 uint8_t GetQosTid (void) const;
566 QosAckPolicy GetQosAckPolicy (void) const;
572 uint8_t GetQosQueueSize (void) const;
579 uint32_t GetSize (void) const;
585 const char * GetTypeString (void) const;
586
592 typedef void (* TracedCallback)(const WifiMacHeader &header);
593
594
595private:
601 uint16_t GetFrameControl (void) const;
607 uint16_t GetQosControl (void) const;
613 void SetFrameControl (uint16_t control);
619 void SetSequenceControl (uint16_t seq);
625 void SetQosControl (uint16_t qos);
631 void PrintFrameControl (std::ostream &os) const;
632
633 uint8_t m_ctrlType;
635 uint8_t m_ctrlToDs;
636 uint8_t m_ctrlFromDs;
638 uint8_t m_ctrlRetry;
640 uint8_t m_ctrlWep;
641 uint8_t m_ctrlOrder;
642 uint16_t m_duration;
646 uint8_t m_seqFrag;
647 uint16_t m_seqSeq;
649 uint8_t m_qosTid;
650 uint8_t m_qosEosp;
653 uint8_t m_qosStuff;
654};
655
656} //namespace ns3
657
658#endif /* WIFI_MAC_HEADER_H */
iterator in a Buffer instance
Definition: buffer.h:99
Protocol header serialization and deserialization.
Definition: header.h:43
an EUI-48 address
Definition: mac48-address.h:44
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
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.
void SetDsNotFrom(void)
Un-set the From DS bit in the Frame Control field.
Mac48Address GetAddr3(void) const
Return the address in the Address 3 field.
bool IsCtl(void) const
Return true if the Type is Control.
uint8_t m_qosEosp
QoS EOSP.
uint8_t m_ctrlRetry
control retry
uint8_t GetQosTid(void) const
Return the Traffic ID of a QoS header.
bool IsTrigger(void) const
Return true if the header is a Trigger header.
bool IsQosAck(void) const
Return if the QoS Ack policy is Normal Ack.
uint8_t m_qosTid
QoS TID.
void SetQosAckPolicy(QosAckPolicy policy)
Set the QoS Ack policy in the QoS control field.
bool IsAck(void) const
Return true if the header is an Ack header.
bool IsBlockAck(void) const
Return true if the header is a BlockAck header.
AddressType
Address types.
Mac48Address GetAddr4(void) const
Return the address in the Address 4 field.
void SetRawDuration(uint16_t duration)
Set the Duration/ID field with the given raw uint16_t value.
Time GetDuration(void) const
Return the duration from the Duration/ID field (Time object).
bool HasData(void) const
Return true if the header type is DATA and is not DATA_NULL.
bool IsRts(void) const
Return true if the header is a RTS header.
void SetQosAmsdu(void)
Set that A-MSDU is present.
void SetFrameControl(uint16_t control)
Set the Frame Control field with the given raw value.
void SetNoRetry(void)
Un-set the Retry bit in the Frame Control field.
bool IsAuthentication(void) const
Return true if the header is an Authentication header.
Mac48Address m_addr1
address 1
uint16_t m_seqSeq
sequence sequence
bool IsQosData(void) const
Return true if the Type is DATA and Subtype is one of the possible values for QoS Data.
void SetNoMoreFragments(void)
Un-set the More Fragment bit in the Frame Control Field.
bool IsFromDs(void) const
uint16_t GetSequenceNumber(void) const
Return the sequence number of the header.
void SetQosTxopLimit(uint8_t txop)
Set TXOP limit in the QoS control field.
bool IsCts(void) const
Return true if the header is a CTS header.
static TypeId GetTypeId(void)
Get the type ID.
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.
uint32_t GetSize(void) const
Return the size of the WifiMacHeader in octets.
uint8_t m_amsduPresent
A-MSDU present.
void SetDsTo(void)
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 IsReassocResp(void) const
Return true if the header is a Reassociation Response header.
Mac48Address GetAddr2(void) const
Return the address in the Address 2 field.
uint16_t GetRawDuration(void) const
Return the raw duration from the Duration/ID field.
bool IsAssocReq(void) const
Return true if the header is an Association Request header.
Mac48Address m_addr4
address 4
Mac48Address m_addr2
address 2
void SetAddr1(Mac48Address address)
Fill the Address 1 field with the given address.
bool IsQosNoAck(void) const
Return if the QoS Ack policy is No Ack.
bool IsCfEnd(void) const
Return true if the header is a CF-End header.
void SetSequenceControl(uint16_t seq)
Set the Sequence Control field with the given raw value.
bool IsProbeResp(void) const
Return true if the header is a Probe Response header.
void SetQosQueueSize(uint8_t size)
Set the Queue Size subfield in the QoS control field.
void SetType(WifiMacType type, bool resetToDsFromDs=true)
Set Type/Subtype values with the correct values depending on the given type.
uint16_t GetQosControl(void) const
Return the raw QoS Control field.
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...
bool IsRetry(void) const
Return if the Retry bit is set.
uint8_t m_ctrlFromDs
control from DS
uint16_t GetFrameControl(void) const
Return the raw Frame Control field.
uint16_t m_duration
duration
const char * GetTypeString(void) const
Return a string corresponds to the header type.
uint8_t m_ctrlWep
control WEP
bool IsReassocReq(void) 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(void) const
Return the QoS Ack policy in the QoS control field.
void SetRetry(void)
Set the Retry bit in the Frame Control field.
bool IsMultihopAction(void) const
Check if the header is a Multihop action header.
void SetDuration(Time duration)
Set the Duration/ID field with the given duration (Time object).
TypeId GetInstanceTypeId(void) const override
Get the most derived TypeId for this Object.
bool IsCfPoll(void) const
Return true if the Type/Subtype is one of the possible CF-Poll headers.
bool IsDisassociation(void) const
Return true if the header is a Disassociation header.
void SetQosNoEosp()
Un-set the end of service period (EOSP) bit in the QoS control field.
uint8_t m_seqFrag
sequence fragment
bool IsDeauthentication(void) const
Return true if the header is a Deauthentication header.
bool IsAction(void) const
Return true if the header is an Action header.
uint8_t m_ctrlMoreData
control more data
void SetDsNotTo(void)
Un-set the To DS bit in the Frame Control field.
bool IsBlockAckReq(void) const
Return true if the header is a BlockAckRequest header.
bool IsProbeReq(void) const
Return true if the header is a Probe Request header.
void Print(std::ostream &os) const override
bool IsMgt(void) const
Return true if the Type is Management.
Mac48Address GetAddr1(void) const
Return the address in the Address 1 field.
bool IsAssocResp(void) const
Return true if the header is an Association Response header.
void SetQosNoMeshControlPresent()
Clear the Mesh Control Present flag for the QoS header.
uint32_t GetSerializedSize(void) const override
void SetNoOrder(void)
Unset order bit in the frame control field.
uint8_t m_qosStuff
QoS stuff.
void SetQosNoAmsdu(void)
Set that A-MSDU is not present.
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.
bool IsData(void) const
Return true if the Type is DATA.
void SetId(uint16_t id)
Set the Duration/ID field with the given ID.
void SetMoreFragments(void)
Set the More Fragment bit in the Frame Control field.
uint32_t Deserialize(Buffer::Iterator start) override
bool IsQosEosp(void) const
Return if the end of service period (EOSP) is set.
void SetDsFrom(void)
Set the From DS bit in the Frame Control field.
WifiMacType GetType(void) const
Return the type (enum WifiMacType)
void SetQosEosp()
Set the end of service period (EOSP) bit in the QoS control field.
void Serialize(Buffer::Iterator start) const override
bool IsMoreFragments(void) const
Return if the More Fragment bit is set.
void SetAddr3(Mac48Address address)
Fill the Address 3 field with the given address.
void SetFragmentNumber(uint8_t frag)
Set the fragment number of the header.
void SetQosMeshControlPresent()
Set the Mesh Control Present flag for the QoS header.
uint16_t GetSequenceControl(void) const
Return the raw Sequence Control field.
uint8_t GetFragmentNumber(void) const
Return the fragment number of the header.
bool IsToDs(void) const
Mac48Address m_addr3
address 3
uint8_t m_ctrlMoreFrag
control more fragments
void SetOrder(void)
Set order bit in the frame control field.
QosAckPolicy
Ack policy for QoS frames.
bool IsQosAmsdu(void) const
Check if the A-MSDU present bit is set in the QoS control field.
uint8_t m_ctrlToDs
control to DS
bool IsCfAck(void) const
Return true if the header is a CF-Ack header.
uint8_t m_qosAckPolicy
QoS Ack policy.
bool IsQosBlockAck(void) const
Return if the QoS Ack policy is Block Ack.
bool IsBeacon(void) const
Return true if the header is a Beacon header.
address
Definition: first.py:40
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
Definition: nstime.h:794
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_CTL_TRIGGER
@ 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_RTS
@ 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_MGT_ACTION
@ WIFI_MAC_MGT_ASSOCIATION_RESPONSE
@ 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_DATA_NULL_CFPOLL
@ WIFI_MAC_MGT_PROBE_RESPONSE
@ WIFI_MAC_QOSDATA_CFPOLL
@ WIFI_MAC_DATA
@ WIFI_MAC_MGT_REASSOCIATION_RESPONSE
@ WIFI_MAC_QOSDATA
def start()
Definition: core.py:1852