|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
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);
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);
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)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
bool m_panCoor
On true this device will become coordinator.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Time m_startCap
The time of the start of the Contention Access Period (CAP).
This class can contain 16 bit addresses.
LrWpanAddressMode m_dstAddrMode
Destination address mode.
uint16_t m_dstPanId
Destination PAN identifier.
void SetPosition(const Vector &position)
LrWpan Slotted CSMA-CA TestSuite.
TimeWithUnit As(const enum Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
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.request params.
virtual void DoRun(void)
Implementation to actually run this TestCase.
Ptr< LrWpanCsmaCa > GetCsmaCa(void) const
Get the CSMA/CA implementation used by this NetDevice.
uint8_t m_sfrmOrd
Superframe Order, indicates the length of the CAP in time slots.
MCPS-DATA.confirm params.
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
int64_t GetMicroSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
LrWpanSlottedCsmacaTestSuite()
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.
Ptr< LrWpanPhy > GetPhy(void) const
Get the PHY used by this NetDevice.
Test the correct allocation of DIRECT transmissions in the contention access period (CAP) of the supe...
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Simulation virtual time values and global simulation resolution.
static void StartConfirm(LrWpanSlottedCsmacaTestCase *testcase, Ptr< LrWpanNetDevice > dev, MlmeStartConfirmParams params)
Function called when MlmeStartConfirm is hit.
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
static void DataIndicationCoordinator(LrWpanSlottedCsmacaTestCase *testcase, Ptr< LrWpanNetDevice > dev, McpsDataIndicationParams params, Ptr< Packet > p)
Function called when McpsDataIndication is hit.
#define NS_LOG_UNCOND(msg)
Output the requested message unconditionally.
@ CAP
Contention Access Period.
void SetChannel(Ptr< SpectrumChannel > channel)
Set the channel to which the NetDevice, and therefore the PHY, should be attached to.
virtual ~LrWpanSlottedCsmacaTestCase()
Time m_apBoundary
Indicates the time after the calculation of the transaction cost (A boundary of an Active Period in t...
MCPS-DATA.indication params.
Time Seconds(double value)
Construct a Time in the indicated unit.
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument.
LrWpanMcpsDataConfirmStatus m_status
The status of the last MSDU transmission.
LrWpanAddressMode m_srcAddrMode
Source address mode.
uint32_t m_transCost
The current transaction cost in symbols.
LrWpanSlottedCsmacaTestCase()
Mac16Address m_dstAddr
Destination address.
virtual void SetAddress(Address address)
This method indirects to LrWpanMac::SetShortAddress ()
static void IncomingSuperframeStatus(LrWpanSlottedCsmacaTestCase *testcase, Ptr< LrWpanNetDevice > dev, SuperframeStatus oldValue, SuperframeStatus newValue)
Function called on each Superframe status change (CAP|CFP|INACTIVE).
static void StartConfirm(MlmeStartConfirmParams params)
SuperframeStatus
Superframe status.
static void TransEndIndication(LrWpanSlottedCsmacaTestCase *testcase, Ptr< LrWpanNetDevice > dev, McpsDataConfirmParams params)
Function called when McpsDataConfirm is hit.
MCPS-DATA.request params.
Ptr< LrWpanMac > GetMac(void) const
Get the MAC used by this NetDevice.
static LrWpanSlottedCsmacaTestSuite lrWpanSlottedCsmacaTestSuite
Static variable for test initialization.
static void DataIndicationCoordinator(McpsDataIndicationParams params, Ptr< Packet > p)
MLME-START.confirm params.
static void TransEndIndication(McpsDataConfirmParams params)
uint8_t m_msduHandle
MSDU handle.
Time m_sentTime
Indicates the time after a successful transmission.