21 #include "ns3/string.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/ht-frame-exchange-manager.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 #include "ns3/node-container.h"
37 #include "ns3/yans-wifi-helper.h"
38 #include "ns3/mobility-helper.h"
39 #include "ns3/pointer.h"
40 #include "ns3/packet-socket-server.h"
41 #include "ns3/packet-socket-client.h"
42 #include "ns3/packet-socket-helper.h"
43 #include "ns3/wifi-default-protection-manager.h"
44 #include "ns3/wifi-default-ack-manager.h"
70 void DoRun (
void)
override;
80 :
TestCase (
"Check the correctness of MPDU aggregation operations"),
97 m_device = CreateObject<WifiNetDevice> ();
104 m_phy = CreateObject<YansWifiPhy> ();
122 m_mac = CreateObject<StaWifiMac> ();
129 protectionManager->SetWifiMac (
m_mac);
130 fem->SetProtectionManager (protectionManager);
132 ackManager->SetWifiMac (
m_mac);
133 fem->SetAckManager (ackManager);
150 Ptr<Packet> currentAggregatedPacket = Create<Packet> ();
199 auto mpduList = mpduAggregator->GetNextAmpdu (item, txParams,
Time::Min (), queueIt);
229 mpduList = mpduAggregator->GetNextAmpdu (item, txParams,
Time::Min (), queueIt);
234 htFem->DequeuePsdu (psdu);
240 for (uint32_t i = 0; i < psdu->
GetNMpdus (); i++)
252 pkt1 = Create<Packet> (1500);
253 pkt2 = Create<Packet> (1500);
279 queueIt = {
nullptr, WifiMacQueue::EMPTY};
282 mpduList = mpduAggregator->GetNextAmpdu (item, txParams,
Time::Min (), queueIt);
284 NS_TEST_EXPECT_MSG_EQ (mpduList.empty (),
true,
"a single packet for this destination should not result in an A-MPDU");
286 htFem->DequeueMpdu (item);
291 queueIt = {
nullptr, WifiMacQueue::EMPTY};
294 mpduList = mpduAggregator->GetNextAmpdu (item, txParams,
Time::Min (), queueIt);
296 NS_TEST_EXPECT_MSG_EQ (mpduList.empty (),
true,
"no MPDU aggregation should be performed if there is no agreement");
301 htFem->NormalAckTimeout (item, txParams.
m_txVector);
306 Simulator::Destroy ();
329 void DoRun (
void)
override;
338 :
TestCase (
"Check the correctness of two-level aggregation operations")
348 m_device = CreateObject<WifiNetDevice> ();
355 m_phy = CreateObject<YansWifiPhy> ();
373 m_mac = CreateObject<StaWifiMac> ();
380 protectionManager->SetWifiMac (
m_mac);
381 fem->SetProtectionManager (protectionManager);
383 ackManager->SetWifiMac (
m_mac);
384 fem->SetAckManager (ackManager);
426 htFem->TryAddMpdu (peeked, txParams,
Time::Min ());
430 bool result = (item != 0);
435 htFem->DequeueMpdu (item);
438 "Unexpected number of MSDUs left in the EDCA queue");
449 htFem->TryAddMpdu (peeked, txParams,
Time::Min ());
450 item = msduAggregator->GetNextAmsdu (peeked, txParams,
Time::Min (), queueIt);
454 htFem->DequeueMpdu (*peeked->GetQueueIteratorPairs ().front ().it);
493 for (uint8_t i = 0; i < 10; i++)
505 queueIt = {
nullptr, WifiMacQueue::EMPTY};
510 auto mpduList = mpduAggregator->GetNextAmpdu (item, txParams, txopLimit, queueIt);
528 htFem->DequeuePsdu (psdu);
531 "Unexpected number of MSDUs left in the EDCA queue");
535 Simulator::Destroy ();
554 void DoRun (
void)
override;
569 :
TestCase (
"Check the correctness of 802.11ax aggregation operations")
579 m_device = CreateObject<WifiNetDevice> ();
590 m_phy = CreateObject<YansWifiPhy> ();
608 m_mac = CreateObject<StaWifiMac> ();
615 protectionManager->SetWifiMac (
m_mac);
616 fem->SetProtectionManager (protectionManager);
618 ackManager->SetWifiMac (
m_mac);
619 fem->SetAckManager (ackManager);
637 uint16_t sequence =
m_mac->
m_txMiddle->PeekNextSequenceNumberFor (&hdr);
671 for (uint16_t i = 0; i < 300; i++)
691 auto mpduList = mpduAggregator->GetNextAmpdu (item, txParams,
Time::Min (), queueIt);
693 htFem->DequeuePsdu (psdu);
696 NS_TEST_EXPECT_MSG_EQ (mpduList.size (), bufferSize,
"A-MPDU should countain " << bufferSize <<
" MPDUs");
697 uint16_t expectedRemainingPacketsInQueue = 300 - bufferSize;
700 Simulator::Destroy ();
709 vhtConfiguration = 0;
745 void DoRun (
void)
override;
773 :
TestCase (
"Test case to check that the Wifi Mac forwards up the same packets received at sender side.")
791 true,
"No DL MU PPDU expected");
793 if (!psduMap[
SU_STA_ID]->GetHeader (0).IsQosData ())
802 std::size_t dist = std::distance (mpdu->begin (), mpdu->end ());
804 m_nMsdus.push_back (dist > 0 ? dist : 1);
831 wifi.SetRemoteStationManager (
"ns3::IdealWifiManager");
835 mac.SetType (
"ns3::StaWifiMac",
846 mac.SetType (
"ns3::ApWifiMac",
856 positionAlloc->Add (Vector (0.0, 0.0, 0.0));
857 positionAlloc->Add (Vector (1.0, 0.0, 0.0));
858 mobility.SetPositionAllocator (positionAlloc);
860 mobility.SetMobilityModel (
"ns3::ConstantPositionMobilityModel");
874 packetSocket.
Install (wifiStaNode);
881 client->SetRemote (socket);
883 client->SetStartTime (
Seconds (1));
884 client->SetStopTime (
Seconds (3.0));
885 Simulator::Schedule (
Seconds (1.5), &PacketSocketClient::SetAttribute, client,
889 server->SetLocal (socket);
891 server->SetStartTime (
Seconds (0.0));
892 server->SetStopTime (
Seconds (4.0));
894 sta_device->
GetMac ()->TraceConnectWithoutContext (
"MacTx",
898 ap_device->
GetMac ()->TraceConnectWithoutContext (
"MacRx",
904 Simulator::Destroy ();
bool m_discarded
whether the packet should be discarded
Ptr< YansWifiPhy > m_phy
Phy.
void MpduDiscarded(WifiMacDropReason reason, Ptr< const WifiMacQueueItem > mpdu)
Fired when the MAC discards an MPDU.
ObjectFactory m_factory
factory
void DoRun(void) override
Implementation to actually run this TestCase.
Ptr< WifiRemoteStationManager > m_manager
remote station manager
Ptr< WifiNetDevice > m_device
WifiNetDevice.
Ptr< StaWifiMac > m_mac
Mac.
802.11ax aggregation test which permits 64 or 256 MPDUs in A-MPDU according to the negociated buffer ...
void DoRunSubTest(uint16_t bufferSize)
Run test for a given buffer size.
Ptr< StaWifiMac > m_mac
Mac.
Ptr< WifiNetDevice > m_device
WifiNetDevice.
void DoRun(void) override
Implementation to actually run this TestCase.
ObjectFactory m_factory
factory
Ptr< WifiRemoteStationManager > m_manager
remote station manager
Ptr< YansWifiPhy > m_phy
Phy.
Test for A-MSDU and A-MPDU aggregation.
void DoRun(void) override
Implementation to actually run this TestCase.
void NotifyPsduForwardedDown(WifiConstPsduMap psduMap, WifiTxVector txVector, double txPowerW)
Callback invoked when the sender MAC passes a PSDU(s) to the PHY.
virtual ~PreservePacketsInAmpdus()
std::list< Ptr< const Packet > > m_packetList
List of packets passed to the MAC.
std::vector< std::size_t > m_nMsdus
Number of MSDUs in MPDUs passed to the PHY.
PreservePacketsInAmpdus()
std::vector< std::size_t > m_nMpdus
Number of MPDUs in PSDUs passed to the PHY.
void NotifyMacForwardUp(Ptr< const Packet > p)
Callback invoked when the receiver MAC forwards a packet up to the upper layer.
void NotifyMacTransmit(Ptr< const Packet > packet)
Callback invoked when an MSDU is passed to the MAC.
Two Level Aggregation Test.
Ptr< WifiRemoteStationManager > m_manager
remote station manager
Ptr< YansWifiPhy > m_phy
Phy.
ObjectFactory m_factory
factory
void DoRun(void) override
Implementation to actually run this TestCase.
Ptr< StaWifiMac > m_mac
Mac.
TwoLevelAggregationTest()
Ptr< WifiNetDevice > m_device
WifiNetDevice.
Wifi Aggregation Test Suite.
WifiAggregationTestSuite()
AttributeValue implementation for Boolean.
The IEEE 802.11ax HE Capabilities.
The HT Capabilities Information Element.
void SetMaxAmsduLength(uint16_t maxAmsduLength)
Set the maximum AMSDU length.
void SetMaxAmpduLength(uint32_t maxAmpduLength)
Set the maximum AMPDU length.
Helper class used to assign positions and mobility models to nodes.
holds a vector of ns3::NetDevice pointers
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
uint32_t AddApplication(Ptr< Application > application)
Associate an Application to this Node.
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Instantiate subclasses of ns3::Object.
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
void Dispose(void)
Dispose of this Object.
an address for a packet socket
void SetProtocol(uint16_t protocol)
Set the protocol.
void SetPhysicalAddress(const Address address)
Set the destination address.
void SetSingleDevice(uint32_t device)
Set the address to match only a specified NetDevice.
Give ns3::PacketSocket powers to ns3::Node.
void Install(Ptr< Node > node) const
Aggregate an instance of a ns3::PacketSocketFactory onto the provided node.
Smart pointer class similar to boost::intrusive_ptr.
Ptr< const WifiMacQueueItem > PeekNextMpdu(uint8_t tid=8, Mac48Address recipient=Mac48Address::GetBroadcast())
Peek the next frame to transmit to the given receiver and of the given TID from the block ack manager...
Ptr< BlockAckManager > GetBaManager(void)
Get the Block Ack Manager associated with this QosTxop.
Ptr< WifiMacQueueItem > GetNextMpdu(Ptr< const WifiMacQueueItem > peekedItem, WifiTxParameters &txParams, Time availableTime, bool initialFrame, WifiMacQueueItem::QueueIteratorPair &queueIt)
Prepare the frame to transmit starting from the MPDU that has been previously peeked by calling PeekN...
void ConfigureStandard(WifiStandard standard) override
Ptr< QosTxop > GetBEQueue(void) const
Accessor for the AC_BE channel access function.
Ptr< WifiRemoteStationManager > GetWifiRemoteStationManager(void) const override
void SetWifiRemoteStationManager(const Ptr< WifiRemoteStationManager > stationManager) override
Ptr< MacTxMiddle > m_txMiddle
TX middle (aggregation etc.)
Ptr< FrameExchangeManager > GetFrameExchangeManager(void) const
Get the Frame Exchange Manager.
void SetAddress(Mac48Address address) override
Ptr< QosTxop > GetVIQueue(void) const
Accessor for the AC_VI channel access function.
The IEEE 802.11 SSID Information Element.
AttributeValue implementation for Ssid.
void SetWifiPhy(const Ptr< WifiPhy > phy) override
Status code for association response.
void SetSuccess(void)
Set success bit to 0 (success).
Hold variables of type string.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Simulation virtual time values and global simulation resolution.
AttributeValue implementation for Time.
Ptr< WifiMacQueue > GetWifiMacQueue() const
Return the packet queue associated with this Txop.
Time GetTxopLimit(void) const
Return the TXOP limit.
Hold an unsigned integer type.
helps to create WifiNetDevice objects
create MAC layers for a ns3::WifiNetDevice.
void SetDevice(const Ptr< NetDevice > device)
Sets the device this PHY is associated with.
DeaggregatedMsdusCI end(void)
Get a constant iterator indicating past-the-last MSDU in the list of aggregated MSDUs.
DeaggregatedMsdusCI begin(void)
Get a constant iterator pointing to the first MSDU in the list of aggregated MSDUs.
uint32_t GetPacketSize(void) const
Return the size in bytes of the packet or control header or management header stored by this item.
const WifiMacHeader & GetHeader(void) const
Get the header stored in this item.
void SetMac(const Ptr< WifiMac > mac)
void SetHeConfiguration(Ptr< HeConfiguration > heConfiguration)
void SetHtConfiguration(Ptr< HtConfiguration > htConfiguration)
Ptr< WifiMac > GetMac(void) const
Address GetAddress(void) const override
void SetVhtConfiguration(Ptr< VhtConfiguration > vhtConfiguration)
Ptr< WifiPhy > GetPhy(void) const
void SetRemoteStationManager(const Ptr< WifiRemoteStationManager > manager)
uint32_t GetIfIndex(void) const override
void SetPhy(const Ptr< WifiPhy > phy)
virtual void ConfigureStandardAndBand(WifiPhyStandard standard, WifiPhyBand band)
Configure the PHY-level parameters for different Wi-Fi standard.
void SetDevice(const Ptr< NetDevice > device)
Sets the device this PHY is associated with.
uint32_t GetSize(void) const
Return the size of the PSDU in bytes.
const WifiMacHeader & GetHeader(std::size_t i) const
Get the header of the i-th MPDU.
std::size_t GetNMpdus(void) const
Return the number of MPDUs constituting the PSDU.
hold a list of per-remote-station state.
WifiTxVector GetDataTxVector(const WifiMacHeader &header)
void AddStationHeCapabilities(Mac48Address from, HeCapabilities heCapabilities)
Records HE capabilities of the remote station.
void SetMaxSsrc(uint32_t maxSsrc)
Sets the maximum STA short retry count (SSRC).
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...
void AddStationHtCapabilities(Mac48Address from, HtCapabilities htCapabilities)
Records HT capabilities of the remote station.
This class stores the TX parameters (TX vector, protection mechanism, acknowledgment mechanism,...
void Clear(void)
Reset the TX parameters.
WifiTxVector m_txVector
TXVECTOR of the frame being prepared.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
manage and create wifi channel objects for the YANS model.
Make it easy to create and manage PHY objects for the YANS model.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time Seconds(double value)
Construct a Time in the indicated unit.
WifiMacDropReason
The reason why an MPDU was dropped.
@ WIFI_PHY_STANDARD_80211ax
HE PHY (clause 26)
@ WIFI_PHY_STANDARD_80211n
HT PHY (clause 20)
@ WIFI_STANDARD_80211n_5GHZ
@ WIFI_STANDARD_80211ax_5GHZ
@ WIFI_PHY_BAND_5GHZ
The 5 GHz band.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
U * PeekPointer(const Ptr< U > &p)
Information needed to remove an MSDU from the queue.
static WifiAggregationTestSuite g_wifiAggregationTestSuite
the test suite