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" 
   55   virtual void DoRun (
void);
 
   62   : 
TestCase (
"Test the 802.15.4 clear channel assessment")
 
   70   std::cout << std::setiosflags (std::ios::fixed) << std::setprecision (9) << 
"[" << 
Simulator::Now ().
GetSeconds () << 
"] " << device->
GetMac ()->GetShortAddress () << 
" PlmeCcaConfirm: " << LrWpanHelper::LrWpanPhyEnumerationPrinter (status) << std::endl;
 
   78   std::ostringstream os;
 
   80   std::cout << std::setiosflags (std::ios::fixed) << std::setprecision (9) << 
"[" << 
Simulator::Now ().
GetSeconds () << 
"] " << device->
GetMac ()->GetShortAddress () << 
" PhyTxBegin: " << os.str () << std::endl;
 
   86   std::ostringstream os;
 
   88   std::cout << std::setiosflags (std::ios::fixed) << std::setprecision (9) << 
"[" << 
Simulator::Now ().
GetSeconds () << 
"] " << device->
GetMac ()->GetShortAddress () << 
" PhyTxEnd: " << os.str () << std::endl;
 
   94   std::ostringstream os;
 
   96   std::cout << std::setiosflags (std::ios::fixed) << std::setprecision (9) << 
"[" << 
Simulator::Now ().
GetSeconds () << 
"] " << device->
GetMac ()->GetShortAddress () << 
" PhyRxBegin: " << os.str () << std::endl;
 
  102   std::ostringstream os;
 
  104   std::cout << std::setiosflags (std::ios::fixed) << std::setprecision (9) << 
"[" << 
Simulator::Now ().
GetSeconds () << 
"] " << device->
GetMac ()->GetShortAddress () << 
" PhyRxEnd (" << sinr << 
"): " << os.str () << std::endl;
 
  107   device->
GetPhy ()->PlmeCcaRequest ();
 
  112   std::ostringstream os;
 
  114   std::cout << std::setiosflags (std::ios::fixed) << std::setprecision (9) << 
"[" << 
Simulator::Now ().
GetSeconds () << 
"] " << device->
GetMac ()->GetShortAddress () << 
" PhyRxDrop: " << os.str () << std::endl;
 
  143   RngSeedManager::SetSeed (1);
 
  144   RngSeedManager::SetRun (6);
 
  156   dev0->AssignStreams (0);
 
  157   dev1->AssignStreams (10);
 
  158   dev2->AssignStreams (20);
 
  167   propModel->SetReference (1.0, 40.0641); 
 
  168   propModel->SetPathLossExponent (2); 
 
  173   dev0->SetChannel (channel);
 
  174   dev1->SetChannel (channel);
 
  175   dev2->SetChannel (channel);
 
  179   n1->AddDevice (dev1);
 
  180   n2->AddDevice (dev2);
 
  184   dev0->GetPhy ()->SetMobility (sender0Mobility);
 
  187   dev1->GetPhy ()->SetMobility (sender1Mobility);
 
  189   sender2Mobility->
SetPosition (Vector (0, 1338, 0));
 
  190   dev2->GetPhy ()->SetMobility (sender2Mobility);
 
  193   dev0->GetMac ()->SetMcpsDataConfirmCallback (MakeNullCallback<void, McpsDataConfirmParams> ());
 
  194   dev1->GetMac ()->SetMcpsDataConfirmCallback (MakeNullCallback<void, McpsDataConfirmParams> ());
 
  195   dev2->GetMac ()->SetMcpsDataConfirmCallback (MakeNullCallback<void, McpsDataConfirmParams> ());
 
  201   dev0->GetCsmaCa ()->SetMacMinBE (0);
 
  202   dev2->GetCsmaCa ()->SetMacMinBE (0);
 
  219   params0.m_dstPanId = 0;
 
  221   params0.m_msduHandle = 0;
 
  223   Simulator::ScheduleNow (&LrWpanMac::McpsDataRequest, dev0->GetMac (), params0, p0);
 
  229   params1.m_dstPanId = 0;
 
  231   params1.m_msduHandle = 0;
 
  233   Simulator::ScheduleNow (&LrWpanMac::McpsDataRequest, dev2->GetMac (), params1, p1);
 
  241   sender2Mobility->
SetPosition (Vector (0, 1340, 0));
 
  243   Simulator::ScheduleNow (&LrWpanMac::McpsDataRequest, dev0->GetMac (), params0, p0);
 
  244   Simulator::ScheduleNow (&LrWpanMac::McpsDataRequest, dev2->GetMac (), params1, p1);
 
  250   Simulator::Destroy ();
 
  260   : 
TestSuite (
"lr-wpan-clear-channel-assessment", UNIT)
 
Smart pointer class similar to boost::intrusive_ptr. 
 
static void PhyTxBegin(LrWpanCcaTestCase *testcase, Ptr< LrWpanNetDevice > device, Ptr< const Packet > packet)
 
Ptr< LrWpanPhy > GetPhy(void) const 
Get the PHY used by this NetDevice. 
 
static void PhyRxEnd(LrWpanCcaTestCase *testcase, Ptr< LrWpanNetDevice > device, Ptr< const Packet > packet, double sinr)
 
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument. 
 
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name. 
 
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not. 
 
virtual void DoRun(void)
Implementation to actually run this TestCase. 
 
virtual void AddPropagationLossModel(Ptr< PropagationLossModel > loss)
set the single-frequency propagation loss model to be used 
 
static void PhyRxBegin(LrWpanCcaTestCase *testcase, Ptr< LrWpanNetDevice > device, Ptr< const Packet > packet)
 
void Print(std::ostream &os) const 
Print the packet contents. 
 
static LrWpanCcaTestSuite g_lrWpanCcaTestSuite
 
static void PhyRxDrop(LrWpanCcaTestCase *testcase, Ptr< LrWpanNetDevice > device, Ptr< const Packet > packet)
 
double GetSeconds(void) const 
Get an approximation of the time stored in this instance in the indicated unit. 
 
void AddTestCase(TestCase *testCase, enum TestDuration duration)
Add an individual child TestCase to this test suite. 
 
LrWpanPhyEnumeration m_status
 
LrWpanAddressMode m_srcAddrMode
Source address mode. 
 
Every class exported by the ns3 library is enclosed in the ns3 namespace. 
 
This class can contain 16 bit addresses. 
 
void SetPosition(const Vector &position)
 
static void PlmeCcaConfirm(LrWpanCcaTestCase *testcase, Ptr< LrWpanNetDevice > device, LrWpanPhyEnumeration status)
 
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node. 
 
virtual void SetPropagationDelayModel(Ptr< PropagationDelayModel > delay)
set the propagation delay model to be used 
 
Time Now(void)
create an ns3::Time instance which contains the current simulation time. 
 
static void PhyTxEnd(LrWpanCcaTestCase *testcase, Ptr< LrWpanNetDevice > device, Ptr< const Packet > packet)
 
LrWpanPhyEnumeration
IEEE802.15.4-2006 PHY Emumerations Table 18 in section 6.2.3. 
 
MCPS-DATA.request params. 
 
Ptr< LrWpanMac > GetMac(void) const 
Get the MAC used by this NetDevice.