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>
103 void EnqueuePkts(std::size_t count, uint32_t size,
const Mac48Address& dest);
115 void DequeueMpdus(
const std::vector<
Ptr<WifiMpdu>>& mpduList);
130 void DoSetup()
override;
131 void DoRun()
override;
132 void DoTeardown()
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>(
"QosSupported",
BooleanValue(
true));
231 auto protectionManager = CreateObject<WifiDefaultProtectionManager>();
232 protectionManager->SetWifiMac(
m_mac);
233 fem->SetProtectionManager(protectionManager);
234 auto ackManager = CreateObject<WifiDefaultAckManager>();
235 ackManager->SetWifiMac(
m_mac);
236 fem->SetAckManager(ackManager);
264 auto mleCommonInfo2 = std::make_shared<CommonInfoBasicMle>();
265 mleCommonInfo2->m_mldMacAddress =
Mac48Address(
"00:00:00:00:00:02");
271 m_managers.at(i)->AddStationMleCommonInfo(mleCommonInfo2->m_mldMacAddress,
275 auto mleCommonInfo3 = std::make_shared<CommonInfoBasicMle>();
276 mleCommonInfo3->m_mldMacAddress =
Mac48Address(
"00:00:00:00:00:03");
279 m_managers.at(i)->AddStationMleCommonInfo(mleCommonInfo3->m_mldMacAddress,
333 std::list<Ptr<const WifiMpdu>> mpdus(mpduList.cbegin(), mpduList.cend());
363 for (std::size_t i = 0; i < count; i++)
365 auto pkt = Create<Packet>(size);
384 auto htFem = DynamicCast<HtFrameExchangeManager>(fem);
385 auto mpduAggregator = htFem->GetMpduAggregator();
399 auto mpduList = mpduAggregator->GetNextAmpdu(item, txParams,
Time::Min());
405 item->UnassignSeqNo();
415 mpduList = mpduAggregator->GetNextAmpdu(item, txParams,
Time::Min());
419 auto psdu = Create<WifiPsdu>(mpduList);
426 "queue should be empty");
428 for (uint32_t i = 0; i < psdu->GetNMpdus(); i++)
450 mpduList = mpduAggregator->GetNextAmpdu(item, txParams,
Time::Min());
454 "a single packet for this destination should not result in an A-MPDU");
465 mpduList = mpduAggregator->GetNextAmpdu(item, txParams,
Time::Min());
469 "no MPDU aggregation should be performed if there is no agreement");
477 htFem->NormalAckTimeout(item, txParams.
m_txVector);
486 Simulator::Destroy();
510 void DoRun()
override;
517 .dataMode =
"HtMcs2",
519 .maxAmsduSize = 3050,
520 .maxAmpduSize = 65535,
542 auto htFem = DynamicCast<HtFrameExchangeManager>(fem);
543 auto msduAggregator = htFem->GetMsduAggregator();
544 auto mpduAggregator = htFem->GetMpduAggregator();
551 htFem->TryAddMpdu(peeked, txParams,
Time::Min());
552 auto item = msduAggregator->GetNextAmsdu(peeked, txParams,
Time::Min());
563 "Unexpected number of MSDUs left in the EDCA queue");
576 htFem->TryAddMpdu(peeked, txParams,
Time::Min());
577 item = msduAggregator->GetNextAmsdu(peeked, txParams,
Time::Min());
585 "queue should be empty");
609 "There must be 2 MSDUs in the A-MSDU");
611 auto mpduList = mpduAggregator->GetNextAmpdu(item, txParams,
m_params.
txopLimit);
628 "Expecting the first MPDU to contain an A-MSDU");
632 "Expecting the second MPDU to contain an A-MSDU");
636 "Expecting the third MPDU not to contain an A-MSDU");
638 auto psdu = Create<WifiPsdu>(mpduList);
644 "Unexpected number of items left in the EDCA queue");
659 "There must be 2 MSDUs in the A-MSDU");
661 auto mpduList2 = mpduAggregator->GetNextAmpdu(item, txParams,
m_params.
txopLimit);
667 "Unexpected number of items left in the EDCA queue");
670 mpduList.at(0)->UnassignSeqNo();
671 mpduList.at(1)->UnassignSeqNo();
672 mpduList.at(2)->UnassignSeqNo();
673 mpduList2.at(0)->UnassignSeqNo();
674 mpduList2.at(1)->UnassignSeqNo();
675 mpduList2.at(2)->UnassignSeqNo();
687 htFem->TryAddMpdu(peeked, txParams,
Time::Min());
688 item = msduAggregator->GetNextAmsdu(peeked, txParams,
Time::Min());
698 "Unexpected number of items left in the EDCA queue");
708 "Expecting the peeked MPDU not to contain an A-MSDU");
715 "Expecting the returned MPDU not to contain an A-MSDU");
736 void DoRun()
override;
744 .dataMode =
"HeMcs11",
745 .bufferSize = bufferSize,
747 .maxAmpduSize = 65535,
761 auto htFem = DynamicCast<HtFrameExchangeManager>(fem);
762 auto mpduAggregator = htFem->GetMpduAggregator();
771 auto mpduList = mpduAggregator->GetNextAmpdu(item, txParams,
Time::Min());
777 "A-MPDU contains an unexpected number of MPDUs");
780 expectedRemainingPacketsInQueue,
781 "Queue contains an unexpected number of MPDUs");
802 void DoRun()
override;
810 .dataMode =
"EhtMcs13",
811 .bufferSize = bufferSize,
813 .maxAmpduSize = 102000,
827 const std::size_t maxNMpdus = 750;
832 auto htFem = DynamicCast<HtFrameExchangeManager>(fem);
833 auto mpduAggregator = htFem->GetMpduAggregator();
834 std::vector<Ptr<WifiMpdu>> mpduList;
842 m_phys.at(linkId)->GetChannelWidth());
845 mpduList = mpduAggregator->GetNextAmpdu(item, txParams,
Time::Min());
849 uint16_t expectedRemainingPacketsInQueue;
862 "A-MPDU contains an unexpected number of MPDUs");
863 expectedRemainingPacketsInQueue = 1200 - maxNMpdus;
865 expectedRemainingPacketsInQueue,
866 "Queue contains an unexpected number of MPDUs");
873 "A-MPDU contains an unexpected number of MPDUs");
876 expectedRemainingPacketsInQueue,
877 "Queue contains an unexpected number of MPDUs");
893 "A-MPDU contains an unexpected number of MPDUs");
896 expectedRemainingPacketsInQueue,
897 "Queue contains an unexpected number of MPDUs");
904 expectedRemainingPacketsInQueue,
905 "Queue contains an unexpected number of MPDUs");
939 void DoRun()
override;
966 :
TestCase(
"Test case to check that the Wifi Mac forwards up the same packets received at "
988 "No DL MU PPDU expected");
990 if (!psduMap[
SU_STA_ID]->GetHeader(0).IsQosData())
999 std::size_t dist = std::distance(mpdu->begin(), mpdu->end());
1001 m_nMsdus.push_back(dist > 0 ? dist : 1);
1028 wifi.SetRemoteStationManager(
"ns3::IdealWifiManager");
1032 mac.SetType(
"ns3::StaWifiMac",
1040 "BE_BlockAckThreshold",
1048 mac.SetType(
"ns3::ApWifiMac",
"Ssid", SsidValue(
ssid),
"BeaconGeneration",
BooleanValue(
true));
1056 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
1057 positionAlloc->Add(Vector(1.0, 0.0, 0.0));
1058 mobility.SetPositionAllocator(positionAlloc);
1060 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
1074 packetSocket.
Install(wifiStaNode);
1081 client->SetRemote(socket);
1085 Simulator::Schedule(
Seconds(1.5),
1086 &PacketSocketClient::SetAttribute,
1092 server->SetLocal(socket);
1110 Simulator::Destroy();
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 DequeueMpdus(const std::vector< Ptr< WifiMpdu >> &mpduList)
Dequeue a PSDU.
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 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.
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.
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.
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.
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...
The IEEE 802.11 SSID Information Element.
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.
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)
virtual void ConfigureStandard(WifiStandard standard)
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,...
void SetWifiRemoteStationManagers(const std::vector< Ptr< WifiRemoteStationManager >> &stationManagers)
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 SetRemoteStationManagers(const std::vector< Ptr< WifiRemoteStationManager >> &managers)
void SetVhtConfiguration(Ptr< VhtConfiguration > vhtConfiguration)
void SetStandard(WifiStandard standard)
Set the Wifi standard.
void SetEhtConfiguration(Ptr< EhtConfiguration > ehtConfiguration)
Ptr< WifiPhy > GetPhy() const
uint32_t GetIfIndex() const override
void SetPhys(const std::vector< Ptr< WifiPhy >> &phys)
Address GetAddress() const override
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.
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.
NLOHMANN_BASIC_JSON_TPL_DECLARATION std::string to_string(const NLOHMANN_BASIC_JSON_TPL &j)
user-defined to_string function for JSON values
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, 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 constexpr uint16_t SU_STA_ID
STA_ID to identify a single user (SU)
U * PeekPointer(const Ptr< U > &p)
params
Fit Fluctuating Two Ray model to the 3GPP TR 38.901 using the Anderson-Darling goodness-of-fit ##.
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