A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
RetransmissionTest Class Reference

It tests the correct execution of the retransmissions in LoRaWAN devices. More...

Inheritance diagram for RetransmissionTest:
Collaboration diagram for RetransmissionTest:

Public Member Functions

 RetransmissionTest ()
 Default constructor.
 ~RetransmissionTest () override
 Destructor.
Public Member Functions inherited from ns3::TestCase
 TestCase (const TestCase &)=delete
 Caller graph was not generated because of its size.
virtual ~TestCase ()
 Destructor.
std::string GetName () const
TestCaseoperator= (const TestCase &)=delete

Private Member Functions

void DoRun () override
 Implementation to actually run this TestCase.
void MacConfirmedTransmissionOutcome (uint8_t txCount, bool ack, Time firstAttempt, Ptr< Packet > packet)
 Callback for tracing the outcome of MAC layer's confirmed packet retransmission and acknowledgement.
void MacSentNewPacket (Ptr< const Packet > packet)
 Callback for tracing MAC layer SentNewPacket.
void PhyReceivedPacket (Ptr< const Packet > packet, uint32_t node)
 Callback for tracing PHY layer ReceivedPacket.
void PhyStartSending (Ptr< const Packet > packet, uint32_t node)
 Callback for tracing PHY layer StartSending.
void Reset ()
 This function resets the simulation and device MAC layer, use before test sub-cases.
void ScheduleRx1Downlink (Time after, bool ack=false)
 Create and schedule the PHY reception of a downlink transmission configured for the LoRaWAN MAC first reception window.
void SendUplink (LoraFrameHeader &fhdr)
 Create and send an empty app payload unconfirmed frame through the MAC layer NbTrans times.

Private Attributes

Ptr< ClassAEndDeviceLorawanMacm_mac
 The end device's MAC layer used in tests.
int m_macConfirmedTxOutcome = 0
 Counter for MacConfirmedTransmissionOutcome calls.
int m_macSentNewPacketCalls = 0
 Counter for MacSentNewPacket calls.
uint8_t m_numTransmissions = 0
 Number of confirmed packet transmissions.
Ptr< Packetm_packet
 Target packet for tracing.
int m_phyReceivedPacketCalls = 0
 Counter for PhyReceivedPacket calls.
int m_phyStartSendingCalls = 0
 Counter for PhyStartSending calls.
bool m_successfullyAcked = false
 Acknowledgement of confirmed packet.

Additional Inherited Members

Public Types inherited from ns3::TestCase
enum class  Duration { QUICK = 1 , EXTENSIVE = 2 , TAKES_FOREVER = 3 }
 How long the test takes to execute. More...
Protected Member Functions inherited from ns3::TestCase
 TestCase (std::string name)
 Constructor.
void AddTestCase (TestCase *testCase, Duration duration=Duration::QUICK)
 Add an individual child TestCase to this test suite.
TestCaseGetParent () const
 Get the parent of this TestCase.
bool IsStatusFailure () const
 Check if any tests failed.
bool IsStatusSuccess () const
 Check if all tests passed.
void SetDataDir (std::string directory)
 Set the data directory where reference trace files can be found.
void ReportTestFailure (std::string cond, std::string actual, std::string limit, std::string message, std::string file, int32_t line)
 Log the failure of this TestCase.
bool MustAssertOnFailure () const
 Check if this run should assert on failure.
bool MustContinueOnFailure () const
 Check if this run should continue on failure.
std::string CreateDataDirFilename (std::string filename)
 Construct the full path to a file in the data directory.
std::string CreateTempDirFilename (std::string filename)
 Construct the full path to a file in a temporary directory.

Detailed Description

It tests the correct execution of the retransmissions in LoRaWAN devices.

(See, LoRaWAN L2 1.0.4 Specifications (2020), Section 4.3.1.3)

Definition at line 2645 of file lorawan-test-suite.cc.

Constructor & Destructor Documentation

◆ RetransmissionTest()

RetransmissionTest::RetransmissionTest ( )

Default constructor.

Definition at line 2733 of file lorawan-test-suite.cc.

References ns3::TestCase::TestCase().

Here is the call graph for this function:

◆ ~RetransmissionTest()

RetransmissionTest::~RetransmissionTest ( )
override

Destructor.

Definition at line 2738 of file lorawan-test-suite.cc.

References m_mac.

Member Function Documentation

