21 #include "ns3/rng-seed-manager.h"
22 #include <ns3/constant-position-mobility-model.h>
23 #include <ns3/core-module.h>
25 #include <ns3/lr-wpan-module.h>
26 #include <ns3/packet.h>
27 #include <ns3/propagation-delay-model.h>
28 #include <ns3/propagation-loss-model.h>
29 #include <ns3/simulator.h>
30 #include <ns3/single-model-spectrum-channel.h>
108 void DoRun()
override;
114 :
TestCase(
"Test the 802.15.4 clear channel assessment")
124 std::cout << std::setiosflags(std::ios::fixed) << std::setprecision(9) <<
"["
126 <<
" PlmeCcaConfirm: " << LrWpanHelper::LrWpanPhyEnumerationPrinter(status)
137 std::ostringstream os;
139 std::cout << std::setiosflags(std::ios::fixed) << std::setprecision(9) <<
"["
141 <<
" PhyTxBegin: " << os.str() << std::endl;
149 std::ostringstream os;
151 std::cout << std::setiosflags(std::ios::fixed) << std::setprecision(9) <<
"["
153 <<
" PhyTxEnd: " << os.str() << std::endl;
161 std::ostringstream os;
163 std::cout << std::setiosflags(std::ios::fixed) << std::setprecision(9) <<
"["
165 <<
" PhyRxBegin: " << os.str() << std::endl;
174 std::ostringstream os;
176 std::cout << std::setiosflags(std::ios::fixed) << std::setprecision(9) <<
"["
178 <<
" PhyRxEnd (" << sinr <<
"): " << os.str() << std::endl;
182 device->
GetPhy()->PlmeCcaRequest();
190 std::ostringstream os;
192 std::cout << std::setiosflags(std::ios::fixed) << std::setprecision(9) <<
"["
194 <<
" PhyRxDrop: " << os.str() << std::endl;
223 RngSeedManager::SetSeed(1);
224 RngSeedManager::SetRun(6);
247 CreateObject<LogDistancePropagationLossModel>();
248 propModel->SetReference(1.0,
250 propModel->SetPathLossExponent(2);
252 CreateObject<ConstantSpeedPropagationDelayModel>();
253 channel->AddPropagationLossModel(propModel);
254 channel->SetPropagationDelayModel(delayModel);
266 CreateObject<ConstantPositionMobilityModel>();
267 sender0Mobility->SetPosition(Vector(0, 0, 0));
268 dev0->
GetPhy()->SetMobility(sender0Mobility);
270 CreateObject<ConstantPositionMobilityModel>();
271 sender1Mobility->SetPosition(Vector(0, 669, 0));
272 dev1->
GetPhy()->SetMobility(sender1Mobility);
274 CreateObject<ConstantPositionMobilityModel>();
275 sender2Mobility->SetPosition(Vector(0, 1338, 0));
276 dev2->
GetPhy()->SetMobility(sender2Mobility);
279 dev0->
GetMac()->SetMcpsDataConfirmCallback(MakeNullCallback<void, McpsDataConfirmParams>());
280 dev1->
GetMac()->SetMcpsDataConfirmCallback(MakeNullCallback<void, McpsDataConfirmParams>());
281 dev2->
GetMac()->SetMcpsDataConfirmCallback(MakeNullCallback<void, McpsDataConfirmParams>());
284 dev1->
GetPhy()->SetPlmeCcaConfirmCallback(
292 dev0->
GetPhy()->TraceConnectWithoutContext(
295 dev0->
GetPhy()->TraceConnectWithoutContext(
298 dev2->
GetPhy()->TraceConnectWithoutContext(
301 dev2->
GetPhy()->TraceConnectWithoutContext(
304 dev1->
GetPhy()->TraceConnectWithoutContext(
307 dev1->
GetPhy()->TraceConnectWithoutContext(
310 dev1->
GetPhy()->TraceConnectWithoutContext(
324 Simulator::ScheduleNow(&LrWpanMac::McpsDataRequest, dev0->
GetMac(), params0, p0);
334 Simulator::ScheduleNow(&LrWpanMac::McpsDataRequest, dev2->
GetMac(), params1, p1);
342 sender2Mobility->SetPosition(Vector(0, 1340, 0));
344 Simulator::ScheduleNow(&LrWpanMac::McpsDataRequest, dev0->
GetMac(), params0, p0);
345 Simulator::ScheduleNow(&LrWpanMac::McpsDataRequest, dev2->
GetMac(), params1, p1);
351 Simulator::Destroy();
367 :
TestSuite(
"lr-wpan-clear-channel-assessment", UNIT)
static void PhyTxEnd(LrWpanCcaTestCase *testcase, Ptr< LrWpanNetDevice > device, Ptr< const Packet > packet)
Function called when PhyTxEnd is hit.
static void PhyTxBegin(LrWpanCcaTestCase *testcase, Ptr< LrWpanNetDevice > device, Ptr< const Packet > packet)
Function called when PhyTxBegin is hit.
static void PhyRxDrop(LrWpanCcaTestCase *testcase, Ptr< LrWpanNetDevice > device, Ptr< const Packet > packet)
Function called when PhyRxDrop is hit.
static void PhyRxBegin(LrWpanCcaTestCase *testcase, Ptr< LrWpanNetDevice > device, Ptr< const Packet > packet)
Function called when PhyRxBegin is hit.
void DoRun() override
Implementation to actually run this TestCase.
LrWpanPhyEnumeration m_status
PHY status.
static void PhyRxEnd(LrWpanCcaTestCase *testcase, Ptr< LrWpanNetDevice > device, Ptr< const Packet > packet, double sinr)
Function called when PhyRxEnd is hit.
static void PlmeCcaConfirm(LrWpanCcaTestCase *testcase, Ptr< LrWpanNetDevice > device, LrWpanPhyEnumeration status)
Function called when PlmeCcaConfirm is hit.
void SetChannel(Ptr< SpectrumChannel > channel)
Set the channel to which the NetDevice, and therefore the PHY, should be attached to.
Ptr< LrWpanMac > GetMac() const
Get the MAC used by this NetDevice.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Ptr< LrWpanPhy > GetPhy() const
Get the PHY used by this NetDevice.
void SetAddress(Address address) override
This method indirects to LrWpanMac::SetShortAddress ()
Ptr< LrWpanCsmaCa > GetCsmaCa() 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.
void Print(std::ostream &os) const
Print the packet contents.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
LrWpanPhyEnumeration
IEEE802.15.4-2006 PHY Emumerations Table 18 in section 6.2.3.
@ IEEE_802_15_4_PHY_UNSPECIFIED
@ TX_OPTION_NONE
TX_OPTION_NONE.
auto MakeBoundCallback(R(*fnPtr)(Args...), BArgs &&... bargs)
Make Callbacks with varying number of bound arguments.
Time Now()
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.
static LrWpanCcaTestSuite g_lrWpanCcaTestSuite
Static variable for test initialization.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
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.
uint8_t m_txOptions
Tx Options (bitfield)