23 #include "ns3/wifi-net-device.h"
24 #include "ns3/yans-wifi-channel.h"
25 #include "ns3/adhoc-wifi-mac.h"
26 #include "ns3/yans-wifi-phy.h"
27 #include "ns3/arf-wifi-manager.h"
28 #include "ns3/propagation-delay-model.h"
29 #include "ns3/propagation-loss-model.h"
30 #include "ns3/error-rate-model.h"
31 #include "ns3/yans-error-rate-model.h"
32 #include "ns3/constant-position-mobility-model.h"
34 #include "ns3/simulator.h"
36 #include "ns3/object-factory.h"
37 #include "ns3/dca-txop.h"
38 #include "ns3/mac-rx-middle.h"
39 #include "ns3/pointer.h"
40 #include "ns3/rng-seed-manager.h"
49 virtual void DoRun (
void);
66 WifiTest::SendOnePacket (Ptr<WifiNetDevice> dev)
68 Ptr<Packet> p = Create<Packet> ();
69 dev->Send (p, dev->GetBroadcast (), 1);
73 WifiTest::CreateOne (Vector pos, Ptr<YansWifiChannel> channel)
75 Ptr<Node> node = CreateObject<Node> ();
76 Ptr<WifiNetDevice> dev = CreateObject<WifiNetDevice> ();
78 Ptr<WifiMac> mac = m_mac.
Create<WifiMac> ();
80 Ptr<ConstantPositionMobilityModel> mobility = CreateObject<ConstantPositionMobilityModel> ();
81 Ptr<YansWifiPhy> phy = CreateObject<YansWifiPhy> ();
82 Ptr<ErrorRateModel> error = CreateObject<YansErrorRateModel> ();
83 phy->SetErrorRateModel (error);
84 phy->SetChannel (channel);
86 phy->SetMobility (node);
88 Ptr<WifiRemoteStationManager> manager = m_manager.
Create<WifiRemoteStationManager> ();
90 mobility->SetPosition (pos);
95 dev->SetRemoteStationManager (manager);
96 node->AddDevice (dev);
102 WifiTest::RunOne (
void)
104 Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> ();
105 Ptr<PropagationDelayModel> propDelay = m_propDelay.
Create<PropagationDelayModel> ();
106 Ptr<PropagationLossModel> propLoss = CreateObject<RandomPropagationLossModel> ();
107 channel->SetPropagationDelayModel (propDelay);
108 channel->SetPropagationLossModel (propLoss);
110 CreateOne (Vector (0.0, 0.0, 0.0), channel);
111 CreateOne (Vector (5.0, 0.0, 0.0), channel);
112 CreateOne (Vector (5.0, 0.0, 0.0), channel);
124 m_propDelay.
SetTypeId (
"ns3::ConstantSpeedPropagationDelayModel");
126 m_manager.
SetTypeId (
"ns3::ArfWifiManager");
128 m_manager.
SetTypeId (
"ns3::AarfWifiManager");
130 m_manager.
SetTypeId (
"ns3::ConstantRateWifiManager");
132 m_manager.
SetTypeId (
"ns3::OnoeWifiManager");
134 m_manager.
SetTypeId (
"ns3::AmrrWifiManager");
136 m_manager.
SetTypeId (
"ns3::IdealWifiManager");
147 m_propDelay.
SetTypeId (
"ns3::RandomPropagationDelayModel");
162 NS_TEST_EXPECT_MSG_EQ (
QosUtilsIsOldPacket (0, 2047),
false,
"2047 is new in comparison to 0");
164 NS_TEST_EXPECT_MSG_EQ (
QosUtilsIsOldPacket (0, 2048),
true,
"2048 is old in comparison to 0");
166 NS_TEST_EXPECT_MSG_EQ (
QosUtilsIsOldPacket (2048, 0),
true,
"0 is old in comparison to 2048");
168 NS_TEST_EXPECT_MSG_EQ (
QosUtilsIsOldPacket (4095, 0),
false,
"0 is new in comparison to 4095");
170 NS_TEST_EXPECT_MSG_EQ (
QosUtilsIsOldPacket (0, 4095),
true,
"4095 is old in comparison to 0");
172 NS_TEST_EXPECT_MSG_EQ (
QosUtilsIsOldPacket (4095, 2047),
true,
"2047 is old in comparison to 4095");
174 NS_TEST_EXPECT_MSG_EQ (
QosUtilsIsOldPacket (2048, 4095),
false,
"4095 is new in comparison to 2048");
176 NS_TEST_EXPECT_MSG_EQ (
QosUtilsIsOldPacket (2049, 0),
false,
"0 is new in comparison to 2049");
186 virtual void DoRun (
void);
197 InterferenceHelperSequenceTest::InterferenceHelperSequenceTest ()
198 :
TestCase (
"InterferenceHelperSequence")
203 InterferenceHelperSequenceTest::SendOnePacket (Ptr<WifiNetDevice> dev)
205 Ptr<Packet> p = Create<Packet> (9999);
206 dev->Send (p, dev->GetBroadcast (), 1);
210 InterferenceHelperSequenceTest::SwitchCh (Ptr<WifiNetDevice> dev)
212 Ptr<WifiPhy> p = dev->GetPhy ();
213 p->SetChannelNumber (1);
217 InterferenceHelperSequenceTest::CreateOne (Vector pos, Ptr<YansWifiChannel> channel)
219 Ptr<Node> node = CreateObject<Node> ();
220 Ptr<WifiNetDevice> dev = CreateObject<WifiNetDevice> ();
222 Ptr<WifiMac> mac = m_mac.
Create<WifiMac> ();
224 Ptr<ConstantPositionMobilityModel> mobility = CreateObject<ConstantPositionMobilityModel> ();
225 Ptr<YansWifiPhy> phy = CreateObject<YansWifiPhy> ();
226 Ptr<ErrorRateModel> error = CreateObject<YansErrorRateModel> ();
227 phy->SetErrorRateModel (error);
228 phy->SetChannel (channel);
229 phy->SetDevice (dev);
230 phy->SetMobility (node);
232 Ptr<WifiRemoteStationManager> manager = m_manager.
Create<WifiRemoteStationManager> ();
234 mobility->SetPosition (pos);
239 dev->SetRemoteStationManager (manager);
240 node->AddDevice (dev);
249 m_propDelay.
SetTypeId (
"ns3::ConstantSpeedPropagationDelayModel");
250 m_manager.
SetTypeId (
"ns3::ConstantRateWifiManager");
255 channel->SetPropagationDelayModel (propDelay);
256 channel->SetPropagationLossModel (propLoss);
263 propLoss->SetDefaultLoss (999);
266 &InterferenceHelperSequenceTest::SendOnePacket,
this,
267 DynamicCast<WifiNetDevice> (senderB->
GetDevice (0)));
270 &InterferenceHelperSequenceTest::SwitchCh,
this,
271 DynamicCast<WifiNetDevice> (rxOnly->
GetDevice (0)));
274 &InterferenceHelperSequenceTest::SendOnePacket,
this,
275 DynamicCast<WifiNetDevice> (senderA->
GetDevice (0)));
278 &InterferenceHelperSequenceTest::SendOnePacket,
this,
279 DynamicCast<WifiNetDevice> (senderB->
GetDevice (0)));
323 virtual void DoRun (
void);
333 Time m_firstTransmissionTime;
334 Time m_secondTransmissionTime;
335 unsigned int m_numSentPackets;
340 Bug555TestCase::Bug555TestCase ()
341 :
TestCase (
"Test case for Bug 555")
346 Bug555TestCase::NotifyPhyTxBegin (Ptr<const Packet> p)
348 if (m_numSentPackets == 0)
354 else if (m_numSentPackets == 1)
361 Bug555TestCase::SendOnePacket (Ptr<WifiNetDevice> dev)
363 Ptr<Packet> p = Create<Packet> (1000);
364 dev->Send (p, dev->GetBroadcast (), 1);
371 m_propDelay.
SetTypeId (
"ns3::ConstantSpeedPropagationDelayModel");
372 m_manager.
SetTypeId (
"ns3::ConstantRateWifiManager");
381 channel->SetPropagationDelayModel (propDelay);
382 channel->SetPropagationLossModel (propLoss);
384 Ptr<Node> txNode = CreateObject<Node> ();
392 txPhy->SetErrorRateModel (txError);
393 txPhy->SetChannel (channel);
394 txPhy->SetDevice (txDev);
395 txPhy->SetMobility (txNode);
398 txPhy->TraceConnectWithoutContext (
"PhyTxBegin",
MakeCallback (&Bug555TestCase::NotifyPhyTxBegin,
this));
400 txMobility->SetPosition (
Vector (0.0, 0.0, 0.0));
403 txDev->SetMac (txMac);
404 txDev->SetPhy (txPhy);
408 m_firstTransmissionTime =
Seconds (0.0);
409 m_secondTransmissionTime =
Seconds (0.0);
410 m_numSentPackets = 0;
423 uint32_t expectedWait1 = 1408 + (0 * 9) + 16 + 18;
426 NS_TEST_ASSERT_MSG_EQ (m_secondTransmissionTime, expectedSecondTransmissionTime,
"The second transmission time not correct!");
437 WifiTestSuite::WifiTestSuite ()
446 static WifiTestSuite g_wifiTestSuite;
smart pointer class similar to boost::intrusive_ptr
void ConfigureStandard(enum WifiPhyStandard standard)
void SetTypeId(TypeId tid)
bool QosUtilsIsOldPacket(uint16_t startingSeq, uint16_t seqNumber)
virtual void DoRun(void)
Implementation to actually run this test case.
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
static void SetRun(uint64_t run)
Set the run number of simulation.
Keep track of the current position and velocity of an object.
static Mac48Address Allocate(void)
Ptr< Object > Create(void) const
base class for all MAC-level wifi objects.This class encapsulates all the low-level MAC functionality...
virtual void DoRun(void)
Implementation to actually run this test case.
calculate a propagation delay.
Ptr< NetDevice > GetDevice(uint32_t index) const
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
TestCase(std::string name)
hold a list of per-remote-station state.
void AggregateObject(Ptr< Object > other)
static void Destroy(void)
virtual void DoRun(void)
Implementation to actually run this test case.
virtual void DoRun(void)
Implementation to actually run this test case.
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual test case to this test suite.
static void SetSeed(uint32_t seed)
set the seed it will duplicate the seed value 6 times
#define NS_ASSERT_MSG(condition, message)
instantiate subclasses of ns3::Object.
Time Seconds(double seconds)
create ns3::Time instances in units of seconds.
uint32_t AddDevice(Ptr< NetDevice > device)
Ptr< T > GetObject(void) const
Time MicroSeconds(uint64_t us)
create ns3::Time instances in units of microseconds.