20#include "ns3/eht-configuration.h"
21#include "ns3/fcfs-wifi-queue-scheduler.h"
22#include "ns3/he-configuration.h"
23#include "ns3/ht-configuration.h"
24#include "ns3/ht-frame-exchange-manager.h"
25#include "ns3/interference-helper.h"
26#include "ns3/mac-tx-middle.h"
27#include "ns3/mgt-action-headers.h"
28#include "ns3/mobility-helper.h"
29#include "ns3/mpdu-aggregator.h"
30#include "ns3/msdu-aggregator.h"
31#include "ns3/multi-link-element.h"
32#include "ns3/node-container.h"
33#include "ns3/packet-socket-client.h"
34#include "ns3/packet-socket-helper.h"
35#include "ns3/packet-socket-server.h"
36#include "ns3/pointer.h"
37#include "ns3/simulator.h"
38#include "ns3/sta-wifi-mac.h"
39#include "ns3/string.h"
41#include "ns3/vht-configuration.h"
42#include "ns3/wifi-default-ack-manager.h"
43#include "ns3/wifi-default-protection-manager.h"
44#include "ns3/wifi-mac-queue.h"
45#include "ns3/wifi-net-device.h"
46#include "ns3/wifi-psdu.h"
47#include "ns3/yans-wifi-helper.h"
48#include "ns3/yans-wifi-phy.h"
49#include <ns3/attribute-container.h>
131 void DoRun()
override;
144 .dataMode =
"HtMcs7",
147 .maxAmpduSize = 65535,
171 m_device = CreateObject<WifiNetDevice>();
173 auto htConfiguration = CreateObject<HtConfiguration>();
177 auto vhtConfiguration = CreateObject<VhtConfiguration>();
179 auto heConfiguration = CreateObject<HeConfiguration>();
184 auto ehtConfiguration = CreateObject<EhtConfiguration>();
193 m_phys.emplace_back(CreateObject<YansWifiPhy>());
194 auto interferenceHelper = CreateObject<InterferenceHelper>();
195 m_phys.back()->SetInterferenceHelper(interferenceHelper);
217 m_mac = CreateObjectWithAttributes<StaWifiMac>(
237 std::vector<Ptr<ChannelAccessManager>> caManagers;
240 caManagers.emplace_back(CreateObject<ChannelAccessManager>());
245 std::vector<Ptr<FrameExchangeManager>> feManagers;
249 feManagers.emplace_back(fem);
250 auto protectionManager = CreateObject<WifiDefaultProtectionManager>();
251 protectionManager->SetWifiMac(
m_mac);
252 fem->SetProtectionManager(protectionManager);
253 auto ackManager = CreateObject<WifiDefaultAckManager>();
254 ackManager->SetWifiMac(
m_mac);
255 fem->SetAckManager(ackManager);
285 auto mleCommonInfo2 = std::make_shared<CommonInfoBasicMle>();
286 mleCommonInfo2->m_mldMacAddress =
Mac48Address(
"00:00:00:00:00:02");
292 m_managers.at(i)->AddStationMleCommonInfo(mleCommonInfo2->m_mldMacAddress,
296 auto mleCommonInfo3 = std::make_shared<CommonInfoBasicMle>();
297 mleCommonInfo3->m_mldMacAddress =
Mac48Address(
"00:00:00:00:00:03");
300 m_managers.at(i)->AddStationMleCommonInfo(mleCommonInfo3->m_mldMacAddress,
354 std::list<Ptr<const WifiMpdu>> mpdus(mpduList.cbegin(), mpduList.cend());
384 for (std::size_t i = 0; i < count; i++)
386 auto pkt = Create<Packet>(size);
405 auto htFem = DynamicCast<HtFrameExchangeManager>(fem);
406 auto mpduAggregator = htFem->GetMpduAggregator();
420 auto mpduList = mpduAggregator->GetNextAmpdu(item, txParams,
Time::Min());
426 item->UnassignSeqNo();
436 mpduList = mpduAggregator->GetNextAmpdu(item, txParams,
Time::Min());
440 auto psdu = Create<WifiPsdu>(mpduList);
447 "queue should be empty");
449 for (
uint32_t i = 0; i < psdu->GetNMpdus(); i++)
471 mpduList = mpduAggregator->GetNextAmpdu(item, txParams,
Time::Min());
475 "a single packet for this destination should not result in an A-MPDU");
486 mpduList = mpduAggregator->GetNextAmpdu(item, txParams,
Time::Min());
490 "no MPDU aggregation should be performed if there is no agreement");
498 htFem->NormalAckTimeout(item, txParams.
m_txVector);
531 void DoRun()
override;
538 .dataMode =
"HtMcs2",
540 .maxAmsduSize = 3050,
541 .maxAmpduSize = 65535,
563 auto htFem = DynamicCast<HtFrameExchangeManager>(fem);
564 auto msduAggregator = htFem->GetMsduAggregator();
565 auto mpduAggregator = htFem->GetMpduAggregator();
572 htFem->TryAddMpdu(peeked, txParams,
Time::Min());
573 auto item = msduAggregator->GetNextAmsdu(peeked, txParams,
Time::Min());
584 "Unexpected number of MSDUs left in the EDCA queue");
597 htFem->TryAddMpdu(peeked, txParams,
Time::Min());
598 item = msduAggregator->GetNextAmsdu(peeked, txParams,
Time::Min());
606 "queue should be empty");
630 "There must be 2 MSDUs in the A-MSDU");
632 auto mpduList = mpduAggregator->GetNextAmpdu(item, txParams,
m_params.
txopLimit);
649 "Expecting the first MPDU to contain an A-MSDU");
653 "Expecting the second MPDU to contain an A-MSDU");
657 "Expecting the third MPDU not to contain an A-MSDU");
659 auto psdu = Create<WifiPsdu>(mpduList);
665 "Unexpected number of items left in the EDCA queue");
680 "There must be 2 MSDUs in the A-MSDU");
682 auto mpduList2 = mpduAggregator->GetNextAmpdu(item, txParams,
m_params.
txopLimit);
688 "Unexpected number of items left in the EDCA queue");
691 mpduList.at(0)->UnassignSeqNo();
692 mpduList.at(1)->UnassignSeqNo();
693 mpduList.at(2)->UnassignSeqNo();
694 mpduList2.at(0)->UnassignSeqNo();
695 mpduList2.at(1)->UnassignSeqNo();
696 mpduList2.at(2)->UnassignSeqNo();
708 htFem->TryAddMpdu(peeked, txParams,
Time::Min());
709 item = msduAggregator->GetNextAmsdu(peeked, txParams,
Time::Min());
719 "Unexpected number of items left in the EDCA queue");
729 "Expecting the peeked MPDU not to contain an A-MSDU");
736 "Expecting the returned MPDU not to contain an A-MSDU");
757 void DoRun()
override;
762 std::to_string(bufferSize),
765 .dataMode =
"HeMcs11",
766 .bufferSize = bufferSize,
768 .maxAmpduSize = 65535,
782 auto htFem = DynamicCast<HtFrameExchangeManager>(fem);
783 auto mpduAggregator = htFem->GetMpduAggregator();
792 auto mpduList = mpduAggregator->GetNextAmpdu(item, txParams,
Time::Min());
798 "A-MPDU contains an unexpected number of MPDUs");
801 expectedRemainingPacketsInQueue,
802 "Queue contains an unexpected number of MPDUs");
823 void DoRun()
override;
828 std::to_string(bufferSize),
831 .dataMode =
"EhtMcs13",
832 .bufferSize = bufferSize,
834 .maxAmpduSize = 102000,
848 const std::size_t maxNMpdus = 750;
853 auto htFem = DynamicCast<HtFrameExchangeManager>(fem);
854 auto mpduAggregator = htFem->GetMpduAggregator();
855 std::vector<Ptr<WifiMpdu>> mpduList;
863 m_phys.at(linkId)->GetChannelWidth());
866 mpduList = mpduAggregator->GetNextAmpdu(item, txParams,
Time::Min());
870 uint16_t expectedRemainingPacketsInQueue;
883 "A-MPDU contains an unexpected number of MPDUs");
884 expectedRemainingPacketsInQueue = 1200 - maxNMpdus;
886 expectedRemainingPacketsInQueue,
887 "Queue contains an unexpected number of MPDUs");
894 "A-MPDU contains an unexpected number of MPDUs");
897 expectedRemainingPacketsInQueue,
898 "Queue contains an unexpected number of MPDUs");
914 "A-MPDU contains an unexpected number of MPDUs");
917 expectedRemainingPacketsInQueue,
918 "Queue contains an unexpected number of MPDUs");
925 expectedRemainingPacketsInQueue,
926 "Queue contains an unexpected number of MPDUs");
960 void DoRun()
override;
987 :
TestCase(
"Test case to check that the Wifi Mac forwards up the same packets received at "
1009 "No DL MU PPDU expected");
1011 if (!psduMap[
SU_STA_ID]->GetHeader(0).IsQosData())
1020 std::size_t dist = std::distance(mpdu->begin(), mpdu->end());
1022 m_nMsdus.push_back(dist > 0 ? dist : 1);
1041 wifiApNode.Create(1);
1045 phy.SetChannel(channel.Create());
1049 wifi.SetRemoteStationManager(
"ns3::IdealWifiManager");
1053 mac.SetType(
"ns3::StaWifiMac",
1061 "BE_BlockAckThreshold",
1067 staDevices = wifi.Install(phy, mac, wifiStaNode);
1072 apDevices = wifi.Install(phy, mac, wifiApNode);
1077 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
1078 positionAlloc->Add(Vector(1.0, 0.0, 0.0));
1079 mobility.SetPositionAllocator(positionAlloc);
1081 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
1082 mobility.Install(wifiApNode);
1083 mobility.Install(wifiStaNode);
1095 packetSocket.
Install(wifiStaNode);
1096 packetSocket.
Install(wifiApNode);
1102 client->SetRemote(socket);
1104 client->SetStartTime(
Seconds(1));
1105 client->SetStopTime(
Seconds(3.0));
1107 &PacketSocketClient::SetAttribute,
1113 server->SetLocal(socket);
1114 wifiApNode.Get(0)->AddApplication(server);
1115 server->SetStartTime(
Seconds(0.0));
1116 server->SetStopTime(
Seconds(4.0));
1118 sta_device->GetMac()->TraceConnectWithoutContext(
1121 sta_device->GetPhy()->TraceConnectWithoutContext(
1124 ap_device->GetMac()->TraceConnectWithoutContext(
bool m_discarded
whether the packet should be discarded
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
Ptr< QosTxop > GetBeQueue() const
void DoSetup() override
Implementation to do any local setup required for this TestCase.
ObjectFactory m_factory
factory
Params m_params
test parameters
void EnqueuePkts(std::size_t count, uint32_t size, const Mac48Address &dest)
Enqueue the given number of packets addressed to the given station and of the given size.
std::vector< Ptr< WifiRemoteStationManager > > m_managers
remote station managers
void DoRun() override
Implementation to actually run this TestCase.
Ptr< WifiNetDevice > m_device
WifiNetDevice.
void DequeueMpdus(const std::vector< Ptr< WifiMpdu > > &mpduList)
Dequeue a PSDU.
void EstablishAgreement(const Mac48Address &recipient)
Establish a BlockAck agreement.
void MpduDiscarded(WifiMacDropReason reason, Ptr< const WifiMpdu > mpdu)
Fired when the MAC discards an MPDU.
std::vector< Ptr< WifiPhy > > m_phys
Phys.
Ptr< StaWifiMac > m_mac
Mac.
802.11be aggregation test which permits up to 1024 MPDUs in A-MPDU according to the negotiated buffer...
void DoRun() override
Implementation to actually run this TestCase.
EhtAggregationTest(uint16_t bufferSize)
Constructor.
802.11ax aggregation test which permits 64 or 256 MPDUs in A-MPDU according to the negotiated buffer ...
HeAggregationTest(uint16_t bufferSize)
Constructor.
void DoRun() override
Implementation to actually run this TestCase.
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.
void DoRun() override
Implementation to actually run this TestCase.
TwoLevelAggregationTest()
Wifi Aggregation Test Suite.
WifiAggregationTestSuite()
A container for one type of attribute.
AttributeValue implementation for Boolean.
The IEEE 802.11be EHT Capabilities.
void SetMaxMpduLength(uint16_t length)
Set the maximum MPDU length.
void SetMaxAmpduLength(uint32_t maxAmpduLength)
Set the maximum A-MPDU length.
FrameExchangeManager is a base class handling the basic frame exchange sequences for non-QoS stations...
The IEEE 802.11ax HE Capabilities.
void SetMaxAmpduLength(uint32_t maxAmpduLength)
Set the maximum AMPDU length.
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.
static Mac48Address GetBroadcast()
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.
AttributeValue implementation for Pointer.
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< const WifiMpdu > mpdu=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...
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
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, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Simulation virtual time values and global simulation resolution.
static Time Min()
Minimum representable Time Not to be confused with Min(Time,Time).
AttributeValue implementation for Time.
Ptr< WifiMacQueue > GetWifiMacQueue() const
Return the packet queue associated with this Txop.
Hold an unsigned integer type.
The IEEE 802.11ac VHT Capabilities.
void SetMaxMpduLength(uint16_t length)
Set the maximum MPDU length.
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.
const std::map< uint8_t, std::unique_ptr< LinkEntity > > & GetLinks() const
virtual void SetAddress(Mac48Address address)
void SetFrameExchangeManagers(const std::vector< Ptr< FrameExchangeManager > > &feManagers)
void SetChannelAccessManagers(const std::vector< Ptr< ChannelAccessManager > > &caManagers)
void SetWifiRemoteStationManagers(const std::vector< Ptr< WifiRemoteStationManager > > &stationManagers)
Ptr< MacTxMiddle > m_txMiddle
TX middle (aggregation etc.)
virtual Ptr< WifiMacQueue > GetTxopQueue(AcIndex ac) const
Get the wifi MAC queue of the (Qos)Txop associated with the given AC, if such (Qos)Txop is installed,...
Ptr< WifiRemoteStationManager > GetWifiRemoteStationManager(uint8_t linkId=0) const
void SetDevice(const Ptr< WifiNetDevice > device)
Sets the device this PHY is associated with.
Mac48Address GetAddress() const
void SetMac(const Ptr< WifiMac > mac)
void SetPhys(const std::vector< Ptr< WifiPhy > > &phys)
void SetHeConfiguration(Ptr< HeConfiguration > heConfiguration)
void SetHtConfiguration(Ptr< HtConfiguration > htConfiguration)
void SetVhtConfiguration(Ptr< VhtConfiguration > vhtConfiguration)
void SetRemoteStationManagers(const std::vector< Ptr< WifiRemoteStationManager > > &managers)
void SetStandard(WifiStandard standard)
Set the Wifi standard.
void SetEhtConfiguration(Ptr< EhtConfiguration > ehtConfiguration)
hold a list of per-remote-station state.
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.
static YansWifiChannelHelper Default()
Create a channel helper in a default working state.
Make it easy to create and manage PHY objects for the YANS model.
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
#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.
WifiStandard
Identifies the IEEE 802.11 specifications that a Wifi device can be configured to use.
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...
std::string GetFrameExchangeManagerTypeIdName(WifiStandard standard, bool qosSupported)
Get the TypeId name for the FrameExchangeManager corresponding to the given standard.
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 constexpr uint16_t SU_STA_ID
STA_ID to identify a single user (SU)
uint8_t nLinks
number of links (>1 only for EHT)
uint32_t maxAmpduSize
maximum A-MPDU size (bytes)
uint16_t bufferSize
the size (in number of MPDUs) of the BlockAck buffer
WifiStandard standard
the standard of the device
uint16_t maxAmsduSize
maximum A-MSDU size (bytes)
std::string dataMode
data mode
Time txopLimit
TXOP limit duration.
Structure holding information specific to a single link.
std::optional< Mac48Address > bssid
BSSID of the AP to associate with over this link.
static WifiAggregationTestSuite g_wifiAggregationTestSuite
the test suite