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/mac-low.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" 59 virtual void DoRun (
void);
68 :
TestCase (
"Check the correctness of MPDU aggregation operations")
78 m_device = CreateObject<WifiNetDevice> ();
85 m_phy = CreateObject<YansWifiPhy> ();
103 m_mac = CreateObject<StaWifiMac> ();
124 Ptr<Packet> currentAggregatedPacket = Create<Packet> ();
130 uint16_t sequence =
m_mac->
m_txMiddle->GetNextSequenceNumberFor (&hdr);
131 hdr.SetSequenceNumber (sequence);
132 hdr.SetFragmentNumber (0);
133 hdr.SetNoMoreFragments ();
155 auto mpduList =
m_mac->
GetBEQueue ()->
GetLow ()->GetMpduAggregator ()->GetNextAmpdu (Create<WifiMacQueueItem> (pkt, hdr),
181 mpduList =
m_mac->
GetBEQueue ()->
GetLow ()->GetMpduAggregator ()->GetNextAmpdu (Create<WifiMacQueueItem> (pkt, hdr),
192 for (uint32_t i = 0; i < psdu->
GetNMpdus (); i++)
204 pkt1 = Create<Packet> (1500);
205 pkt2 = Create<Packet> (1500);
210 hdr1.SetSequenceNumber (3);
226 mpduList =
m_mac->
GetBEQueue ()->
GetLow ()->GetMpduAggregator ()->GetNextAmpdu (Create<WifiMacQueueItem> (pkt1, hdr1),
228 NS_TEST_EXPECT_MSG_EQ (mpduList.empty (),
true,
"a single packet for this destination should not result in an A-MPDU");
230 mpduList =
m_mac->
GetBEQueue ()->
GetLow ()->GetMpduAggregator ()->GetNextAmpdu (Create<WifiMacQueueItem> (pkt2, hdr2),
232 NS_TEST_EXPECT_MSG_EQ (mpduList.empty (),
true,
"no MPDU aggregation should be performed if there is no agreement");
242 Simulator::Destroy ();
265 virtual void DoRun (
void);
274 :
TestCase (
"Check the correctness of two-level aggregation operations")
284 m_device = CreateObject<WifiNetDevice> ();
291 m_phy = CreateObject<YansWifiPhy> ();
309 m_mac = CreateObject<StaWifiMac> ();
331 Ptr<Packet> currentAggregatedPacket = Create<Packet> ();
353 item =
m_mac->
GetBEQueue ()->
GetLow ()->GetMsduAggregator ()->GetNextAmsdu (hdr.GetAddr1 (), 0, txVector,
354 currentAggregatedPacket->GetSize ());
355 bool result = (item != 0);
372 item =
m_mac->
GetBEQueue ()->
GetLow ()->GetMsduAggregator ()->GetNextAmsdu (hdr.GetAddr1 (), 0, txVector,
373 currentAggregatedPacket->GetSize ());
374 result = (item != 0);
389 item =
m_mac->
GetBEQueue ()->
GetLow ()->GetMsduAggregator ()->GetNextAmsdu (hdr.GetAddr1 (), 0, txVector,
390 currentAggregatedPacket->GetSize ());
392 result = (item != 0);
417 pkt = Create<Packet> (1400);
421 for (uint8_t i = 0; i < 10; i++)
426 txVector =
m_mac->
GetVIQueue ()->
GetLow ()->GetDataTxVector (Create<const WifiMacQueueItem> (pkt, hdr));
432 txVector, 0, txopLimit);
435 auto mpduList =
m_mac->
GetVIQueue ()->
GetLow ()->GetMpduAggregator ()->GetNextAmpdu (mpdu, txVector, txopLimit);
452 "Unexpected number of MSDUs left in the EDCA queue");
457 Simulator::Destroy ();
491 :
TestCase (
"Check the correctness of 802.11ax aggregation operations")
501 m_device = CreateObject<WifiNetDevice> ();
512 m_phy = CreateObject<YansWifiPhy> ();
530 m_mac = CreateObject<StaWifiMac> ();
548 Ptr<Packet> currentAggregatedPacket = Create<Packet> ();
554 uint16_t sequence =
m_mac->
m_txMiddle->GetNextSequenceNumberFor (&hdr);
555 hdr.SetSequenceNumber (sequence);
556 hdr.SetFragmentNumber (0);
557 hdr.SetNoMoreFragments ();
575 for (uint16_t i = 0; i < 300; i++)
590 auto mpduList =
m_mac->
GetBEQueue ()->
GetLow ()->GetMpduAggregator ()-> GetNextAmpdu (Create<WifiMacQueueItem> (pkt, hdr),
593 NS_TEST_EXPECT_MSG_EQ (mpduList.size (), bufferSize,
"A-MPDU should countain " << bufferSize <<
" MPDUs");
594 uint16_t expectedRemainingPacketsInQueue = 300 - bufferSize + 1;
597 Simulator::Destroy ();
606 vhtConfiguration = 0;
642 virtual void DoRun (
void);
670 :
TestCase (
"Test case to check that the Wifi Mac forwards up the same packets received at sender side.")
688 true,
"No DL MU PPDU expected");
690 if (!psduMap[
SU_STA_ID]->GetHeader (0).IsQosData ())
699 std::size_t dist = std::distance (mpdu->begin (), mpdu->end ());
701 m_nMsdus.push_back (dist > 0 ? dist : 1);
728 wifi.SetRemoteStationManager (
"ns3::IdealWifiManager");
732 mac.SetType (
"ns3::StaWifiMac",
743 mac.SetType (
"ns3::ApWifiMac",
753 positionAlloc->
Add (Vector (0.0, 0.0, 0.0));
754 positionAlloc->
Add (Vector (1.0, 0.0, 0.0));
755 mobility.SetPositionAllocator (positionAlloc);
757 mobility.SetMobilityModel (
"ns3::ConstantPositionMobilityModel");
766 socket.SetPhysicalAddress (ap_device->
GetAddress ());
767 socket.SetProtocol (1);
771 packetSocket.
Install (wifiStaNode);
782 Simulator::Schedule (
Seconds (1.5), &PacketSocketClient::SetAttribute, client,
792 sta_device->GetMac ()->GetAttribute (
"BE_Txop", ptr);
797 qosTxop->
GetLow ()->GetPhy ()->TraceConnectWithoutContext (
"PhyTxPsduBegin",
799 ap_device->
GetMac ()->TraceConnectWithoutContext (
"MacRx",
805 Simulator::Destroy ();
void Dispose(void)
Dispose of this Object.
Ptr< StaWifiMac > m_mac
Mac.
void SetWifiPhy(const Ptr< WifiPhy > phy)
ObjectFactory m_factory
factory
uint32_t AddApplication(Ptr< Application > application)
Associate an Application to this Node.
void MissedAck(void)
Event handler when an Ack is missed.
Wifi Aggregation Test Suite.
Test for A-MSDU and A-MPDU aggregation.
void SetStopTime(Time stop)
Specify application stop time.
Simulation virtual time values and global simulation resolution.
std::list< Ptr< const Packet > > m_packetList
List of packets passed to the MAC.
virtual void DoRun(void)
Implementation to actually run this TestCase.
AttributeValue implementation for Boolean.
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...
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
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
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
virtual void ConfigureStandardAndBand(WifiPhyStandard standard, WifiPhyBand band)
Configure the PHY-level parameters for different Wi-Fi standard.
Handle packet fragmentation and retransmissions for QoS data frames as well as MSDU aggregation (A-MS...
an address for a packet socket
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)
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< WifiNetDevice > m_device
WifiNetDevice.
Ptr< StaWifiMac > m_mac
Mac.
ObjectFactory m_factory
factory
helps to create WifiNetDevice objects
Ptr< YansWifiPhy > m_phy
Phy.
Give ns3::PacketSocket powers to ns3::Node.
void SetSingleDevice(uint32_t device)
Set the address to match only a specified NetDevice.
Address GetAddress(void) const
void SetWifiRemoteStationManager(const Ptr< WifiRemoteStationManager > stationManager)
Set up WifiRemoteStationManager associated with this StaWifiMac.
void SetMaxAmpduLength(uint32_t maxAmpduLength)
Set the maximum AMPDU length.
uint32_t GetSize(void) const
Return the size of the PSDU in bytes.
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 SetHeConfiguration(Ptr< HeConfiguration > heConfiguration)
Ptr< WifiRemoteStationManager > m_manager
remote station manager
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.
Ptr< BlockAckManager > m_baManager
the block ack manager
holds a vector of ns3::NetDevice pointers
void SetAddress(Mac48Address address)
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.
Ptr< WifiNetDevice > m_device
WifiNetDevice.
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()
const WifiMacHeader & GetHeader(std::size_t i) const
Get the header of the i-th MPDU.
void DoRunSubTest(uint16_t bufferSize)
Run test for a given buffer size.
Ptr< const Packet > GetPacket(void) const
Get the packet stored in this item.
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
Ptr< MacLow > GetLow(void) const
Return the MacLow associated with this Txop.
std::size_t GetNMpdus(void) const
Return the number of MPDUs constituting the PSDU.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
Hold objects of type Ptr<T>.
static WifiAggregationTestSuite g_wifiAggregationTestSuite
the test suite
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
Ptr< const Packet > m_currentPacket
the current packet
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 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.
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)
Implementation to actually run this TestCase.
virtual void DoRun(void)
Implementation to actually run this TestCase.
void SetRemote(PacketSocketAddress addr)
set the remote address and protocol to be used
802.11ax aggregation test which permits 64 or 256 MPDUs in A-MPDU according to the negociated buffer ...
virtual void DoRun(void)
Implementation to actually run this TestCase.
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.
void Add(Vector v)
Add a position to the list of positions.
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.
WifiMacHeader m_currentHdr
the current header
void ConfigureStandard(WifiStandard standard)
void NotifyPsduForwardedDown(WifiConstPsduMap psduMap, WifiTxVector txVector, double txPowerW)
Callback invoked when the sender MAC passes a PSDU(s) to the PHY.
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 SetStartTime(Time start)
Specify application start time.
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...
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.