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>
45 virtual void DoRun (
void);
51 :
TestCase (
"Test the 802.15.4 collision handling")
90 dev0->SetChannel (channel);
91 dev1->SetChannel (channel);
92 dev2->SetChannel (channel);
101 dev0->GetPhy ()->SetMobility (sender0Mobility);
107 dev1->GetPhy ()->SetMobility (sender1Mobility);
108 n1->AggregateObject (sender1Mobility);
113 dev2->GetPhy ()->SetMobility (sender2Mobility);
114 n2->AggregateObject (sender2Mobility);
119 dev0->GetCsmaCa ()->SetMacMinBE (0);
120 dev1->GetCsmaCa ()->SetMacMinBE (0);
121 dev2->GetCsmaCa ()->SetMacMinBE (0);
130 params.m_dstPanId = 0;
131 params.m_msduHandle = 0;
135 std::cout <<
"*** First test " << std::endl;
138 Simulator::Schedule (
Seconds (0.1),
139 &LrWpanMac::McpsDataRequest,
140 dev0->GetMac (), params, p0);
143 Simulator::Schedule (
Seconds (0.1),
144 &LrWpanMac::McpsDataRequest,
145 dev1->GetMac (), params, p1);
152 std::cout <<
"*** Second test " << std::endl;
157 Simulator::Schedule (
Seconds (0.1),
158 &LrWpanMac::McpsDataRequest,
159 dev0->GetMac (), params, p0);
162 Simulator::Schedule (
Seconds (0.1),
163 &LrWpanMac::McpsDataRequest,
164 dev1->GetMac (), params, p1);
171 std::cout <<
"*** Third test " << std::endl;
173 params.m_txOptions = 0;
180 Simulator::Schedule (
Seconds (0.0001),
181 &LrWpanMac::McpsDataRequest,
182 dev2->GetMac (), params, p2);
185 Simulator::Schedule (
Seconds (0.0002),
186 &LrWpanMac::McpsDataRequest,
187 dev1->GetMac (), params, p0);
191 std::cout <<
"m_rxPackets = " << int(
m_rxPackets) << std::endl;
195 std::cout <<
"*** Fourth test " << std::endl;
200 Simulator::Schedule (
Seconds (0.1),
201 &LrWpanMac::McpsDataRequest,
202 dev1->GetMac (), params, p0);
205 Simulator::Schedule (
Seconds (0.1),
206 &LrWpanMac::McpsDataRequest,
207 dev2->GetMac (), params, p1);
211 std::cout <<
"m_rxPackets = " << int(
m_rxPackets) << std::endl;
214 Simulator::Destroy ();
virtual void DoRun(void)
Implementation to actually run this TestCase.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
virtual void AddPropagationLossModel(Ptr< PropagationLossModel > loss)
set the single-frequency propagation loss model to be used
static void DataIndication(McpsDataIndicationParams params, Ptr< Packet > p)
void AddTestCase(TestCase *testCase, enum TestDuration duration)
Add an individual child TestCase to this test suite.
virtual ~LrWpanCollisionTestCase()
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
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.
virtual void SetPropagationDelayModel(Ptr< PropagationDelayModel > delay)
set the propagation delay model to be used
static LrWpanCollisionTestSuite g_lrWpanCollisionTestSuite
MCPS-DATA.request params.
void DataIndication(McpsDataIndicationParams params, Ptr< Packet > p)
MCPS-DATA.indication params.