21#include <ns3/lr-wpan-module.h>
22#include <ns3/mac16-address.h>
23#include <ns3/mac64-address.h>
24#include <ns3/mobility-module.h>
25#include <ns3/packet.h>
26#include <ns3/propagation-module.h>
27#include <ns3/spectrum-module.h>
54 void DoRun()
override;
60 :
TestCase(
"Test the 802.15.4 collision handling")
94 CreateObject<LogDistancePropagationLossModel>();
96 CreateObject<ConstantSpeedPropagationDelayModel>();
97 channel->AddPropagationLossModel(propModel);
98 channel->SetPropagationDelayModel(delayModel);
110 CreateObject<ConstantPositionMobilityModel>();
111 sender0Mobility->SetPosition(Vector(0, 0, 0));
112 dev0->
GetPhy()->SetMobility(sender0Mobility);
116 CreateObject<ConstantPositionMobilityModel>();
118 sender1Mobility->SetPosition(Vector(0, 1, 0));
119 dev1->
GetPhy()->SetMobility(sender1Mobility);
123 CreateObject<ConstantPositionMobilityModel>();
125 sender2Mobility->SetPosition(Vector(30, 0, 0));
126 dev2->
GetPhy()->SetMobility(sender2Mobility);
129 dev0->
GetMac()->SetMcpsDataIndicationCallback(
149 std::cout <<
"*** First test " << std::endl;
152 Simulator::Schedule(
Seconds(0.1), &LrWpanMac::McpsDataRequest, dev0->
GetMac(), params, p0);
155 Simulator::Schedule(
Seconds(0.1), &LrWpanMac::McpsDataRequest, dev1->
GetMac(), params, p1);
162 std::cout <<
"*** Second test " << std::endl;
167 Simulator::Schedule(
Seconds(0.1), &LrWpanMac::McpsDataRequest, dev0->
GetMac(), params, p0);
170 Simulator::Schedule(
Seconds(0.1), &LrWpanMac::McpsDataRequest, dev1->
GetMac(), params, p1);
177 std::cout <<
"*** Third test " << std::endl;
186 Simulator::Schedule(
Seconds(0.0001), &LrWpanMac::McpsDataRequest, dev2->
GetMac(), params, p2);
189 Simulator::Schedule(
Seconds(0.0002), &LrWpanMac::McpsDataRequest, dev1->
GetMac(), params, p0);
197 std::cout <<
"*** Fourth test " << std::endl;
202 Simulator::Schedule(
Seconds(0.1), &LrWpanMac::McpsDataRequest, dev1->
GetMac(), params, p0);
205 Simulator::Schedule(
Seconds(0.1), &LrWpanMac::McpsDataRequest, dev2->
GetMac(), params, p1);
212 Simulator::Destroy();
void DoRun() override
Implementation to actually run this TestCase.
~LrWpanCollisionTestCase() override
uint8_t m_rxPackets
Rx packets counter.
void DataIndication(McpsDataIndicationParams params, Ptr< Packet > p)
Function called when DataIndication is hit.
LrWpanCollisionTestCase()
LrWpan Collision TestSuite.
LrWpanCollisionTestSuite()
void SetChannel(Ptr< SpectrumChannel > channel)
Set the channel to which the NetDevice, and therefore the PHY, should be attached to.
Ptr< LrWpanMac > GetMac() const
Get the MAC used by this NetDevice.
Ptr< LrWpanPhy > GetPhy() const
Get the PHY used by this NetDevice.
void SetAddress(Address address) override
This method indirects to LrWpanMac::SetShortAddress ()
Ptr< LrWpanCsmaCa > GetCsmaCa() const
Get the CSMA/CA implementation used by this NetDevice.
This class can contain 16 bit addresses.
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
@ TX_OPTION_ACK
TX_OPTION_ACK.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Time Seconds(double value)
Construct a Time in the indicated unit.
static LrWpanCollisionTestSuite g_lrWpanCollisionTestSuite
Static variable for test initialization.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
MCPS-DATA.indication params.
MCPS-DATA.request params.
LrWpanAddressMode m_srcAddrMode
Source address mode.
LrWpanAddressMode m_dstAddrMode
Destination address mode.
uint16_t m_dstPanId
Destination PAN identifier.
Mac16Address m_dstAddr
Destination address.
uint8_t m_msduHandle
MSDU handle.
uint8_t m_txOptions
Tx Options (bitfield)