23 #include <ns3/core-module.h> 24 #include <ns3/lr-wpan-module.h> 25 #include <ns3/propagation-loss-model.h> 26 #include <ns3/propagation-delay-model.h> 27 #include <ns3/simulator.h> 28 #include <ns3/single-model-spectrum-channel.h> 29 #include <ns3/constant-position-mobility-model.h> 30 #include <ns3/packet.h> 106 virtual void DoRun (
void);
116 :
TestCase (
"Lrwpan: Slotted CSMA-CA test")
190 channel->AddPropagationLossModel (propModel);
191 channel->SetPropagationDelayModel (delayModel);
198 n1->AddDevice (dev1);
204 dev0->GetPhy ()->SetMobility (sender0Mobility);
208 dev1->GetPhy ()->SetMobility (sender1Mobility);
215 dev0->GetMac ()->SetMlmeStartConfirmCallback (cb0);
219 dev1->GetMac ()->SetMcpsDataConfirmCallback (cb1);
223 dev1->GetCsmaCa ()->SetLrWpanMacTransCostCallback (cb2);
227 dev0->GetMac ()->SetMcpsDataIndicationCallback (cb5);
231 dev1->GetMac ()->TraceConnectWithoutContext (
"MacIncSuperframeStatus",
242 dev1->GetMac ()->SetPanId (5);
243 dev1->GetMac ()->SetAssociatedCoor (
Mac16Address (
"00:01"));
252 Simulator::ScheduleWithContext (1,
Seconds (2.0),
253 &LrWpanMac::MlmeStartRequest,
254 dev0->GetMac (), params);
264 params2.m_msduHandle = 0;
268 Simulator::ScheduleWithContext (1,
Seconds (2.93),
269 &LrWpanMac::McpsDataRequest,
270 dev1->GetMac (), params2, p1);
276 Time activePeriodsSum;
277 Time transactionTime;
279 uint32_t activePeriodSize = 20;
286 symbolRate = (uint64_t) dev1->GetMac ()->GetPhy ()->GetDataOrSymbolRate (
false);
288 boundary = (activePeriodsSum.
GetMicroSeconds () * 1000 * 1000 * symbolRate) % activePeriodSize;
290 NS_TEST_EXPECT_MSG_EQ (boundary, 0,
"Error, the transaction is not calculated on a boundary of an Active Period in the CAP");
303 if (p1->GetSize () > 18)
329 Simulator::Destroy ();
348 :
TestSuite (
"lr-wpan-slotted-csmaca", UNIT)
static void StartConfirm(LrWpanSlottedCsmacaTestCase *testcase, Ptr< LrWpanNetDevice > dev, MlmeStartConfirmParams params)
Function called when MlmeStartConfirm is hit.
TimeWithUnit As(const enum Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
uint16_t m_dstPanId
Destination PAN identifier.
Simulation virtual time values and global simulation resolution.
static void TransEndIndication(McpsDataConfirmParams params)
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Time m_sentTime
Indicates the time after a successful transmission.
LrWpanSlottedCsmacaTestCase()
LrWpan Slotted CSMA-CA TestSuite.
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument.
virtual ~LrWpanSlottedCsmacaTestCase()
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Time m_startCap
The time of the start of the Contention Access Period (CAP).
SuperframeStatus
Superframe status.
MLME-START.request params.
static void IncomingSuperframeStatus(LrWpanSlottedCsmacaTestCase *testcase, Ptr< LrWpanNetDevice > dev, SuperframeStatus oldValue, SuperframeStatus newValue)
Function called on each Superframe status change (CAP|CFP|INACTIVE).
virtual void SetAddress(Address address)
This method indirects to LrWpanMac::SetShortAddress ()
uint32_t m_transCost
The current transaction cost in symbols.
uint8_t m_sfrmOrd
Superframe Order, indicates the length of the CAP in time slots.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
MCPS-DATA.confirm params.
uint8_t m_bcnOrd
Beacon Order, Used to calculate the beacon interval, a value of 15 indicates no periodic beacons will...
uint16_t m_PanId
Pan Identifier used by the device.
LrWpanMcpsDataConfirmStatus m_status
The status of the last MSDU transmission.
int64_t GetMicroSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
LrWpanSlottedCsmacaTestSuite()
#define NS_LOG_UNCOND(msg)
Output the requested message unconditionally.
static void TransEndIndication(LrWpanSlottedCsmacaTestCase *testcase, Ptr< LrWpanNetDevice > dev, McpsDataConfirmParams params)
Function called when McpsDataConfirm is hit.
This class can contain 16 bit addresses.
Test the correct allocation of DIRECT transmissions in the contention access period (CAP) of the supe...
static void DataIndicationCoordinator(LrWpanSlottedCsmacaTestCase *testcase, Ptr< LrWpanNetDevice > dev, McpsDataIndicationParams params, Ptr< Packet > p)
Function called when McpsDataIndication is hit.
void SetPosition(const Vector &position)
Contention Access Period.
Time m_apBoundary
Indicates the time after the calculation of the transaction cost (A boundary of an Active Period in t...
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
static LrWpanSlottedCsmacaTestSuite lrWpanSlottedCsmacaTestSuite
Static variable for test initialization.
Time Seconds(double value)
Construct a Time in the indicated unit.
static void StartConfirm(MlmeStartConfirmParams params)
virtual void DoRun(void)
Implementation to actually run this TestCase.
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
bool m_panCoor
On true this device will become coordinator.
MCPS-DATA.request params.
static void TransactionCost(LrWpanSlottedCsmacaTestCase *testcase, Ptr< LrWpanNetDevice > dev, uint32_t trans)
Function called to indicated the calculated transaction cost in slotted CSMA-CA.
MLME-START.confirm params.
MCPS-DATA.indication params.
static void DataIndicationCoordinator(McpsDataIndicationParams params, Ptr< Packet > p)