|
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>
31 #include "ns3/rng-seed-manager.h"
96 virtual void DoRun (
void);
103 :
TestCase (
"Test the 802.15.4 clear channel assessment")
111 std::cout << std::setiosflags (std::ios::fixed) << std::setprecision (9) <<
"[" <<
Simulator::Now ().
As (Time::S) <<
"] " << device->
GetMac ()->GetShortAddress () <<
" PlmeCcaConfirm: " << LrWpanHelper::LrWpanPhyEnumerationPrinter (status) << std::endl;
119 std::ostringstream os;
121 std::cout << std::setiosflags (std::ios::fixed) << std::setprecision (9) <<
"[" <<
Simulator::Now ().
As (Time::S) <<
"] " << device->
GetMac ()->GetShortAddress () <<
" PhyTxBegin: " << os.str () << std::endl;
127 std::ostringstream os;
129 std::cout << std::setiosflags (std::ios::fixed) << std::setprecision (9) <<
"[" <<
Simulator::Now ().
As (Time::S) <<
"] " << device->
GetMac ()->GetShortAddress () <<
" PhyTxEnd: " << os.str () << std::endl;
135 std::ostringstream os;
137 std::cout << std::setiosflags (std::ios::fixed) << std::setprecision (9) <<
"[" <<
Simulator::Now ().
As (Time::S) <<
"] " << device->
GetMac ()->GetShortAddress () <<
" PhyRxBegin: " << os.str () << std::endl;
143 std::ostringstream os;
145 std::cout << std::setiosflags (std::ios::fixed) << std::setprecision (9) <<
"[" <<
Simulator::Now ().
As (Time::S) <<
"] " << device->
GetMac ()->GetShortAddress () <<
" PhyRxEnd (" << sinr <<
"): " << os.str () << std::endl;
148 device->
GetPhy ()->PlmeCcaRequest ();
153 std::ostringstream os;
155 std::cout << std::setiosflags (std::ios::fixed) << std::setprecision (9) <<
"[" <<
Simulator::Now ().
As (Time::S) <<
"] " << device->
GetMac ()->GetShortAddress () <<
" PhyRxDrop: " << os.str () << std::endl;
184 RngSeedManager::SetSeed (1);
185 RngSeedManager::SetRun (6);
211 channel->AddPropagationLossModel (propModel);
212 channel->SetPropagationDelayModel (delayModel);
225 dev0->
GetPhy ()->SetMobility (sender0Mobility);
228 dev1->
GetPhy ()->SetMobility (sender1Mobility);
230 sender2Mobility->
SetPosition (Vector (0, 1338, 0));
231 dev2->
GetPhy ()->SetMobility (sender2Mobility);
234 dev0->
GetMac ()->SetMcpsDataConfirmCallback (MakeNullCallback<void, McpsDataConfirmParams> ());
235 dev1->
GetMac ()->SetMcpsDataConfirmCallback (MakeNullCallback<void, McpsDataConfirmParams> ());
236 dev2->
GetMac ()->SetMcpsDataConfirmCallback (MakeNullCallback<void, McpsDataConfirmParams> ());
264 Simulator::ScheduleNow (&LrWpanMac::McpsDataRequest, dev0->
GetMac (), params0, p0);
274 Simulator::ScheduleNow (&LrWpanMac::McpsDataRequest, dev2->
GetMac (), params1, p1);
282 sender2Mobility->
SetPosition (Vector (0, 1340, 0));
284 Simulator::ScheduleNow (&LrWpanMac::McpsDataRequest, dev0->
GetMac (), params0, p0);
285 Simulator::ScheduleNow (&LrWpanMac::McpsDataRequest, dev2->
GetMac (), params1, p1);
291 Simulator::Destroy ();
307 :
TestSuite (
"lr-wpan-clear-channel-assessment", UNIT)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
static void PhyTxBegin(LrWpanCcaTestCase *testcase, Ptr< LrWpanNetDevice > device, Ptr< const Packet > packet)
Function called when PhyTxBegin is hit.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
virtual void DoRun(void)
Implementation to actually run this TestCase.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
@ TX_OPTION_NONE
TX_OPTION_NONE.
static void PhyTxEnd(LrWpanCcaTestCase *testcase, Ptr< LrWpanNetDevice > device, Ptr< const Packet > packet)
Function called when PhyTxEnd is hit.
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)
TimeWithUnit As(const enum Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
static LrWpanCcaTestSuite g_lrWpanCcaTestSuite
Static variable for test initialization.
Ptr< LrWpanCsmaCa > GetCsmaCa(void) const
Get the CSMA/CA implementation used by this NetDevice.
uint8_t m_txOptions
Tx Options (bitfield)
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
void SetReference(double referenceDistance, double referenceLoss)
Set the reference path loss at a given distance.
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Ptr< LrWpanPhy > GetPhy(void) const
Get the PHY used by this NetDevice.
static void PhyRxDrop(LrWpanCcaTestCase *testcase, Ptr< LrWpanNetDevice > device, Ptr< const Packet > packet)
Function called when PhyRxDrop is hit.
LrWpanPhyEnumeration
IEEE802.15.4-2006 PHY Emumerations Table 18 in section 6.2.3.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
void SetChannel(Ptr< SpectrumChannel > channel)
Set the channel to which the NetDevice, and therefore the PHY, should be attached to.
static void PhyRxEnd(LrWpanCcaTestCase *testcase, Ptr< LrWpanNetDevice > device, Ptr< const Packet > packet, double sinr)
Function called when PhyRxEnd is hit.
static void PhyRxBegin(LrWpanCcaTestCase *testcase, Ptr< LrWpanNetDevice > device, Ptr< const Packet > packet)
Function called when PhyRxBegin is hit.
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument.
void SetPathLossExponent(double n)
LrWpanAddressMode m_srcAddrMode
Source address mode.
void Print(std::ostream &os) const
Print the packet contents.
LrWpanPhyEnumeration m_status
PHY status.
Mac16Address m_dstAddr
Destination address.
virtual void SetAddress(Address address)
This method indirects to LrWpanMac::SetShortAddress ()
static void PlmeCcaConfirm(LrWpanCcaTestCase *testcase, Ptr< LrWpanNetDevice > device, LrWpanPhyEnumeration status)
Function called when PlmeCcaConfirm is hit.
@ IEEE_802_15_4_PHY_UNSPECIFIED
MCPS-DATA.request params.
Ptr< LrWpanMac > GetMac(void) const
Get the MAC used by this NetDevice.
uint8_t m_msduHandle
MSDU handle.