OLD | NEW |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2015 | 3 * Copyright (c) 2015 |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 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 | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 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 | 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 | 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 * | 17 * |
18 * Author: Sébastien Deronne <sebastien.deronne@gmail.com> | 18 * Author: Sébastien Deronne <sebastien.deronne@gmail.com> |
19 */ | 19 */ |
20 | 20 |
21 #include "ns3/string.h" | 21 #include "ns3/string.h" |
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/mac-low.h" |
26 #include "ns3/edca-txop-n.h" | 26 #include "ns3/qos-txop.h" |
27 #include "ns3/yans-wifi-phy.h" | 27 #include "ns3/yans-wifi-phy.h" |
28 #include "ns3/mac-tx-middle.h" | 28 #include "ns3/mac-tx-middle.h" |
29 #include "ns3/dcf-manager.h" | 29 #include "ns3/dcf-manager.h" |
30 #include "ns3/msdu-aggregator.h" | 30 #include "ns3/msdu-aggregator.h" |
31 #include "ns3/mpdu-aggregator.h" | 31 #include "ns3/mpdu-aggregator.h" |
32 | 32 |
33 using namespace ns3; | 33 using namespace ns3; |
34 | 34 |
35 /** | 35 /** |
36 * \ingroup wifi-test | 36 * \ingroup wifi-test |
37 * \ingroup tests | 37 * \ingroup tests |
38 * | 38 * |
39 * \brief Ampdu Aggregation Test | 39 * \brief Ampdu Aggregation Test |
40 */ | 40 */ |
41 class AmpduAggregationTest : public TestCase | 41 class AmpduAggregationTest : public TestCase |
42 { | 42 { |
43 public: | 43 public: |
44 AmpduAggregationTest (); | 44 AmpduAggregationTest (); |
45 | 45 |
46 private: | 46 private: |
47 virtual void DoRun (void); | 47 virtual void DoRun (void); |
48 Ptr<MacLow> m_low; ///< MacLow | 48 Ptr<MacLow> m_low; ///< MacLow |
49 Ptr<YansWifiPhy> m_phy; ///< Phy | 49 Ptr<YansWifiPhy> m_phy; ///< Phy |
50 Ptr<EdcaTxopN> m_edca; ///< EDCA | 50 Ptr<QosTxop> m_txop; ///< QosTxop |
51 Ptr<MacTxMiddle> m_txMiddle; ///< MacTxMiddle | 51 Ptr<MacTxMiddle> m_txMiddle; ///< MacTxMiddle |
52 Ptr<WifiRemoteStationManager> m_manager; ///< remote station manager | 52 Ptr<WifiRemoteStationManager> m_manager; ///< remote station manager |
53 ObjectFactory m_factory; ///< factory | 53 ObjectFactory m_factory; ///< factory |
54 Ptr<MpduAggregator> m_mpduAggregator; ///< A-MPDU aggregrator | 54 Ptr<MpduAggregator> m_mpduAggregator; ///< A-MPDU aggregrator |
55 Ptr<DcfManager> m_dcfManager; ///< DCF manager | 55 Ptr<DcfManager> m_dcfManager; ///< DCF manager |
56 }; | 56 }; |
57 | 57 |
58 AmpduAggregationTest::AmpduAggregationTest () | 58 AmpduAggregationTest::AmpduAggregationTest () |
59 : TestCase ("Check the correctness of MPDU aggregation operations") | 59 : TestCase ("Check the correctness of MPDU aggregation operations") |
60 { | 60 { |
(...skipping 24 matching lines...) Expand all Loading... |
85 m_low = CreateObject<MacLow> (); | 85 m_low = CreateObject<MacLow> (); |
86 m_low->SetPhy (m_phy); | 86 m_low->SetPhy (m_phy); |
87 m_low->SetWifiRemoteStationManager (m_manager); | 87 m_low->SetWifiRemoteStationManager (m_manager); |
88 m_low->SetAddress (Mac48Address ("00:00:00:00:00:01")); | 88 m_low->SetAddress (Mac48Address ("00:00:00:00:00:01")); |
89 | 89 |
90 m_dcfManager = CreateObject<DcfManager> (); | 90 m_dcfManager = CreateObject<DcfManager> (); |
91 m_dcfManager->SetupLow (m_low); | 91 m_dcfManager->SetupLow (m_low); |
92 m_dcfManager->SetupPhyListener (m_phy); | 92 m_dcfManager->SetupPhyListener (m_phy); |
93 m_dcfManager->SetSlot (MicroSeconds (9)); | 93 m_dcfManager->SetSlot (MicroSeconds (9)); |
94 | 94 |
95 m_edca = CreateObject<EdcaTxopN> (); | 95 m_txop = CreateObject<QosTxop> (); |
96 m_edca->SetLow (m_low); | 96 m_txop->SetLow (m_low); |
97 m_edca->SetAccessCategory (AC_BE); | 97 m_txop->SetAccessCategory (AC_BE); |
98 m_edca->SetWifiRemoteStationManager (m_manager); | 98 m_txop->SetWifiRemoteStationManager (m_manager); |
99 m_edca->SetManager (m_dcfManager); | 99 m_txop->SetManager (m_dcfManager); |
100 | 100 |
101 m_txMiddle = Create<MacTxMiddle> (); | 101 m_txMiddle = Create<MacTxMiddle> (); |
102 m_edca->SetTxMiddle (m_txMiddle); | 102 m_txop->SetTxMiddle (m_txMiddle); |
103 m_edca->CompleteConfig (); | 103 m_txop->CompleteConfig (); |
104 | 104 |
105 /* | 105 /* |
106 * Configure MPDU aggregation. | 106 * Configure MPDU aggregation. |
107 */ | 107 */ |
108 m_factory = ObjectFactory (); | 108 m_factory = ObjectFactory (); |
109 m_factory.SetTypeId ("ns3::MpduAggregator"); | 109 m_factory.SetTypeId ("ns3::MpduAggregator"); |
110 m_mpduAggregator = m_factory.Create<MpduAggregator> (); | 110 m_mpduAggregator = m_factory.Create<MpduAggregator> (); |
111 m_mpduAggregator->SetMaxAmpduSize (65535); | 111 m_mpduAggregator->SetMaxAmpduSize (65535); |
112 m_edca->SetMpduAggregator (m_mpduAggregator); | 112 m_txop->SetMpduAggregator (m_mpduAggregator); |
113 | 113 |
114 /* | 114 /* |
115 * Create a dummy packet of 1500 bytes and fill mac header fields. | 115 * Create a dummy packet of 1500 bytes and fill mac header fields. |
116 */ | 116 */ |
117 Ptr<const Packet> pkt = Create<Packet> (1500); | 117 Ptr<const Packet> pkt = Create<Packet> (1500); |
118 Ptr<Packet> currentAggregatedPacket = Create<Packet> (); | 118 Ptr<Packet> currentAggregatedPacket = Create<Packet> (); |
119 WifiMacHeader hdr; | 119 WifiMacHeader hdr; |
120 hdr.SetAddr1 (Mac48Address ("00:00:00:00:00:02")); | 120 hdr.SetAddr1 (Mac48Address ("00:00:00:00:00:02")); |
121 hdr.SetAddr2 (Mac48Address ("00:00:00:00:00:01")); | 121 hdr.SetAddr2 (Mac48Address ("00:00:00:00:00:01")); |
122 hdr.SetType (WIFI_MAC_QOSDATA); | 122 hdr.SetType (WIFI_MAC_QOSDATA); |
123 hdr.SetQosTid (0); | 123 hdr.SetQosTid (0); |
124 uint16_t sequence = m_txMiddle->GetNextSequenceNumberFor (&hdr); | 124 uint16_t sequence = m_txMiddle->GetNextSequenceNumberFor (&hdr); |
125 hdr.SetSequenceNumber (sequence); | 125 hdr.SetSequenceNumber (sequence); |
126 hdr.SetFragmentNumber (0); | 126 hdr.SetFragmentNumber (0); |
127 hdr.SetNoMoreFragments (); | 127 hdr.SetNoMoreFragments (); |
128 hdr.SetNoRetry (); | 128 hdr.SetNoRetry (); |
129 | 129 |
130 /* | 130 /* |
131 * Establish agreement. | 131 * Establish agreement. |
132 */ | 132 */ |
133 MgtAddBaRequestHeader reqHdr; | 133 MgtAddBaRequestHeader reqHdr; |
134 reqHdr.SetImmediateBlockAck (); | 134 reqHdr.SetImmediateBlockAck (); |
135 reqHdr.SetTid (0); | 135 reqHdr.SetTid (0); |
136 reqHdr.SetBufferSize (0); | 136 reqHdr.SetBufferSize (0); |
137 reqHdr.SetTimeout (0); | 137 reqHdr.SetTimeout (0); |
138 reqHdr.SetStartingSequence (0); | 138 reqHdr.SetStartingSequence (0); |
139 m_edca->m_baManager->CreateAgreement (&reqHdr, hdr.GetAddr1 ()); | 139 m_txop->m_baManager->CreateAgreement (&reqHdr, hdr.GetAddr1 ()); |
140 | 140 |
141 //----------------------------------------------------------------------------
------------------------- | 141 //----------------------------------------------------------------------------
------------------------- |
142 | 142 |
143 /* | 143 /* |
144 * Test behavior when no other packets are in the queue | 144 * Test behavior when no other packets are in the queue |
145 */ | 145 */ |
146 m_low->m_currentHdr = hdr; | 146 m_low->m_currentHdr = hdr; |
147 m_low->m_currentPacket = pkt->Copy (); | 147 m_low->m_currentPacket = pkt->Copy (); |
148 m_low->m_currentTxVector = m_low->GetDataTxVector (m_low->m_currentPacket, &m_
low->m_currentHdr); | 148 m_low->m_currentTxVector = m_low->GetDataTxVector (m_low->m_currentPacket, &m_
low->m_currentHdr); |
149 | 149 |
(...skipping 13 matching lines...) Expand all Loading... |
163 hdr1.SetAddr1 (Mac48Address ("00:00:00:00:00:02")); | 163 hdr1.SetAddr1 (Mac48Address ("00:00:00:00:00:02")); |
164 hdr1.SetAddr2 (Mac48Address ("00:00:00:00:00:01")); | 164 hdr1.SetAddr2 (Mac48Address ("00:00:00:00:00:01")); |
165 hdr1.SetType (WIFI_MAC_QOSDATA); | 165 hdr1.SetType (WIFI_MAC_QOSDATA); |
166 hdr1.SetQosTid (0); | 166 hdr1.SetQosTid (0); |
167 | 167 |
168 hdr2.SetAddr1 (Mac48Address ("00:00:00:00:00:02")); | 168 hdr2.SetAddr1 (Mac48Address ("00:00:00:00:00:02")); |
169 hdr2.SetAddr2 (Mac48Address ("00:00:00:00:00:01")); | 169 hdr2.SetAddr2 (Mac48Address ("00:00:00:00:00:01")); |
170 hdr2.SetType (WIFI_MAC_QOSDATA); | 170 hdr2.SetType (WIFI_MAC_QOSDATA); |
171 hdr2.SetQosTid (0); | 171 hdr2.SetQosTid (0); |
172 | 172 |
173 m_edca->GetQueue ()->Enqueue (Create<WifiMacQueueItem> (pkt1, hdr1)); | 173 m_txop->GetQueue ()->Enqueue (Create<WifiMacQueueItem> (pkt1, hdr1)); |
174 m_edca->GetQueue ()->Enqueue (Create<WifiMacQueueItem> (pkt2, hdr2)); | 174 m_txop->GetQueue ()->Enqueue (Create<WifiMacQueueItem> (pkt2, hdr2)); |
175 | 175 |
176 isAmpdu = m_low->IsAmpdu (pkt, hdr); | 176 isAmpdu = m_low->IsAmpdu (pkt, hdr); |
177 uint32_t aggregationQueueSize = m_low->m_aggregateQueue[0]->GetNPackets (); | 177 uint32_t aggregationQueueSize = m_low->m_aggregateQueue[0]->GetNPackets (); |
178 NS_TEST_EXPECT_MSG_EQ (isAmpdu, true, "MPDU aggregation failed"); | 178 NS_TEST_EXPECT_MSG_EQ (isAmpdu, true, "MPDU aggregation failed"); |
179 NS_TEST_EXPECT_MSG_EQ (m_low->m_currentPacket->GetSize (), 4606, "A-MPDU size
is not correct"); | 179 NS_TEST_EXPECT_MSG_EQ (m_low->m_currentPacket->GetSize (), 4606, "A-MPDU size
is not correct"); |
180 NS_TEST_EXPECT_MSG_EQ (aggregationQueueSize, 3, "aggregation queue should not
be empty"); | 180 NS_TEST_EXPECT_MSG_EQ (aggregationQueueSize, 3, "aggregation queue should not
be empty"); |
181 NS_TEST_EXPECT_MSG_EQ (m_edca->GetQueue ()->GetNPackets (), 0, "queue should b
e empty"); | 181 NS_TEST_EXPECT_MSG_EQ (m_txop->GetQueue ()->GetNPackets (), 0, "queue should b
e empty"); |
182 | 182 |
183 Ptr <WifiMacQueueItem> dequeuedItem; | 183 Ptr <WifiMacQueueItem> dequeuedItem; |
184 WifiMacHeader dequeuedHdr; | 184 WifiMacHeader dequeuedHdr; |
185 uint32_t i = 0; | 185 uint32_t i = 0; |
186 for (; aggregationQueueSize > 0; aggregationQueueSize--, i++) | 186 for (; aggregationQueueSize > 0; aggregationQueueSize--, i++) |
187 { | 187 { |
188 dequeuedItem = m_low->m_aggregateQueue[0]->Dequeue (); | 188 dequeuedItem = m_low->m_aggregateQueue[0]->Dequeue (); |
189 dequeuedHdr = dequeuedItem->GetHeader (); | 189 dequeuedHdr = dequeuedItem->GetHeader (); |
190 NS_TEST_EXPECT_MSG_EQ (dequeuedHdr.GetSequenceNumber (), i, "wrong sequenc
e number"); | 190 NS_TEST_EXPECT_MSG_EQ (dequeuedHdr.GetSequenceNumber (), i, "wrong sequenc
e number"); |
191 } | 191 } |
(...skipping 19 matching lines...) Expand all Loading... |
211 hdr2.SetQosTid (0); | 211 hdr2.SetQosTid (0); |
212 | 212 |
213 Ptr<const Packet> pkt3 = Create<Packet> (1500); | 213 Ptr<const Packet> pkt3 = Create<Packet> (1500); |
214 WifiMacHeader hdr3; | 214 WifiMacHeader hdr3; |
215 hdr3.SetSequenceNumber (0); | 215 hdr3.SetSequenceNumber (0); |
216 hdr3.SetAddr1 (Mac48Address ("00:00:00:00:00:03")); | 216 hdr3.SetAddr1 (Mac48Address ("00:00:00:00:00:03")); |
217 hdr3.SetAddr2 (Mac48Address ("00:00:00:00:00:01")); | 217 hdr3.SetAddr2 (Mac48Address ("00:00:00:00:00:01")); |
218 hdr3.SetType (WIFI_MAC_DATA); | 218 hdr3.SetType (WIFI_MAC_DATA); |
219 hdr3.SetQosTid (0); | 219 hdr3.SetQosTid (0); |
220 | 220 |
221 m_edca->GetQueue ()->Enqueue (Create<WifiMacQueueItem> (pkt3, hdr3)); | 221 m_txop->GetQueue ()->Enqueue (Create<WifiMacQueueItem> (pkt3, hdr3)); |
222 | 222 |
223 isAmpdu = m_low->IsAmpdu (pkt1, hdr1); | 223 isAmpdu = m_low->IsAmpdu (pkt1, hdr1); |
224 NS_TEST_EXPECT_MSG_EQ (isAmpdu, false, "a single packet for this destination s
hould not result in an A-MPDU"); | 224 NS_TEST_EXPECT_MSG_EQ (isAmpdu, false, "a single packet for this destination s
hould not result in an A-MPDU"); |
225 NS_TEST_EXPECT_MSG_EQ (m_low->m_aggregateQueue[0]->GetNPackets (), 0, "aggrega
tion queue is not flushed"); | 225 NS_TEST_EXPECT_MSG_EQ (m_low->m_aggregateQueue[0]->GetNPackets (), 0, "aggrega
tion queue is not flushed"); |
226 | 226 |
227 m_edca->m_currentHdr = hdr2; | 227 m_txop->m_currentHdr = hdr2; |
228 m_edca->m_currentPacket = pkt2->Copy (); | 228 m_txop->m_currentPacket = pkt2->Copy (); |
229 isAmpdu = m_low->IsAmpdu (pkt2, hdr2); | 229 isAmpdu = m_low->IsAmpdu (pkt2, hdr2); |
230 NS_TEST_EXPECT_MSG_EQ (isAmpdu, false, "no MPDU aggregation should be performe
d if there is no agreement"); | 230 NS_TEST_EXPECT_MSG_EQ (isAmpdu, false, "no MPDU aggregation should be performe
d if there is no agreement"); |
231 NS_TEST_EXPECT_MSG_EQ (m_low->m_aggregateQueue[0]->GetNPackets (), 0, "aggrega
tion queue is not flushed"); | 231 NS_TEST_EXPECT_MSG_EQ (m_low->m_aggregateQueue[0]->GetNPackets (), 0, "aggrega
tion queue is not flushed"); |
232 | 232 |
233 m_manager->SetMaxSlrc (0); //set to 0 in order to fake that the maximum number
of retries has been reached | 233 m_manager->SetMaxSlrc (0); //set to 0 in order to fake that the maximum number
of retries has been reached |
234 m_edca->MissedAck (); | 234 m_txop->MissedAck (); |
235 | 235 |
236 NS_TEST_EXPECT_MSG_EQ (m_edca->m_currentPacket, 0, "packet should be discarded
"); | 236 NS_TEST_EXPECT_MSG_EQ (m_txop->m_currentPacket, 0, "packet should be discarded
"); |
237 m_edca->GetQueue ()->Remove (pkt3); | 237 m_txop->GetQueue ()->Remove (pkt3); |
238 | 238 |
239 Simulator::Destroy (); | 239 Simulator::Destroy (); |
240 | 240 |
241 m_txMiddle = 0; | 241 m_txMiddle = 0; |
242 | 242 |
243 m_low->Dispose (); | 243 m_low->Dispose (); |
244 m_low = 0; | 244 m_low = 0; |
245 | 245 |
246 m_edca->Dispose (); | 246 m_txop->Dispose (); |
247 m_edca = 0; | 247 m_txop = 0; |
248 | 248 |
249 m_dcfManager->Dispose (); | 249 m_dcfManager->Dispose (); |
250 m_dcfManager = 0; | 250 m_dcfManager = 0; |
251 } | 251 } |
252 | 252 |
253 /** | 253 /** |
254 * \ingroup wifi-test | 254 * \ingroup wifi-test |
255 * \ingroup tests | 255 * \ingroup tests |
256 * | 256 * |
257 * \brief Two Level Aggregation Test | 257 * \brief Two Level Aggregation Test |
258 */ | 258 */ |
259 class TwoLevelAggregationTest : public TestCase | 259 class TwoLevelAggregationTest : public TestCase |
260 { | 260 { |
261 public: | 261 public: |
262 TwoLevelAggregationTest (); | 262 TwoLevelAggregationTest (); |
263 | 263 |
264 private: | 264 private: |
265 virtual void DoRun (void); | 265 virtual void DoRun (void); |
266 Ptr<MacLow> m_low; ///< MacLow | 266 Ptr<MacLow> m_low; ///< MacLow |
267 Ptr<YansWifiPhy> m_phy; ///< Phy | 267 Ptr<YansWifiPhy> m_phy; ///< Phy |
268 Ptr<EdcaTxopN> m_edca; ///< EDCA | 268 Ptr<QosTxop> m_txop; ///< QosTxop |
269 Ptr<WifiRemoteStationManager> m_manager; ///< remote station manager | 269 Ptr<WifiRemoteStationManager> m_manager; ///< remote station manager |
270 ObjectFactory m_factory; ///< factory | 270 ObjectFactory m_factory; ///< factory |
271 Ptr<MsduAggregator> m_msduAggregator; ///< A-MSDU aggregator | 271 Ptr<MsduAggregator> m_msduAggregator; ///< A-MSDU aggregator |
272 Ptr<MpduAggregator> m_mpduAggregator; ///< A-MPDU aggregator | 272 Ptr<MpduAggregator> m_mpduAggregator; ///< A-MPDU aggregator |
273 }; | 273 }; |
274 | 274 |
275 TwoLevelAggregationTest::TwoLevelAggregationTest () | 275 TwoLevelAggregationTest::TwoLevelAggregationTest () |
276 : TestCase ("Check the correctness of two-level aggregation operations") | 276 : TestCase ("Check the correctness of two-level aggregation operations") |
277 { | 277 { |
278 } | 278 } |
(...skipping 16 matching lines...) Expand all Loading... |
295 m_manager = m_factory.Create<WifiRemoteStationManager> (); | 295 m_manager = m_factory.Create<WifiRemoteStationManager> (); |
296 m_manager->SetupPhy (m_phy); | 296 m_manager->SetupPhy (m_phy); |
297 | 297 |
298 /* | 298 /* |
299 * Create and configure maclayer. | 299 * Create and configure maclayer. |
300 */ | 300 */ |
301 m_low = CreateObject<MacLow> (); | 301 m_low = CreateObject<MacLow> (); |
302 m_low->SetPhy (m_phy); | 302 m_low->SetPhy (m_phy); |
303 m_low->SetWifiRemoteStationManager (m_manager); | 303 m_low->SetWifiRemoteStationManager (m_manager); |
304 | 304 |
305 m_edca = CreateObject<EdcaTxopN> (); | 305 m_txop = CreateObject<QosTxop> (); |
306 m_edca->SetLow (m_low); | 306 m_txop->SetLow (m_low); |
307 m_edca->SetAccessCategory (AC_BE); | 307 m_txop->SetAccessCategory (AC_BE); |
308 m_edca->SetWifiRemoteStationManager (m_manager); | 308 m_txop->SetWifiRemoteStationManager (m_manager); |
309 m_edca->CompleteConfig (); | 309 m_txop->CompleteConfig (); |
310 | 310 |
311 /* | 311 /* |
312 * Configure aggregation. | 312 * Configure aggregation. |
313 */ | 313 */ |
314 m_msduAggregator = CreateObject<MsduAggregator> (); | 314 m_msduAggregator = CreateObject<MsduAggregator> (); |
315 m_mpduAggregator = CreateObject<MpduAggregator> (); | 315 m_mpduAggregator = CreateObject<MpduAggregator> (); |
316 | 316 |
317 m_msduAggregator->SetMaxAmsduSize (4095); | 317 m_msduAggregator->SetMaxAmsduSize (4095); |
318 m_mpduAggregator->SetMaxAmpduSize (65535); | 318 m_mpduAggregator->SetMaxAmpduSize (65535); |
319 | 319 |
320 m_edca->SetMsduAggregator (m_msduAggregator); | 320 m_txop->SetMsduAggregator (m_msduAggregator); |
321 m_edca->SetMpduAggregator (m_mpduAggregator); | 321 m_txop->SetMpduAggregator (m_mpduAggregator); |
322 | 322 |
323 /* | 323 /* |
324 * Create dummy packets of 1500 bytes and fill mac header fields that will be
used for the tests. | 324 * Create dummy packets of 1500 bytes and fill mac header fields that will be
used for the tests. |
325 */ | 325 */ |
326 Ptr<const Packet> pkt = Create<Packet> (1500); | 326 Ptr<const Packet> pkt = Create<Packet> (1500); |
327 Ptr<Packet> currentAggregatedPacket = Create<Packet> (); | 327 Ptr<Packet> currentAggregatedPacket = Create<Packet> (); |
328 WifiMacHeader hdr, peekedHdr; | 328 WifiMacHeader hdr, peekedHdr; |
329 hdr.SetAddr1 (Mac48Address ("00:00:00:00:00:01")); | 329 hdr.SetAddr1 (Mac48Address ("00:00:00:00:00:01")); |
330 hdr.SetAddr2 (Mac48Address ("00:00:00:00:00:02")); | 330 hdr.SetAddr2 (Mac48Address ("00:00:00:00:00:02")); |
331 hdr.SetType (WIFI_MAC_QOSDATA); | 331 hdr.SetType (WIFI_MAC_QOSDATA); |
332 hdr.SetQosTid (0); | 332 hdr.SetQosTid (0); |
333 Time tstamp; | 333 Time tstamp; |
334 | 334 |
335 //----------------------------------------------------------------------------
------------------------- | 335 //----------------------------------------------------------------------------
------------------------- |
336 | 336 |
337 /* | 337 /* |
338 * Test MSDU aggregation of two packets using MacLow::PerformMsduAggregation. | 338 * Test MSDU aggregation of two packets using MacLow::PerformMsduAggregation. |
339 * It checks whether aggregation succeeded: | 339 * It checks whether aggregation succeeded: |
340 * - returned packet should be different from 0; | 340 * - returned packet should be different from 0; |
341 * - A-MSDU frame size should be 3030 bytes (= 2 packets + headers + padd
ing); | 341 * - A-MSDU frame size should be 3030 bytes (= 2 packets + headers + padd
ing); |
342 * - one packet should be removed from the queue (the other packet is rem
oved later in MacLow::AggregateToAmpdu) . | 342 * - one packet should be removed from the queue (the other packet is rem
oved later in MacLow::AggregateToAmpdu) . |
343 */ | 343 */ |
344 m_edca->GetQueue ()->Enqueue (Create<WifiMacQueueItem> (pkt, hdr)); | 344 m_txop->GetQueue ()->Enqueue (Create<WifiMacQueueItem> (pkt, hdr)); |
345 m_edca->GetQueue ()->Enqueue (Create<WifiMacQueueItem> (pkt, hdr)); | 345 m_txop->GetQueue ()->Enqueue (Create<WifiMacQueueItem> (pkt, hdr)); |
346 | 346 |
347 Ptr<const WifiMacQueueItem> peekedItem = m_edca->GetQueue ()->PeekByTidAndAddr
ess (0, WifiMacHeader::ADDR1, | 347 Ptr<const WifiMacQueueItem> peekedItem = m_txop->GetQueue ()->PeekByTidAndAddr
ess (0, WifiMacHeader::ADDR1, |
348
hdr.GetAddr1 ()); | 348
hdr.GetAddr1 ()); |
349 Ptr<const Packet> peekedPacket = peekedItem->GetPacket (); | 349 Ptr<const Packet> peekedPacket = peekedItem->GetPacket (); |
350 peekedHdr = peekedItem->GetHeader (); | 350 peekedHdr = peekedItem->GetHeader (); |
351 tstamp = peekedItem->GetTimeStamp (); | 351 tstamp = peekedItem->GetTimeStamp (); |
352 m_low->m_currentPacket = peekedPacket->Copy (); | 352 m_low->m_currentPacket = peekedPacket->Copy (); |
353 m_low->m_currentHdr = peekedHdr; | 353 m_low->m_currentHdr = peekedHdr; |
354 m_low->m_currentTxVector = m_low->GetDataTxVector (m_low->m_currentPacket, &m_
low->m_currentHdr); | 354 m_low->m_currentTxVector = m_low->GetDataTxVector (m_low->m_currentPacket, &m_
low->m_currentHdr); |
355 | 355 |
356 Ptr<Packet> packet = m_low->PerformMsduAggregation (peekedPacket, &peekedHdr,
&tstamp, currentAggregatedPacket, 0); | 356 Ptr<Packet> packet = m_low->PerformMsduAggregation (peekedPacket, &peekedHdr,
&tstamp, currentAggregatedPacket, 0); |
357 | 357 |
358 bool result = (packet != 0); | 358 bool result = (packet != 0); |
359 NS_TEST_EXPECT_MSG_EQ (result, true, "aggregation failed"); | 359 NS_TEST_EXPECT_MSG_EQ (result, true, "aggregation failed"); |
360 NS_TEST_EXPECT_MSG_EQ (packet->GetSize (), 3030, "wrong packet size"); | 360 NS_TEST_EXPECT_MSG_EQ (packet->GetSize (), 3030, "wrong packet size"); |
361 NS_TEST_EXPECT_MSG_EQ (m_edca->GetQueue ()->GetNPackets (), 0, "aggregated pac
kets not removed from the queue"); | 361 NS_TEST_EXPECT_MSG_EQ (m_txop->GetQueue ()->GetNPackets (), 0, "aggregated pac
kets not removed from the queue"); |
362 | 362 |
363 //----------------------------------------------------------------------------
------------------------- | 363 //----------------------------------------------------------------------------
------------------------- |
364 | 364 |
365 /* | 365 /* |
366 * Aggregation is refused when the maximum size is reached. | 366 * Aggregation is refused when the maximum size is reached. |
367 * It checks whether MSDU aggregation has been rejected because the maximum MP
DU size is set to 0 (returned packet should be equal to 0). | 367 * It checks whether MSDU aggregation has been rejected because the maximum MP
DU 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::Aggr
egateToAmpdu. | 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::Aggr
egateToAmpdu. |
369 */ | 369 */ |
370 m_factory = ObjectFactory (); | 370 m_factory = ObjectFactory (); |
371 m_factory.SetTypeId ("ns3::MpduAggregator"); | 371 m_factory.SetTypeId ("ns3::MpduAggregator"); |
372 m_mpduAggregator = m_factory.Create<MpduAggregator> (); | 372 m_mpduAggregator = m_factory.Create<MpduAggregator> (); |
373 m_mpduAggregator->SetMaxAmpduSize (65535); | 373 m_mpduAggregator->SetMaxAmpduSize (65535); |
374 m_edca->SetMpduAggregator (m_mpduAggregator); | 374 m_txop->SetMpduAggregator (m_mpduAggregator); |
375 | 375 |
376 m_edca->GetQueue ()->Enqueue (Create<WifiMacQueueItem> (pkt, hdr)); | 376 m_txop->GetQueue ()->Enqueue (Create<WifiMacQueueItem> (pkt, hdr)); |
377 packet = m_low->PerformMsduAggregation (peekedPacket, &peekedHdr, &tstamp, cur
rentAggregatedPacket, 0); | 377 packet = m_low->PerformMsduAggregation (peekedPacket, &peekedHdr, &tstamp, cur
rentAggregatedPacket, 0); |
378 | 378 |
379 result = (packet != 0); | 379 result = (packet != 0); |
380 NS_TEST_EXPECT_MSG_EQ (result, false, "maximum aggregated frame size check fai
led"); | 380 NS_TEST_EXPECT_MSG_EQ (result, false, "maximum aggregated frame size check fai
led"); |
381 | 381 |
382 //----------------------------------------------------------------------------
------------------------- | 382 //----------------------------------------------------------------------------
------------------------- |
383 | 383 |
384 /* | 384 /* |
385 * Aggregation does not occur when there is no more packets in the queue. | 385 * Aggregation does not occur when there is no more packets in the queue. |
386 * It checks whether MSDU aggregation has been rejected because there is no pa
ckets ready in the queue (returned packet should be equal to 0). | 386 * It checks whether MSDU aggregation has been rejected because there is no pa
ckets 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 empt
y. | 387 * This test is needed to ensure that there is no issue when the queue is empt
y. |
388 */ | 388 */ |
389 m_mpduAggregator->SetMaxAmpduSize (4095); | 389 m_mpduAggregator->SetMaxAmpduSize (4095); |
390 | 390 |
391 m_edca->GetQueue ()->Remove (pkt); | 391 m_txop->GetQueue ()->Remove (pkt); |
392 m_edca->GetQueue ()->Remove (pkt); | 392 m_txop->GetQueue ()->Remove (pkt); |
393 packet = m_low->PerformMsduAggregation (peekedPacket, &peekedHdr, &tstamp, cur
rentAggregatedPacket, 0); | 393 packet = m_low->PerformMsduAggregation (peekedPacket, &peekedHdr, &tstamp, cur
rentAggregatedPacket, 0); |
394 | 394 |
395 result = (packet != 0); | 395 result = (packet != 0); |
396 NS_TEST_EXPECT_MSG_EQ (result, false, "aggregation failed to stop as queue is
empty"); | 396 NS_TEST_EXPECT_MSG_EQ (result, false, "aggregation failed to stop as queue is
empty"); |
397 | 397 |
398 Simulator::Destroy (); | 398 Simulator::Destroy (); |
399 | 399 |
400 m_low->Dispose (); | 400 m_low->Dispose (); |
401 m_low = 0; | 401 m_low = 0; |
402 | 402 |
403 m_edca->Dispose (); | 403 m_txop->Dispose (); |
404 m_edca = 0; | 404 m_txop = 0; |
405 } | 405 } |
406 | 406 |
407 | 407 |
408 /** | 408 /** |
409 * \ingroup wifi-test | 409 * \ingroup wifi-test |
410 * \ingroup tests | 410 * \ingroup tests |
411 * | 411 * |
412 * \brief Wifi Aggregation Test Suite | 412 * \brief Wifi Aggregation Test Suite |
413 */ | 413 */ |
414 class WifiAggregationTestSuite : public TestSuite | 414 class WifiAggregationTestSuite : public TestSuite |
415 { | 415 { |
416 public: | 416 public: |
417 WifiAggregationTestSuite (); | 417 WifiAggregationTestSuite (); |
418 }; | 418 }; |
419 | 419 |
420 WifiAggregationTestSuite::WifiAggregationTestSuite () | 420 WifiAggregationTestSuite::WifiAggregationTestSuite () |
421 : TestSuite ("aggregation-wifi", UNIT) | 421 : TestSuite ("aggregation-wifi", UNIT) |
422 { | 422 { |
423 AddTestCase (new AmpduAggregationTest, TestCase::QUICK); | 423 AddTestCase (new AmpduAggregationTest, TestCase::QUICK); |
424 AddTestCase (new TwoLevelAggregationTest, TestCase::QUICK); | 424 AddTestCase (new TwoLevelAggregationTest, TestCase::QUICK); |
425 } | 425 } |
426 | 426 |
427 static WifiAggregationTestSuite g_wifiAggregationTestSuite; ///< the test suite | 427 static WifiAggregationTestSuite g_wifiAggregationTestSuite; ///< the test suite |
OLD | NEW |