10#include <ns3/constant-position-mobility-model.h>
11#include <ns3/core-module.h>
13#include <ns3/lr-wpan-module.h>
14#include <ns3/packet.h>
15#include <ns3/propagation-delay-model.h>
16#include <ns3/propagation-loss-model.h>
17#include <ns3/simulator.h>
18#include <ns3/single-model-spectrum-channel.h>
92 void DoRun()
override;
102 :
TestCase(
"Lrwpan: Slotted CSMA-CA test")
118 if (params.m_status == MacStatus::SUCCESS)
132 <<
"s Coordinator Received DATA packet (size " << p->GetSize() <<
" bytes)");
149 if (newValue == SuperframeStatus::CAP)
185 channel->AddPropagationLossModel(propModel);
186 channel->SetPropagationDelayModel(delayModel);
188 dev0->SetChannel(channel);
189 dev1->SetChannel(channel);
198 sender0Mobility->SetPosition(Vector(0, 0, 0));
199 dev0->GetPhy()->SetMobility(sender0Mobility);
203 sender1Mobility->SetPosition(Vector(0, 10, 0));
204 dev1->GetPhy()->SetMobility(sender1Mobility);
210 dev0->GetMac()->SetMlmeStartConfirmCallback(cb0);
214 dev1->GetMac()->SetMcpsDataConfirmCallback(cb1);
218 dev1->GetCsmaCa()->SetLrWpanMacTransCostCallback(cb2);
222 dev0->GetMac()->SetMcpsDataIndicationCallback(cb5);
225 dev1->GetMac()->TraceConnectWithoutContext(
226 "MacIncSuperframeStatus",
236 dev1->GetMac()->SetPanId(5);
237 dev1->GetMac()->SetAssociatedCoor(
Mac16Address(
"00:01"));
241 params.m_panCoor =
true;
243 params.m_bcnOrd = 14;
244 params.m_sfrmOrd = 6;
272 Time activePeriodsSum;
273 Time transactionTime;
281 symbolRate = (uint64_t)dev1->GetMac()->GetPhy()->GetDataOrSymbolRate(
false);
283 boundary = (activePeriodsSum.
GetMicroSeconds() * 1000 * 1000 * symbolRate) % activePeriodSize;
288 "Error, the transaction is not calculated on a boundary of an Active Period in the CAP");
299 if (p1->GetSize() > 18)
325 "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.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
#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.