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);
203 sender0Mobility->SetPosition (Vector (0,0,0));
204 dev0->
GetPhy ()->SetMobility (sender0Mobility);
207 sender1Mobility->SetPosition (Vector (0,10,0));
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);
252 Simulator::ScheduleWithContext (1,
Seconds (2.0),
253 &LrWpanMac::MlmeStartRequest,
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");
329 Simulator::Destroy ();
348 :
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.
static void TransEndIndication(LrWpanSlottedCsmacaTestCase *testcase, Ptr< LrWpanNetDevice > dev, McpsDataConfirmParams params)
Function called when McpsDataConfirm is hit.
LrWpanSlottedCsmacaTestCase()
uint32_t m_transCost
The current transaction cost in symbols.
virtual ~LrWpanSlottedCsmacaTestCase()
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...
virtual void DoRun(void)
Implementation to actually run this TestCase.
LrWpan Slotted CSMA-CA TestSuite.
LrWpanSlottedCsmacaTestSuite()
virtual void SetAddress(Address address)
This method indirects to LrWpanMac::SetShortAddress ()
void SetChannel(Ptr< SpectrumChannel > channel)
Set the channel to which the NetDevice, and therefore the PHY, should be attached to.
Ptr< LrWpanPhy > GetPhy(void) const
Get the PHY used by this NetDevice.
Ptr< LrWpanMac > GetMac(void) const
Get the MAC used by this NetDevice.
Ptr< LrWpanCsmaCa > GetCsmaCa(void) 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(void) 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.
int64_t GetMicroSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
TimeWithUnit As(const enum Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific 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.
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument.
Time Now(void)
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.
static void DataIndicationCoordinator(McpsDataIndicationParams params, Ptr< Packet > p)
static void StartConfirm(MlmeStartConfirmParams params)
static void TransEndIndication(McpsDataConfirmParams params)
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.
LrWpanMcpsDataConfirmStatus m_status
The status of the last MSDU transmission.
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.
bool m_panCoor
On true this device will become coordinator.
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.
uint8_t m_sfrmOrd
Superframe Order, indicates the length of the CAP in time slots.