A Discrete-Event Network Simulator
API
qos-wifi-mac-helper.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
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: Mirko Banchi <mk.banchi@gmail.com>
19  */
20 
21 #include "qos-wifi-mac-helper.h"
22 #include "ns3/msdu-aggregator.h"
23 #include "ns3/wifi-mac.h"
24 #include "ns3/edca-txop-n.h"
25 #include "ns3/pointer.h"
26 #include "ns3/boolean.h"
27 #include "ns3/uinteger.h"
28 #include "ns3/mpdu-aggregator.h"
29 #include "ns3/mac-low.h"
30 
31 namespace ns3 {
32 
34 {
35 }
36 
38 {
39 }
40 
43 {
44  QosWifiMacHelper helper;
45 
46  //We're making QoS-enabled Wi-Fi MACs here, so we set the necessary
47  //attribute. I've carefully positioned this here so that someone
48  //who knows what they're doing can override with explicit attributes.
49  helper.SetType ("ns3::StaWifiMac",
50  "QosSupported", BooleanValue (true));
51 
52  return helper;
53 }
54 
55 void
56 QosWifiMacHelper::SetType (std::string type,
57  std::string n0, const AttributeValue &v0,
58  std::string n1, const AttributeValue &v1,
59  std::string n2, const AttributeValue &v2,
60  std::string n3, const AttributeValue &v3,
61  std::string n4, const AttributeValue &v4,
62  std::string n5, const AttributeValue &v5,
63  std::string n6, const AttributeValue &v6,
64  std::string n7, const AttributeValue &v7)
65 {
66  m_mac.SetTypeId (type);
67  m_mac.Set (n0, v0);
68  m_mac.Set (n1, v1);
69  m_mac.Set (n2, v2);
70  m_mac.Set (n3, v3);
71  m_mac.Set (n4, v4);
72  m_mac.Set (n5, v5);
73  m_mac.Set (n6, v6);
74  m_mac.Set (n7, v7);
75 }
76 
77 void
79  std::string n0, const AttributeValue &v0,
80  std::string n1, const AttributeValue &v1,
81  std::string n2, const AttributeValue &v2,
82  std::string n3, const AttributeValue &v3)
83 {
84  std::map<AcIndex, ObjectFactory>::iterator it = m_aggregators.find (ac);
85  if (it != m_aggregators.end ())
86  {
87  it->second.SetTypeId (type);
88  it->second.Set (n0, v0);
89  it->second.Set (n1, v1);
90  it->second.Set (n2, v2);
91  it->second.Set (n3, v3);
92  }
93  else
94  {
95  ObjectFactory factory;
96  factory.SetTypeId (type);
97  factory.Set (n0, v0);
98  factory.Set (n1, v1);
99  factory.Set (n2, v2);
100  factory.Set (n3, v3);
101  m_aggregators.insert (std::make_pair (ac, factory));
102  }
103 }
104 
105 void
107  std::string n0, const AttributeValue &v0,
108  std::string n1, const AttributeValue &v1,
109  std::string n2, const AttributeValue &v2,
110  std::string n3, const AttributeValue &v3)
111 {
114  m_mpduAggregator.Set (n0, v0);
115  m_mpduAggregator.Set (n1, v1);
116  m_mpduAggregator.Set (n2, v2);
117  m_mpduAggregator.Set (n3, v3);
118 }
119 
120 void
122 {
123  m_bAckThresholds[ac] = threshold;
124 }
125 
126 void
128 {
130 }
131 
132 void
133 QosWifiMacHelper::Setup (Ptr<WifiMac> mac, enum AcIndex ac, std::string dcaAttrName) const
134 {
135  std::map<AcIndex, ObjectFactory>::const_iterator it = m_aggregators.find (ac);
136  PointerValue ptr;
137  mac->GetAttribute (dcaAttrName, ptr);
138  Ptr<EdcaTxopN> edca = ptr.Get<EdcaTxopN> ();
139 
140  if (m_mpduAggregator.GetTypeId ().GetUid () != 0)
141  {
143  Ptr<MacLow> low = edca->Low ();
144  low->SetMpduAggregator (mpduaggregator);
145  }
146  if (it != m_aggregators.end ())
147  {
148  ObjectFactory factory = it->second;
149  Ptr<MsduAggregator> aggregator = factory.Create<MsduAggregator> ();
150  edca->SetMsduAggregator (aggregator);
151  }
152  if (m_bAckThresholds.find (ac) != m_bAckThresholds.end ())
153  {
154  edca->SetBlockAckThreshold (m_bAckThresholds.find (ac)->second);
155  }
156  if (m_bAckInactivityTimeouts.find (ac) != m_bAckInactivityTimeouts.end ())
157  {
158  edca->SetBlockAckInactivityTimeout (m_bAckInactivityTimeouts.find (ac)->second);
159  }
160 }
161 
164 {
166 
167  Setup (mac, AC_VO, "VO_EdcaTxopN");
168  Setup (mac, AC_VI, "VI_EdcaTxopN");
169  Setup (mac, AC_BE, "BE_EdcaTxopN");
170  Setup (mac, AC_BK, "BK_EdcaTxopN");
171 
172  return mac;
173 }
174 
175 } //namespace ns3
Abstract class that concrete mpdu aggregators have to implement.
std::map< AcIndex, ObjectFactory > m_aggregators
TypeId GetTypeId(void) const
Get the TypeId which will be created by this ObjectFactory.
Ptr< T > Get(void) const
Definition: pointer.h:194
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
AttributeValue implementation for Boolean.
Definition: boolean.h:34
void SetBlockAckInactivityTimeout(uint16_t timeout)
Hold a value for an Attribute.
Definition: attribute.h:68
virtual void SetType(std::string type, std::string n0="", const AttributeValue &v0=EmptyAttributeValue(), std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue())
Set the underlying type of the MAC and its attributes.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
void SetMsduAggregatorForAc(AcIndex ac, std::string type, std::string n0="", const AttributeValue &v0=EmptyAttributeValue(), std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue())
Set the class, type and attributes for the Msdu aggregator.
std::map< AcIndex, uint8_t > m_bAckThresholds
ns3::Time timeout
Video.
Definition: qos-utils.h:43
Voice.
Definition: qos-utils.h:45
Best Effort.
Definition: qos-utils.h:39
Ptr< MacLow > Low(void)
Return the MacLow associated with this EdcaTxopN.
Definition: edca-txop-n.cc:430
Background.
Definition: qos-utils.h:41
This queue contains packets for a particular access class.
Definition: edca-txop-n.h:82
void SetBlockAckThresholdForAc(enum AcIndex ac, uint8_t threshold)
This method sets value of block ack threshold for a specific access class.
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
base class for all MAC-level wifi objects.
Definition: wifi-mac.h:44
std::map< AcIndex, uint16_t > m_bAckInactivityTimeouts
void SetMpduAggregatorForAc(enum AcIndex ac, std::string type, std::string n0="", const AttributeValue &v0=EmptyAttributeValue(), std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue())
Set the class, type and attributes for the Mpdu aggregator.
void SetBlockAckThreshold(uint8_t threshold)
Set threshold for block ACK mechanism.
QosWifiMacHelper()
Create a QosWifiMacHelper that is used to make life easier when working with Wifi devices using a QOS...
static QosWifiMacHelper Default(void)
Create a mac helper in a default working state.
tuple mac
Definition: third.py:92
create QoS-enabled MAC layers for a ns3::WifiNetDevice.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Hold objects of type Ptr.
Definition: pointer.h:36
virtual ~QosWifiMacHelper()
Destroy a QosWifiMacHelper.
virtual Ptr< WifiMac > Create(void) const
void Set(std::string name, const AttributeValue &value)
Set an attribute to be set during construction.
uint16_t GetUid(void) const
Get the internal id of this TypeId.
Definition: type-id.cc:1051
void SetMsduAggregator(Ptr< MsduAggregator > aggr)
void Setup(Ptr< WifiMac > mac, enum AcIndex ac, std::string dcaAttrName) const
Instantiate subclasses of ns3::Object.
void SetBlockAckInactivityTimeoutForAc(enum AcIndex ac, uint16_t timeout)
Sets value of block ack inactivity timeout for a specific access class.
Abstract class that concrete msdu aggregators have to implement.
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition: qos-utils.h:36
void SetMpduAggregator(Ptr< MpduAggregator > aggregator)
Set up MpduAggregator associated with this MacLow.
Definition: mac-low.cc:2705