◆ DoRun()

void RetransmissionTest::DoRun ( )
overrideprivatevirtual

Implementation to actually run this TestCase.

Subclasses should override this method to conduct their tests.

Implements ns3::TestCase.

Definition at line 2856 of file lorawan-test-suite.cc.

References ns3::lorawan::LorawanMacHeader::CONFIRMED_DATA_UP, ns3::Create(), ns3::lorawan::LoraFrameHeader::GetFCnt(), m_mac, m_macConfirmedTxOutcome, m_macSentNewPacketCalls, m_numTransmissions, m_phyReceivedPacketCalls, m_phyStartSendingCalls, m_successfullyAcked, ns3::MilliSeconds(), NS_LOG_DEBUG, NS_TEST_ASSERT_MSG_EQ, NS_TEST_EXPECT_MSG_EQ, Reset(), ns3::Simulator::Schedule(), ScheduleRx1Downlink(), ns3::Seconds(), ns3::lorawan::EndDeviceLorawanMac::Send(), SendUplink(), and ns3::lorawan::LorawanMacHeader::UNCONFIRMED_DATA_UP.

Here is the call graph for this function:

◆ MacConfirmedTransmissionOutcome()

void RetransmissionTest::MacConfirmedTransmissionOutcome ( uint8_t txCount,
bool ack,
Time firstAttempt,
Ptr< Packet > packet )
private

Callback for tracing the outcome of MAC layer's confirmed packet retransmission and acknowledgement.

Note
This callback only traces confirmed packets, unused otherwise.
Parameters
txCountNumber of transmissions attempted during the process.
ackWhether the retransmission process led to acknowledgement.
firstAttemptTimestamp of the initial transmission attempt.
PacketThe packet being retransmitted.

Definition at line 2797 of file lorawan-test-suite.cc.

References m_macConfirmedTxOutcome, m_numTransmissions, m_packet, and m_successfullyAcked.

Referenced by Reset().

Here is the caller graph for this function:

◆ MacSentNewPacket()

void RetransmissionTest::MacSentNewPacket ( Ptr< const Packet > packet)
private

Callback for tracing MAC layer SentNewPacket.

Parameters
PacketThe packet sent.

Definition at line 2791 of file lorawan-test-suite.cc.

References m_macSentNewPacketCalls.

Referenced by Reset().

Here is the caller graph for this function:

◆ PhyReceivedPacket()

void RetransmissionTest::PhyReceivedPacket ( Ptr< const Packet > packet,
uint32_t node )
private

Callback for tracing PHY layer ReceivedPacket.

Parameters
PacketThe packet being received.
nodeThe sender node id if any, 0 otherwise.

Definition at line 2817 of file lorawan-test-suite.cc.

References m_phyReceivedPacketCalls.

Referenced by Reset().

Here is the caller graph for this function:

◆ PhyStartSending()

void RetransmissionTest::PhyStartSending ( Ptr< const Packet > packet,
uint32_t node )
private

Callback for tracing PHY layer StartSending.

Parameters
PacketThe packet being sent.
nodeThe sender node id if any, 0 otherwise.

Definition at line 2811 of file lorawan-test-suite.cc.

References m_phyStartSendingCalls.

Referenced by Reset().

Here is the caller graph for this function:

◆ Reset()

void RetransmissionTest::Reset ( )
private

This function resets the simulation and device MAC layer, use before test sub-cases.

Definition at line 2823 of file lorawan-test-suite.cc.

References ns3::CreateObject(), ns3::Simulator::Destroy(), ns3::DynamicCast(), ns3::lorawan::LorawanMacHelper::ED_A, ns3::lorawan::LorawanMacHelper::EU, ns3::lorawan::LorawanMacHelper::Install(), m_mac, m_macConfirmedTxOutcome, m_macSentNewPacketCalls, m_numTransmissions, m_phyReceivedPacketCalls, m_phyStartSendingCalls, m_successfullyAcked, MacConfirmedTransmissionOutcome(), MacSentNewPacket(), ns3::MakeCallback(), NS_TEST_EXPECT_MSG_NE, PhyReceivedPacket(), PhyStartSending(), ns3::lorawan::LorawanMacHelper::SetDeviceType(), and ns3::lorawan::LorawanMacHelper::SetRegion().

Referenced by DoRun().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ScheduleRx1Downlink()

