20#include "ns3/fcfs-wifi-queue-scheduler.h"
21#include "ns3/he-configuration.h"
22#include "ns3/ht-configuration.h"
23#include "ns3/ht-frame-exchange-manager.h"
24#include "ns3/interference-helper.h"
25#include "ns3/mac-tx-middle.h"
26#include "ns3/mobility-helper.h"
27#include "ns3/mpdu-aggregator.h"
28#include "ns3/msdu-aggregator.h"
29#include "ns3/node-container.h"
30#include "ns3/packet-socket-client.h"
31#include "ns3/packet-socket-helper.h"
32#include "ns3/packet-socket-server.h"
33#include "ns3/pointer.h"
34#include "ns3/simulator.h"
35#include "ns3/sta-wifi-mac.h"
36#include "ns3/string.h"
38#include "ns3/vht-configuration.h"
39#include "ns3/wifi-default-ack-manager.h"
40#include "ns3/wifi-default-protection-manager.h"
41#include "ns3/wifi-mac-queue.h"
42#include "ns3/wifi-net-device.h"
43#include "ns3/wifi-psdu.h"
44#include "ns3/yans-wifi-helper.h"
45#include "ns3/yans-wifi-phy.h"
46#include <ns3/attribute-container.h>
73 void DoRun()
override;
83 :
TestCase(
"Check the correctness of MPDU aggregation operations"),
100 m_device = CreateObject<WifiNetDevice>();
107 m_phy = CreateObject<YansWifiPhy>();
127 m_mac = CreateObjectWithAttributes<StaWifiMac>(
"QosSupported",
BooleanValue(
true));
135 protectionManager->SetWifiMac(
m_mac);
136 fem->SetProtectionManager(protectionManager);
138 ackManager->SetWifiMac(
m_mac);
139 fem->SetAckManager(ackManager);
157 Ptr<Packet> currentAggregatedPacket = Create<Packet>();
207 auto mpduList = mpduAggregator->GetNextAmpdu(item, txParams,
Time::Min());
238 mpduList = mpduAggregator->GetNextAmpdu(item, txParams,
Time::Min());
243 htFem->DequeuePsdu(psdu);
249 "queue should be empty");
263 pkt1 = Create<Packet>(1500);
264 pkt2 = Create<Packet>(1500);
294 mpduList = mpduAggregator->GetNextAmpdu(item, txParams,
Time::Min());
298 "a single packet for this destination should not result in an A-MPDU");
300 htFem->DequeueMpdu(item);
309 mpduList = mpduAggregator->GetNextAmpdu(item, txParams,
Time::Min());
313 "no MPDU aggregation should be performed if there is no agreement");
320 htFem->NormalAckTimeout(item, txParams.
m_txVector);
325 Simulator::Destroy();
333 htConfiguration =
nullptr;
348 void DoRun()
override;
357 :
TestCase(
"Check the correctness of two-level aggregation operations")
367 m_device = CreateObject<WifiNetDevice>();
375 m_phy = CreateObject<YansWifiPhy>();
395 m_mac = CreateObjectWithAttributes<StaWifiMac>(
"QosSupported",
BooleanValue(
true));
403 protectionManager->SetWifiMac(
m_mac);
404 fem->SetProtectionManager(protectionManager);
406 ackManager->SetWifiMac(
m_mac);
407 fem->SetAckManager(ackManager);
453 htFem->TryAddMpdu(peeked, txParams,
Time::Min());
461 htFem->DequeueMpdu(item);
465 "Unexpected number of MSDUs left in the EDCA queue");
478 htFem->TryAddMpdu(peeked, txParams,
Time::Min());
479 item = msduAggregator->GetNextAmsdu(peeked, txParams,
Time::Min());
483 htFem->DequeueMpdu(peeked);
487 "queue should be empty");
527 for (uint8_t i = 0; i < 10; i++)
530 Create<WifiMpdu>(Create<Packet>(1300), hdr));
546 "There must be 2 MSDUs in the A-MSDU");
548 auto mpduList = mpduAggregator->GetNextAmpdu(item, txParams, txopLimit);
567 htFem->DequeuePsdu(psdu);
571 "Unexpected number of MSDUs left in the EDCA queue");
575 Simulator::Destroy();
579 htConfiguration =
nullptr;
595 void DoRun()
override;
610 :
TestCase(
"Check the correctness of 802.11ax aggregation operations")
620 m_device = CreateObject<WifiNetDevice>();
631 m_phy = CreateObject<YansWifiPhy>();
651 m_mac = CreateObjectWithAttributes<StaWifiMac>(
"QosSupported",
BooleanValue(
true));
659 protectionManager->SetWifiMac(
m_mac);
660 fem->SetProtectionManager(protectionManager);
662 ackManager->SetWifiMac(
m_mac);
663 fem->SetAckManager(ackManager);
682 uint16_t sequence =
m_mac->
m_txMiddle->PeekNextSequenceNumberFor(&hdr);
716 for (uint16_t i = 0; i < 300; i++)
737 auto mpduList = mpduAggregator->GetNextAmpdu(item, txParams,
Time::Min());
739 htFem->DequeuePsdu(psdu);
744 "A-MPDU should countain " << bufferSize <<
" MPDUs");
745 uint16_t expectedRemainingPacketsInQueue = 300 - bufferSize;
747 expectedRemainingPacketsInQueue,
748 "queue should contain 300 - " << bufferSize <<
" = "
749 << expectedRemainingPacketsInQueue
752 Simulator::Destroy();
760 htConfiguration =
nullptr;
761 vhtConfiguration =
nullptr;
762 heConfiguration =
nullptr;
797 void DoRun()
override;
824 :
TestCase(
"Test case to check that the Wifi Mac forwards up the same packets received at "
846 "No DL MU PPDU expected");
848 if (!psduMap[
SU_STA_ID]->GetHeader(0).IsQosData())
857 std::size_t dist = std::distance(mpdu->begin(), mpdu->end());
859 m_nMsdus.push_back(dist > 0 ? dist : 1);
886 wifi.SetRemoteStationManager(
"ns3::IdealWifiManager");
890 mac.SetType(
"ns3::StaWifiMac",
898 "BE_BlockAckThreshold",
914 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
915 positionAlloc->Add(Vector(1.0, 0.0, 0.0));
916 mobility.SetPositionAllocator(positionAlloc);
918 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
932 packetSocket.
Install(wifiStaNode);
939 client->SetRemote(socket);
941 client->SetStartTime(
Seconds(1));
942 client->SetStopTime(
Seconds(3.0));
943 Simulator::Schedule(
Seconds(1.5),
944 &PacketSocketClient::SetAttribute,
950 server->SetLocal(socket);
952 server->SetStartTime(
Seconds(0.0));
953 server->SetStopTime(
Seconds(4.0));
955 sta_device->
GetMac()->TraceConnectWithoutContext(
961 ap_device->
GetMac()->TraceConnectWithoutContext(
968 Simulator::Destroy();
bool m_discarded
whether the packet should be discarded
Ptr< YansWifiPhy > m_phy
Phy.
ObjectFactory m_factory
factory
Ptr< WifiRemoteStationManager > m_manager
remote station manager
void DoRun() override
Implementation to actually run this TestCase.
Ptr< WifiNetDevice > m_device
WifiNetDevice.
void MpduDiscarded(WifiMacDropReason reason, Ptr< const WifiMpdu > mpdu)
Fired when the MAC discards an MPDU.
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.
ObjectFactory m_factory
factory
void DoRun() override
Implementation to actually run this TestCase.
Ptr< WifiRemoteStationManager > m_manager
remote station manager
Ptr< YansWifiPhy > m_phy
Phy.
Test for A-MSDU and A-MPDU aggregation.
void DoRun() 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.
std::list< Ptr< const Packet > > m_packetList
List of packets passed to the MAC.
~PreservePacketsInAmpdus() override
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
void DoRun() override
Implementation to actually run this TestCase.
Ptr< YansWifiPhy > m_phy
Phy.
ObjectFactory m_factory
factory
Ptr< StaWifiMac > m_mac
Mac.
TwoLevelAggregationTest()
Ptr< WifiNetDevice > m_device
WifiNetDevice.
Wifi Aggregation Test Suite.
WifiAggregationTestSuite()
A container for one type of attribute.
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.
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
void Dispose()
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< BlockAckManager > GetBaManager()
Get the Block Ack Manager associated with this QosTxop.
Ptr< WifiMpdu > PeekNextMpdu(uint8_t linkId, uint8_t tid=8, Mac48Address recipient=Mac48Address::GetBroadcast(), Ptr< WifiMpdu > item=nullptr)
Peek the next frame to transmit on the given link to the given receiver and of the given TID from the...
Ptr< WifiMpdu > GetNextMpdu(uint8_t linkId, Ptr< WifiMpdu > peekedItem, WifiTxParameters &txParams, Time availableTime, bool initialFrame)
Prepare the frame to transmit on the given link starting from the MPDU that has been previously peeke...
The IEEE 802.11 SSID Information Element.
AttributeValue implementation for Ssid.
void SetState(MacState value)
Set the current MAC state.
void SetWifiPhys(const std::vector< Ptr< WifiPhy > > &phys) override
Status code for association response.
void SetSuccess()
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.
Time GetTxopLimit() const
Return the TXOP limit.
Ptr< WifiMacQueue > GetWifiMacQueue() const
Return the packet queue associated with this Txop.
Hold an unsigned integer type.
helps to create WifiNetDevice objects
create MAC layers for a ns3::WifiNetDevice.
Ptr< FrameExchangeManager > GetFrameExchangeManager(uint8_t linkId=SINGLE_LINK_OP_ID) const
Get the Frame Exchange Manager associated with the given link.
Ptr< QosTxop > GetBEQueue() const
Accessor for the AC_BE channel access function.
virtual void SetMacQueueScheduler(Ptr< WifiMacQueueScheduler > scheduler)
Set the wifi MAC queue scheduler.
virtual void SetAddress(Mac48Address address)
virtual void ConfigureStandard(WifiStandard standard)
void SetWifiRemoteStationManager(Ptr< WifiRemoteStationManager > stationManager)
Ptr< MacTxMiddle > m_txMiddle
TX middle (aggregation etc.)
Ptr< QosTxop > GetVIQueue() const
Accessor for the AC_VI channel access function.
Ptr< WifiRemoteStationManager > GetWifiRemoteStationManager(uint8_t linkId=0) const
void SetDevice(const Ptr< WifiNetDevice > device)
Sets the device this PHY is associated with.
void SetMac(const Ptr< WifiMac > mac)
void SetHeConfiguration(Ptr< HeConfiguration > heConfiguration)
void SetHtConfiguration(Ptr< HtConfiguration > htConfiguration)
Ptr< WifiMac > GetMac() const
void SetVhtConfiguration(Ptr< VhtConfiguration > vhtConfiguration)
void SetRemoteStationManager(const Ptr< WifiRemoteStationManager > manager)
void SetStandard(WifiStandard standard)
Set the Wifi standard.
Ptr< WifiPhy > GetPhy() const
uint32_t GetIfIndex() const override
void SetPhy(const Ptr< WifiPhy > phy)
Address GetAddress() const override
uint16_t GetChannelWidth() const
virtual void ConfigureStandard(WifiStandard standard)
Configure the PHY-level parameters for different Wi-Fi standard.
void SetDevice(const Ptr< WifiNetDevice > device)
Sets the device this PHY is associated with.
const WifiMacHeader & GetHeader(std::size_t i) const
Get the header of the i-th MPDU.
uint32_t GetSize() const
Return the size of the PSDU in bytes.
std::size_t GetNMpdus() const
Return the number of MPDUs constituting the PSDU.
hold a list of per-remote-station state.
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...
WifiTxVector GetDataTxVector(const WifiMacHeader &header, uint16_t allowedWidth)
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,...
WifiTxVector m_txVector
TXVECTOR of the frame being prepared.
void Clear()
Reset the TX parameters.
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.
void SetInterferenceHelper(const Ptr< InterferenceHelper > helper) override
Sets the interference helper.
#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.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
U * PeekPointer(const Ptr< U > &p)
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
static constexpr uint8_t SINGLE_LINK_OP_ID
Link ID for single link operations (helps tracking places where correct link ID is to be used to supp...
static WifiAggregationTestSuite g_wifiAggregationTestSuite
the test suite