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> ();
150 Ptr<Packet> currentAggregatedPacket = Create<Packet> ();
156 hdr.SetFragmentNumber (0);
157 hdr.SetNoMoreFragments ();
199 auto mpduList = mpduAggregator->GetNextAmpdu (item, txParams,
Time::Min (), queueIt);
229 mpduList = mpduAggregator->GetNextAmpdu (item, txParams,
Time::Min (), queueIt);
240 for (uint32_t i = 0; i < psdu->GetNMpdus (); i++)
252 pkt1 = Create<Packet> (1500);
253 pkt2 = Create<Packet> (1500);
258 hdr1.SetSequenceNumber (3);
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");
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");
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> ();
430 bool result = (item != 0);
438 "Unexpected number of MSDUs left in the EDCA queue");
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);
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> ();
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);
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");
869 socket.SetPhysicalAddress (ap_device->
GetAddress ());
870 socket.SetProtocol (1);
874 packetSocket.
Install (wifiStaNode);
885 Simulator::Schedule (
Seconds (1.5), &PacketSocketClient::SetAttribute, client,
894 sta_device->GetMac ()->TraceConnectWithoutContext (
"MacTx",
896 sta_device->GetPhy ()->TraceConnectWithoutContext (
"PhyTxPsduBegin",
898 ap_device->
GetMac ()->TraceConnectWithoutContext (
"MacRx",
904 Simulator::Destroy ();
void Dispose(void)
Dispose of this Object.
Ptr< StaWifiMac > m_mac
Mac.
ObjectFactory m_factory
factory
uint32_t AddApplication(Ptr< Application > application)
Associate an Application to this Node.
Wifi Aggregation Test Suite.
Test for A-MSDU and A-MPDU aggregation.
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...
void SetStopTime(Time stop)
Specify application stop time.
Simulation virtual time values and global simulation resolution.
Smart pointer class similar to boost::intrusive_ptr.
std::list< Ptr< const Packet > > m_packetList
List of packets passed to the MAC.
std::vector< Ptr< WifiMacQueueItem > > GetNextAmpdu(Ptr< WifiMacQueueItem > mpdu, WifiTxParameters &txParams, Time availableTime, WifiMacQueueItem::QueueIteratorPair queueIt) const
Attempt to aggregate other MPDUs to the given MPDU, while meeting the following constraints: ...
AttributeValue implementation for Boolean.
virtual void SetProtectionManager(Ptr< WifiProtectionManager > protectionManager)
Set the Protection Manager to use.
DeaggregatedMsdusCI end(void)
Get a constant iterator indicating past-the-last MSDU in the list of aggregated MSDUs.
void SetLocal(PacketSocketAddress addr)
set the local address and protocol to be used
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
std::vector< std::size_t > m_nMpdus
Number of MPDUs in PSDUs passed to the PHY.
Ptr< WifiRemoteStationManager > m_manager
remote station manager
Hold variables of type string.
Make it easy to create and manage PHY objects for the YANS model.
void NotifyMacTransmit(Ptr< const Packet > packet)
Callback invoked when an MSDU is passed to the MAC.
ObjectFactory m_factory
factory
void MpduDiscarded(WifiMacDropReason reason, Ptr< const WifiMacQueueItem > mpdu)
Fired when the MAC discards an MPDU.
virtual void ConfigureStandardAndBand(WifiPhyStandard standard, WifiPhyBand band)
Configure the PHY-level parameters for different Wi-Fi standard.
DeaggregatedMsdusCI begin(void)
Get a constant iterator pointing to the first MSDU in the list of aggregated MSDUs.
void Clear(void)
Reset the TX parameters.
an address for a packet socket
void SetWifiRemoteStationManager(const Ptr< WifiRemoteStationManager > stationManager) override
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
U * PeekPointer(const Ptr< U > &p)
void SetHtConfiguration(Ptr< HtConfiguration > htConfiguration)
Information needed to remove an MSDU from the queue.
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.
Ptr< BlockAckManager > GetBaManager(void)
Get the Block Ack Manager associated with this QosTxop.
Ptr< WifiNetDevice > m_device
WifiNetDevice.
Ptr< StaWifiMac > m_mac
Mac.
ObjectFactory m_factory
factory
helps to create WifiNetDevice objects
Ptr< WifiRemoteStationManager > GetWifiRemoteStationManager(void) const override
Ptr< YansWifiPhy > m_phy
Phy.
void SetWifiPhy(const Ptr< WifiPhy > phy) override
Give ns3::PacketSocket powers to ns3::Node.
void SetSingleDevice(uint32_t device)
Set the address to match only a specified NetDevice.
void DoRun(void) override
Implementation to actually run this TestCase.
void SetMaxAmpduLength(uint32_t maxAmpduLength)
Set the maximum AMPDU length.
void NotifyMacForwardUp(Ptr< const Packet > p)
Callback invoked when the receiver MAC forwards a packet up to the upper layer.
void SetDevice(const Ptr< NetDevice > device)
Sets the device this PHY is associated with.
PreservePacketsInAmpdus()
void SetWifiMac(Ptr< RegularWifiMac > mac)
Set the MAC which is using this Acknowledgment Manager.
WifiTxVector GetDataTxVector(const WifiMacHeader &header)
void SetHeConfiguration(Ptr< HeConfiguration > heConfiguration)
virtual void SetAckManager(Ptr< WifiAckManager > ackManager)
Set the Acknowledgment Manager to use.
void SetSuccess(void)
Set success bit to 0 (success).
void DoRun(void) override
Implementation to actually run this TestCase.
Ptr< WifiRemoteStationManager > m_manager
remote station manager
const WifiMacHeader & GetHeader(void) const
Get the header stored in this item.
void SetDevice(const Ptr< NetDevice > device)
Sets the device this PHY is associated with.
AttributeValue implementation for Time.
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.
void AddStationHtCapabilities(Mac48Address from, HtCapabilities htCapabilities)
Records HT capabilities of the remote station.
Ptr< WifiNetDevice > m_device
WifiNetDevice.
Hold an unsigned integer type.
Address GetAddress(void) const override
void SetWifiMac(Ptr< RegularWifiMac > mac)
Set the MAC which is using this Protection Manager.
holds a vector of ns3::NetDevice pointers
void DequeueMpdu(Ptr< WifiMacQueueItem > mpdu) override
Dequeue the given MPDU from the queue in which it is stored.
void SetMaxSsrc(uint32_t maxSsrc)
Sets the maximum STA short retry count (SSRC).
void AddStationHeCapabilities(Mac48Address from, HeCapabilities heCapabilities)
Records HE capabilities of the remote station.
TwoLevelAggregationTest()
Ptr< StaWifiMac > m_mac
Mac.
bool m_discarded
whether the packet should be discarded
Ptr< WifiNetDevice > m_device
WifiNetDevice.
void SetAddress(Mac48Address address) override
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.
WifiAggregationTestSuite()
void DoRunSubTest(uint16_t bufferSize)
Run test for a given buffer size.
Ptr< FrameExchangeManager > GetFrameExchangeManager(void) const
Get the Frame Exchange Manager.
Status code for association response.
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
WifiTxVector m_txVector
TXVECTOR of the frame being prepared.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
static WifiAggregationTestSuite g_wifiAggregationTestSuite
the test suite
Ptr< QosTxop > GetVIQueue(void) const
Accessor for the AC_VI channel access function.
manage and create wifi channel objects for the YANS model.
create MAC layers for a ns3::WifiNetDevice.
void DoRun(void) override
Implementation to actually run this TestCase.
void SetMaxAmsduLength(uint16_t maxAmsduLength)
Set the maximum AMSDU length.
The IEEE 802.11 SSID Information Element.
Two Level Aggregation Test.
Helper class used to assign positions and mobility models to nodes.
Ptr< MpduAggregator > GetMpduAggregator(void) const
Returns the aggregator used to construct A-MPDU subframes.
Instantiate subclasses of ns3::Object.
void SetPhy(const Ptr< WifiPhy > phy)
Ptr< QosTxop > GetBEQueue(void) const
Accessor for the AC_BE channel access function.
Ptr< WifiMac > GetMac(void) const
void DoRun(void) override
Implementation to actually run this TestCase.
void NormalAckTimeout(Ptr< WifiMacQueueItem > mpdu, const WifiTxVector &txVector)
Called when the Ack timeout expires.
void SetRemote(PacketSocketAddress addr)
set the remote address and protocol to be used
Ptr< MsduAggregator > GetMsduAggregator(void) const
Returns the aggregator used to construct A-MSDU subframes.
802.11ax aggregation test which permits 64 or 256 MPDUs in A-MPDU according to the negociated buffer ...
Time Seconds(double value)
Construct a Time in the indicated unit.
AttributeValue implementation for Ssid.
Ptr< WifiMacQueue > GetWifiMacQueue() const
Return the packet queue associated with this Txop.
This class stores the TX parameters (TX vector, protection mechanism, acknowledgment mechanism...
Ptr< Txop > m_dcf
the DCF/EDCAF that gained channel access
void Add(Vector v)
Add a position to the list of positions.
void ConfigureStandard(WifiStandard standard) override
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
void Install(Ptr< Node > node) const
Aggregate an instance of a ns3::PacketSocketFactory onto the provided node.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Ptr< YansWifiPhy > m_phy
Phy.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
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 NotifyPsduForwardedDown(WifiConstPsduMap psduMap, WifiTxVector txVector, double txPowerW)
Callback invoked when the sender MAC passes a PSDU(s) to the PHY.
bool TryAddMpdu(Ptr< const WifiMacQueueItem > mpdu, WifiTxParameters &txParams, Time availableTime) const
Recompute the protection and acknowledgment methods to use if the given MPDU is added to the frame be...
uint32_t GetPacketSize(void) const
Return the size in bytes of the packet or control header or management header stored by this item...
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.
void DequeuePsdu(Ptr< const WifiPsdu > psdu)
Dequeue the MPDUs of the given PSDU from the queue in which they are stored.
void SetStartTime(Time start)
Specify application start time.
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
void SetVhtConfiguration(Ptr< VhtConfiguration > vhtConfiguration)
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...
WifiMacDropReason
The reason why an MPDU was dropped.
Ptr< MacTxMiddle > m_txMiddle
TX middle (aggregation etc.)
std::vector< std::size_t > m_nMsdus
Number of MSDUs in MPDUs passed to the PHY.
virtual ~PreservePacketsInAmpdus()
void SetRemoteStationManager(const Ptr< WifiRemoteStationManager > manager)
Ptr< WifiRemoteStationManager > m_manager
remote station manager
Time GetTxopLimit(void) const
Return the TXOP limit.