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/mpdu-aggregator.h"
24 #include "ns3/wifi-mac.h"
25 #include "ns3/edca-txop-n.h"
26 #include "ns3/pointer.h"
27 #include "ns3/boolean.h"
28 #include "ns3/uinteger.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  std::string n8, const AttributeValue &v8,
66  std::string n9, const AttributeValue &v9,
67  std::string n10, const AttributeValue &v10)
68 {
69  m_mac.SetTypeId (type);
70  m_mac.Set (n0, v0);
71  m_mac.Set (n1, v1);
72  m_mac.Set (n2, v2);
73  m_mac.Set (n3, v3);
74  m_mac.Set (n4, v4);
75  m_mac.Set (n5, v5);
76  m_mac.Set (n6, v6);
77  m_mac.Set (n7, v7);
78  m_mac.Set (n8, v8);
79  m_mac.Set (n9, v9);
80  m_mac.Set (n10, v10);
81 }
82 
83 void
85  std::string n0, const AttributeValue &v0,
86  std::string n1, const AttributeValue &v1,
87  std::string n2, const AttributeValue &v2,
88  std::string n3, const AttributeValue &v3)
89 {
90  std::map<AcIndex, ObjectFactory>::iterator it = m_msduAggregators.find (ac);
91  if (it != m_msduAggregators.end ())
92  {
93  it->second.SetTypeId (type);
94  it->second.Set (n0, v0);
95  it->second.Set (n1, v1);
96  it->second.Set (n2, v2);
97  it->second.Set (n3, v3);
98  }
99  else
100  {
101  ObjectFactory factory;
102  factory.SetTypeId (type);
103  factory.Set (n0, v0);
104  factory.Set (n1, v1);
105  factory.Set (n2, v2);
106  factory.Set (n3, v3);
107  m_msduAggregators.insert (std::make_pair (ac, factory));
108  }
109 }
110 
111 void
113  std::string n0, const AttributeValue &v0,
114  std::string n1, const AttributeValue &v1,
115  std::string n2, const AttributeValue &v2,
116  std::string n3, const AttributeValue &v3)
117 {
118  std::map<AcIndex, ObjectFactory>::iterator it = m_mpduAggregators.find (ac);
119  if (it != m_mpduAggregators.end ())
120  {
121  it->second.SetTypeId (type);
122  it->second.Set (n0, v0);
123  it->second.Set (n1, v1);
124  it->second.Set (n2, v2);
125  it->second.Set (n3, v3);
126  }
127  else
128  {
129  ObjectFactory factory;
130  factory.SetTypeId (type);
131  factory.Set (n0, v0);
132  factory.Set (n1, v1);
133  factory.Set (n2, v2);
134  factory.Set (n3, v3);
135  m_mpduAggregators.insert (std::make_pair (ac, factory));
136  }
137 }
138 
139 void
141 {
142  m_bAckThresholds[ac] = threshold;
143 }
144 
145 void
147 {
149 }
150 
151 void
152 QosWifiMacHelper::Setup (Ptr<WifiMac> mac, enum AcIndex ac, std::string edcaAttrName) const
153 {
154  PointerValue ptr;
155  mac->GetAttribute (edcaAttrName, ptr);
156  Ptr<EdcaTxopN> edca = ptr.Get<EdcaTxopN> ();
157 
158  std::map<AcIndex, ObjectFactory>::const_iterator it_msdu = m_msduAggregators.find (ac);
159  if (it_msdu != m_msduAggregators.end ())
160  {
161  ObjectFactory factory = it_msdu->second;
162  Ptr<MsduAggregator> msduAggregator = factory.Create<MsduAggregator> ();
163  edca->SetMsduAggregator (msduAggregator);
164  }
165 
166  std::map<AcIndex, ObjectFactory>::const_iterator it_mpdu = m_mpduAggregators.find (ac);
167  if (it_mpdu != m_mpduAggregators.end ())
168  {
169  ObjectFactory factory = it_mpdu->second;
170  Ptr<MpduAggregator> mpduAggregator = factory.Create<MpduAggregator> ();
171  edca->SetMpduAggregator (mpduAggregator);
172  }
173 
174  if (m_bAckThresholds.find (ac) != m_bAckThresholds.end ())
175  {
176  edca->SetBlockAckThreshold (m_bAckThresholds.find (ac)->second);
177  }
178 
179  if (m_bAckInactivityTimeouts.find (ac) != m_bAckInactivityTimeouts.end ())
180  {
181  edca->SetBlockAckInactivityTimeout (m_bAckInactivityTimeouts.find (ac)->second);
182  }
183 }
184 
187 {
189 
190  Setup (mac, AC_VO, "VO_EdcaTxopN");
191  Setup (mac, AC_VI, "VI_EdcaTxopN");
192  Setup (mac, AC_BE, "BE_EdcaTxopN");
193  Setup (mac, AC_BK, "BK_EdcaTxopN");
194 
195  return mac;
196 }
197 
198 } //namespace ns3
Abstract class that concrete mpdu aggregators have to implement.
std::map< AcIndex, ObjectFactory > m_mpduAggregators
A-MPDU aggregators.
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:36
std::map< AcIndex, ObjectFactory > m_msduAggregators
A-MSDU aggregators.
void SetBlockAckInactivityTimeout(uint16_t timeout)
Set the Block Ack inactivity timeout.
Hold a value for an Attribute.
Definition: attribute.h:68
void Setup(Ptr< WifiMac > mac, enum AcIndex ac, std::string edcaAttrName) const
Setup function.
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
Block ACK thresholds.
ns3::Time timeout
Video.
Definition: qos-utils.h:45
Voice.
Definition: qos-utils.h:47
Best Effort.
Definition: qos-utils.h:41
Background.
Definition: qos-utils.h:43
This queue contains packets for a particular access class.
Definition: edca-txop-n.h:68
void SetBlockAckThresholdForAc(enum AcIndex ac, uint8_t threshold)
This method sets value of block ack threshold for a specific access class.
ObjectFactory m_mac
MAC object.
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:41
std::map< AcIndex, uint16_t > m_bAckInactivityTimeouts
Block ACK inactivity timeouts.
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.
void SetMsduAggregator(const Ptr< MsduAggregator > aggr)
Set the aggregator used to construct A-MSDU subframes.
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.
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(), std::string n8="", const AttributeValue &v8=EmptyAttributeValue(), std::string n9="", const AttributeValue &v9=EmptyAttributeValue(), std::string n10="", const AttributeValue &v10=EmptyAttributeValue())
Set the underlying type of the MAC and its attributes.
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:38
void SetMpduAggregator(const Ptr< MpduAggregator > aggr)
Set the aggregator used to construct A-MPDU subframes.