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);
208 propModel->SetReference (1.0, 40.0641);
209 propModel->SetPathLossExponent (2);
211 channel->AddPropagationLossModel (propModel);
212 channel->SetPropagationDelayModel (delayModel);
224 sender0Mobility->SetPosition (Vector (0, 0, 0));
225 dev0->
GetPhy ()->SetMobility (sender0Mobility);
227 sender1Mobility->SetPosition (Vector (0, 669, 0));
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)
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.
virtual void DoRun(void)
Implementation to actually run this TestCase.
static void PhyRxBegin(LrWpanCcaTestCase *testcase, Ptr< LrWpanNetDevice > device, Ptr< const Packet > packet)
Function called when PhyRxBegin is hit.
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.
virtual void SetAddress(Address address)
This method indirects to LrWpanMac::SetShortAddress ()
void SetChannel(Ptr< SpectrumChannel > channel)
Set the channel to which the NetDevice, and therefore the PHY, should be attached to.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Ptr< LrWpanPhy > GetPhy(void) const
Get the PHY used by this NetDevice.
Ptr< LrWpanMac > GetMac(void) const
Get the MAC used by this NetDevice.
Ptr< LrWpanCsmaCa > GetCsmaCa(void) 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 enum 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.
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument.
Time Now(void)
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)