|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
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> ();
240 for (uint32_t i = 0; i < psdu->
GetNMpdus (); i++)
252 pkt1 = Create<Packet> (1500);
253 pkt2 = Create<Packet> (1500);
279 queueIt = WifiMacQueue::EMPTY;
284 NS_TEST_EXPECT_MSG_EQ (mpduList.empty (),
true,
"a single packet for this destination should not result in an A-MPDU");
291 queueIt = WifiMacQueue::EMPTY;
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");
493 for (uint8_t i = 0; i < 10; i++)
505 queueIt = 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++)
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");
874 packetSocket.
Install (wifiStaNode);
885 Simulator::Schedule (
Seconds (1.5), &PacketSocketClient::SetAttribute, client,
894 sta_device->
GetMac ()->TraceConnectWithoutContext (
"MacTx",
898 ap_device->
GetMac ()->TraceConnectWithoutContext (
"MacRx",
904 Simulator::Destroy ();
holds a vector of ns3::NetDevice pointers
@ WIFI_STANDARD_80211n_5GHZ
Ptr< FrameExchangeManager > GetFrameExchangeManager(void) const
Get the Frame Exchange Manager.
DeaggregatedMsdusCI begin(void)
Get a constant iterator pointing to the first MSDU in the list of aggregated MSDUs.
Ptr< StaWifiMac > m_mac
Mac.
Make it easy to create and manage PHY objects for the YANS model.
void SetDevice(const Ptr< NetDevice > device)
Sets the device this PHY is associated with.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Ptr< WifiRemoteStationManager > m_manager
remote station manager
void Add(Vector v)
Add a position to the list of positions.
void Dispose(void)
Dispose of this Object.
void DoRun(void) override
Implementation to actually run this TestCase.
void SetMaxSsrc(uint32_t maxSsrc)
Sets the maximum STA short retry count (SSRC).
AttributeValue implementation for Boolean.
void MpduDiscarded(WifiMacDropReason reason, Ptr< const WifiMacQueueItem > mpdu)
Fired when the MAC discards an MPDU.
void AddStationHeCapabilities(Mac48Address from, HeCapabilities heCapabilities)
Records HE capabilities of the remote station.
Test for A-MSDU and A-MPDU aggregation.
Ptr< YansWifiPhy > m_phy
Phy.
WifiMacDropReason
The reason why an MPDU was dropped.
void SetDevice(const Ptr< NetDevice > device)
Sets the device this PHY is associated with.
Ptr< WifiPhy > GetPhy(void) const
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< WifiRemoteStationManager > m_manager
remote station manager
void SetMac(const Ptr< WifiMac > mac)
helps to create WifiNetDevice objects
std::vector< std::size_t > m_nMpdus
Number of MPDUs in PSDUs passed to the PHY.
virtual void SetAckManager(Ptr< WifiAckManager > ackManager)
Set the Acknowledgment Manager to use.
void DoRun(void) override
Implementation to actually run this TestCase.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
void SetHeConfiguration(Ptr< HeConfiguration > heConfiguration)
static WifiAggregationTestSuite g_wifiAggregationTestSuite
the test suite
Ptr< StaWifiMac > m_mac
Mac.
Ptr< WifiNetDevice > m_device
WifiNetDevice.
@ WIFI_PHY_BAND_5GHZ
The 5 GHz band.
void SetMaxAmpduLength(uint32_t maxAmpduLength)
Set the maximum AMPDU length.
@ WIFI_STANDARD_80211ax_5GHZ
DeaggregatedMsdusCI end(void)
Get a constant iterator indicating past-the-last MSDU in the list of aggregated MSDUs.
void SetVhtConfiguration(Ptr< VhtConfiguration > vhtConfiguration)
Ptr< BlockAckManager > GetBaManager(void)
Get the Block Ack Manager associated with this QosTxop.
The IEEE 802.11ax HE Capabilities.
void SetWifiMac(Ptr< RegularWifiMac > mac)
Set the MAC which is using this Protection Manager.
std::list< Ptr< const Packet > > m_packetList
List of packets passed to the MAC.
hold a list of per-remote-station state.
an address for a packet socket
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 SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
virtual void SetProtectionManager(Ptr< WifiProtectionManager > protectionManager)
Set the Protection Manager to use.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
Address GetAddress(void) const override
uint32_t GetPacketSize(void) const
Return the size in bytes of the packet or control header or management header stored by this item.
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
This class stores the TX parameters (TX vector, protection mechanism, acknowledgment mechanism,...
void SetRemote(PacketSocketAddress addr)
set the remote address and protocol to be used
const WifiMacHeader & GetHeader(void) const
Get the header stored in this item.
Time GetTxopLimit(void) const
Return the TXOP limit.
U * PeekPointer(const Ptr< U > &p)
ObjectFactory m_factory
factory
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
AttributeValue implementation for Ssid.
The IEEE 802.11 SSID Information Element.
void SetHtConfiguration(Ptr< HtConfiguration > htConfiguration)
ObjectFactory m_factory
factory
PreservePacketsInAmpdus()
void SetStopTime(Time stop)
Specify application stop time.
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.
TwoLevelAggregationTest()
@ WIFI_PHY_STANDARD_80211ax
HE PHY (clause 26)
std::list< Ptr< WifiMacQueueItem > >::const_iterator ConstIterator
Const iterator typedef.
void SetStartTime(Time start)
Specify application start time.
Ptr< StaWifiMac > m_mac
Mac.
Ptr< WifiNetDevice > m_device
WifiNetDevice.
virtual ~PreservePacketsInAmpdus()
void NotifyMacForwardUp(Ptr< const Packet > p)
Callback invoked when the receiver MAC forwards a packet up to the upper layer.
ObjectFactory m_factory
factory
void SetAddress(Mac48Address address) override
The HT Capabilities Information Element.
WifiAggregationTestSuite()
const WifiMacHeader & GetHeader(std::size_t i) const
Get the header of the i-th MPDU.
uint32_t AddApplication(Ptr< Application > application)
Associate an Application to this Node.
void SetWifiMac(Ptr< RegularWifiMac > mac)
Set the MAC which is using this Acknowledgment Manager.
void SetSuccess(void)
Set success bit to 0 (success).
void SetWifiPhy(const Ptr< WifiPhy > phy) override
Ptr< WifiMacQueue > GetWifiMacQueue() const
Return the packet queue associated with this Txop.
Instantiate subclasses of ns3::Object.
802.11ax aggregation test which permits 64 or 256 MPDUs in A-MPDU according to the negociated buffer ...
uint32_t GetSize(void) const
Return the size of the PSDU in bytes.
void Clear(void)
Reset the TX parameters.
bool m_discarded
whether the packet should be discarded
void SetMaxAmsduLength(uint16_t maxAmsduLength)
Set the maximum AMSDU length.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
std::size_t GetNMpdus(void) const
Return the number of MPDUs constituting the PSDU.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Simulation virtual time values and global simulation resolution.
Wifi Aggregation Test Suite.
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...
void SetSingleDevice(uint32_t device)
Set the address to match only a specified NetDevice.
Ptr< WifiMacQueueItem > GetNextAmsdu(Ptr< const WifiMacQueueItem > peekedItem, WifiTxParameters &txParams, Time availableTime, WifiMacQueueItem::ConstIterator &queueIt) const
Attempt to aggregate other MSDUs to the given A-MSDU while meeting the following constraints:
void SetWifiRemoteStationManager(const Ptr< WifiRemoteStationManager > stationManager) override
Give ns3::PacketSocket powers to ns3::Node.
Status code for association response.
void AddStationHtCapabilities(Mac48Address from, HtCapabilities htCapabilities)
Records HT capabilities of the remote station.
virtual void DequeueMpdu(Ptr< const WifiMacQueueItem > mpdu)
Dequeue the given MPDU from the queue in which it is stored.
Two Level Aggregation Test.
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...
uint32_t GetIfIndex(void) const override
WifiTxVector GetDataTxVector(const WifiMacHeader &header)
@ WIFI_PHY_STANDARD_80211n
HT PHY (clause 20)
Hold variables of type string.
Ptr< MpduAggregator > GetMpduAggregator(void) const
Returns the aggregator used to construct A-MPDU subframes.
void DoRun(void) override
Implementation to actually run this TestCase.
void ConfigureStandard(WifiStandard standard) override
WifiTxVector m_txVector
TXVECTOR of the frame being prepared.
Ptr< WifiMacQueueItem > GetNextMpdu(Ptr< const WifiMacQueueItem > peekedItem, WifiTxParameters &txParams, Time availableTime, bool initialFrame, WifiMacQueueItem::ConstIterator &queueIt)
Prepare the frame to transmit starting from the MPDU that has been previously peeked by calling PeekN...
Time Seconds(double value)
Construct a Time in the indicated unit.
void SetRemoteStationManager(const Ptr< WifiRemoteStationManager > manager)
virtual void ConfigureStandardAndBand(WifiPhyStandard standard, WifiPhyBand band)
Configure the PHY-level parameters for different Wi-Fi standard.
void DoRunSubTest(uint16_t bufferSize)
Run test for a given buffer size.
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
void SetPhysicalAddress(const Address address)
Set the destination address.
AttributeValue implementation for Time.
Ptr< MacTxMiddle > m_txMiddle
TX middle (aggregation etc.)
keep track of a set of node pointers.
void NotifyMacTransmit(Ptr< const Packet > packet)
Callback invoked when an MSDU is passed to the MAC.
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...
void SetProtocol(uint16_t protocol)
Set the protocol.
void DoRun(void) override
Implementation to actually run this TestCase.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Hold an unsigned integer type.
Ptr< WifiRemoteStationManager > GetWifiRemoteStationManager(void) const override
Ptr< WifiNetDevice > m_device
WifiNetDevice.
manage and create wifi channel objects for the YANS model.
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
create MAC layers for a ns3::WifiNetDevice.
Ptr< QosTxop > GetBEQueue(void) const
Accessor for the AC_BE channel access function.
Ptr< MsduAggregator > GetMsduAggregator(void) const
Returns the aggregator used to construct A-MSDU subframes.
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
void DequeuePsdu(Ptr< const WifiPsdu > psdu)
Dequeue the MPDUs of the given PSDU from the queue in which they are stored.
ConstIterator GetQueueIterator(void) const
Get a const iterator pointing to the position of the MPDU in the queue.
void SetLocal(PacketSocketAddress addr)
set the local address and protocol to be used
std::vector< std::size_t > m_nMsdus
Number of MSDUs in MPDUs passed to the PHY.
std::vector< Ptr< WifiMacQueueItem > > GetNextAmpdu(Ptr< WifiMacQueueItem > mpdu, WifiTxParameters &txParams, Time availableTime, WifiMacQueueItem::ConstIterator queueIt) const
Attempt to aggregate other MPDUs to the given MPDU, while meeting the following constraints:
Ptr< QosTxop > GetVIQueue(void) const
Accessor for the AC_VI channel access function.
Ptr< YansWifiPhy > m_phy
Phy.
Helper class used to assign positions and mobility models to nodes.
Ptr< YansWifiPhy > m_phy
Phy.
void SetPhy(const Ptr< WifiPhy > phy)
Ptr< WifiRemoteStationManager > m_manager
remote station manager
void NormalAckTimeout(Ptr< WifiMacQueueItem > mpdu, const WifiTxVector &txVector)
Called when the Ack timeout expires.
Ptr< WifiMac > GetMac(void) const
Ptr< Txop > m_dcf
the DCF/EDCAF that gained channel access
void NotifyPsduForwardedDown(WifiConstPsduMap psduMap, WifiTxVector txVector, double txPowerW)
Callback invoked when the sender MAC passes a PSDU(s) to the PHY.