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

It tests the correct execution of the ADR backoff procedure of LoRaWAN devices. More...

Inheritance diagram for AdrBackoffTest:
Collaboration diagram for AdrBackoffTest:

Public Member Functions

 AdrBackoffTest ()
 Default constructor.
 ~AdrBackoffTest () override
 Destructor.
Public Member Functions inherited from ns3::TestCase
 TestCase (const TestCase &)=delete
virtual ~TestCase ()
 Destructor.
std::string GetName () const
TestCaseoperator= (const TestCase &)=delete

Private Member Functions

void DoRun () override
 Implementation to actually run this TestCase.
void ReceiveDownlink ()
 Create and receive an empty payload downlink destined for the LoRaWAN MAC.
void Reset ()
 This function resets the simulation and device MAC layer, use before test sub-cases.
void SendUplink (Time after, LoraFrameHeader &fhdr)
 Create and send an empty app payload unconfirmed frame through the MAC layer to increment of the FCnt and ADRACKCnt and eventually activate the ADR backoff procedure configurations of the MAC layer.

Private Attributes

Ptr< ClassAEndDeviceLorawanMacm_mac
 The end device's MAC layer used in tests.

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 ADR backoff procedure of LoRaWAN devices.

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

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

Constructor & Destructor Documentation

◆ AdrBackoffTest()

AdrBackoffTest::AdrBackoffTest ( )

Default constructor.

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

References ns3::TestCase::TestCase().

Here is the call graph for this function:

◆ ~AdrBackoffTest()

AdrBackoffTest::~AdrBackoffTest ( )
override

Destructor.

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

References m_mac.

Member Function Documentation

◆ DoRun()

void AdrBackoffTest::DoRun ( )
overrideprivatevirtual

Implementation to actually run this TestCase.

Subclasses should override this method to conduct their tests.

Implements ns3::TestCase.

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

References ns3::lorawan::EndDeviceLorawanMac::ADR_ACK_DELAY, ns3::lorawan::EndDeviceLorawanMac::ADR_ACK_LIMIT, ns3::Create(), ns3::lorawan::LoraFrameHeader::GetAdrAckReq(), ns3::lorawan::LoraFrameHeader::GetFCnt(), m_mac, ns3::Minutes(), NS_LOG_DEBUG, NS_TEST_EXPECT_MSG_EQ, ReceiveDownlink(), Reset(), and SendUplink().

Here is the call graph for this function:

◆ ReceiveDownlink()

void AdrBackoffTest::ReceiveDownlink ( )
private

Create and receive an empty payload downlink destined for the LoRaWAN MAC.

This is used to test resetting the ADR backoff procedure.

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

References ns3::Create(), ns3::DynamicCast(), m_mac, ns3::lorawan::LoraFrameHeader::SetAsDownlink(), ns3::lorawan::LorawanMacHeader::SetMType(), 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:

◆ Reset()

void AdrBackoffTest::Reset ( )
private

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

Todo
Install should not require a node in input.

Definition at line 2126 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, NS_TEST_EXPECT_MSG_NE, 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:

◆ SendUplink()

void AdrBackoffTest::SendUplink ( Time after,
LoraFrameHeader & fhdr )
private

Create and send an empty app payload unconfirmed frame through the MAC layer to increment of the FCnt and ADRACKCnt and eventually activate the ADR backoff procedure configurations of the MAC layer.

The packet is sent after a delay (simulated time is fast-forwarded to the event) such that the device does not incur any duty-cycle limitation. The sent packet FHDR is returned as argument for validation purposes.

Parameters
afterDelay to schedule the packet after to avoid duty-cycle limitations
fhdr[out] FHDR of the constructed frame passed to PHY by the MAC

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

References ns3::Create(), m_mac, NS_LOG_LOGIC, ns3::Simulator::Run(), ns3::Simulator::Schedule(), 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> AdrBackoffTest::m_mac
private

The end device's MAC layer used in tests.

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

Referenced by ~AdrBackoffTest(), DoRun(), ReceiveDownlink(), Reset(), and SendUplink().


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