22 #include <ns3/callback.h> 23 #include <ns3/packet.h> 24 #include <ns3/simulator.h> 25 #include <ns3/lr-wpan-error-model.h> 26 #include <ns3/propagation-loss-model.h> 27 #include <ns3/lr-wpan-net-device.h> 28 #include <ns3/lr-wpan-mac.h> 30 #include <ns3/net-device.h> 31 #include <ns3/single-model-spectrum-channel.h> 32 #include <ns3/mac16-address.h> 33 #include <ns3/constant-position-mobility-model.h> 34 #include "ns3/rng-seed-manager.h" 62 virtual void DoRun (
void);
86 virtual void DoRun (
void);
90 :
TestCase (
"Test the 802.15.4 error model vs distance"),
109 RngSeedManager::SetSeed (1);
110 RngSeedManager::SetRun (6);
118 dev0->AssignStreams (0);
119 dev1->AssignStreams (10);
125 channel->AddPropagationLossModel (model);
129 n1->AddDevice (dev1);
131 dev0->GetPhy ()->SetMobility (mob0);
133 dev1->GetPhy ()->SetMobility (mob1);
137 dev1->GetMac ()->SetMcpsDataIndicationCallback (cb0);
150 for (
int i = 0; i < 1000; i++)
152 p = Create<Packet> (20);
153 Simulator::Schedule (
Seconds (i),
154 &LrWpanMac::McpsDataRequest,
155 dev0->GetMac (), params, p);
164 Simulator::Destroy ();
169 :
TestCase (
"Test the 802.15.4 error model")
214 :
TestSuite (
"lr-wpan-error-model", UNIT)
uint16_t m_dstPanId
Destination PAN identifier.
Mac16Address m_dstAddr
Destination address.
LrWpanErrorDistanceTestCase()
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
static LrWpanErrorModelTestSuite g_lrWpanErrorModelTestSuite
Static variable for test initialization.
virtual void DoRun(void)
Implementation to actually run this TestCase.
uint8_t m_msduHandle
MSDU handle.
LrWpan Error Vs Distance Test.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
#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.
virtual void DoRun(void)
Implementation to actually run this TestCase.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
uint8_t m_txOptions
Tx Options (bitfield)
#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...
LrWpanAddressMode m_srcAddrMode
Source address mode.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
LrWpanAddressMode m_dstAddrMode
Destination address mode.
LrWpanErrorModelTestCase()
LrWpan Error model TestSuite.
double GetChunkSuccessRate(double snr, uint32_t nbits) const
Return chunk success rate for given SNR.
This class can contain 16 bit addresses.
LrWpanErrorModelTestSuite()
void SetPosition(const Vector &position)
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
uint32_t m_received
The number of received packets.
uint32_t GetReceived(void) const
Get the number of received packets.
Time Seconds(double value)
Construct a Time in the indicated unit.
virtual ~LrWpanErrorModelTestCase()
MCPS-DATA.request params.
virtual ~LrWpanErrorDistanceTestCase()
MCPS-DATA.indication params.
void Callback(McpsDataIndicationParams params, Ptr< Packet > p)
Function to be called when a packet is received.