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")
128 if (params.m_status == LrWpanMcpsDataConfirmStatus::IEEE_802_15_4_SUCCESS)
142 <<
"s Coordinator Received DATA packet (size " << p->GetSize() <<
" bytes)");
159 if (newValue == SuperframeStatus::CAP)
192 CreateObject<LogDistancePropagationLossModel>();
194 CreateObject<ConstantSpeedPropagationDelayModel>();
195 channel->AddPropagationLossModel(propModel);
196 channel->SetPropagationDelayModel(delayModel);
198 dev0->SetChannel(channel);
199 dev1->SetChannel(channel);
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);
247 dev1->GetMac()->SetAssociatedCoor(
Mac16Address(
"00:01"));
251 params.m_panCoor =
true;
253 params.m_bcnOrd = 14;
254 params.m_sfrmOrd = 6;
282 Time activePeriodsSum;
283 Time transactionTime;
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");
309 if (p1->GetSize() > 18)
335 "Error, the transaction time is not the expected value");
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 MlmeStartRequest(MlmeStartRequestParams params)
IEEE 802.15.4-2006, section 7.1.14.1 MLME-START.request Request to allow a PAN coordinator to initiat...
void McpsDataRequest(McpsDataRequestParams params, Ptr< Packet > p)
IEEE 802.15.4-2006, section 7.1.1.1 MCPS-DATA.request Request to transfer a MSDU.
This class can contain 16 bit addresses.
Smart pointer class similar to boost::intrusive_ptr.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static void ScheduleWithContext(uint32_t context, const Time &delay, FUNC f, Ts &&... args)
Schedule an event with the given context.
static Time Now()
Return the current simulation virtual time.
static void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
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.
auto MakeBoundCallback(R(*fnPtr)(Args...), BArgs &&... bargs)
Make Callbacks with varying number of bound arguments.
#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 LrWpanSlottedCsmacaTestSuite lrWpanSlottedCsmacaTestSuite
Static variable for test initialization.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
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.