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) <<
"["
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;
236 dev0->AssignStreams(0);
237 dev1->AssignStreams(10);
238 dev2->AssignStreams(20);
247 CreateObject<LogDistancePropagationLossModel>();
248 propModel->SetReference(1.0,
250 propModel->SetPathLossExponent(2);
252 CreateObject<ConstantSpeedPropagationDelayModel>();
253 channel->AddPropagationLossModel(propModel);
254 channel->SetPropagationDelayModel(delayModel);
256 dev0->SetChannel(channel);
257 dev1->SetChannel(channel);
258 dev2->SetChannel(channel);
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(
288 dev0->GetCsmaCa()->SetMacMinBE(0);
289 dev2->GetCsmaCa()->SetMacMinBE(0);
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(
342 sender2Mobility->SetPosition(Vector(0, 1340, 0));
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.
static std::string LrWpanPhyEnumerationPrinter(LrWpanPhyEnumeration e)
Transform the LrWpanPhyEnumeration enumeration into a printable string.
void McpsDataRequest(McpsDataRequestParams params, Ptr< Packet > p)
IEEE 802.15.4-2006, section 7.1.1.1 MCPS-DATA.request Request to transfer a MSDU.
This class can contain 16 bit addresses.
Smart pointer class similar to boost::intrusive_ptr.
static void SetRun(uint64_t run)
Set the run number of simulation.
static void SetSeed(uint32_t seed)
Set the seed.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static Time Now()
Return the current simulation virtual time.
static void Run()
Run the simulation.
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
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.
#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)