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" 
   97   virtual void DoRun (
void);
 
  104   : 
TestCase (
"Test the 802.15.4 clear channel assessment")
 
  112   std::cout << std::setiosflags (std::ios::fixed) << std::setprecision (9) << 
"[" << 
Simulator::Now ().
GetSeconds () << 
"] " << device->
GetMac ()->GetShortAddress () << 
" PlmeCcaConfirm: " << LrWpanHelper::LrWpanPhyEnumerationPrinter (status) << std::endl;
 
  120   std::ostringstream os;
 
  122   std::cout << std::setiosflags (std::ios::fixed) << std::setprecision (9) << 
"[" << 
Simulator::Now ().
GetSeconds () << 
"] " << device->
GetMac ()->GetShortAddress () << 
" PhyTxBegin: " << os.str () << std::endl;
 
  128   std::ostringstream os;
 
  130   std::cout << std::setiosflags (std::ios::fixed) << std::setprecision (9) << 
"[" << 
Simulator::Now ().
GetSeconds () << 
"] " << device->
GetMac ()->GetShortAddress () << 
" PhyTxEnd: " << os.str () << std::endl;
 
  136   std::ostringstream os;
 
  138   std::cout << std::setiosflags (std::ios::fixed) << std::setprecision (9) << 
"[" << 
Simulator::Now ().
GetSeconds () << 
"] " << device->
GetMac ()->GetShortAddress () << 
" PhyRxBegin: " << os.str () << std::endl;
 
  144   std::ostringstream os;
 
  146   std::cout << std::setiosflags (std::ios::fixed) << std::setprecision (9) << 
"[" << 
Simulator::Now ().
GetSeconds () << 
"] " << device->
GetMac ()->GetShortAddress () << 
" PhyRxEnd (" << sinr << 
"): " << os.str () << std::endl;
 
  149   device->
GetPhy ()->PlmeCcaRequest ();
 
  154   std::ostringstream os;
 
  156   std::cout << std::setiosflags (std::ios::fixed) << std::setprecision (9) << 
"[" << 
Simulator::Now ().
GetSeconds () << 
"] " << device->
GetMac ()->GetShortAddress () << 
" PhyRxDrop: " << os.str () << std::endl;
 
  185   RngSeedManager::SetSeed (1);
 
  186   RngSeedManager::SetRun (6);
 
  198   dev0->AssignStreams (0);
 
  199   dev1->AssignStreams (10);
 
  200   dev2->AssignStreams (20);
 
  209   propModel->SetReference (1.0, 40.0641); 
 
  210   propModel->SetPathLossExponent (2); 
 
  215   dev0->SetChannel (channel);
 
  216   dev1->SetChannel (channel);
 
  217   dev2->SetChannel (channel);
 
  221   n1->AddDevice (dev1);
 
  222   n2->AddDevice (dev2);
 
  226   dev0->GetPhy ()->SetMobility (sender0Mobility);
 
  229   dev1->GetPhy ()->SetMobility (sender1Mobility);
 
  231   sender2Mobility->
SetPosition (Vector (0, 1338, 0));
 
  232   dev2->GetPhy ()->SetMobility (sender2Mobility);
 
  235   dev0->GetMac ()->SetMcpsDataConfirmCallback (MakeNullCallback<void, McpsDataConfirmParams> ());
 
  236   dev1->GetMac ()->SetMcpsDataConfirmCallback (MakeNullCallback<void, McpsDataConfirmParams> ());
 
  237   dev2->GetMac ()->SetMcpsDataConfirmCallback (MakeNullCallback<void, McpsDataConfirmParams> ());
 
  243   dev0->GetCsmaCa ()->SetMacMinBE (0);
 
  244   dev2->GetCsmaCa ()->SetMacMinBE (0);
 
  261   params0.m_dstPanId = 0;
 
  263   params0.m_msduHandle = 0;
 
  265   Simulator::ScheduleNow (&LrWpanMac::McpsDataRequest, dev0->GetMac (), params0, p0);
 
  271   params1.m_dstPanId = 0;
 
  273   params1.m_msduHandle = 0;
 
  275   Simulator::ScheduleNow (&LrWpanMac::McpsDataRequest, dev2->GetMac (), params1, p1);
 
  283   sender2Mobility->
SetPosition (Vector (0, 1340, 0));
 
  285   Simulator::ScheduleNow (&LrWpanMac::McpsDataRequest, dev0->GetMac (), params0, p0);
 
  286   Simulator::ScheduleNow (&LrWpanMac::McpsDataRequest, dev2->GetMac (), params1, p1);
 
  292   Simulator::Destroy ();
 
  308   : 
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)
Function called when PhyTxBegin is hit. 
 
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)
Function called when PhyRxEnd is hit. 
 
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)
Add the single-frequency propagation loss model to be used. 
 
static void PhyRxBegin(LrWpanCcaTestCase *testcase, Ptr< LrWpanNetDevice > device, Ptr< const Packet > packet)
Function called when PhyRxBegin is hit. 
 
void Print(std::ostream &os) const 
Print the packet contents. 
 
static LrWpanCcaTestSuite g_lrWpanCcaTestSuite
Static variable for test initialization. 
 
static void PhyRxDrop(LrWpanCcaTestCase *testcase, Ptr< LrWpanNetDevice > device, Ptr< const Packet > packet)
Function called when PhyRxDrop is hit. 
 
double GetSeconds(void) const 
Get an approximation of the time stored in this instance in the indicated unit. 
 
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite. 
 
LrWpanPhyEnumeration m_status
PHY 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)
Function called when PlmeCcaConfirm is hit. 
 
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)
Function called when PhyTxEnd is hit. 
 
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.