19#include "ns3/rng-seed-manager.h"
20#include <ns3/callback.h>
21#include <ns3/constant-position-mobility-model.h>
23#include <ns3/lr-wpan-error-model.h>
24#include <ns3/lr-wpan-mac.h>
25#include <ns3/lr-wpan-net-device.h>
26#include <ns3/mac16-address.h>
27#include <ns3/net-device.h>
29#include <ns3/packet.h>
30#include <ns3/propagation-loss-model.h>
31#include <ns3/simulator.h>
32#include <ns3/single-model-spectrum-channel.h>
61 void DoRun()
override;
85 void DoRun()
override;
89 :
TestCase(
"Test the 802.15.4 error model vs distance"),
108 RngSeedManager::SetSeed(1);
109 RngSeedManager::SetRun(6);
124 channel->AddPropagationLossModel(model);
130 dev0->
GetPhy()->SetMobility(mob0);
132 dev1->
GetPhy()->SetMobility(mob1);
136 dev1->
GetMac()->SetMcpsDataIndicationCallback(cb0);
147 mob0->SetPosition(Vector(0, 0, 0));
148 mob1->SetPosition(Vector(100, 0, 0));
149 for (
int i = 0; i < 1000; i++)
151 p = Create<Packet>(20);
152 Simulator::Schedule(
Seconds(i), &LrWpanMac::McpsDataRequest, dev0->
GetMac(), params, p);
161 Simulator::Destroy();
166 :
TestCase(
"Test the 802.15.4 error model")
181 double ber = 1.0 - model->GetChunkSuccessRate(pow(10.0, snr / 10.0), 1);
184 ber = 1.0 - model->GetChunkSuccessRate(pow(10.0, snr / 10.0), 1);
187 ber = 1.0 - model->GetChunkSuccessRate(pow(10.0, snr / 10.0), 1);
190 ber = 1.0 - model->GetChunkSuccessRate(pow(10.0, snr / 10.0), 1);
193 ber = 1.0 - model->GetChunkSuccessRate(pow(10.0, snr / 10.0), 1);
LrWpan Error Vs Distance Test.
void Callback(McpsDataIndicationParams params, Ptr< Packet > p)
Function to be called when a packet is received.
uint32_t GetReceived() const
Get the number of received packets.
LrWpanErrorDistanceTestCase()
uint32_t m_received
The number of received packets.
void DoRun() override
Implementation to actually run this TestCase.
~LrWpanErrorDistanceTestCase() override
void DoRun() override
Implementation to actually run this TestCase.
~LrWpanErrorModelTestCase() override
LrWpanErrorModelTestCase()
LrWpan Error model TestSuite.
LrWpanErrorModelTestSuite()
void SetChannel(Ptr< SpectrumChannel > channel)
Set the channel to which the NetDevice, and therefore the PHY, should be attached to.
Ptr< LrWpanMac > GetMac() const
Get the MAC used by this NetDevice.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Ptr< LrWpanPhy > GetPhy() const
Get the PHY used by this NetDevice.
void SetAddress(Address address) override
This method indirects to LrWpanMac::SetShortAddress ()
This class can contain 16 bit addresses.
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
#define NS_TEST_ASSERT_MSG_EQ_TOL(actual, limit, tol, msg)
Test that actual and expected (limit) values are equal to plus or minus some tolerance and report and...
Time Seconds(double value)
Construct a Time in the indicated unit.
static LrWpanErrorModelTestSuite g_lrWpanErrorModelTestSuite
Static variable for test initialization.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
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...
MCPS-DATA.indication params.
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)