22 #include "ns3/wifi-net-device.h" 23 #include "ns3/yans-wifi-channel.h" 24 #include "ns3/yans-wifi-phy.h" 25 #include "ns3/adhoc-wifi-mac.h" 26 #include "ns3/constant-position-mobility-model.h" 27 #include "ns3/simulator.h" 43 virtual void DoRun (
void);
97 phy->SetNTxPower (18);
98 phy->SetTxPowerStart (0);
99 phy->SetTxPowerEnd (17);
110 mac->SetAddress (Mac48Address::Allocate ());
113 dev->SetRemoteStationManager (manager);
114 node->AddDevice (dev);
131 manager->SetAttribute (
"SuccessThreshold",
UintegerValue (10));
147 dev->
Send (p, remoteAddress, 1);
154 WifiTxVector txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
167 for (
int i = 0; i < 10; i++)
169 manager->ReportDataOk (remoteAddress, &packetHeader, 0, ackMode, 0, packet->
GetSize ());
172 txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
185 manager->ReportDataFailed (remoteAddress, &packetHeader, packet->
GetSize ());
187 txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
200 for (
int i = 0; i < 7; i++)
202 manager->ReportDataOk (remoteAddress, &packetHeader, 0, ackMode, 0, packet->
GetSize ());
203 manager->ReportDataFailed (remoteAddress, &packetHeader, packet->
GetSize ());
205 manager->ReportDataOk (remoteAddress, &packetHeader, 0, ackMode, 0, packet->
GetSize ());
207 txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
220 manager->ReportDataFailed (remoteAddress, &packetHeader, packet->
GetSize ());
222 txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
235 manager->ReportDataFailed (remoteAddress, &packetHeader, packet->
GetSize ());
236 manager->ReportDataFailed (remoteAddress, &packetHeader, packet->
GetSize ());
238 txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
251 for (
int i = 0; i < 10; i++)
253 manager->ReportDataOk (remoteAddress, &packetHeader, 0, ackMode, 0, packet->
GetSize ());
256 txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
269 manager->ReportDataFailed (remoteAddress, &packetHeader, packet->
GetSize ());
271 txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
284 for (
int i = 0; i < 10; i++)
286 manager->ReportDataOk (remoteAddress, &packetHeader, 0, ackMode, 0, packet->
GetSize ());
289 txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
302 for (
int i = 0; i < 10; i++)
304 manager->ReportDataOk (remoteAddress, &packetHeader, 0, ackMode, 0, packet->
GetSize ());
307 txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
320 manager->ReportDataOk (remoteAddress, &packetHeader, 0, ackMode, 0, packet->
GetSize ());
322 for (
int i = 0; i < 2; i++)
324 manager->ReportDataFailed (remoteAddress,&packetHeader, packet->
GetSize ());
327 txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
334 Simulator::Destroy ();
349 manager->SetAttribute (
"SuccessThreshold2",
UintegerValue (10));
367 dev->
Send (p, remoteAddress, 1);
374 WifiTxVector txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
388 for (
int i = 0; i < 3; i++)
390 manager->ReportDataOk (remoteAddress, &packetHeader, 0, ackMode, 0, packet->
GetSize ());
393 txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
406 manager->ReportDataFailed (remoteAddress, &packetHeader, packet->
GetSize ());
408 txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
422 for (
int i = 0; i < 10; i++)
424 manager->ReportDataOk (remoteAddress, &packetHeader, 0, ackMode, 0, packet->
GetSize ());
427 txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
441 for (
int i = 0; i < 3; i++)
443 manager->ReportDataOk (remoteAddress, &packetHeader, 0, ackMode, 0, packet->
GetSize ());
446 txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
459 for (
int i = 0; i < 16 * 3; i++)
461 manager->ReportDataOk (remoteAddress, &packetHeader, 0, ackMode, 0, packet->
GetSize ());
464 txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
477 manager->ReportDataFailed (remoteAddress,&packetHeader, packet->
GetSize ());
479 txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
492 for (
int i = 0; i < 16; i++)
494 manager->ReportDataFailed (remoteAddress,&packetHeader, packet->
GetSize ());
497 txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
511 manager->ReportDataFailed (remoteAddress,&packetHeader, packet->
GetSize ());
513 txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
526 for (
int i = 0; i < 3; i++)
528 manager->ReportDataOk (remoteAddress, &packetHeader, 0, ackMode, 0, packet->
GetSize ());
531 txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
546 for (
int i = 0; i < 9 * 3; i++)
548 manager->ReportDataOk (remoteAddress, &packetHeader, 0, ackMode, 0, packet->
GetSize ());
551 txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
558 for (
int i = 0; i < 3; i++)
560 manager->ReportDataOk (remoteAddress, &packetHeader, 0, ackMode, 0, packet->
GetSize ());
563 txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
570 Simulator::Destroy ();
585 manager->SetAttribute (
"Alpha",
DoubleValue (1.25));
587 manager->SetAttribute (
"Tau",
DoubleValue (0.015));
609 dev->
Send (p, remoteAddress, 1);
642 WifiTxVector txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
659 for (
int i = 0; i < 6; i++)
661 manager->ReportDataOk (remoteAddress, &packetHeader, 0, ackMode, 0, packet->
GetSize ());
664 txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
674 manager->ReportDataOk (remoteAddress, &packetHeader, 0, ackMode, 0, packet->
GetSize ());
676 txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
689 for (
int i = 0; i < 4; i++)
691 manager->ReportDataFailed (remoteAddress,&packetHeader, packet->
GetSize ());
694 txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
701 manager->ReportDataFailed (remoteAddress,&packetHeader, packet->
GetSize ());
703 txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
716 for (
int i = 0; i < 7; i++)
718 manager->ReportDataOk (remoteAddress, &packetHeader, 0, ackMode, 0, packet->
GetSize ());
721 txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
728 for (
int i = 0; i < 10; i++)
730 manager->ReportDataOk (remoteAddress, &packetHeader, 0, ackMode, 0, packet->
GetSize ());
733 txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
740 for (
int i = 0; i < 13; i++)
742 manager->ReportDataOk (remoteAddress, &packetHeader, 0, ackMode, 0, packet->
GetSize ());
745 txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
752 for (
int i = 0; i < 19; i++)
754 manager->ReportDataOk (remoteAddress, &packetHeader, 0, ackMode, 0, packet->
GetSize ());
757 txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
764 for (
int i = 0; i < 23; i++)
766 manager->ReportDataOk (remoteAddress, &packetHeader, 0, ackMode, 0, packet->
GetSize ());
769 txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
776 for (
int i = 0; i < 33; i++)
778 manager->ReportDataOk (remoteAddress, &packetHeader, 0, ackMode, 0, packet->
GetSize ());
781 txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
788 for (
int i = 0; i < 43; i++)
790 manager->ReportDataOk (remoteAddress, &packetHeader, 0, ackMode, 0, packet->
GetSize ());
793 txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
808 for (
int i = 0; i < 49; i++)
810 manager->ReportDataOk (remoteAddress, &packetHeader, 0, ackMode, 0, packet->
GetSize ());
813 txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
820 manager->ReportDataOk (remoteAddress, &packetHeader, 0, ackMode, 0, packet->
GetSize ());
822 txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
836 for (
int i = 0; i < 16 * 50; i++)
838 manager->ReportDataOk (remoteAddress, &packetHeader, 0, ackMode, 0, packet->
GetSize ());
841 txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
854 for (
int i = 0; i < 6; i++)
856 manager->ReportDataFailed (remoteAddress,&packetHeader, packet->
GetSize ());
859 txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
872 for (
int i = 0; i < 16 * 6; i++)
874 manager->ReportDataFailed (remoteAddress,&packetHeader, packet->
GetSize ());
877 txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
890 for (
int i = 0; i < 6; i++)
892 manager->ReportDataFailed (remoteAddress,&packetHeader, packet->
GetSize ());
895 txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
906 for (
int i = 0; i < 11; i++)
908 manager->ReportDataFailed (remoteAddress,&packetHeader, packet->
GetSize ());
911 txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
926 for (
int i = 0; i < 25; i++)
928 manager->ReportDataOk (remoteAddress, &packetHeader, 0, ackMode, 0, packet->
GetSize ());
931 txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
938 for (
int i = 0; i < 5; i++)
940 manager->ReportDataFailed (remoteAddress,&packetHeader, packet->
GetSize ());
943 txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
950 for (
int i = 0; i < 5; i++)
952 manager->ReportDataFailed (remoteAddress,&packetHeader, packet->
GetSize ());
955 txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
962 for (
int i = 0; i < 25; i++)
964 manager->ReportDataOk (remoteAddress, &packetHeader, 0, ackMode, 0, packet->
GetSize ());
967 txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
980 for (
int i = 0; i < 16; i++)
982 for (
int j = 0; j < 25; j++)
984 manager->ReportDataOk (remoteAddress, &packetHeader, 0, ackMode, 0, packet->
GetSize ());
987 for (
int j = 0; j < 5; j++)
989 manager->ReportDataFailed (remoteAddress,&packetHeader, packet->
GetSize ());
993 txVector = manager->GetDataTxVector (remoteAddress, &packetHeader, packet);
1000 Simulator::Stop (
Seconds (10.0));
1003 Simulator::Destroy ();
1029 :
TestSuite (
"power-rate-adaptation-wifi", UNIT)
PowerRateAdaptationTest()
PowerRateAdaptationTestSuite()
AttributeValue implementation for Boolean.
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).
void TestAparf()
Test aparf function.
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Power Rate Adaptation Test.
uint16_t GetGuardInterval(void) const
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Power Rate Adaptation Test Suite.
Ptr< WifiRemoteStationManager > GetRemoteStationManager(void) const
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
static PowerRateAdaptationTestSuite g_powerRateAdaptationTestSuite
the test suite
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Hold an unsigned integer type.
#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.
ObjectFactory m_manager
manager
WifiMode GetMode(void) const
hold a list of per-remote-station state.
OFDM PHY for the 5 GHz band (Clause 17)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
Ptr< Node > ConfigureNode()
Configure nde function.
void TestParf()
Test parf function.
Instantiate subclasses of ns3::Object.
Time Seconds(double value)
Construct a Time in the indicated unit.
virtual void DoRun(void)
Implementation to actually run this TestCase.
uint8_t GetTxPowerLevel(void) const
uint16_t GetChannelWidth(void) const
This class can be used to hold variables of floating point type such as 'double' or 'float'...
void TestRrpaa()
Test rrpaa function.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
uint64_t GetDataRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const