OLD | NEW |
(Empty) | |
| 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/uinteger.h" |
| 26 |
| 27 namespace ns3 { |
| 28 |
| 29 QosWifiMacHelper::QosWifiMacHelper () |
| 30 { |
| 31 m_aggregators.insert (std::make_pair (AC_VO, ObjectFactory ())); |
| 32 m_aggregators.insert (std::make_pair (AC_VI, ObjectFactory ())); |
| 33 m_aggregators.insert (std::make_pair (AC_BE, ObjectFactory ())); |
| 34 m_aggregators.insert (std::make_pair (AC_BK, ObjectFactory ())); |
| 35 |
| 36 m_queues.insert (std::make_pair (AC_VO, ObjectFactory ())); |
| 37 m_queues.insert (std::make_pair (AC_VI, ObjectFactory ())); |
| 38 m_queues.insert (std::make_pair (AC_BE, ObjectFactory ())); |
| 39 m_queues.insert (std::make_pair (AC_BK, ObjectFactory ())); |
| 40 |
| 41 m_queues[AC_VO].SetTypeId ("ns3::EdcaTxopN"); |
| 42 m_queues[AC_VI].SetTypeId ("ns3::EdcaTxopN"); |
| 43 m_queues[AC_BE].SetTypeId ("ns3::EdcaTxopN"); |
| 44 m_queues[AC_BK].SetTypeId ("ns3::EdcaTxopN"); |
| 45 } |
| 46 |
| 47 QosWifiMacHelper::~QosWifiMacHelper () |
| 48 {} |
| 49 |
| 50 QosWifiMacHelper |
| 51 QosWifiMacHelper::Default (void) |
| 52 { |
| 53 QosWifiMacHelper helper; |
| 54 helper.SetType ("ns3::QstaWifiMac"); |
| 55 /* For more details about this default parameters see IEE802.11 section 7.3.2.
29 */ |
| 56 helper.SetEdcaParametersForAc (AC_VO,"MinCw", UintegerValue (3), |
| 57 "MaxCw", UintegerValue (7), |
| 58 "Aifsn", UintegerValue (2)); |
| 59 helper.SetEdcaParametersForAc (AC_VI,"MinCw", UintegerValue (7), |
| 60 "MaxCw", UintegerValue (15), |
| 61 "Aifsn", UintegerValue (2)); |
| 62 helper.SetEdcaParametersForAc (AC_BE,"MinCw", UintegerValue (15), |
| 63 "MaxCw", UintegerValue (1023), |
| 64 "Aifsn", UintegerValue (3)); |
| 65 helper.SetEdcaParametersForAc (AC_BK,"MinCw", UintegerValue (15), |
| 66 "MaxCw", UintegerValue (1023), |
| 67 "Aifsn", UintegerValue (7)); |
| 68 return helper; |
| 69 } |
| 70 |
| 71 void |
| 72 QosWifiMacHelper::SetType (std::string type, |
| 73 std::string n0, const AttributeValue &v0, |
| 74 std::string n1, const AttributeValue &v1, |
| 75 std::string n2, const AttributeValue &v2, |
| 76 std::string n3, const AttributeValue &v3, |
| 77 std::string n4, const AttributeValue &v4, |
| 78 std::string n5, const AttributeValue &v5, |
| 79 std::string n6, const AttributeValue &v6, |
| 80 std::string n7, const AttributeValue &v7) |
| 81 { |
| 82 m_mac.SetTypeId (type); |
| 83 m_mac.Set (n0, v0); |
| 84 m_mac.Set (n1, v1); |
| 85 m_mac.Set (n2, v2); |
| 86 m_mac.Set (n3, v3); |
| 87 m_mac.Set (n4, v4); |
| 88 m_mac.Set (n5, v5); |
| 89 m_mac.Set (n6, v6); |
| 90 m_mac.Set (n7, v7); |
| 91 } |
| 92 |
| 93 void |
| 94 QosWifiMacHelper::SetMsduAggregatorForAc (AccessClass accessClass, std::string t
ype, |
| 95 std::string n0, const AttributeValue &
v0, |
| 96 std::string n1, const AttributeValue &
v1, |
| 97 std::string n2, const AttributeValue &
v2, |
| 98 std::string n3, const AttributeValue &
v3) |
| 99 { |
| 100 std::map<AccessClass, ObjectFactory>::iterator it; |
| 101 it = m_aggregators.find (accessClass); |
| 102 if (it != m_aggregators.end ()) |
| 103 { |
| 104 it->second.SetTypeId (type); |
| 105 it->second.Set (n0, v0); |
| 106 it->second.Set (n1, v1); |
| 107 it->second.Set (n2, v2); |
| 108 it->second.Set (n3, v3); |
| 109 } |
| 110 } |
| 111 |
| 112 void |
| 113 QosWifiMacHelper::SetEdcaParametersForAc (AccessClass accessClass, |
| 114 std::string n0, const AttributeValue &
v0, |
| 115 std::string n1, const AttributeValue &
v1, |
| 116 std::string n2, const AttributeValue &
v2, |
| 117 std::string n3, const AttributeValue &
v3) |
| 118 { |
| 119 std::map<AccessClass, ObjectFactory>::iterator it; |
| 120 it = m_queues.find (accessClass); |
| 121 if (it != m_queues.end ()) |
| 122 { |
| 123 it->second.Set (n0, v0); |
| 124 it->second.Set (n1, v1); |
| 125 it->second.Set (n2, v2); |
| 126 it->second.Set (n3, v3); |
| 127 } |
| 128 } |
| 129 |
| 130 Ptr<WifiMac> |
| 131 QosWifiMacHelper::Create (void) const |
| 132 { |
| 133 Ptr<WifiMac> mac = m_mac.Create<WifiMac> (); |
| 134 ·· |
| 135 Ptr<EdcaTxopN> edcaQueue; |
| 136 Ptr<MsduAggregator> aggregator; |
| 137 std::map<AccessClass, ObjectFactory>::const_iterator itQueue; |
| 138 std::map<AccessClass, ObjectFactory>::const_iterator itAggr; |
| 139 |
| 140 /* Setting for VO queue */ |
| 141 itQueue = m_queues.find (AC_VO); |
| 142 itAggr = m_aggregators.find (AC_VO); |
| 143 |
| 144 edcaQueue = itQueue->second.Create<EdcaTxopN> (); |
| 145 if (itAggr->second.GetTypeId ().GetUid () != 0) |
| 146 { |
| 147 aggregator = itAggr->second.Create<MsduAggregator> (); |
| 148 edcaQueue->SetMsduAggregator (aggregator); |
| 149 } |
| 150 mac->SetAttribute ("VO_EdcaTxopN", PointerValue (edcaQueue)); |
| 151 |
| 152 /* Setting for VI queue */ |
| 153 itQueue = m_queues.find (AC_VI); |
| 154 itAggr = m_aggregators.find (AC_VI); |
| 155 |
| 156 edcaQueue = itQueue->second.Create<EdcaTxopN> (); |
| 157 if (itAggr->second.GetTypeId ().GetUid () != 0) |
| 158 { |
| 159 aggregator = itAggr->second.Create<MsduAggregator> (); |
| 160 edcaQueue->SetMsduAggregator (aggregator); |
| 161 } |
| 162 mac->SetAttribute ("VI_EdcaTxopN", PointerValue (edcaQueue)); |
| 163 |
| 164 /* Setting for BE queue */ |
| 165 itQueue = m_queues.find (AC_BE); |
| 166 itAggr = m_aggregators.find (AC_BE); |
| 167 |
| 168 edcaQueue = itQueue->second.Create<EdcaTxopN> (); |
| 169 if (itAggr->second.GetTypeId ().GetUid () != 0) |
| 170 { |
| 171 aggregator = itAggr->second.Create<MsduAggregator> (); |
| 172 edcaQueue->SetMsduAggregator (aggregator); |
| 173 } |
| 174 mac->SetAttribute ("BE_EdcaTxopN", PointerValue (edcaQueue)); |
| 175 ·· |
| 176 /* Setting for BK queue */ |
| 177 itQueue = m_queues.find (AC_BK); |
| 178 itAggr = m_aggregators.find (AC_BK); |
| 179 |
| 180 edcaQueue = itQueue->second.Create<EdcaTxopN> (); |
| 181 if (itAggr->second.GetTypeId ().GetUid () != 0) |
| 182 { |
| 183 aggregator = itAggr->second.Create<MsduAggregator> (); |
| 184 edcaQueue->SetMsduAggregator (aggregator); |
| 185 } |
| 186 mac->SetAttribute ("BK_EdcaTxopN", PointerValue (edcaQueue)); |
| 187 |
| 188 return mac; |
| 189 } |
| 190 |
| 191 } //namespace ns3 |
OLD | NEW |