A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 #include "qos-wifi-mac-helper.h"
21 #include "ns3/msdu-aggregator.h"
22 #include "ns3/wifi-mac.h"
23 #include "ns3/edca-txop-n.h"
24 #include "ns3/pointer.h"
25 #include "ns3/boolean.h"
26 #include "ns3/uinteger.h"
27 
28 namespace ns3 {
29 
31 {
32 }
33 
35 {
36 }
37 
40 {
41  QosWifiMacHelper helper;
42 
43  // We're making QoS-enabled Wi-Fi MACs here, so we set the necessary
44  // attribute. I've carefully positioned this here so that someone
45  // who knows what they're doing can override with explicit
46  // attributes.
47  helper.SetType ("ns3::StaWifiMac",
48  "QosSupported", BooleanValue (true));
49 
50  return helper;
51 }
52 
53 void
54 QosWifiMacHelper::SetType (std::string type,
55  std::string n0, const AttributeValue &v0,
56  std::string n1, const AttributeValue &v1,
57  std::string n2, const AttributeValue &v2,
58  std::string n3, const AttributeValue &v3,
59  std::string n4, const AttributeValue &v4,
60  std::string n5, const AttributeValue &v5,
61  std::string n6, const AttributeValue &v6,
62  std::string n7, const AttributeValue &v7)
63 {
64  m_mac.SetTypeId (type);
65  m_mac.Set (n0, v0);
66  m_mac.Set (n1, v1);
67  m_mac.Set (n2, v2);
68  m_mac.Set (n3, v3);
69  m_mac.Set (n4, v4);
70  m_mac.Set (n5, v5);
71  m_mac.Set (n6, v6);
72  m_mac.Set (n7, v7);
73 }
74 
75 void
77  std::string n0, const AttributeValue &v0,
78  std::string n1, const AttributeValue &v1,
79  std::string n2, const AttributeValue &v2,
80  std::string n3, const AttributeValue &v3)
81 {
82  std::map<AcIndex, ObjectFactory>::iterator it = m_aggregators.find (ac);
83  if (it != m_aggregators.end ())
84  {
85  it->second.SetTypeId (type);
86  it->second.Set (n0, v0);
87  it->second.Set (n1, v1);
88  it->second.Set (n2, v2);
89  it->second.Set (n3, v3);
90  }
91  else
92  {
93  ObjectFactory factory;
94  factory.SetTypeId (type);
95  factory.Set (n0, v0);
96  factory.Set (n1, v1);
97  factory.Set (n2, v2);
98  factory.Set (n3, v3);
99  m_aggregators.insert (std::make_pair (ac, factory));
100  }
101 }
102 
103 void
105 {
106  m_bAckThresholds[ac] = threshold;
107 }
108 
109 void
111 {
113 }
114 
115 void
116 QosWifiMacHelper::Setup (Ptr<WifiMac> mac, enum AcIndex ac, std::string dcaAttrName) const
117 {
118  std::map<AcIndex, ObjectFactory>::const_iterator it = m_aggregators.find (ac);
119  PointerValue ptr;
120  mac->GetAttribute (dcaAttrName, ptr);
121  Ptr<EdcaTxopN> edca = ptr.Get<EdcaTxopN> ();
122 
123  if (it != m_aggregators.end ())
124  {
125  ObjectFactory factory = it->second;
126  Ptr<MsduAggregator> aggregator = factory.Create<MsduAggregator> ();
127  edca->SetMsduAggregator (aggregator);
128  }
129  if (m_bAckThresholds.find (ac) != m_bAckThresholds.end ())
130  {
131  edca->SetBlockAckThreshold (m_bAckThresholds.find (ac)->second);
132  }
133  if (m_bAckInactivityTimeouts.find (ac) != m_bAckInactivityTimeouts.end ())
134  {
135  edca->SetBlockAckInactivityTimeout (m_bAckInactivityTimeouts.find (ac)->second);
136  }
137 }
138 
139 
142 {
143  Ptr<WifiMac> mac = m_mac.Create<WifiMac> ();
144 
145  Setup (mac, AC_VO, "VO_EdcaTxopN");
146  Setup (mac, AC_VI, "VI_EdcaTxopN");
147  Setup (mac, AC_BE, "BE_EdcaTxopN");
148  Setup (mac, AC_BK, "BK_EdcaTxopN");
149 
150  return mac;
151 }
152 
153 } // namespace ns3