11#include "ns3/constant-position-mobility-model.h" 
   12#include "ns3/core-module.h" 
   14#include "ns3/lr-wpan-module.h" 
   15#include "ns3/packet.h" 
   16#include "ns3/propagation-delay-model.h" 
   17#include "ns3/propagation-loss-model.h" 
   18#include "ns3/rng-seed-manager.h" 
   19#include "ns3/simulator.h" 
   20#include "ns3/single-model-spectrum-channel.h" 
  105    void DoRun() 
override;
 
 
  111    : 
TestCase(
"Test the 802.15.4 clear channel assessment")
 
 
  121    std::cout << std::setiosflags(std::ios::fixed) << std::setprecision(9) << 
"[" 
 
  134    std::ostringstream os;
 
  136    std::cout << std::setiosflags(std::ios::fixed) << std::setprecision(9) << 
"[" 
  138              << 
" PhyTxBegin: " << os.str() << std::endl;
 
 
  146    std::ostringstream os;
 
  148    std::cout << std::setiosflags(std::ios::fixed) << std::setprecision(9) << 
"[" 
  150              << 
" PhyTxEnd: " << os.str() << std::endl;
 
 
  158    std::ostringstream os;
 
  160    std::cout << std::setiosflags(std::ios::fixed) << std::setprecision(9) << 
"[" 
  162              << 
" PhyRxBegin: " << os.str() << std::endl;
 
 
  171    std::ostringstream os;
 
  173    std::cout << std::setiosflags(std::ios::fixed) << std::setprecision(9) << 
"[" 
  175              << 
" PhyRxEnd (" << sinr << 
"): " << os.str() << std::endl;
 
  179    device->GetPhy()->PlmeCcaRequest();
 
 
  187    std::ostringstream os;
 
  189    std::cout << std::setiosflags(std::ios::fixed) << std::setprecision(9) << 
"[" 
  191              << 
" PhyRxDrop: " << os.str() << std::endl;
 
 
  233    dev0->AssignStreams(0);
 
  234    dev1->AssignStreams(10);
 
  235    dev2->AssignStreams(20);
 
  245    propModel->SetReference(1.0,
 
  247    propModel->SetPathLossExponent(2); 
 
  250    channel->AddPropagationLossModel(propModel);
 
  251    channel->SetPropagationDelayModel(delayModel);
 
  253    dev0->SetChannel(channel);
 
  254    dev1->SetChannel(channel);
 
  255    dev2->SetChannel(channel);
 
  264    sender0Mobility->SetPosition(Vector(0, 0, 0));
 
  265    dev0->GetPhy()->SetMobility(sender0Mobility);
 
  268    sender1Mobility->SetPosition(Vector(0, 669, 0));
 
  269    dev1->GetPhy()->SetMobility(sender1Mobility);
 
  272    sender2Mobility->SetPosition(Vector(0, 1338, 0));
 
  273    dev2->GetPhy()->SetMobility(sender2Mobility);
 
  281    dev1->GetPhy()->SetPlmeCcaConfirmCallback(
 
  285    dev0->GetCsmaCa()->SetMacMinBE(0);
 
  286    dev2->GetCsmaCa()->SetMacMinBE(0);
 
  289    dev0->GetPhy()->TraceConnectWithoutContext(
 
  292    dev0->GetPhy()->TraceConnectWithoutContext(
 
  295    dev2->GetPhy()->TraceConnectWithoutContext(
 
  298    dev2->GetPhy()->TraceConnectWithoutContext(
 
  301    dev1->GetPhy()->TraceConnectWithoutContext(
 
  304    dev1->GetPhy()->TraceConnectWithoutContext(
 
  307    dev1->GetPhy()->TraceConnectWithoutContext(
 
  339    sender2Mobility->SetPosition(Vector(0, 1340, 0));
 
 
  372    void DoRun() 
override;
 
 
  378    : 
TestCase(
"Test CCA false positives vulnerable window caused by turnAround")
 
 
  446    dev0->AssignStreams(0);
 
  447    dev1->AssignStreams(10);
 
  448    dev2->AssignStreams(20);
 
  450    dev0->GetMac()->SetExtendedAddress(
"00:00:00:00:00:00:CA:FE");
 
  451    dev1->GetMac()->SetExtendedAddress(
"00:00:00:00:00:00:00:01");
 
  452    dev2->GetMac()->SetExtendedAddress(
"00:00:00:00:00:00:00:02");
 
  466    channel->AddPropagationLossModel(propModel);
 
  467    channel->SetPropagationDelayModel(delayModel);
 
  469    dev0->SetChannel(channel);
 
  470    dev1->SetChannel(channel);
 
  471    dev2->SetChannel(channel);
 
  480    dev0Mobility->SetPosition(Vector(0, 0, 0));
 
  481    dev0->GetPhy()->SetMobility(dev0Mobility);
 
  484    dev1Mobility->SetPosition(Vector(10, 0, 0));
 
  485    dev1->GetPhy()->SetMobility(dev1Mobility);
 
  488    dev2Mobility->SetPosition(Vector(5, 5, 0));
 
  489    dev2->GetPhy()->SetMobility(dev2Mobility);
 
  493    dev0->GetCsmaCa()->SetMacMinBE(0);
 
  494    dev1->GetCsmaCa()->SetMacMinBE(0);
 
  495    dev2->GetCsmaCa()->SetMacMinBE(0);
 
  498    dev0->GetMac()->SetMcpsDataIndicationCallback(
 
  501    dev1->GetMac()->SetMcpsDataIndicationCallback(
 
  504    dev2->GetMac()->SetMcpsDataIndicationCallback(
 
  514    params.m_dstPanId = 0;
 
  518    params.m_msduHandle = 0;
 
  584                          "Collision is meant to happen and no packets should be received");
 
 
Test the sensitivity of the CSMA/CA clear channel assestment (CCA)
void DoRun() override
Implementation to actually run this TestCase.
uint8_t countPackets
Count the number of packets received in the test.
~CCAVulnerableWindowTest() override
CCAVulnerableWindowTest()
void DataIndication(McpsDataIndicationParams params, Ptr< Packet > p)
Function called when a Data indication is invoked.
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 void ScheduleWithContext(uint32_t context, const Time &delay, FUNC f, Ts &&... args)
Schedule an event with the given context.
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.
Callback< R, Args... > MakeNullCallback()
#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.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Time Seconds(double value)
Construct a Time in the indicated unit.
static LrWpanCcaTestSuite g_lrWpanCcaTestSuite
Static variable for test initialization.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void LogComponentEnable(const std::string &name, LogLevel level)
Enable the logging output associated with that log component.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
LogLevel
Logging severity classes and levels.
@ LOG_PREFIX_FUNC
Prefix all trace prints with function.
@ LOG_PREFIX_TIME
Prefix all trace prints with simulation time.
@ LOG_LEVEL_DEBUG
LOG_DEBUG and above.
@ LOG_PREFIX_NODE
Prefix all trace prints with simulation node.
void LogComponentEnableAll(LogLevel level)
Enable the logging output for all registered log components.
MCPS-DATA.indication params.
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.