author | Dean Armstrong <deanarm@gmail.com> |
Wed, 01 Dec 2010 22:13:26 +0000 | |
changeset 6674 | 52f8688d6d01 |
parent 6673 | ec22aa763e2d |
permissions | -rw-r--r-- |
4408 | 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" |
|
6673
ec22aa763e2d
Bug 978: Consolidate Wi-Fi MAC high functionality
Dean Armstrong <deanarm@gmail.com>
parents:
6331
diff
changeset
|
25 |
#include "ns3/boolean.h" |
4408 | 26 |
#include "ns3/uinteger.h" |
27 |
||
28 |
namespace ns3 { |
|
29 |
||
30 |
QosWifiMacHelper::QosWifiMacHelper () |
|
6674
52f8688d6d01
Bug 978: Run check-style.py on files touched in the reorganisation
Dean Armstrong <deanarm@gmail.com>
parents:
6673
diff
changeset
|
31 |
{ |
52f8688d6d01
Bug 978: Run check-style.py on files touched in the reorganisation
Dean Armstrong <deanarm@gmail.com>
parents:
6673
diff
changeset
|
32 |
} |
4408 | 33 |
|
34 |
QosWifiMacHelper::~QosWifiMacHelper () |
|
6674
52f8688d6d01
Bug 978: Run check-style.py on files touched in the reorganisation
Dean Armstrong <deanarm@gmail.com>
parents:
6673
diff
changeset
|
35 |
{ |
52f8688d6d01
Bug 978: Run check-style.py on files touched in the reorganisation
Dean Armstrong <deanarm@gmail.com>
parents:
6673
diff
changeset
|
36 |
} |
4408 | 37 |
|
38 |
QosWifiMacHelper |
|
39 |
QosWifiMacHelper::Default (void) |
|
40 |
{ |
|
41 |
QosWifiMacHelper helper; |
|
6673
ec22aa763e2d
Bug 978: Consolidate Wi-Fi MAC high functionality
Dean Armstrong <deanarm@gmail.com>
parents:
6331
diff
changeset
|
42 |
|
ec22aa763e2d
Bug 978: Consolidate Wi-Fi MAC high functionality
Dean Armstrong <deanarm@gmail.com>
parents:
6331
diff
changeset
|
43 |
// We're making QoS-enabled Wi-Fi MACs here, so we set the necessary |
ec22aa763e2d
Bug 978: Consolidate Wi-Fi MAC high functionality
Dean Armstrong <deanarm@gmail.com>
parents:
6331
diff
changeset
|
44 |
// attribute. I've carefully positioned this here so that someone |
ec22aa763e2d
Bug 978: Consolidate Wi-Fi MAC high functionality
Dean Armstrong <deanarm@gmail.com>
parents:
6331
diff
changeset
|
45 |
// who knows what they're doing can override with explicit |
ec22aa763e2d
Bug 978: Consolidate Wi-Fi MAC high functionality
Dean Armstrong <deanarm@gmail.com>
parents:
6331
diff
changeset
|
46 |
// attributes. |
ec22aa763e2d
Bug 978: Consolidate Wi-Fi MAC high functionality
Dean Armstrong <deanarm@gmail.com>
parents:
6331
diff
changeset
|
47 |
helper.SetType ("ns3::StaWifiMac", |
ec22aa763e2d
Bug 978: Consolidate Wi-Fi MAC high functionality
Dean Armstrong <deanarm@gmail.com>
parents:
6331
diff
changeset
|
48 |
"QosSupported", BooleanValue (true)); |
ec22aa763e2d
Bug 978: Consolidate Wi-Fi MAC high functionality
Dean Armstrong <deanarm@gmail.com>
parents:
6331
diff
changeset
|
49 |
|
4408 | 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 |
|
6331
eee2eab36748
Bug 910: Replace AccessClass with 802.11-style AcIndex
Dean Armstrong <deanarm@gmail.com>
parents:
6294
diff
changeset
|
76 |
QosWifiMacHelper::SetMsduAggregatorForAc (AcIndex ac, std::string type, |
4408 | 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 |
{ |
|
6331
eee2eab36748
Bug 910: Replace AccessClass with 802.11-style AcIndex
Dean Armstrong <deanarm@gmail.com>
parents:
6294
diff
changeset
|
82 |
std::map<AcIndex, ObjectFactory>::iterator it = m_aggregators.find (ac); |
4408 | 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 |
} |
|
5467
c7aa69502cdd
A-MSDU aggregation is not a default feature.
Mirko Banchi <mk.banchi@gmail.com>
parents:
4720
diff
changeset
|
91 |
else |
c7aa69502cdd
A-MSDU aggregation is not a default feature.
Mirko Banchi <mk.banchi@gmail.com>
parents:
4720
diff
changeset
|
92 |
{ |
c7aa69502cdd
A-MSDU aggregation is not a default feature.
Mirko Banchi <mk.banchi@gmail.com>
parents:
4720
diff
changeset
|
93 |
ObjectFactory factory; |
c7aa69502cdd
A-MSDU aggregation is not a default feature.
Mirko Banchi <mk.banchi@gmail.com>
parents:
4720
diff
changeset
|
94 |
factory.SetTypeId (type); |
c7aa69502cdd
A-MSDU aggregation is not a default feature.
Mirko Banchi <mk.banchi@gmail.com>
parents:
4720
diff
changeset
|
95 |
factory.Set (n0, v0); |
c7aa69502cdd
A-MSDU aggregation is not a default feature.
Mirko Banchi <mk.banchi@gmail.com>
parents:
4720
diff
changeset
|
96 |
factory.Set (n1, v1); |
c7aa69502cdd
A-MSDU aggregation is not a default feature.
Mirko Banchi <mk.banchi@gmail.com>
parents:
4720
diff
changeset
|
97 |
factory.Set (n2, v2); |
c7aa69502cdd
A-MSDU aggregation is not a default feature.
Mirko Banchi <mk.banchi@gmail.com>
parents:
4720
diff
changeset
|
98 |
factory.Set (n3, v3); |
6331
eee2eab36748
Bug 910: Replace AccessClass with 802.11-style AcIndex
Dean Armstrong <deanarm@gmail.com>
parents:
6294
diff
changeset
|
99 |
m_aggregators.insert (std::make_pair (ac, factory)); |
5467
c7aa69502cdd
A-MSDU aggregation is not a default feature.
Mirko Banchi <mk.banchi@gmail.com>
parents:
4720
diff
changeset
|
100 |
} |
4408 | 101 |
} |
102 |
||
103 |
void |
|
6331
eee2eab36748
Bug 910: Replace AccessClass with 802.11-style AcIndex
Dean Armstrong <deanarm@gmail.com>
parents:
6294
diff
changeset
|
104 |
QosWifiMacHelper::SetBlockAckThresholdForAc (enum AcIndex ac, uint8_t threshold) |
6294
6cefb3c0696a
add methods in QosWifiMacHelper for block ack parameters setup
Mirko Banchi <mk.banchi@gmail.com>
parents:
5467
diff
changeset
|
105 |
{ |
6331
eee2eab36748
Bug 910: Replace AccessClass with 802.11-style AcIndex
Dean Armstrong <deanarm@gmail.com>
parents:
6294
diff
changeset
|
106 |
m_bAckThresholds[ac] = threshold; |
6294
6cefb3c0696a
add methods in QosWifiMacHelper for block ack parameters setup
Mirko Banchi <mk.banchi@gmail.com>
parents:
5467
diff
changeset
|
107 |
} |
6cefb3c0696a
add methods in QosWifiMacHelper for block ack parameters setup
Mirko Banchi <mk.banchi@gmail.com>
parents:
5467
diff
changeset
|
108 |
|
6cefb3c0696a
add methods in QosWifiMacHelper for block ack parameters setup
Mirko Banchi <mk.banchi@gmail.com>
parents:
5467
diff
changeset
|
109 |
void |
6331
eee2eab36748
Bug 910: Replace AccessClass with 802.11-style AcIndex
Dean Armstrong <deanarm@gmail.com>
parents:
6294
diff
changeset
|
110 |
QosWifiMacHelper::SetBlockAckInactivityTimeoutForAc (enum AcIndex ac, uint16_t timeout) |
6294
6cefb3c0696a
add methods in QosWifiMacHelper for block ack parameters setup
Mirko Banchi <mk.banchi@gmail.com>
parents:
5467
diff
changeset
|
111 |
{ |
6331
eee2eab36748
Bug 910: Replace AccessClass with 802.11-style AcIndex
Dean Armstrong <deanarm@gmail.com>
parents:
6294
diff
changeset
|
112 |
m_bAckInactivityTimeouts[ac] = timeout; |
6294
6cefb3c0696a
add methods in QosWifiMacHelper for block ack parameters setup
Mirko Banchi <mk.banchi@gmail.com>
parents:
5467
diff
changeset
|
113 |
} |
6cefb3c0696a
add methods in QosWifiMacHelper for block ack parameters setup
Mirko Banchi <mk.banchi@gmail.com>
parents:
5467
diff
changeset
|
114 |
|
6cefb3c0696a
add methods in QosWifiMacHelper for block ack parameters setup
Mirko Banchi <mk.banchi@gmail.com>
parents:
5467
diff
changeset
|
115 |
void |
6331
eee2eab36748
Bug 910: Replace AccessClass with 802.11-style AcIndex
Dean Armstrong <deanarm@gmail.com>
parents:
6294
diff
changeset
|
116 |
QosWifiMacHelper::Setup (Ptr<WifiMac> mac, enum AcIndex ac, std::string dcaAttrName) const |
4408 | 117 |
{ |
6331
eee2eab36748
Bug 910: Replace AccessClass with 802.11-style AcIndex
Dean Armstrong <deanarm@gmail.com>
parents:
6294
diff
changeset
|
118 |
std::map<AcIndex, ObjectFactory>::const_iterator it = m_aggregators.find (ac); |
6294
6cefb3c0696a
add methods in QosWifiMacHelper for block ack parameters setup
Mirko Banchi <mk.banchi@gmail.com>
parents:
5467
diff
changeset
|
119 |
PointerValue ptr; |
6cefb3c0696a
add methods in QosWifiMacHelper for block ack parameters setup
Mirko Banchi <mk.banchi@gmail.com>
parents:
5467
diff
changeset
|
120 |
mac->GetAttribute (dcaAttrName, ptr); |
6cefb3c0696a
add methods in QosWifiMacHelper for block ack parameters setup
Mirko Banchi <mk.banchi@gmail.com>
parents:
5467
diff
changeset
|
121 |
Ptr<EdcaTxopN> edca = ptr.Get<EdcaTxopN> (); |
6674
52f8688d6d01
Bug 978: Run check-style.py on files touched in the reorganisation
Dean Armstrong <deanarm@gmail.com>
parents:
6673
diff
changeset
|
122 |
|
5467
c7aa69502cdd
A-MSDU aggregation is not a default feature.
Mirko Banchi <mk.banchi@gmail.com>
parents:
4720
diff
changeset
|
123 |
if (it != m_aggregators.end ()) |
c7aa69502cdd
A-MSDU aggregation is not a default feature.
Mirko Banchi <mk.banchi@gmail.com>
parents:
4720
diff
changeset
|
124 |
{ |
c7aa69502cdd
A-MSDU aggregation is not a default feature.
Mirko Banchi <mk.banchi@gmail.com>
parents:
4720
diff
changeset
|
125 |
ObjectFactory factory = it->second; |
c7aa69502cdd
A-MSDU aggregation is not a default feature.
Mirko Banchi <mk.banchi@gmail.com>
parents:
4720
diff
changeset
|
126 |
Ptr<MsduAggregator> aggregator = factory.Create<MsduAggregator> (); |
c7aa69502cdd
A-MSDU aggregation is not a default feature.
Mirko Banchi <mk.banchi@gmail.com>
parents:
4720
diff
changeset
|
127 |
edca->SetMsduAggregator (aggregator); |
c7aa69502cdd
A-MSDU aggregation is not a default feature.
Mirko Banchi <mk.banchi@gmail.com>
parents:
4720
diff
changeset
|
128 |
} |
6294
6cefb3c0696a
add methods in QosWifiMacHelper for block ack parameters setup
Mirko Banchi <mk.banchi@gmail.com>
parents:
5467
diff
changeset
|
129 |
if (m_bAckThresholds.find (ac) != m_bAckThresholds.end ()) |
6cefb3c0696a
add methods in QosWifiMacHelper for block ack parameters setup
Mirko Banchi <mk.banchi@gmail.com>
parents:
5467
diff
changeset
|
130 |
{ |
6cefb3c0696a
add methods in QosWifiMacHelper for block ack parameters setup
Mirko Banchi <mk.banchi@gmail.com>
parents:
5467
diff
changeset
|
131 |
edca->SetBlockAckThreshold (m_bAckThresholds.find(ac)->second); |
6cefb3c0696a
add methods in QosWifiMacHelper for block ack parameters setup
Mirko Banchi <mk.banchi@gmail.com>
parents:
5467
diff
changeset
|
132 |
} |
6cefb3c0696a
add methods in QosWifiMacHelper for block ack parameters setup
Mirko Banchi <mk.banchi@gmail.com>
parents:
5467
diff
changeset
|
133 |
if (m_bAckInactivityTimeouts.find (ac) != m_bAckInactivityTimeouts.end ()) |
6cefb3c0696a
add methods in QosWifiMacHelper for block ack parameters setup
Mirko Banchi <mk.banchi@gmail.com>
parents:
5467
diff
changeset
|
134 |
{ |
6cefb3c0696a
add methods in QosWifiMacHelper for block ack parameters setup
Mirko Banchi <mk.banchi@gmail.com>
parents:
5467
diff
changeset
|
135 |
edca->SetBlockAckInactivityTimeout (m_bAckInactivityTimeouts.find(ac)->second); |
6cefb3c0696a
add methods in QosWifiMacHelper for block ack parameters setup
Mirko Banchi <mk.banchi@gmail.com>
parents:
5467
diff
changeset
|
136 |
} |
4408 | 137 |
} |
138 |
||
4720
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4408
diff
changeset
|
139 |
|
4408 | 140 |
Ptr<WifiMac> |
141 |
QosWifiMacHelper::Create (void) const |
|
142 |
{ |
|
143 |
Ptr<WifiMac> mac = m_mac.Create<WifiMac> (); |
|
6674
52f8688d6d01
Bug 978: Run check-style.py on files touched in the reorganisation
Dean Armstrong <deanarm@gmail.com>
parents:
6673
diff
changeset
|
144 |
|
4720
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4408
diff
changeset
|
145 |
Setup (mac, AC_VO, "VO_EdcaTxopN"); |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4408
diff
changeset
|
146 |
Setup (mac, AC_VI, "VI_EdcaTxopN"); |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4408
diff
changeset
|
147 |
Setup (mac, AC_BE, "BE_EdcaTxopN"); |
15221757964f
bug 641: CwMin setting for 802.11b
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4408
diff
changeset
|
148 |
Setup (mac, AC_BK, "BK_EdcaTxopN"); |
4408 | 149 |
|
150 |
return mac; |
|
151 |
} |
|
152 |
||
153 |
} //namespace ns3 |