11#include "ns3/lr-wpan-mac.h"
12#include "ns3/lr-wpan-phy.h"
13#include "ns3/packet.h"
14#include "ns3/simulator.h"
15#include "ns3/single-model-spectrum-channel.h"
35 void DoRun()
override;
65 void DoRun()
override;
84 :
TestCase(
"PLME and PD SAP IEEE 802.15.4 interfaces test")
99 <<
" LQI: " <<
static_cast<uint16_t
>(lqi)
100 <<
" RSSI: " <<
static_cast<int16_t
>(rssi) <<
" dBm.");
120 sender->SetChannel(channel);
121 receiver->SetChannel(channel);
122 channel->AddRx(receiver);
126 receiver->SetPdDataIndicationCallback(
137 "Error,the number of expected received packets should be more than 0");
142 :
TestCase(
"Collision of two IEEE 802.15.4 frames test")
157 <<
" LQI: " <<
static_cast<uint16_t
>(lqi)
158 <<
" RSSI: " <<
static_cast<int16_t
>(rssi) <<
" dBm.");
192 sender->SetChannel(channel);
193 sender2->SetChannel(channel);
194 receiver->SetChannel(channel);
195 channel->AddRx(receiver);
202 receiver->SetPdDataIndicationCallback(
206 receiver->TraceConnectWithoutContext(
220 "Error,the receiver should only be able to receive the first packet");
224 "Error, one packet should be dropped due to collision");
Test the collision of two packets and the reaction ( packet drop ) of this collision in the packet pr...
void PacketCollisionDrop(Ptr< const Packet > p)
Callback for packet drop due to collision.
~LrWpanPhyCollisionTestCase() override
LrWpanPhyCollisionTestCase()
void ReceivePdDataIndication(uint32_t psduLength, Ptr< Packet > p, uint8_t lqi, int8_t rssi)
Receives a PdData indication.
void DoRun() override
Implementation to actually run this TestCase.
uint16_t m_receivedPackets
Counts the number of received packets.
int8_t m_receivedRssi
Saves the value of the received packet RSSI.
uint16_t m_packetDroppedByCollision
Counts the number of packets dropped due to collision.
LrWpanPlmeAndPdInterfaceTestCase()
~LrWpanPlmeAndPdInterfaceTestCase() override
void ReceivePdDataIndication(uint32_t psduLength, Ptr< Packet > p, uint8_t lqi, int8_t rssi)
Receives a PdData indication.
void DoRun() override
Implementation to actually run this TestCase.
uint16_t m_receivedPackets
Counts the number of received packets.
LrWpan PLME and PD Interfaces TestSuite.
LrWpanPlmeAndPdInterfaceTestSuite()
Smart pointer class similar to boost::intrusive_ptr.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static Time Now()
Return the current simulation virtual time.
static void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
TestCase(const TestCase &)=delete
Caller graph was not generated because of its size.
TestSuite(std::string name, Type type=Type::UNIT)
Construct a new test suite.
void PdDataRequest(const uint32_t psduLength, Ptr< Packet > p)
IEEE 802.15.4-2006 section 6.2.1.1 PD-DATA.request Request to transfer MPDU from MAC (transmitting).
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...
#define NS_LOG_UNCOND(msg)
Output the requested message unconditionally.
@ IEEE_802_15_4_PHY_RX_ON
@ IEEE_802_15_4_PHY_TX_ON
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_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_GT(actual, limit, msg)
Test that an actual value is greater than a limit and report and abort if not.
Time Seconds(double value)
Construct a Time in the indicated unit.
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.
LogLevel
Logging severity classes and levels.
@ LOG_LEVEL_ALL
Print everything.
@ LOG_PREFIX_FUNC
Prefix all trace prints with function.
@ LOG_PREFIX_TIME
Prefix all trace prints with simulation time.
void LogComponentEnableAll(LogLevel level)
Enable the logging output for all registered log components.
static LrWpanPlmeAndPdInterfaceTestSuite g_lrWpanPlmeAndPdInterfaceTestSuite
Static variable for test initialization.