21 #include <ns3/constant-position-mobility-model.h>
22 #include <ns3/core-module.h>
24 #include <ns3/lr-wpan-module.h>
25 #include <ns3/packet.h>
26 #include <ns3/propagation-delay-model.h>
27 #include <ns3/propagation-loss-model.h>
28 #include <ns3/simulator.h>
29 #include <ns3/single-model-spectrum-channel.h>
102 void DoRun()
override;
112 :
TestCase(
"Lrwpan: Slotted CSMA-CA test")
142 <<
"s Coordinator Received DATA packet (size " << p->
GetSize() <<
" bytes)");
192 CreateObject<LogDistancePropagationLossModel>();
194 CreateObject<ConstantSpeedPropagationDelayModel>();
195 channel->AddPropagationLossModel(propModel);
196 channel->SetPropagationDelayModel(delayModel);
207 CreateObject<ConstantPositionMobilityModel>();
208 sender0Mobility->SetPosition(Vector(0, 0, 0));
209 dev0->
GetPhy()->SetMobility(sender0Mobility);
211 CreateObject<ConstantPositionMobilityModel>();
213 sender1Mobility->SetPosition(Vector(0, 10, 0));
214 dev1->
GetPhy()->SetMobility(sender1Mobility);
220 dev0->
GetMac()->SetMlmeStartConfirmCallback(cb0);
224 dev1->
GetMac()->SetMcpsDataConfirmCallback(cb1);
228 dev1->
GetCsmaCa()->SetLrWpanMacTransCostCallback(cb2);
232 dev0->
GetMac()->SetMcpsDataIndicationCallback(cb5);
235 dev1->
GetMac()->TraceConnectWithoutContext(
236 "MacIncSuperframeStatus",
246 dev1->
GetMac()->SetPanId(5);
255 Simulator::ScheduleWithContext(1,
257 &LrWpanMac::MlmeStartRequest,
272 Simulator::ScheduleWithContext(1,
274 &LrWpanMac::McpsDataRequest,
282 Time activePeriodsSum;
283 Time transactionTime;
285 uint32_t activePeriodSize = 20;
291 symbolRate = (uint64_t)dev1->
GetMac()->GetPhy()->GetDataOrSymbolRate(
false);
293 boundary = (activePeriodsSum.
GetMicroSeconds() * 1000 * 1000 * symbolRate) % activePeriodSize;
298 "Error, the transaction is not calculated on a boundary of an Active Period in the CAP");
335 "Error, the transaction time is not the expected value");
337 Simulator::Destroy();
354 :
TestSuite(
"lr-wpan-slotted-csmaca", UNIT)
Test the correct allocation of DIRECT transmissions in the contention access period (CAP) of the supe...
Time m_sentTime
Indicates the time after a successful transmission.
Time m_startCap
The time of the start of the Contention Access Period (CAP).
static void DataIndicationCoordinator(LrWpanSlottedCsmacaTestCase *testcase, Ptr< LrWpanNetDevice > dev, McpsDataIndicationParams params, Ptr< Packet > p)
Function called when McpsDataIndication is hit.
static void StartConfirm(LrWpanSlottedCsmacaTestCase *testcase, Ptr< LrWpanNetDevice > dev, MlmeStartConfirmParams params)
Function called when MlmeStartConfirm is hit.
~LrWpanSlottedCsmacaTestCase() override
static void TransEndIndication(LrWpanSlottedCsmacaTestCase *testcase, Ptr< LrWpanNetDevice > dev, McpsDataConfirmParams params)
Function called when McpsDataConfirm is hit.
LrWpanSlottedCsmacaTestCase()
void DoRun() override
Implementation to actually run this TestCase.
uint32_t m_transCost
The current transaction cost in symbols.
static void IncomingSuperframeStatus(LrWpanSlottedCsmacaTestCase *testcase, Ptr< LrWpanNetDevice > dev, SuperframeStatus oldValue, SuperframeStatus newValue)
Function called on each Superframe status change (CAP|CFP|INACTIVE).
static void TransactionCost(LrWpanSlottedCsmacaTestCase *testcase, Ptr< LrWpanNetDevice > dev, uint32_t trans)
Function called to indicated the calculated transaction cost in slotted CSMA-CA.
Time m_apBoundary
Indicates the time after the calculation of the transaction cost (A boundary of an Active Period in t...
LrWpan Slotted CSMA-CA TestSuite.
LrWpanSlottedCsmacaTestSuite()
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.
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Simulation virtual time values and global simulation resolution.
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
int64_t GetMicroSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
#define NS_LOG_UNCOND(msg)
Output the requested message unconditionally.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
SuperframeStatus
Superframe status.
@ CAP
Contention Access Period.
auto MakeBoundCallback(R(*fnPtr)(Args...), BArgs &&... bargs)
Make Callbacks with varying number of bound arguments.
Time Now()
create an ns3::Time instance which contains the current simulation time.
#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.
void DataIndicationCoordinator(McpsDataIndicationParams params, Ptr< Packet > p)
void TransEndIndication(McpsDataConfirmParams params)
void StartConfirm(MlmeStartConfirmParams params)
static LrWpanSlottedCsmacaTestSuite lrWpanSlottedCsmacaTestSuite
Static variable for test initialization.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
params
Fit Fluctuating Two Ray model to the 3GPP TR 38.901 using the Anderson-Darling goodness-of-fit ##.
MCPS-DATA.confirm params.
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.
MLME-START.confirm params.
MLME-START.request params.