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>
109 void DoRun()
override;
115 :
TestCase(
"Test the 802.15.4 clear channel assessment")
125 std::cout << std::setiosflags(std::ios::fixed) << std::setprecision(9) <<
"["
138 std::ostringstream os;
140 std::cout << std::setiosflags(std::ios::fixed) << std::setprecision(9) <<
"["
142 <<
" PhyTxBegin: " << os.str() << std::endl;
150 std::ostringstream os;
152 std::cout << std::setiosflags(std::ios::fixed) << std::setprecision(9) <<
"["
154 <<
" PhyTxEnd: " << os.str() << std::endl;
162 std::ostringstream os;
164 std::cout << std::setiosflags(std::ios::fixed) << std::setprecision(9) <<
"["
166 <<
" PhyRxBegin: " << os.str() << std::endl;
175 std::ostringstream os;
177 std::cout << std::setiosflags(std::ios::fixed) << std::setprecision(9) <<
"["
179 <<
" PhyRxEnd (" << sinr <<
"): " << os.str() << std::endl;
183 device->GetPhy()->PlmeCcaRequest();
191 std::ostringstream os;
193 std::cout << std::setiosflags(std::ios::fixed) << std::setprecision(9) <<
"["
195 <<
" PhyRxDrop: " << os.str() << std::endl;
237 dev0->AssignStreams(0);
238 dev1->AssignStreams(10);
239 dev2->AssignStreams(20);
248 CreateObject<LogDistancePropagationLossModel>();
249 propModel->SetReference(1.0,
251 propModel->SetPathLossExponent(2);
253 CreateObject<ConstantSpeedPropagationDelayModel>();
254 channel->AddPropagationLossModel(propModel);
255 channel->SetPropagationDelayModel(delayModel);
257 dev0->SetChannel(channel);
258 dev1->SetChannel(channel);
259 dev2->SetChannel(channel);
267 CreateObject<ConstantPositionMobilityModel>();
268 sender0Mobility->SetPosition(Vector(0, 0, 0));
269 dev0->GetPhy()->SetMobility(sender0Mobility);
271 CreateObject<ConstantPositionMobilityModel>();
272 sender1Mobility->SetPosition(Vector(0, 669, 0));
273 dev1->GetPhy()->SetMobility(sender1Mobility);
275 CreateObject<ConstantPositionMobilityModel>();
276 sender2Mobility->SetPosition(Vector(0, 1338, 0));
277 dev2->GetPhy()->SetMobility(sender2Mobility);
280 dev0->GetMac()->SetMcpsDataConfirmCallback(MakeNullCallback<void, McpsDataConfirmParams>());
281 dev1->GetMac()->SetMcpsDataConfirmCallback(MakeNullCallback<void, McpsDataConfirmParams>());
282 dev2->GetMac()->SetMcpsDataConfirmCallback(MakeNullCallback<void, McpsDataConfirmParams>());
285 dev1->GetPhy()->SetPlmeCcaConfirmCallback(
289 dev0->GetCsmaCa()->SetMacMinBE(0);
290 dev2->GetCsmaCa()->SetMacMinBE(0);
293 dev0->GetPhy()->TraceConnectWithoutContext(
296 dev0->GetPhy()->TraceConnectWithoutContext(
299 dev2->GetPhy()->TraceConnectWithoutContext(
302 dev2->GetPhy()->TraceConnectWithoutContext(
305 dev1->GetPhy()->TraceConnectWithoutContext(
308 dev1->GetPhy()->TraceConnectWithoutContext(
311 dev1->GetPhy()->TraceConnectWithoutContext(
343 sender2Mobility->SetPosition(Vector(0, 1340, 0));
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.
PhyEnumeration m_status
PHY status.
static void PlmeCcaConfirm(LrWpanCcaTestCase *testcase, Ptr< LrWpanNetDevice > device, PhyEnumeration status)
Function called when PlmeCcaConfirm 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.
static void PhyRxEnd(LrWpanCcaTestCase *testcase, Ptr< LrWpanNetDevice > device, Ptr< const Packet > packet, double sinr)
Function called when PhyRxEnd is hit.
static std::string LrWpanPhyEnumerationPrinter(lrwpan::PhyEnumeration e)
Transform the LrWpanPhyEnumeration enumeration into a printable string.
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, Duration duration=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.
void McpsDataRequest(McpsDataRequestParams params, Ptr< Packet > p) override
IEEE 802.15.4-2006, section 7.1.1.1 MCPS-DATA.request Request to transfer a MSDU.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
PhyEnumeration
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.
AddressMode m_dstAddrMode
Destination address mode.
Mac16Address m_dstAddr
Destination address.
uint16_t m_dstPanId
Destination PAN identifier.
AddressMode m_srcAddrMode
Source address mode.
uint8_t m_txOptions
Tx Options (bitfield)
uint8_t m_msduHandle
MSDU handle.