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>
103 void DoRun()
override;
113 :
TestCase(
"Lrwpan: Slotted CSMA-CA test")
129 if (params.m_status == MacStatus::SUCCESS)
143 <<
"s Coordinator Received DATA packet (size " << p->GetSize() <<
" bytes)");
160 if (newValue == SuperframeStatus::CAP)
193 CreateObject<LogDistancePropagationLossModel>();
195 CreateObject<ConstantSpeedPropagationDelayModel>();
196 channel->AddPropagationLossModel(propModel);
197 channel->SetPropagationDelayModel(delayModel);
199 dev0->SetChannel(channel);
200 dev1->SetChannel(channel);
208 CreateObject<ConstantPositionMobilityModel>();
209 sender0Mobility->SetPosition(Vector(0, 0, 0));
210 dev0->GetPhy()->SetMobility(sender0Mobility);
212 CreateObject<ConstantPositionMobilityModel>();
214 sender1Mobility->SetPosition(Vector(0, 10, 0));
215 dev1->GetPhy()->SetMobility(sender1Mobility);
221 dev0->GetMac()->SetMlmeStartConfirmCallback(cb0);
225 dev1->GetMac()->SetMcpsDataConfirmCallback(cb1);
229 dev1->GetCsmaCa()->SetLrWpanMacTransCostCallback(cb2);
233 dev0->GetMac()->SetMcpsDataIndicationCallback(cb5);
236 dev1->GetMac()->TraceConnectWithoutContext(
237 "MacIncSuperframeStatus",
247 dev1->GetMac()->SetPanId(5);
248 dev1->GetMac()->SetAssociatedCoor(
Mac16Address(
"00:01"));
252 params.m_panCoor =
true;
254 params.m_bcnOrd = 14;
255 params.m_sfrmOrd = 6;
283 Time activePeriodsSum;
284 Time transactionTime;
292 symbolRate = (uint64_t)dev1->GetMac()->GetPhy()->GetDataOrSymbolRate(
false);
294 boundary = (activePeriodsSum.
GetMicroSeconds() * 1000 * 1000 * symbolRate) % activePeriodSize;
299 "Error, the transaction is not calculated on a boundary of an Active Period in the CAP");
310 if (p1->GetSize() > 18)
336 "Error, the transaction time is not the expected value");
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()
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, Duration duration=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.
void MlmeStartRequest(MlmeStartRequestParams params) override
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) override
IEEE 802.15.4-2006, section 7.1.1.1 MCPS-DATA.request Request to transfer a MSDU.
#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.
AddressMode m_dstAddrMode
Destination address mode.
Mac16Address m_dstAddr
Destination address.
uint16_t m_dstPanId
Destination PAN identifier.
AddressMode m_srcAddrMode
Source address mode.
uint8_t m_msduHandle
MSDU handle.
MLME-START.confirm params.
MLME-START.request params.