|
|
| 22 |
#include "ns3/test.h" |
22 |
#include "ns3/test.h" |
| 23 |
#include "ns3/simulator.h" |
23 |
#include "ns3/simulator.h" |
| 24 |
#include "ns3/wifi-mac-queue.h" |
24 |
#include "ns3/wifi-mac-queue.h" |
| 25 |
#include "ns3/mac-low.h" |
25 |
#include "ns3/sta-wifi-mac.h" |
| 26 |
#include "ns3/qos-txop.h" |
|
|
| 27 |
#include "ns3/yans-wifi-phy.h" |
26 |
#include "ns3/yans-wifi-phy.h" |
| 28 |
#include "ns3/mac-tx-middle.h" |
27 |
#include "ns3/mac-tx-middle.h" |
|
|
28 |
#include "ns3/mac-low.h" |
| 29 |
#include "ns3/msdu-aggregator.h" |
29 |
#include "ns3/msdu-aggregator.h" |
| 30 |
#include "ns3/mpdu-aggregator.h" |
30 |
#include "ns3/mpdu-aggregator.h" |
| 31 |
#include "ns3/mgt-headers.h" |
31 |
#include "ns3/wifi-net-device.h" |
| 32 |
#include "ns3/wifi-remote-station-manager.h" |
32 |
#include "ns3/ht-configuration.h" |
| 33 |
|
33 |
|
| 34 |
using namespace ns3; |
34 |
using namespace ns3; |
| 35 |
|
35 |
|
|
|
| 46 |
|
46 |
|
| 47 |
private: |
47 |
private: |
| 48 |
virtual void DoRun (void); |
48 |
virtual void DoRun (void); |
| 49 |
Ptr<MacLow> m_low; ///< MacLow |
49 |
Ptr<WifiNetDevice> m_device; ///<WifiNetDevice |
|
|
50 |
Ptr<StaWifiMac> m_mac; ///< Mac |
| 50 |
Ptr<YansWifiPhy> m_phy; ///< Phy |
51 |
Ptr<YansWifiPhy> m_phy; ///< Phy |
| 51 |
Ptr<QosTxop> m_txop; ///< QosTxop |
|
|
| 52 |
Ptr<MacTxMiddle> m_txMiddle; ///< MacTxMiddle |
| 53 |
Ptr<WifiRemoteStationManager> m_manager; ///< remote station manager |
52 |
Ptr<WifiRemoteStationManager> m_manager; ///< remote station manager |
| 54 |
ObjectFactory m_factory; ///< factory |
53 |
ObjectFactory m_factory; ///< factory |
| 55 |
Ptr<MpduAggregator> m_mpduAggregator; ///< A-MPDU aggregrator |
|
|
| 56 |
Ptr<ChannelAccessManager> m_channelAccessManager; ///< channel access manager |
| 57 |
}; |
54 |
}; |
| 58 |
|
55 |
|
| 59 |
AmpduAggregationTest::AmpduAggregationTest () |
56 |
AmpduAggregationTest::AmpduAggregationTest () |
|
|
| 65 |
AmpduAggregationTest::DoRun (void) |
62 |
AmpduAggregationTest::DoRun (void) |
| 66 |
{ |
63 |
{ |
| 67 |
/* |
64 |
/* |
|
|
65 |
* Create device and attach HT configuration. |
| 66 |
*/ |
| 67 |
m_device = CreateObject<WifiNetDevice> (); |
| 68 |
Ptr<HtConfiguration> htConfiguration = CreateObject<HtConfiguration> (); |
| 69 |
m_device->SetHtConfiguration (htConfiguration); |
| 70 |
|
| 71 |
/* |
| 68 |
* Create and configure phy layer. |
72 |
* Create and configure phy layer. |
| 69 |
*/ |
73 |
*/ |
| 70 |
m_phy = CreateObject<YansWifiPhy> (); |
74 |
m_phy = CreateObject<YansWifiPhy> (); |
|
|
75 |
m_phy->SetDevice (m_device); |
| 71 |
m_phy->ConfigureStandard (WIFI_PHY_STANDARD_80211n_5GHZ); |
76 |
m_phy->ConfigureStandard (WIFI_PHY_STANDARD_80211n_5GHZ); |
|
|
77 |
m_device->SetPhy (m_phy); |
| 72 |
|
78 |
|
| 73 |
/* |
79 |
/* |
| 74 |
* Create and configure manager. |
80 |
* Create and configure manager. |
|
Lines 78-116
AmpduAggregationTest::DoRun (void)
|
Link Here
|
|---|
|
| 78 |
m_factory.Set ("DataMode", StringValue ("HtMcs7")); |
84 |
m_factory.Set ("DataMode", StringValue ("HtMcs7")); |
| 79 |
m_manager = m_factory.Create<WifiRemoteStationManager> (); |
85 |
m_manager = m_factory.Create<WifiRemoteStationManager> (); |
| 80 |
m_manager->SetupPhy (m_phy); |
86 |
m_manager->SetupPhy (m_phy); |
| 81 |
m_manager->SetHtSupported (true); |
87 |
m_device->SetRemoteStationManager (m_manager); |
| 82 |
|
88 |
|
| 83 |
/* |
89 |
/* |
| 84 |
* Create and configure mac layer. |
90 |
* Create and configure mac layer. |
| 85 |
*/ |
91 |
*/ |
| 86 |
m_low = CreateObject<MacLow> (); |
92 |
m_mac = CreateObject<StaWifiMac> (); |
| 87 |
m_low->SetPhy (m_phy); |
93 |
m_mac->SetDevice (m_device); |
| 88 |
m_low->SetWifiRemoteStationManager (m_manager); |
94 |
m_mac->SetWifiPhy (m_phy); |
| 89 |
m_low->SetAddress (Mac48Address ("00:00:00:00:00:01")); |
95 |
m_mac->SetWifiRemoteStationManager (m_manager); |
| 90 |
|
96 |
m_mac->SetAddress (Mac48Address ("00:00:00:00:00:01")); |
| 91 |
m_channelAccessManager = CreateObject<ChannelAccessManager> (); |
97 |
m_mac->ConfigureStandard (WIFI_PHY_STANDARD_80211n_5GHZ); |
| 92 |
m_channelAccessManager->SetupLow (m_low); |
98 |
m_device->SetMac (m_mac); |
| 93 |
m_channelAccessManager->SetupPhyListener (m_phy); |
|
|
| 94 |
m_channelAccessManager->SetSlot (MicroSeconds (9)); |
| 95 |
|
| 96 |
m_txop = CreateObject<QosTxop> (); |
| 97 |
m_txop->SetMacLow (m_low); |
| 98 |
m_txop->SetAccessCategory (AC_BE); |
| 99 |
m_txop->SetWifiRemoteStationManager (m_manager); |
| 100 |
m_txop->SetChannelAccessManager (m_channelAccessManager); |
| 101 |
|
| 102 |
m_txMiddle = Create<MacTxMiddle> (); |
| 103 |
m_txop->SetTxMiddle (m_txMiddle); |
| 104 |
m_txop->CompleteConfig (); |
| 105 |
|
99 |
|
| 106 |
/* |
100 |
/* |
| 107 |
* Configure MPDU aggregation. |
101 |
* Configure MPDU aggregation. |
| 108 |
*/ |
102 |
*/ |
| 109 |
m_factory = ObjectFactory (); |
103 |
m_mac->GetBEQueue ()->GetMpduAggregator ()->SetMaxAmpduSize (65535); |
| 110 |
m_factory.SetTypeId ("ns3::MpduAggregator"); |
|
|
| 111 |
m_mpduAggregator = m_factory.Create<MpduAggregator> (); |
| 112 |
m_mpduAggregator->SetMaxAmpduSize (65535); |
| 113 |
m_txop->SetMpduAggregator (m_mpduAggregator); |
| 114 |
|
104 |
|
| 115 |
/* |
105 |
/* |
| 116 |
* Create a dummy packet of 1500 bytes and fill mac header fields. |
106 |
* Create a dummy packet of 1500 bytes and fill mac header fields. |
|
Lines 122-128
AmpduAggregationTest::DoRun (void)
|
Link Here
|
|---|
|
| 122 |
hdr.SetAddr2 (Mac48Address ("00:00:00:00:00:01")); |
112 |
hdr.SetAddr2 (Mac48Address ("00:00:00:00:00:01")); |
| 123 |
hdr.SetType (WIFI_MAC_QOSDATA); |
113 |
hdr.SetType (WIFI_MAC_QOSDATA); |
| 124 |
hdr.SetQosTid (0); |
114 |
hdr.SetQosTid (0); |
| 125 |
uint16_t sequence = m_txMiddle->GetNextSequenceNumberFor (&hdr); |
115 |
uint16_t sequence = m_mac->m_txMiddle->GetNextSequenceNumberFor (&hdr); |
| 126 |
hdr.SetSequenceNumber (sequence); |
116 |
hdr.SetSequenceNumber (sequence); |
| 127 |
hdr.SetFragmentNumber (0); |
117 |
hdr.SetFragmentNumber (0); |
| 128 |
hdr.SetNoMoreFragments (); |
118 |
hdr.SetNoMoreFragments (); |
|
Lines 137-156
AmpduAggregationTest::DoRun (void)
|
Link Here
|
|---|
|
| 137 |
reqHdr.SetBufferSize (0); |
127 |
reqHdr.SetBufferSize (0); |
| 138 |
reqHdr.SetTimeout (0); |
128 |
reqHdr.SetTimeout (0); |
| 139 |
reqHdr.SetStartingSequence (0); |
129 |
reqHdr.SetStartingSequence (0); |
| 140 |
m_txop->m_baManager->CreateAgreement (&reqHdr, hdr.GetAddr1 ()); |
130 |
m_mac->GetBEQueue ()->m_baManager->CreateAgreement (&reqHdr, hdr.GetAddr1 ()); |
| 141 |
|
131 |
|
| 142 |
//----------------------------------------------------------------------------------------------------- |
132 |
//----------------------------------------------------------------------------------------------------- |
| 143 |
|
133 |
|
| 144 |
/* |
134 |
/* |
| 145 |
* Test behavior when no other packets are in the queue |
135 |
* Test behavior when no other packets are in the queue |
| 146 |
*/ |
136 |
*/ |
| 147 |
m_low->m_currentHdr = hdr; |
137 |
m_mac->GetBEQueue ()->GetLow ()->m_currentHdr = hdr; |
| 148 |
m_low->m_currentPacket = pkt->Copy (); |
138 |
m_mac->GetBEQueue ()->GetLow ()->m_currentPacket = pkt->Copy (); |
| 149 |
m_low->m_currentTxVector = m_low->GetDataTxVector (m_low->m_currentPacket, &m_low->m_currentHdr); |
139 |
m_mac->GetBEQueue ()->GetLow ()->m_currentTxVector = m_mac->GetBEQueue ()->GetLow ()->GetDataTxVector (m_mac->GetBEQueue ()->GetLow ()->m_currentPacket, &m_mac->GetBEQueue ()->GetLow ()->m_currentHdr); |
| 150 |
|
140 |
|
| 151 |
bool isAmpdu = m_low->IsAmpdu (pkt, hdr); |
141 |
bool isAmpdu = m_mac->GetBEQueue ()->GetLow ()->IsAmpdu (pkt, hdr); |
| 152 |
NS_TEST_EXPECT_MSG_EQ (isAmpdu, false, "a single packet should not result in an A-MPDU"); |
142 |
NS_TEST_EXPECT_MSG_EQ (isAmpdu, false, "a single packet should not result in an A-MPDU"); |
| 153 |
NS_TEST_EXPECT_MSG_EQ (m_low->m_aggregateQueue[0]->GetNPackets (), 0, "aggregation queue is not flushed"); |
143 |
NS_TEST_EXPECT_MSG_EQ (m_mac->GetBEQueue ()->GetLow ()->m_aggregateQueue[0]->GetNPackets (), 0, "aggregation queue is not flushed"); |
| 154 |
|
144 |
|
| 155 |
//----------------------------------------------------------------------------------------------------- |
145 |
//----------------------------------------------------------------------------------------------------- |
| 156 |
|
146 |
|
|
Lines 171-192
AmpduAggregationTest::DoRun (void)
|
Link Here
|
|---|
|
| 171 |
hdr2.SetType (WIFI_MAC_QOSDATA); |
161 |
hdr2.SetType (WIFI_MAC_QOSDATA); |
| 172 |
hdr2.SetQosTid (0); |
162 |
hdr2.SetQosTid (0); |
| 173 |
|
163 |
|
| 174 |
m_txop->GetWifiMacQueue ()->Enqueue (Create<WifiMacQueueItem> (pkt1, hdr1)); |
164 |
m_mac->GetBEQueue ()->GetWifiMacQueue ()->Enqueue (Create<WifiMacQueueItem> (pkt1, hdr1)); |
| 175 |
m_txop->GetWifiMacQueue ()->Enqueue (Create<WifiMacQueueItem> (pkt2, hdr2)); |
165 |
m_mac->GetBEQueue ()->GetWifiMacQueue ()->Enqueue (Create<WifiMacQueueItem> (pkt2, hdr2)); |
| 176 |
|
166 |
|
| 177 |
isAmpdu = m_low->IsAmpdu (pkt, hdr); |
167 |
isAmpdu = m_mac->GetBEQueue ()->GetLow ()->IsAmpdu (pkt, hdr); |
| 178 |
uint32_t aggregationQueueSize = m_low->m_aggregateQueue[0]->GetNPackets (); |
168 |
uint32_t aggregationQueueSize = m_mac->GetBEQueue ()->GetLow ()->m_aggregateQueue[0]->GetNPackets (); |
| 179 |
NS_TEST_EXPECT_MSG_EQ (isAmpdu, true, "MPDU aggregation failed"); |
169 |
NS_TEST_EXPECT_MSG_EQ (isAmpdu, true, "MPDU aggregation failed"); |
| 180 |
NS_TEST_EXPECT_MSG_EQ (m_low->m_currentPacket->GetSize (), 4606, "A-MPDU size is not correct"); |
170 |
NS_TEST_EXPECT_MSG_EQ (m_mac->GetBEQueue ()->GetLow ()->m_currentPacket->GetSize (), 4606, "A-MPDU size is not correct"); |
| 181 |
NS_TEST_EXPECT_MSG_EQ (aggregationQueueSize, 3, "aggregation queue should not be empty"); |
171 |
NS_TEST_EXPECT_MSG_EQ (aggregationQueueSize, 3, "aggregation queue should not be empty"); |
| 182 |
NS_TEST_EXPECT_MSG_EQ (m_txop->GetWifiMacQueue ()->GetNPackets (), 0, "queue should be empty"); |
172 |
NS_TEST_EXPECT_MSG_EQ (m_mac->GetBEQueue ()->GetWifiMacQueue ()->GetNPackets (), 0, "queue should be empty"); |
| 183 |
|
173 |
|
| 184 |
Ptr <WifiMacQueueItem> dequeuedItem; |
174 |
Ptr <WifiMacQueueItem> dequeuedItem; |
| 185 |
WifiMacHeader dequeuedHdr; |
175 |
WifiMacHeader dequeuedHdr; |
| 186 |
uint32_t i = 0; |
176 |
uint32_t i = 0; |
| 187 |
for (; aggregationQueueSize > 0; aggregationQueueSize--, i++) |
177 |
for (; aggregationQueueSize > 0; aggregationQueueSize--, i++) |
| 188 |
{ |
178 |
{ |
| 189 |
dequeuedItem = m_low->m_aggregateQueue[0]->Dequeue (); |
179 |
dequeuedItem = m_mac->GetBEQueue ()->GetLow ()->m_aggregateQueue[0]->Dequeue (); |
| 190 |
dequeuedHdr = dequeuedItem->GetHeader (); |
180 |
dequeuedHdr = dequeuedItem->GetHeader (); |
| 191 |
NS_TEST_EXPECT_MSG_EQ (dequeuedHdr.GetSequenceNumber (), i, "wrong sequence number"); |
181 |
NS_TEST_EXPECT_MSG_EQ (dequeuedHdr.GetSequenceNumber (), i, "wrong sequence number"); |
| 192 |
} |
182 |
} |
|
Lines 219-254
AmpduAggregationTest::DoRun (void)
|
Link Here
|
|---|
|
| 219 |
hdr3.SetType (WIFI_MAC_DATA); |
209 |
hdr3.SetType (WIFI_MAC_DATA); |
| 220 |
hdr3.SetQosTid (0); |
210 |
hdr3.SetQosTid (0); |
| 221 |
|
211 |
|
| 222 |
m_txop->GetWifiMacQueue ()->Enqueue (Create<WifiMacQueueItem> (pkt3, hdr3)); |
212 |
m_mac->GetBEQueue ()->GetWifiMacQueue ()->Enqueue (Create<WifiMacQueueItem> (pkt3, hdr3)); |
| 223 |
|
213 |
|
| 224 |
isAmpdu = m_low->IsAmpdu (pkt1, hdr1); |
214 |
isAmpdu = m_mac->GetBEQueue ()->GetLow ()->IsAmpdu (pkt1, hdr1); |
| 225 |
NS_TEST_EXPECT_MSG_EQ (isAmpdu, false, "a single packet for this destination should not result in an A-MPDU"); |
215 |
NS_TEST_EXPECT_MSG_EQ (isAmpdu, false, "a single packet for this destination should not result in an A-MPDU"); |
| 226 |
NS_TEST_EXPECT_MSG_EQ (m_low->m_aggregateQueue[0]->GetNPackets (), 0, "aggregation queue is not flushed"); |
216 |
NS_TEST_EXPECT_MSG_EQ (m_mac->GetBEQueue ()->GetLow ()->m_aggregateQueue[0]->GetNPackets (), 0, "aggregation queue is not flushed"); |
| 227 |
|
217 |
|
| 228 |
m_txop->m_currentHdr = hdr2; |
218 |
m_mac->GetBEQueue ()->m_currentHdr = hdr2; |
| 229 |
m_txop->m_currentPacket = pkt2->Copy (); |
219 |
m_mac->GetBEQueue ()->m_currentPacket = pkt2->Copy (); |
| 230 |
isAmpdu = m_low->IsAmpdu (pkt2, hdr2); |
220 |
isAmpdu = m_mac->GetBEQueue ()->GetLow ()->IsAmpdu (pkt2, hdr2); |
| 231 |
NS_TEST_EXPECT_MSG_EQ (isAmpdu, false, "no MPDU aggregation should be performed if there is no agreement"); |
221 |
NS_TEST_EXPECT_MSG_EQ (isAmpdu, false, "no MPDU aggregation should be performed if there is no agreement"); |
| 232 |
NS_TEST_EXPECT_MSG_EQ (m_low->m_aggregateQueue[0]->GetNPackets (), 0, "aggregation queue is not flushed"); |
222 |
NS_TEST_EXPECT_MSG_EQ (m_mac->GetBEQueue ()->GetLow ()->m_aggregateQueue[0]->GetNPackets (), 0, "aggregation queue is not flushed"); |
| 233 |
|
223 |
|
| 234 |
m_manager->SetMaxSsrc (0); //set to 0 in order to fake that the maximum number of retries has been reached |
224 |
m_manager->SetMaxSsrc (0); //set to 0 in order to fake that the maximum number of retries has been reached |
| 235 |
m_txop->MissedAck (); |
225 |
m_mac->GetBEQueue ()->MissedAck (); |
| 236 |
|
226 |
|
| 237 |
NS_TEST_EXPECT_MSG_EQ (m_txop->m_currentPacket, 0, "packet should be discarded"); |
227 |
NS_TEST_EXPECT_MSG_EQ (m_mac->GetBEQueue ()->m_currentPacket, 0, "packet should be discarded"); |
| 238 |
m_txop->GetWifiMacQueue ()->Remove (pkt3); |
228 |
m_mac->GetBEQueue ()->GetWifiMacQueue ()->Remove (pkt3); |
| 239 |
|
229 |
|
| 240 |
Simulator::Destroy (); |
230 |
Simulator::Destroy (); |
| 241 |
|
231 |
|
| 242 |
m_txMiddle = 0; |
232 |
m_manager->Dispose (); |
| 243 |
|
233 |
m_manager = 0; |
| 244 |
m_low->Dispose (); |
|
|
| 245 |
m_low = 0; |
| 246 |
|
234 |
|
| 247 |
m_txop->Dispose (); |
235 |
m_device->Dispose (); |
| 248 |
m_txop = 0; |
236 |
m_device = 0; |
| 249 |
|
237 |
|
| 250 |
m_channelAccessManager->Dispose (); |
238 |
htConfiguration = 0; |
| 251 |
m_channelAccessManager = 0; |
|
|
| 252 |
} |
239 |
} |
| 253 |
|
240 |
|
| 254 |
/** |
241 |
/** |
|
|
| 264 |
|
251 |
|
| 265 |
private: |
252 |
private: |
| 266 |
virtual void DoRun (void); |
253 |
virtual void DoRun (void); |
| 267 |
Ptr<MacLow> m_low; ///< MacLow |
254 |
Ptr<WifiNetDevice> m_device; ///<WifiNetDevice |
|
|
255 |
Ptr<StaWifiMac> m_mac; ///< Mac |
| 268 |
Ptr<YansWifiPhy> m_phy; ///< Phy |
256 |
Ptr<YansWifiPhy> m_phy; ///< Phy |
| 269 |
Ptr<QosTxop> m_txop; ///< QosTxop |
|
|
| 270 |
Ptr<WifiRemoteStationManager> m_manager; ///< remote station manager |
257 |
Ptr<WifiRemoteStationManager> m_manager; ///< remote station manager |
| 271 |
ObjectFactory m_factory; ///< factory |
258 |
ObjectFactory m_factory; ///< factory |
| 272 |
Ptr<MsduAggregator> m_msduAggregator; ///< A-MSDU aggregator |
|
|
| 273 |
Ptr<MpduAggregator> m_mpduAggregator; ///< A-MPDU aggregator |
| 274 |
}; |
259 |
}; |
| 275 |
|
260 |
|
| 276 |
TwoLevelAggregationTest::TwoLevelAggregationTest () |
261 |
TwoLevelAggregationTest::TwoLevelAggregationTest () |
|
|
| 282 |
TwoLevelAggregationTest::DoRun (void) |
267 |
TwoLevelAggregationTest::DoRun (void) |
| 283 |
{ |
268 |
{ |
| 284 |
/* |
269 |
/* |
|
|
270 |
* Create device and attach HT configuration. |
| 271 |
*/ |
| 272 |
m_device = CreateObject<WifiNetDevice> (); |
| 273 |
Ptr<HtConfiguration> htConfiguration = CreateObject<HtConfiguration> (); |
| 274 |
m_device->SetHtConfiguration (htConfiguration); |
| 275 |
|
| 276 |
/* |
| 285 |
* Create and configure phy layer. |
277 |
* Create and configure phy layer. |
| 286 |
*/ |
278 |
*/ |
| 287 |
m_phy = CreateObject<YansWifiPhy> (); |
279 |
m_phy = CreateObject<YansWifiPhy> (); |
|
|
280 |
m_phy->SetDevice (m_device); |
| 288 |
m_phy->ConfigureStandard (WIFI_PHY_STANDARD_80211n_5GHZ); |
281 |
m_phy->ConfigureStandard (WIFI_PHY_STANDARD_80211n_5GHZ); |
|
|
282 |
m_device->SetPhy (m_phy); |
| 289 |
|
283 |
|
| 290 |
/* |
284 |
/* |
| 291 |
* Create and configure manager. |
285 |
* Create and configure manager. |
|
Lines 295-325
TwoLevelAggregationTest::DoRun (void)
|
Link Here
|
|---|
|
| 295 |
m_factory.Set ("DataMode", StringValue ("HtMcs7")); |
289 |
m_factory.Set ("DataMode", StringValue ("HtMcs7")); |
| 296 |
m_manager = m_factory.Create<WifiRemoteStationManager> (); |
290 |
m_manager = m_factory.Create<WifiRemoteStationManager> (); |
| 297 |
m_manager->SetupPhy (m_phy); |
291 |
m_manager->SetupPhy (m_phy); |
|
|
292 |
m_device->SetRemoteStationManager (m_manager); |
| 298 |
|
293 |
|
| 299 |
/* |
294 |
/* |
| 300 |
* Create and configure maclayer. |
295 |
* Create and configure mac layer. |
| 301 |
*/ |
296 |
*/ |
| 302 |
m_low = CreateObject<MacLow> (); |
297 |
m_mac = CreateObject<StaWifiMac> (); |
| 303 |
m_low->SetPhy (m_phy); |
298 |
m_mac->SetDevice (m_device); |
| 304 |
m_low->SetWifiRemoteStationManager (m_manager); |
299 |
m_mac->SetWifiPhy (m_phy); |
| 305 |
|
300 |
m_mac->SetWifiRemoteStationManager (m_manager); |
| 306 |
m_txop = CreateObject<QosTxop> (); |
301 |
m_mac->SetAddress (Mac48Address ("00:00:00:00:00:01")); |
| 307 |
m_txop->SetMacLow (m_low); |
302 |
m_mac->ConfigureStandard (WIFI_PHY_STANDARD_80211n_5GHZ); |
| 308 |
m_txop->SetAccessCategory (AC_BE); |
303 |
m_device->SetMac (m_mac); |
| 309 |
m_txop->SetWifiRemoteStationManager (m_manager); |
|
|
| 310 |
m_txop->CompleteConfig (); |
| 311 |
|
304 |
|
| 312 |
/* |
305 |
/* |
| 313 |
* Configure aggregation. |
306 |
* Configure aggregation. |
| 314 |
*/ |
307 |
*/ |
| 315 |
m_msduAggregator = CreateObject<MsduAggregator> (); |
308 |
m_mac->GetBEQueue ()->GetMsduAggregator ()->SetMaxAmsduSize (4095); |
| 316 |
m_mpduAggregator = CreateObject<MpduAggregator> (); |
309 |
m_mac->GetBEQueue ()->GetMpduAggregator ()->SetMaxAmpduSize (65535); |
| 317 |
|
|
|
| 318 |
m_msduAggregator->SetMaxAmsduSize (4095); |
| 319 |
m_mpduAggregator->SetMaxAmpduSize (65535); |
| 320 |
|
| 321 |
m_txop->SetMsduAggregator (m_msduAggregator); |
| 322 |
m_txop->SetMpduAggregator (m_mpduAggregator); |
| 323 |
|
310 |
|
| 324 |
/* |
311 |
/* |
| 325 |
* Create dummy packets of 1500 bytes and fill mac header fields that will be used for the tests. |
312 |
* Create dummy packets of 1500 bytes and fill mac header fields that will be used for the tests. |
|
Lines 342-364
TwoLevelAggregationTest::DoRun (void)
|
Link Here
|
|---|
|
| 342 |
* - A-MSDU frame size should be 3030 bytes (= 2 packets + headers + padding); |
329 |
* - A-MSDU frame size should be 3030 bytes (= 2 packets + headers + padding); |
| 343 |
* - one packet should be removed from the queue (the other packet is removed later in MacLow::AggregateToAmpdu) . |
330 |
* - one packet should be removed from the queue (the other packet is removed later in MacLow::AggregateToAmpdu) . |
| 344 |
*/ |
331 |
*/ |
| 345 |
m_txop->GetWifiMacQueue ()->Enqueue (Create<WifiMacQueueItem> (pkt, hdr)); |
332 |
m_mac->GetBEQueue ()->GetWifiMacQueue ()->Enqueue (Create<WifiMacQueueItem> (pkt, hdr)); |
| 346 |
m_txop->GetWifiMacQueue ()->Enqueue (Create<WifiMacQueueItem> (pkt, hdr)); |
333 |
m_mac->GetBEQueue ()->GetWifiMacQueue ()->Enqueue (Create<WifiMacQueueItem> (pkt, hdr)); |
| 347 |
|
334 |
|
| 348 |
Ptr<const WifiMacQueueItem> peekedItem = m_txop->GetWifiMacQueue ()->PeekByTidAndAddress (0, hdr.GetAddr1 ()); |
335 |
Ptr<const WifiMacQueueItem> peekedItem = m_mac->GetBEQueue ()->GetWifiMacQueue ()->PeekByTidAndAddress (0, hdr.GetAddr1 ()); |
| 349 |
Ptr<const Packet> peekedPacket = peekedItem->GetPacket (); |
336 |
Ptr<const Packet> peekedPacket = peekedItem->GetPacket (); |
| 350 |
peekedHdr = peekedItem->GetHeader (); |
337 |
peekedHdr = peekedItem->GetHeader (); |
| 351 |
tstamp = peekedItem->GetTimeStamp (); |
338 |
tstamp = peekedItem->GetTimeStamp (); |
| 352 |
m_low->m_currentPacket = peekedPacket->Copy (); |
339 |
m_mac->GetBEQueue ()->GetLow ()->m_currentPacket = peekedPacket->Copy (); |
| 353 |
m_low->m_currentHdr = peekedHdr; |
340 |
m_mac->GetBEQueue ()->GetLow ()->m_currentHdr = peekedHdr; |
| 354 |
m_low->m_currentTxVector = m_low->GetDataTxVector (m_low->m_currentPacket, &m_low->m_currentHdr); |
341 |
m_mac->GetBEQueue ()->GetLow ()->m_currentTxVector = m_mac->GetBEQueue ()->GetLow ()->GetDataTxVector (m_mac->GetBEQueue ()->GetLow ()->m_currentPacket, &m_mac->GetBEQueue ()->GetLow ()->m_currentHdr); |
| 355 |
|
342 |
|
| 356 |
Ptr<Packet> packet = m_low->PerformMsduAggregation (peekedPacket, &peekedHdr, &tstamp, currentAggregatedPacket, 0); |
343 |
Ptr<Packet> packet = m_mac->GetBEQueue ()->GetLow ()->PerformMsduAggregation (peekedPacket, &peekedHdr, &tstamp, currentAggregatedPacket, 0); |
| 357 |
|
344 |
|
| 358 |
bool result = (packet != 0); |
345 |
bool result = (packet != 0); |
| 359 |
NS_TEST_EXPECT_MSG_EQ (result, true, "aggregation failed"); |
346 |
NS_TEST_EXPECT_MSG_EQ (result, true, "aggregation failed"); |
| 360 |
NS_TEST_EXPECT_MSG_EQ (packet->GetSize (), 3030, "wrong packet size"); |
347 |
NS_TEST_EXPECT_MSG_EQ (packet->GetSize (), 3030, "wrong packet size"); |
| 361 |
NS_TEST_EXPECT_MSG_EQ (m_txop->GetWifiMacQueue ()->GetNPackets (), 0, "aggregated packets not removed from the queue"); |
348 |
NS_TEST_EXPECT_MSG_EQ (m_mac->GetBEQueue ()->GetWifiMacQueue ()->GetNPackets (), 0, "aggregated packets not removed from the queue"); |
| 362 |
|
349 |
|
| 363 |
//----------------------------------------------------------------------------------------------------- |
350 |
//----------------------------------------------------------------------------------------------------- |
| 364 |
|
351 |
|
|
Lines 367-380
TwoLevelAggregationTest::DoRun (void)
|
Link Here
|
|---|
|
| 367 |
* It checks whether MSDU aggregation has been rejected because the maximum MPDU size is set to 0 (returned packet should be equal to 0). |
354 |
* It checks whether MSDU aggregation has been rejected because the maximum MPDU size is set to 0 (returned packet should be equal to 0). |
| 368 |
* This test is needed to ensure that no packets are removed from the queue in MacLow::PerformMsduAggregation, since aggregation will no occur in MacLow::AggregateToAmpdu. |
355 |
* This test is needed to ensure that no packets are removed from the queue in MacLow::PerformMsduAggregation, since aggregation will no occur in MacLow::AggregateToAmpdu. |
| 369 |
*/ |
356 |
*/ |
| 370 |
m_factory = ObjectFactory (); |
357 |
m_mac->GetBEQueue ()->GetMpduAggregator ()->SetMaxAmpduSize (65535); |
| 371 |
m_factory.SetTypeId ("ns3::MpduAggregator"); |
|
|
| 372 |
m_mpduAggregator = m_factory.Create<MpduAggregator> (); |
| 373 |
m_mpduAggregator->SetMaxAmpduSize (65535); |
| 374 |
m_txop->SetMpduAggregator (m_mpduAggregator); |
| 375 |
|
358 |
|
| 376 |
m_txop->GetWifiMacQueue ()->Enqueue (Create<WifiMacQueueItem> (pkt, hdr)); |
359 |
m_mac->GetBEQueue ()->GetWifiMacQueue ()->Enqueue (Create<WifiMacQueueItem> (pkt, hdr)); |
| 377 |
packet = m_low->PerformMsduAggregation (peekedPacket, &peekedHdr, &tstamp, currentAggregatedPacket, 0); |
360 |
packet = m_mac->GetBEQueue ()->GetLow ()->PerformMsduAggregation (peekedPacket, &peekedHdr, &tstamp, currentAggregatedPacket, 0); |
| 378 |
|
361 |
|
| 379 |
result = (packet != 0); |
362 |
result = (packet != 0); |
| 380 |
NS_TEST_EXPECT_MSG_EQ (result, false, "maximum aggregated frame size check failed"); |
363 |
NS_TEST_EXPECT_MSG_EQ (result, false, "maximum aggregated frame size check failed"); |
|
Lines 386-410
TwoLevelAggregationTest::DoRun (void)
|
Link Here
|
|---|
|
| 386 |
* It checks whether MSDU aggregation has been rejected because there is no packets ready in the queue (returned packet should be equal to 0). |
369 |
* It checks whether MSDU aggregation has been rejected because there is no packets ready in the queue (returned packet should be equal to 0). |
| 387 |
* This test is needed to ensure that there is no issue when the queue is empty. |
370 |
* This test is needed to ensure that there is no issue when the queue is empty. |
| 388 |
*/ |
371 |
*/ |
| 389 |
m_mpduAggregator->SetMaxAmpduSize (4095); |
372 |
m_mac->GetBEQueue ()->GetMpduAggregator ()->SetMaxAmpduSize (4095); |
| 390 |
|
373 |
|
| 391 |
m_txop->GetWifiMacQueue ()->Remove (pkt); |
374 |
m_mac->GetBEQueue ()->GetWifiMacQueue ()->Remove (pkt); |
| 392 |
m_txop->GetWifiMacQueue ()->Remove (pkt); |
375 |
m_mac->GetBEQueue ()->GetWifiMacQueue ()->Remove (pkt); |
| 393 |
packet = m_low->PerformMsduAggregation (peekedPacket, &peekedHdr, &tstamp, currentAggregatedPacket, 0); |
376 |
packet = m_mac->GetBEQueue ()->GetLow ()->PerformMsduAggregation (peekedPacket, &peekedHdr, &tstamp, currentAggregatedPacket, 0); |
| 394 |
|
377 |
|
| 395 |
result = (packet != 0); |
378 |
result = (packet != 0); |
| 396 |
NS_TEST_EXPECT_MSG_EQ (result, false, "aggregation failed to stop as queue is empty"); |
379 |
NS_TEST_EXPECT_MSG_EQ (result, false, "aggregation failed to stop as queue is empty"); |
| 397 |
|
380 |
|
| 398 |
Simulator::Destroy (); |
381 |
Simulator::Destroy (); |
| 399 |
|
382 |
|
| 400 |
m_low->Dispose (); |
383 |
m_device = 0; |
| 401 |
m_low = 0; |
384 |
htConfiguration = 0; |
| 402 |
|
|
|
| 403 |
m_txop->Dispose (); |
| 404 |
m_txop = 0; |
| 405 |
} |
385 |
} |
| 406 |
|
386 |
|
| 407 |
|
|
|
| 408 |
/** |
387 |
/** |
| 409 |
* \ingroup wifi-test |
388 |
* \ingroup wifi-test |
| 410 |
* \ingroup tests |
389 |
* \ingroup tests |