28#include "ns3/callback.h"
29#include "ns3/core-module.h"
31#include "ns3/network-server-helper.h"
32#include "ns3/network-server.h"
38using namespace lorawan;
68 void DoRun()
override;
75 :
TestCase(
"Verify that the NetworkServer application can receive"
76 " packets sent in the uplink by devices")
95 endDevice->GetDevice(0)->Send(Create<Packet>(20),
Address(), 0);
114 nsNode->GetApplication(0)->TraceConnectWithoutContext(
165 void DoRun()
override;
172 :
TestCase(
"Verify that devices requesting an acknowledgment receive"
173 " a reply from the network server.")
197 endDevice->GetDevice(0)
203 endDevice->GetDevice(0)->Send(Create<Packet>(20),
Address(), 0);
227 ->TraceConnectWithoutContext(
228 "RequiredTransmissions",
270 void DoRun()
override;
280 :
TestCase(
"Verify that the NetworkServer application correctly responds to "
281 "LinkCheck requests")
312 macLayer->AddMacCommand(Create<LinkCheckReq>());
314 endDevice->GetDevice(0)->Send(Create<Packet>(20),
Address(), 0);
338 ->TraceConnectWithoutContext(
"LastKnownGatewayCount",
It verifies that devices requesting an acknowledgment receive a reply from the network server.
DownlinkPacketTest()
Default constructor.
~DownlinkPacketTest() override
Destructor.
bool m_receivedPacketAtEd
Set to true if a packet is received by the end device.
void DoRun() override
Implementation to actually run this TestCase.
void ReceivedPacketAtEndDevice(uint8_t requiredTransmissions, bool success, Time time, Ptr< Packet > packet)
Record the exit status of a MAC layer packet retransmission process of an end device.
void SendPacket(Ptr< Node > endDevice, bool requestAck)
Send a packet from the input end device.
It verifies that the NetworkServer application correctly responds to LinkCheck requests.
void DoRun() override
Implementation to actually run this TestCase.
void SendPacket(Ptr< Node > endDevice, bool requestAck)
Send a packet containing a LinkCheckReq MAC command from the input end device.
LinkCheckTest()
Default constructor.
~LinkCheckTest() override
Destructor.
int m_numberOfGatewaysThatReceivedPacket
Stores the number of gateways that received the last packet carrying a LinkCheckReq MAC command.
bool m_receivedPacketAtEd
Set to true if a packet containing a LinkCheckAns MAC command is received by the end device.
void LastKnownGatewayCount(int newValue, int oldValue)
Trace changes in the last known gateway count variable (updated on reception of LinkCheckAns MAC comm...
The TestSuite class names the TestSuite, identifies what type of TestSuite, and enables the TestCases...
NetworkServerTestSuite()
Default constructor.
It verifies that the NetworkServer application can receive packets sent in uplink by devices.
UplinkPacketTest()
Default constructor.
void DoRun() override
Implementation to actually run this TestCase.
void ReceivedPacket(Ptr< const Packet > packet)
Callback for tracing ReceivedPacket.
~UplinkPacketTest() override
Destructor.
bool m_receivedPacket
Set to true if a packet is received by the server.
void SendPacket(Ptr< Node > endDevice)
Send a packet from the input end device.
a polymophic address class
keep track of a set of node pointers.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
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 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.
Simulation virtual time values and global simulation resolution.
Class representing the MAC layer of a LoRaWAN device.
Hold together all LoRa related objects.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Time Seconds(double value)
Construct a Time in the indicated unit.
NetworkComponents InitializeNetwork(int nDevices, int nGateways)
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...
@ LOG_LEVEL_ALL
Print everything.
@ 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.
static NetworkServerTestSuite lorawanTestSuite
Stores the main elements of a simulated LoRaWAN network.
Ptr< Node > nsNode
A pointer to the network server Node.
Ptr< LoraChannel > channel
A pointer to the LoraChannel object.
NodeContainer endDevices
Container of the end device nodes.
NodeContainer gateways
Container of the gateway nodes.