22 #include <ns3/packet.h> 23 #include <ns3/lr-wpan-module.h> 24 #include <ns3/mobility-module.h> 25 #include <ns3/propagation-module.h> 26 #include <ns3/spectrum-module.h> 27 #include <ns3/mac16-address.h> 28 #include <ns3/mac64-address.h> 55 virtual void DoRun (
void);
61 :
TestCase (
"Test the 802.15.4 collision handling")
97 channel->AddPropagationLossModel (propModel);
98 channel->SetPropagationDelayModel (delayModel);
106 n1->AddDevice (dev1);
107 n2->AddDevice (dev2);
111 dev0->GetPhy ()->SetMobility (sender0Mobility);
117 dev1->GetPhy ()->SetMobility (sender1Mobility);
118 n1->AggregateObject (sender1Mobility);
123 dev2->GetPhy ()->SetMobility (sender2Mobility);
124 n2->AggregateObject (sender2Mobility);
129 dev0->GetCsmaCa ()->SetMacMinBE (0);
130 dev1->GetCsmaCa ()->SetMacMinBE (0);
131 dev2->GetCsmaCa ()->SetMacMinBE (0);
140 params.m_dstPanId = 0;
141 params.m_msduHandle = 0;
145 std::cout <<
"*** First test " << std::endl;
148 Simulator::Schedule (
Seconds (0.1),
149 &LrWpanMac::McpsDataRequest,
150 dev0->GetMac (), params, p0);
153 Simulator::Schedule (
Seconds (0.1),
154 &LrWpanMac::McpsDataRequest,
155 dev1->GetMac (), params, p1);
162 std::cout <<
"*** Second test " << std::endl;
167 Simulator::Schedule (
Seconds (0.1),
168 &LrWpanMac::McpsDataRequest,
169 dev0->GetMac (), params, p0);
172 Simulator::Schedule (
Seconds (0.1),
173 &LrWpanMac::McpsDataRequest,
174 dev1->GetMac (), params, p1);
181 std::cout <<
"*** Third test " << std::endl;
183 params.m_txOptions = 0;
190 Simulator::Schedule (
Seconds (0.0001),
191 &LrWpanMac::McpsDataRequest,
192 dev2->GetMac (), params, p2);
195 Simulator::Schedule (
Seconds (0.0002),
196 &LrWpanMac::McpsDataRequest,
197 dev1->GetMac (), params, p0);
201 std::cout <<
"m_rxPackets = " << int(
m_rxPackets) << std::endl;
205 std::cout <<
"*** Fourth test " << std::endl;
210 Simulator::Schedule (
Seconds (0.1),
211 &LrWpanMac::McpsDataRequest,
212 dev1->GetMac (), params, p0);
215 Simulator::Schedule (
Seconds (0.1),
216 &LrWpanMac::McpsDataRequest,
217 dev2->GetMac (), params, p1);
221 std::cout <<
"m_rxPackets = " << int(
m_rxPackets) << std::endl;
224 Simulator::Destroy ();
virtual void DoRun(void)
Implementation to actually run this TestCase.
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
uint8_t m_rxPackets
Rx packets counter.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
LrWpan Collision TestSuite.
static void DataIndication(McpsDataIndicationParams params, Ptr< Packet > p)
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
virtual ~LrWpanCollisionTestCase()
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
LrWpanAddressMode m_srcAddrMode
Source address mode.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
LrWpanCollisionTestSuite()
LrWpanCollisionTestCase()
This class can contain 16 bit addresses.
void SetPosition(const Vector &position)
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
Time Seconds(double value)
Construct a Time in the indicated unit.
static LrWpanCollisionTestSuite g_lrWpanCollisionTestSuite
Static variable for test initialization.
MCPS-DATA.request params.
void DataIndication(McpsDataIndicationParams params, Ptr< Packet > p)
Function called when DataIndication is hit.
MCPS-DATA.indication params.