A Discrete-Event Network Simulator
API
wifi-aggregation-test.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2015
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: Sébastien Deronne <sebastien.deronne@gmail.com>
19  */
20 
21 #include "ns3/string.h"
22 #include "ns3/test.h"
23 #include "ns3/simulator.h"
24 #include "ns3/wifi-mac-queue.h"
25 #include "ns3/wifi-psdu.h"
26 #include "ns3/sta-wifi-mac.h"
27 #include "ns3/yans-wifi-phy.h"
28 #include "ns3/mac-tx-middle.h"
29 #include "ns3/mac-low.h"
30 #include "ns3/msdu-aggregator.h"
31 #include "ns3/mpdu-aggregator.h"
32 #include "ns3/wifi-net-device.h"
33 #include "ns3/ht-configuration.h"
34 #include "ns3/vht-configuration.h"
35 #include "ns3/he-configuration.h"
36 
37 using namespace ns3;
38 
46 {
47 public:
49 
50 private:
51  virtual void DoRun (void);
57 };
58 
60  : TestCase ("Check the correctness of MPDU aggregation operations")
61 {
62 }
63 
64 void
66 {
67  /*
68  * Create device and attach HT configuration.
69  */
70  m_device = CreateObject<WifiNetDevice> ();
71  Ptr<HtConfiguration> htConfiguration = CreateObject<HtConfiguration> ();
72  m_device->SetHtConfiguration (htConfiguration);
73 
74  /*
75  * Create and configure phy layer.
76  */
77  m_phy = CreateObject<YansWifiPhy> ();
81 
82  /*
83  * Create and configure manager.
84  */
86  m_factory.SetTypeId ("ns3::ConstantRateWifiManager");
87  m_factory.Set ("DataMode", StringValue ("HtMcs7"));
91 
92  /*
93  * Create and configure mac layer.
94  */
95  m_mac = CreateObject<StaWifiMac> ();
99  m_mac->SetAddress (Mac48Address ("00:00:00:00:00:01"));
101  m_device->SetMac (m_mac);
102 
103  /*
104  * Configure MPDU aggregation.
105  */
106  m_mac->SetAttribute ("BE_MaxAmpduSize", UintegerValue (65535));
107  HtCapabilities htCapabilities;
108  htCapabilities.SetMaxAmpduLength (65535);
109  m_manager->AddStationHtCapabilities (Mac48Address ("00:00:00:00:00:02"), htCapabilities);
110  m_manager->AddStationHtCapabilities (Mac48Address ("00:00:00:00:00:03"), htCapabilities);
111 
112  /*
113  * Create a dummy packet of 1500 bytes and fill mac header fields.
114  */
115  Ptr<const Packet> pkt = Create<Packet> (1500);
116  Ptr<Packet> currentAggregatedPacket = Create<Packet> ();
117  WifiMacHeader hdr;
118  hdr.SetAddr1 (Mac48Address ("00:00:00:00:00:02"));
119  hdr.SetAddr2 (Mac48Address ("00:00:00:00:00:01"));
120  hdr.SetType (WIFI_MAC_QOSDATA);
121  hdr.SetQosTid (0);
122  uint16_t sequence = m_mac->m_txMiddle->GetNextSequenceNumberFor (&hdr);
123  hdr.SetSequenceNumber (sequence);
124  hdr.SetFragmentNumber (0);
125  hdr.SetNoMoreFragments ();
126  hdr.SetNoRetry ();
127 
128  /*
129  * Establish agreement.
130  */
131  MgtAddBaRequestHeader reqHdr;
132  reqHdr.SetImmediateBlockAck ();
133  reqHdr.SetTid (0);
134  reqHdr.SetBufferSize (64);
135  reqHdr.SetTimeout (0);
136  reqHdr.SetStartingSequence (0);
137  m_mac->GetBEQueue ()->m_baManager->CreateAgreement (&reqHdr, hdr.GetAddr1 ());
138  m_mac->GetBEQueue ()->m_baManager->NotifyAgreementEstablished (hdr.GetAddr1 (), 0, 0);
139 
140  //-----------------------------------------------------------------------------------------------------
141 
142  /*
143  * Test behavior when no other packets are in the queue
144  */
145  WifiTxVector txVector = m_mac->GetBEQueue ()->GetLow ()->GetDataTxVector (Create<const WifiMacQueueItem> (pkt, hdr));
146 
147  auto mpduList = m_mac->GetBEQueue ()->GetLow ()->GetMpduAggregator ()->GetNextAmpdu (Create<WifiMacQueueItem> (pkt, hdr),
148  txVector);
149  NS_TEST_EXPECT_MSG_EQ (mpduList.empty (), true, "a single packet should not result in an A-MPDU");
150 
151  //-----------------------------------------------------------------------------------------------------
152 
153  /*
154  * Test behavior when 2 more packets are in the queue
155  */
156  Ptr<const Packet> pkt1 = Create<Packet> (1500);
157  Ptr<const Packet> pkt2 = Create<Packet> (1500);
158  WifiMacHeader hdr1, hdr2;
159 
160  hdr1.SetAddr1 (Mac48Address ("00:00:00:00:00:02"));
161  hdr1.SetAddr2 (Mac48Address ("00:00:00:00:00:01"));
162  hdr1.SetType (WIFI_MAC_QOSDATA);
163  hdr1.SetQosTid (0);
164 
165  hdr2.SetAddr1 (Mac48Address ("00:00:00:00:00:02"));
166  hdr2.SetAddr2 (Mac48Address ("00:00:00:00:00:01"));
167  hdr2.SetType (WIFI_MAC_QOSDATA);
168  hdr2.SetQosTid (0);
169 
170  m_mac->GetBEQueue ()->GetWifiMacQueue ()->Enqueue (Create<WifiMacQueueItem> (pkt1, hdr1));
171  m_mac->GetBEQueue ()->GetWifiMacQueue ()->Enqueue (Create<WifiMacQueueItem> (pkt2, hdr2));
172 
173  mpduList = m_mac->GetBEQueue ()->GetLow ()->GetMpduAggregator ()->GetNextAmpdu (Create<WifiMacQueueItem> (pkt, hdr),
174  txVector);
175  Ptr<WifiPsdu> psdu = Create<WifiPsdu> (mpduList);
176 
177  NS_TEST_EXPECT_MSG_EQ (mpduList.empty (), false, "MPDU aggregation failed");
178  NS_TEST_EXPECT_MSG_EQ (psdu->GetSize (), 4606, "A-MPDU size is not correct");
179  NS_TEST_EXPECT_MSG_EQ (mpduList.size (), 3, "A-MPDU should contain 3 MPDUs");
180  NS_TEST_EXPECT_MSG_EQ (m_mac->GetBEQueue ()->GetWifiMacQueue ()->GetNPackets (), 0, "queue should be empty");
181 
182  Ptr <WifiMacQueueItem> dequeuedItem;
183  WifiMacHeader dequeuedHdr;
184  for (uint32_t i = 0; i < psdu->GetNMpdus (); i++)
185  {
186  NS_TEST_EXPECT_MSG_EQ (psdu->GetHeader (i).GetSequenceNumber (), i, "wrong sequence number");
187  }
188 
189  //-----------------------------------------------------------------------------------------------------
190 
191  /*
192  * Test behavior when the 802.11n station and another non-QoS station are associated to the AP.
193  * The AP sends an A-MPDU to the 802.11n station followed by the last retransmission of a non-QoS data frame to the non-QoS station.
194  * This is used to reproduce bug 2224.
195  */
196  pkt1 = Create<Packet> (1500);
197  pkt2 = Create<Packet> (1500);
198  hdr1.SetAddr1 (Mac48Address ("00:00:00:00:00:02"));
199  hdr1.SetAddr2 (Mac48Address ("00:00:00:00:00:01"));
200  hdr1.SetType (WIFI_MAC_QOSDATA);
201  hdr1.SetQosTid (0);
202  hdr1.SetSequenceNumber (3);
203  hdr2.SetAddr1 (Mac48Address ("00:00:00:00:00:03"));
204  hdr2.SetAddr2 (Mac48Address ("00:00:00:00:00:01"));
205  hdr2.SetType (WIFI_MAC_QOSDATA);
206  hdr2.SetQosTid (0);
207 
208  Ptr<const Packet> pkt3 = Create<Packet> (1500);
209  WifiMacHeader hdr3;
210  hdr3.SetSequenceNumber (0);
211  hdr3.SetAddr1 (Mac48Address ("00:00:00:00:00:03"));
212  hdr3.SetAddr2 (Mac48Address ("00:00:00:00:00:01"));
213  hdr3.SetType (WIFI_MAC_QOSDATA);
214  hdr3.SetQosTid (0);
215 
216  m_mac->GetBEQueue ()->GetWifiMacQueue ()->Enqueue (Create<WifiMacQueueItem> (pkt3, hdr3));
217 
218  mpduList = m_mac->GetBEQueue ()->GetLow ()->GetMpduAggregator ()->GetNextAmpdu (Create<WifiMacQueueItem> (pkt1, hdr1),
219  txVector);
220  NS_TEST_EXPECT_MSG_EQ (mpduList.empty (), true, "a single packet for this destination should not result in an A-MPDU");
221 
222  mpduList = m_mac->GetBEQueue ()->GetLow ()->GetMpduAggregator ()->GetNextAmpdu (Create<WifiMacQueueItem> (pkt2, hdr2),
223  txVector);
224  NS_TEST_EXPECT_MSG_EQ (mpduList.empty (), true, "no MPDU aggregation should be performed if there is no agreement");
225 
226  m_manager->SetMaxSsrc (0); //set to 0 in order to fake that the maximum number of retries has been reached
227  m_mac->GetBEQueue ()->m_currentHdr = hdr2;
228  m_mac->GetBEQueue ()->m_currentPacket = pkt2->Copy ();
229  m_mac->GetBEQueue ()->MissedAck ();
230 
231  NS_TEST_EXPECT_MSG_EQ (m_mac->GetBEQueue ()->m_currentPacket, 0, "packet should be discarded");
232  m_mac->GetBEQueue ()->GetWifiMacQueue ()->Remove (pkt3);
233 
234  Simulator::Destroy ();
235 
236  m_manager->Dispose ();
237  m_manager = 0;
238 
239  m_device->Dispose ();
240  m_device = 0;
241 
242  htConfiguration = 0;
243 }
244 
252 {
253 public:
255 
256 private:
257  virtual void DoRun (void);
263 };
264 
266  : TestCase ("Check the correctness of two-level aggregation operations")
267 {
268 }
269 
270 void
272 {
273  /*
274  * Create device and attach HT configuration.
275  */
276  m_device = CreateObject<WifiNetDevice> ();
277  Ptr<HtConfiguration> htConfiguration = CreateObject<HtConfiguration> ();
278  m_device->SetHtConfiguration (htConfiguration);
279 
280  /*
281  * Create and configure phy layer.
282  */
283  m_phy = CreateObject<YansWifiPhy> ();
286  m_device->SetPhy (m_phy);
287 
288  /*
289  * Create and configure manager.
290  */
292  m_factory.SetTypeId ("ns3::ConstantRateWifiManager");
293  m_factory.Set ("DataMode", StringValue ("HtMcs7"));
297 
298  /*
299  * Create and configure mac layer.
300  */
301  m_mac = CreateObject<StaWifiMac> ();
305  m_mac->SetAddress (Mac48Address ("00:00:00:00:00:01"));
307  m_device->SetMac (m_mac);
308 
309  /*
310  * Configure aggregation.
311  */
312  m_mac->SetAttribute ("BE_MaxAmsduSize", UintegerValue (4095));
313  m_mac->SetAttribute ("BE_MaxAmpduSize", UintegerValue (65535));
314  HtCapabilities htCapabilities;
315  htCapabilities.SetMaxAmsduLength (7935);
316  htCapabilities.SetMaxAmpduLength (65535);
317  m_manager->AddStationHtCapabilities (Mac48Address ("00:00:00:00:00:02"), htCapabilities);
318 
319  /*
320  * Create dummy packets of 1500 bytes and fill mac header fields that will be used for the tests.
321  */
322  Ptr<const Packet> pkt = Create<Packet> (1500);
323  Ptr<Packet> currentAggregatedPacket = Create<Packet> ();
324  WifiMacHeader hdr;
325  hdr.SetAddr1 (Mac48Address ("00:00:00:00:00:02"));
326  hdr.SetAddr2 (Mac48Address ("00:00:00:00:00:01"));
327  hdr.SetType (WIFI_MAC_QOSDATA);
328  hdr.SetQosTid (0);
329 
330  //-----------------------------------------------------------------------------------------------------
331 
332  /*
333  * Test MSDU aggregation of two packets using MsduAggregator::GetNextAmsdu.
334  * It checks whether aggregation succeeded:
335  * - returned packet should be different from 0;
336  * - A-MSDU frame size should be 3030 bytes (= 2 packets + headers + padding);
337  * - one packet should be removed from the queue (the other packet is removed later in MacLow::AggregateToAmpdu) .
338  */
339  m_mac->GetBEQueue ()->GetWifiMacQueue ()->Enqueue (Create<WifiMacQueueItem> (pkt, hdr));
340  m_mac->GetBEQueue ()->GetWifiMacQueue ()->Enqueue (Create<WifiMacQueueItem> (pkt, hdr));
341 
342  WifiTxVector txVector = m_mac->GetBEQueue ()->GetLow ()->GetDataTxVector (Create<const WifiMacQueueItem> (pkt, hdr));
343 
345  item = m_mac->GetBEQueue ()->GetLow ()->GetMsduAggregator ()->GetNextAmsdu (hdr.GetAddr1 (), 0, txVector,
346  currentAggregatedPacket->GetSize ());
347  bool result = (item != 0);
348  NS_TEST_EXPECT_MSG_EQ (result, true, "aggregation failed");
349  NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->GetSize (), 3030, "wrong packet size");
350  NS_TEST_EXPECT_MSG_EQ (m_mac->GetBEQueue ()->GetWifiMacQueue ()->GetNPackets (), 0, "aggregated packets not removed from the queue");
351 
352  //-----------------------------------------------------------------------------------------------------
353 
354  /*
355  * Aggregation is refused when the maximum size is reached.
356  * It checks whether MSDU aggregation has been rejected because the maximum MPDU size is set to 0 (returned packet should be equal to 0).
357  * This test is needed to ensure that no packets are removed from the queue in
358  * MsduAggregator::GetNextAmsdu, since aggregation will no occur in MacLow::AggregateToAmpdu.
359  */
360  m_mac->SetAttribute ("BE_MaxAmpduSize", UintegerValue (65535));
361 
362  m_mac->GetBEQueue ()->GetWifiMacQueue ()->Enqueue (Create<WifiMacQueueItem> (pkt, hdr));
363 
364  item = m_mac->GetBEQueue ()->GetLow ()->GetMsduAggregator ()->GetNextAmsdu (hdr.GetAddr1 (), 0, txVector,
365  currentAggregatedPacket->GetSize ());
366  result = (item != 0);
367  NS_TEST_EXPECT_MSG_EQ (result, false, "maximum aggregated frame size check failed");
368 
369  //-----------------------------------------------------------------------------------------------------
370 
371  /*
372  * Aggregation does not occur when there is no more packets in the queue.
373  * It checks whether MSDU aggregation has been rejected because there is no packets ready in the queue (returned packet should be equal to 0).
374  * This test is needed to ensure that there is no issue when the queue is empty.
375  */
376  m_mac->SetAttribute ("BE_MaxAmpduSize", UintegerValue (4095));
377 
378  m_mac->GetBEQueue ()->GetWifiMacQueue ()->Remove (pkt);
379  m_mac->GetBEQueue ()->GetWifiMacQueue ()->Remove (pkt);
380 
381  item = m_mac->GetBEQueue ()->GetLow ()->GetMsduAggregator ()->GetNextAmsdu (hdr.GetAddr1 (), 0, txVector,
382  currentAggregatedPacket->GetSize ());
383 
384  result = (item != 0);
385  NS_TEST_EXPECT_MSG_EQ (result, false, "aggregation failed to stop as queue is empty");
386 
387  //-----------------------------------------------------------------------------------------------------
388 
389  /*
390  * Aggregation of MPDUs is stopped to prevent that the PPDU duration exceeds the TXOP limit.
391  * In this test, the VI AC is used, which has a default TXOP limit of 3008 microseconds.
392  */
393 
394  // Establish agreement.
395  uint8_t tid = 5;
396  MgtAddBaRequestHeader reqHdr;
397  reqHdr.SetImmediateBlockAck ();
398  reqHdr.SetTid (tid);
399  reqHdr.SetBufferSize (64);
400  reqHdr.SetTimeout (0);
401  reqHdr.SetStartingSequence (0);
402  m_mac->GetVIQueue ()->m_baManager->CreateAgreement (&reqHdr, hdr.GetAddr1 ());
403  m_mac->GetVIQueue ()->m_baManager->NotifyAgreementEstablished (hdr.GetAddr1 (), tid, 0);
404 
405  m_mac->SetAttribute ("VI_MaxAmsduSize", UintegerValue (3050)); // max 2 MSDUs per A-MSDU
406  m_mac->SetAttribute ("VI_MaxAmpduSize", UintegerValue (65535));
407  m_manager->SetAttribute ("DataMode", StringValue ("HtMcs2")); // 19.5Mbps
408 
409  pkt = Create<Packet> (1400);
410  hdr.SetQosTid (tid);
411 
412  // Add 10 MSDUs to the EDCA queue
413  for (uint8_t i = 0; i < 10; i++)
414  {
415  m_mac->GetVIQueue ()->GetWifiMacQueue ()->Enqueue (Create<WifiMacQueueItem> (pkt, hdr));
416  }
417 
418  txVector = m_mac->GetVIQueue ()->GetLow ()->GetDataTxVector (Create<const WifiMacQueueItem> (pkt, hdr));
419  Time txopLimit = m_mac->GetVIQueue ()->GetTxopLimit (); // 3.008 ms
420 
421  // Compute the first MPDU to be aggregated in an A-MPDU. It must contain an A-MSDU
422  // aggregating two MSDUs
423  Ptr<WifiMacQueueItem> mpdu = m_mac->GetVIQueue ()->GetLow ()->GetMsduAggregator ()->GetNextAmsdu (hdr.GetAddr1 (), tid,
424  txVector, 0, txopLimit);
425  NS_TEST_EXPECT_MSG_EQ (m_mac->GetVIQueue ()->GetWifiMacQueue ()->GetNPackets (), 8, "There must be 8 MSDUs left in EDCA queue");
426 
427  auto mpduList = m_mac->GetVIQueue ()->GetLow ()->GetMpduAggregator ()->GetNextAmpdu (mpdu, txVector, txopLimit);
428 
429  // The maximum number of bytes that can be transmitted in a TXOP is (approximately, as we
430  // do not consider that the preamble is transmitted at a different rate):
431  // 19.5 Mbps * 3.008 ms = 7332 bytes
432  // Given that the max A-MSDU size is set to 3050, an A-MSDU will contain two MSDUs and have
433  // a size of 2 * 1400 (MSDU size) + 2 * 14 (A-MSDU subframe header size) + 2 (one padding field) = 2830 bytes
434  // Hence, we expect that the A-MPDU will consist of:
435  // - 2 MPDUs containing each an A-MSDU. The size of each MPDU is 2830 (A-MSDU) + 30 (header+trailer) = 2860
436  // - 1 MPDU containing a single MSDU. The size of such MPDU is 1400 (MSDU) + 30 (header+trailer) = 1430
437  // The size of the A-MPDU is 4 + 2860 + 4 + 2860 + 4 + 1430 = 7162
438  NS_TEST_EXPECT_MSG_EQ (mpduList.empty (), false, "aggregation failed");
439  NS_TEST_EXPECT_MSG_EQ (mpduList.size (), 3, "Unexpected number of MPDUs in the A-MPDU");
440  NS_TEST_EXPECT_MSG_EQ (mpduList.at (0)->GetSize (), 2860, "Unexpected size of the first MPDU");
441  NS_TEST_EXPECT_MSG_EQ (mpduList.at (1)->GetSize (), 2860, "Unexpected size of the second MPDU");
442  NS_TEST_EXPECT_MSG_EQ (mpduList.at (2)->GetSize (), 1430, "Unexpected size of the first MPDU");
443  NS_TEST_EXPECT_MSG_EQ (m_mac->GetVIQueue ()->GetWifiMacQueue ()->GetNPackets (), 5,
444  "Unexpected number of MSDUs left in the EDCA queue");
445 
446  Ptr<WifiPsdu> psdu = Create<WifiPsdu> (mpduList);
447  NS_TEST_EXPECT_MSG_EQ (psdu->GetSize (), 7162, "Unexpected size of the A-MPDU");
448 
449  Simulator::Destroy ();
450 
451  m_device->Dispose ();
452  m_device = 0;
453  htConfiguration = 0;
454 }
455 
463 {
464 public:
466 
467 private:
468  void DoRun (void);
469  void DoRunSubTest (uint16_t bufferSize);
475 };
476 
478  : TestCase ("Check the correctness of 802.11ax aggregation operations")
479 {
480 }
481 
482 void
483 HeAggregationTest::DoRunSubTest (uint16_t bufferSize)
484 {
485  /*
486  * Create device and attach configurations.
487  */
488  m_device = CreateObject<WifiNetDevice> ();
489  Ptr<HtConfiguration> htConfiguration = CreateObject<HtConfiguration> ();
490  m_device->SetHtConfiguration (htConfiguration);
491  Ptr<VhtConfiguration> vhtConfiguration = CreateObject<VhtConfiguration> ();
492  m_device->SetVhtConfiguration (vhtConfiguration);
493  Ptr<HeConfiguration> heConfiguration = CreateObject<HeConfiguration> ();
494  m_device->SetHeConfiguration (heConfiguration);
495 
496  /*
497  * Create and configure phy layer.
498  */
499  m_phy = CreateObject<YansWifiPhy> ();
502  m_device->SetPhy (m_phy);
503 
504  /*
505  * Create and configure manager.
506  */
508  m_factory.SetTypeId ("ns3::ConstantRateWifiManager");
509  m_factory.Set ("DataMode", StringValue ("HeMcs11"));
513 
514  /*
515  * Create and configure mac layer.
516  */
517  m_mac = CreateObject<StaWifiMac> ();
521  m_mac->SetAddress (Mac48Address ("00:00:00:00:00:01"));
523  m_device->SetMac (m_mac);
524 
525  /*
526  * Configure aggregation.
527  */
528  HeCapabilities heCapabilities;
529  m_manager->AddStationHeCapabilities (Mac48Address ("00:00:00:00:00:02"), heCapabilities);
530 
531  /*
532  * Create a dummy packet of 100 bytes and fill mac header fields.
533  */
534  Ptr<const Packet> pkt = Create<Packet> (100);
535  Ptr<Packet> currentAggregatedPacket = Create<Packet> ();
536  WifiMacHeader hdr;
537  hdr.SetAddr1 (Mac48Address ("00:00:00:00:00:02"));
538  hdr.SetAddr2 (Mac48Address ("00:00:00:00:00:01"));
539  hdr.SetType (WIFI_MAC_QOSDATA);
540  hdr.SetQosTid (0);
541  uint16_t sequence = m_mac->m_txMiddle->GetNextSequenceNumberFor (&hdr);
542  hdr.SetSequenceNumber (sequence);
543  hdr.SetFragmentNumber (0);
544  hdr.SetNoMoreFragments ();
545  hdr.SetNoRetry ();
546 
547  /*
548  * Establish agreement.
549  */
550  MgtAddBaRequestHeader reqHdr;
551  reqHdr.SetImmediateBlockAck ();
552  reqHdr.SetTid (0);
553  reqHdr.SetBufferSize (bufferSize);
554  reqHdr.SetTimeout (0);
555  reqHdr.SetStartingSequence (0);
556  m_mac->GetBEQueue ()->m_baManager->CreateAgreement (&reqHdr, hdr.GetAddr1 ());
557  m_mac->GetBEQueue ()->m_baManager->NotifyAgreementEstablished (hdr.GetAddr1 (), 0, 0);
558 
559  /*
560  * Test behavior when 300 packets are ready for transmission but negociated buffer size is 64
561  */
562  for (uint16_t i = 0; i < 300; i++)
563  {
564  Ptr<const Packet> pkt = Create<Packet> (100);
565  WifiMacHeader hdr;
566 
567  hdr.SetAddr1 (Mac48Address ("00:00:00:00:00:02"));
568  hdr.SetAddr2 (Mac48Address ("00:00:00:00:00:01"));
569  hdr.SetType (WIFI_MAC_QOSDATA);
570  hdr.SetQosTid (0);
571 
572  m_mac->GetBEQueue ()->GetWifiMacQueue ()->Enqueue (Create<WifiMacQueueItem> (pkt, hdr));
573  }
574 
575  WifiTxVector txVector = m_mac->GetBEQueue ()->GetLow ()->GetDataTxVector (Create<const WifiMacQueueItem> (pkt, hdr));
576 
577  auto mpduList = m_mac->GetBEQueue ()->GetLow ()->GetMpduAggregator ()-> GetNextAmpdu (Create<WifiMacQueueItem> (pkt, hdr),
578  txVector);
579  NS_TEST_EXPECT_MSG_EQ (mpduList.empty (), false, "MPDU aggregation failed");
580  NS_TEST_EXPECT_MSG_EQ (mpduList.size (), bufferSize, "A-MPDU should countain " << bufferSize << " MPDUs");
581  uint16_t expectedRemainingPacketsInQueue = 300 - bufferSize + 1;
582  NS_TEST_EXPECT_MSG_EQ (m_mac->GetBEQueue ()->GetWifiMacQueue ()->GetNPackets (), expectedRemainingPacketsInQueue, "queue should contain 300 - "<< bufferSize - 1 << " = "<< expectedRemainingPacketsInQueue << " packets");
583 
584  Simulator::Destroy ();
585 
586  m_manager->Dispose ();
587  m_manager = 0;
588 
589  m_device->Dispose ();
590  m_device = 0;
591 
592  htConfiguration = 0;
593  vhtConfiguration = 0;
594  heConfiguration = 0;
595 }
596 
597 void
599 {
600  DoRunSubTest (64);
601  DoRunSubTest (256);
602 }
603 
611 {
612 public:
614 };
615 
617  : TestSuite ("aggregation-wifi", UNIT)
618 {
619  AddTestCase (new AmpduAggregationTest, TestCase::QUICK);
620  AddTestCase (new TwoLevelAggregationTest, TestCase::QUICK);
621  AddTestCase (new HeAggregationTest, TestCase::QUICK);
622 }
623 
void Dispose(void)
Dispose of this Object.
Definition: object.cc:214
Ptr< StaWifiMac > m_mac
Mac.
void SetWifiPhy(const Ptr< WifiPhy > phy)
ObjectFactory m_factory
factory
void MissedAck(void)
Event handler when an ACK is missed.
Definition: qos-txop.cc:793
Wifi Aggregation Test Suite.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
virtual void DoRun(void)
Implementation to actually run this TestCase.
HT PHY for the 5 GHz band (clause 20)
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:852
Ptr< WifiRemoteStationManager > m_manager
remote station manager
Hold variables of type string.
Definition: string.h:41
ObjectFactory m_factory
factory
A suite of tests to run.
Definition: test.h:1342
void SetImmediateBlockAck()
Enable immediate Block ACK.
void SetBufferSize(uint16_t size)
Set buffer size.
Implement the header for management frames of type add block ack request.
Definition: mgt-headers.h:997
void SetHtConfiguration(Ptr< HtConfiguration > htConfiguration)
The HT Capabilities Information ElementThis class knows how to serialise and deserialise the HT Capab...
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Definition: test.h:285
void ConfigureStandard(WifiPhyStandard standard)
Definition: wifi-mac.cc:270
Ptr< WifiNetDevice > m_device
WifiNetDevice.
encapsulates test code
Definition: test.h:1155
Ptr< StaWifiMac > m_mac
Mac.
ObjectFactory m_factory
factory
Ptr< YansWifiPhy > m_phy
Phy.
void SetWifiRemoteStationManager(const Ptr< WifiRemoteStationManager > stationManager)
Set up WifiRemoteStationManager associated with this StaWifiMac.
uint32_t GetSize(void) const
Return the size of the PSDU.
Definition: wifi-psdu.cc:241
void SetDevice(const Ptr< NetDevice > device)
Sets the device this PHY is associated with.
Definition: wifi-phy.cc:719
void SetHeConfiguration(Ptr< HeConfiguration > heConfiguration)
HE PHY for the 5 GHz band (clause 26)
Ptr< WifiRemoteStationManager > m_manager
remote station manager
void SetAddr1(Mac48Address address)
Fill the Address 1 field with the given address.
void SetDevice(const Ptr< NetDevice > device)
Sets the device this PHY is associated with.
Definition: wifi-mac.cc:221
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
void SetMac(const Ptr< WifiMac > mac)
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
Ptr< WifiNetDevice > m_device
WifiNetDevice.
void SetMaxAmpduLength(uint32_t maxampdulength)
Set the maximum AMPDU length.
Hold an unsigned integer type.
Definition: uinteger.h:44
void SetTid(uint8_t tid)
Set Traffic ID (TID).
void AddStationHtCapabilities(Mac48Address from, HtCapabilities htcapabilities)
Records HT capabilities of the remote station.
Ptr< BlockAckManager > m_baManager
the Block ACK manager
Definition: qos-txop.h:605
void SetAddress(Mac48Address address)
void SetMaxSsrc(uint32_t maxSsrc)
Sets the maximum STA short retry count (SSRC).
Ptr< StaWifiMac > m_mac
Mac.
void SetStartingSequence(uint16_t seq)
Set the starting sequence number.
Ptr< WifiNetDevice > m_device
WifiNetDevice.
void AddStationHeCapabilities(Mac48Address from, HeCapabilities hecapabilities)
Records HE capabilities of the remote station.
void SetMaxAmsduLength(uint16_t maxamsdulength)
Set the maximum AMSDU length.
virtual void SetupPhy(const Ptr< WifiPhy > phy)
Set up PHY associated with this device since it is the object that knows the full set of transmit rat...
hold a list of per-remote-station state.
const WifiMacHeader & GetHeader(std::size_t i) const
Get the header of the i-th MPDU.
Definition: wifi-psdu.cc:248
void DoRunSubTest(uint16_t bufferSize)
Ptr< const Packet > GetPacket(void) const
Get the packet stored in this item.
Ptr< MacLow > GetLow(void) const
Return the MacLow associated with this Txop.
Definition: txop.cc:355
std::size_t GetNMpdus(void) const
Return the number of MPDUs constituting the PSDU.
Definition: wifi-psdu.cc:276
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint16_t GetSequenceNumber(void) const
Return the sequence number of the header.
static WifiAggregationTestSuite g_wifiAggregationTestSuite
the test suite
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
Definition: packet.cc:121
an EUI-48 address
Definition: mac48-address.h:43
Ptr< const Packet > m_currentPacket
the current packet
Definition: txop.h:526
void Set(std::string name, const AttributeValue &value)
Set an attribute to be set during construction.
Ptr< QosTxop > GetVIQueue(void) const
Accessor for the AC_VI channel access function.
Two Level Aggregation Test.
Ampdu Aggregation Test.
Instantiate subclasses of ns3::Object.
void SetPhy(const Ptr< WifiPhy > phy)
Ptr< QosTxop > GetBEQueue(void) const
Accessor for the AC_BE channel access function.
void DoRun(void)
Implementation to actually run this TestCase.
virtual void DoRun(void)
Implementation to actually run this TestCase.
void SetSequenceNumber(uint16_t seq)
Set the sequence number of the header.
802.11ax aggregation test which permits 64 or 256 MPDUs in A-MPDU according to the negociated buffer ...
Ptr< WifiMacQueue > GetWifiMacQueue() const
Return the packet queue associated with this Txop.
Definition: txop.cc:178
Ptr< YansWifiPhy > m_phy
Phy.
virtual void ConfigureStandard(WifiPhyStandard standard)
Configure the PHY-level parameters for different Wi-Fi standard.
Definition: wifi-phy.cc:1217
void SetTimeout(uint16_t timeout)
Set timeout.
WifiMacHeader m_currentHdr
the current header
Definition: txop.h:527
Ptr< YansWifiPhy > m_phy
Phy.
The IEEE 802.11ax HE Capabilities.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:185
void SetVhtConfiguration(Ptr< VhtConfiguration > vhtConfiguration)
Ptr< MacTxMiddle > m_txMiddle
TX middle (aggregation etc.)
Implements the IEEE 802.11 MAC header.
void SetRemoteStationManager(const Ptr< WifiRemoteStationManager > manager)
Ptr< WifiRemoteStationManager > m_manager
remote station manager
Time GetTxopLimit(void) const
Return the TXOP limit.
Definition: txop.cc:302