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

It tests the functionalities of LoRaWAN MAC commands received by devices. More...

+ Inheritance diagram for MacCommandTest:
+ Collaboration diagram for MacCommandTest:

Public Member Functions

 MacCommandTest ()
 Default constructor.
 
 ~MacCommandTest () 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 Reset ()
 This function resets the state of the MAC layer used for tests.
 
template<typename T , typename... Ts>
std::vector< Ptr< MacCommand > > RunMacCommand (Ts &&... args)
 Have this class' MAC layer receive a downlink packet carrying the input MAC command.
 

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...
 
- Static Public Attributes inherited from ns3::TestCase
static constexpr auto QUICK = Duration::QUICK
 Deprecated test duration simple enums.
 
static constexpr auto EXTENSIVE = Duration::EXTENSIVE
 
static constexpr auto TAKES_FOREVER = Duration::TAKES_FOREVER
 
- 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 functionalities of LoRaWAN MAC commands received by devices.

This means testing that (i) settings in the downlink MAC commands are correctly applied/rejected by the device, and that (ii) the correct answer (if expected) is produced by the device.

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

Constructor & Destructor Documentation

◆ MacCommandTest()

MacCommandTest::MacCommandTest ( )

Default constructor.

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

◆ ~MacCommandTest()

MacCommandTest::~MacCommandTest ( )
override

Destructor.

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

References m_mac.

Member Function Documentation

◆ DoRun()

void MacCommandTest::DoRun ( )
overrideprivatevirtual

Implementation to actually run this TestCase.

Subclasses should override this method to conduct their tests.

Implements ns3::TestCase.

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

References ns3::DynamicCast(), m_mac, NS_LOG_DEBUG, NS_TEST_ASSERT_MSG_EQ, NS_TEST_ASSERT_MSG_NE, NS_TEST_EXPECT_MSG_EQ, NS_TEST_EXPECT_MSG_NE, Reset(), and RunMacCommand().

+ Here is the call graph for this function:

◆ Reset()

void MacCommandTest::Reset ( )
private

This function resets the state of the MAC layer used for tests.

Use it before each call of RunMacCommand. Otherwise, on consecutive calls the MAC layer will not send due to duty-cycle limitations.

Todo
Create should not require a node in input.

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

References ns3::CreateObject(), 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:

◆ RunMacCommand()

template<typename T , typename... Ts>
std::vector< Ptr< MacCommand > > MacCommandTest::RunMacCommand ( Ts &&... args)
private

Have this class' MAC layer receive a downlink packet carrying the input MAC command.

After, trigger a new empty uplink packet send that can then be used to examine the MAC command answers in the header.

Template Parameters
T[explicit] The type of MAC command to create.
Ts[deduced] Types of the constructor arguments.
Parameters
[in]argsMAC command constructor arguments.
Returns
The list of MAC commands produced by the device as an answer.

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

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

Member Data Documentation

◆ m_mac

Ptr<ClassAEndDeviceLorawanMac> MacCommandTest::m_mac
private

The end device's MAC layer used in tests.

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

Referenced by ~MacCommandTest(), DoRun(), Reset(), and RunMacCommand().


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