void RetransmissionTest::ScheduleRx1Downlink ( Time after,
bool ack = false )
private

Create and schedule the PHY reception of a downlink transmission configured for the LoRaWAN MAC first reception window.

This is used to test stopping the retransmission process.

Note
This does not call Simulator::Run(), enabling preemptive scheduling, but must be manually timed to happen during the first reception window

It constrains the device to a single uplink channel to force-out the first reception window frequency. The downlink spreading factor is taken from the current MAC configuration.

Parameters
afterDelay to schedule the packet after (must target the first reception window)
ackWhether to set the ACK flag in the frame header

Definition at line 2761 of file lorawan-test-suite.cc.

References ns3::Create(), ns3::lorawan::DOWN, ns3::DynamicCast(), m_mac, ns3::MilliSeconds(), ns3::Simulator::Schedule(), ns3::lorawan::LoraFrameHeader::SetAck(), ns3::lorawan::LoraFrameHeader::SetAsDownlink(), ns3::lorawan::LorawanMacHeader::SetFType(), ns3::lorawan::SimpleEndDeviceLoraPhy::StartReceive(), and ns3::lorawan::LorawanMacHeader::UNCONFIRMED_DATA_DOWN.

Referenced by DoRun().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SendUplink()

void RetransmissionTest::SendUplink ( LoraFrameHeader & fhdr)
private

Create and send an empty app payload unconfirmed frame through the MAC layer NbTrans times.

The sent packet FHDR is returned as argument for validation purposes.

Parameters
fhdr[out] FHDR of the constructed frame passed to PHY by the MAC

Definition at line 2744 of file lorawan-test-suite.cc.

References ns3::Create(), m_mac, m_packet, NS_LOG_LOGIC, ns3::Simulator::Run(), ns3::Simulator::ScheduleNow(), ns3::lorawan::EndDeviceLorawanMac::Send(), and ns3::lorawan::LoraFrameHeader::SetAsUplink().

Referenced by DoRun().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_mac

Ptr<ClassAEndDeviceLorawanMac> RetransmissionTest::m_mac
private

The end device's MAC layer used in tests.

Definition at line 2721 of file lorawan-test-suite.cc.

Referenced by ~RetransmissionTest(), DoRun(), Reset(), ScheduleRx1Downlink(), and SendUplink().

◆ m_macConfirmedTxOutcome

int RetransmissionTest::m_macConfirmedTxOutcome = 0
private

Counter for MacConfirmedTransmissionOutcome calls.

Definition at line 2725 of file lorawan-test-suite.cc.

Referenced by DoRun(), MacConfirmedTransmissionOutcome(), and Reset().

◆ m_macSentNewPacketCalls

int RetransmissionTest::m_macSentNewPacketCalls = 0
private

Counter for MacSentNewPacket calls.

Definition at line 2724 of file lorawan-test-suite.cc.

Referenced by DoRun(), MacSentNewPacket(), and Reset().

◆ m_numTransmissions

uint8_t RetransmissionTest::m_numTransmissions = 0
private

Number of confirmed packet transmissions.

Definition at line 2729 of file lorawan-test-suite.cc.

Referenced by DoRun(), MacConfirmedTransmissionOutcome(), and Reset().

◆ m_packet

Ptr<Packet> RetransmissionTest::m_packet
private

Target packet for tracing.

Definition at line 2722 of file lorawan-test-suite.cc.

Referenced by MacConfirmedTransmissionOutcome(), and SendUplink().

◆ m_phyReceivedPacketCalls

int RetransmissionTest::m_phyReceivedPacketCalls = 0
private

Counter for PhyReceivedPacket calls.

Definition at line 2727 of file lorawan-test-suite.cc.

Referenced by DoRun(), PhyReceivedPacket(), and Reset().

◆ m_phyStartSendingCalls

int RetransmissionTest::m_phyStartSendingCalls = 0
private

Counter for PhyStartSending calls.

Definition at line 2726 of file lorawan-test-suite.cc.

Referenced by DoRun(), PhyStartSending(), and Reset().

◆ m_successfullyAcked

bool RetransmissionTest::m_successfullyAcked = false
private

Acknowledgement of confirmed packet.

Definition at line 2730 of file lorawan-test-suite.cc.

Referenced by DoRun(), MacConfirmedTransmissionOutcome(), and Reset().


The documentation for this class was generated from the following file: