lr-wpan: fix doxygen warnings and tweak tests

This commit is contained in:
Tommaso Pecorella
2021-05-01 21:47:26 +02:00
parent fa68baa2f0
commit a676a1ca39
11 changed files with 159 additions and 68 deletions

View File

@@ -39,16 +39,32 @@
using namespace ns3;
/**
* Function called when a Data indication is invoked
* \param params MCPS data indication parameters
* \param p packet
*/
static void DataIndication (McpsDataIndicationParams params, Ptr<Packet> p)
{
NS_LOG_UNCOND ("Received packet of size " << p->GetSize ());
}
/**
* Function called when a Data confirm is invoked
* \param params MCPS data confirm parameters
*/
static void DataConfirm (McpsDataConfirmParams params)
{
NS_LOG_UNCOND ("LrWpanMcpsDataConfirmStatus = " << params.m_status);
}
/**
* Function called when a the PHY state changes
* \param context context
* \param now time at which the function is called
* \param oldState old PHY state
* \param newState new PHY state
*/
static void StateChangeNotification (std::string context, Time now, LrWpanPhyEnumeration oldState, LrWpanPhyEnumeration newState)
{
NS_LOG_UNCOND (context << " state change at " << now.As (Time::S)

View File

@@ -54,10 +54,15 @@
using namespace ns3;
using namespace std;
static uint32_t g_received = 0;
static uint32_t g_received = 0; //!< number of packets received
NS_LOG_COMPONENT_DEFINE ("LrWpanErrorDistancePlot");
/**
* Function called when a Data indication is invoked
* \param params MCPS data indication parameters
* \param p packet
*/
static void
LrWpanErrorDistanceCallback (McpsDataIndicationParams params, Ptr<Packet> p)
{

View File

@@ -29,12 +29,23 @@
using namespace ns3;
void GetSetTRXStateConfirm (LrWpanPhyEnumeration status)
/**
* Function called when a the PHY state change is confirmed
* \param status PHY state
*/
void
GetSetTRXStateConfirm (LrWpanPhyEnumeration status)
{
NS_LOG_UNCOND ("At: " << Simulator::Now ()
<< " Received Set TRX Confirm: " << status);
}
/**
* Function called when a the PHY receives a packet
* \param psduLength PSDU length
* \param p packet
* \param lqi link quality indication
*/
void
ReceivePdDataIndication (uint32_t psduLength,
Ptr<Packet> p,
@@ -45,7 +56,13 @@ ReceivePdDataIndication (uint32_t psduLength,
(uint16_t) lqi);
}
void SendOnePacket (Ptr<LrWpanPhy> sender, Ptr<LrWpanPhy> receiver)
/**
* Send one packet
* \param sender sender PHY
* \param receiver receiver PHY
*/
void
SendOnePacket (Ptr<LrWpanPhy> sender, Ptr<LrWpanPhy> receiver)
{
uint32_t n = 10;
Ptr<Packet> p = Create<Packet> (n);

View File

@@ -116,7 +116,7 @@ public:
* \brief Associate the nodes to the same PAN and initiate beacon enabled mode.
*
* \param c a set of nodes
* \param panID the PAN id
* \param panId the PAN id
* \param coor the address of the PAN coordinator
* \param bcnOrd indicates the interval between beacons.
* The value must be an int between 0 and 14.

View File

@@ -179,14 +179,6 @@ SuperframeField::Deserialize (Buffer::Iterator i)
return i;
}
/**
* output stream output operator
*
* \param os output stream
* \param superframeField The Superframe Specification Field
*
* \returns output stream
*/
std::ostream &
operator << (std::ostream &os, const SuperframeField &superframeField)
{
@@ -312,6 +304,13 @@ GtsFields::Deserialize (Buffer::Iterator i)
return i;
}
std::ostream &
operator << (std::ostream &os, const GtsFields &gtsFields)
{
os << " GTS specification = " << uint32_t (gtsFields.GetGtsSpecField ())
<< ", GTS direction = " << uint32_t (gtsFields.GetGtsDirectionField ());
return os;
}
/***********************************************************
* Pending Address Fields
@@ -472,14 +471,6 @@ PendingAddrFields::Deserialize (Buffer::Iterator i)
return i;
}
/**
* output stream output operator
*
* \param os output stream
* \param PendingAddrField the Pending Address Specification Field
*
* \returns output stream
*/
std::ostream &
operator << (std::ostream &os, const PendingAddrFields &pendingAddrFields)
{

View File

@@ -37,6 +37,7 @@
namespace ns3 {
/**
* \ingroup lr-wpan
* The device Capabilities.
*/
enum DeviceType
@@ -92,26 +93,32 @@ public:
void SetAssocPermit (bool assocPermit);
/**
* Get the Superframe Specification Beacon Order field.
* \return the Superframe Specification Beacon Order field.
*/
uint8_t GetBeaconOrder (void) const;
/**
* Get the Superframe Specification Frame Order field.
* \return The Superframe Specification Frame Order field.
*/
uint8_t GetFrameOrder (void) const;
/**
* Check if the Final CAP Slot bit is enabled.
* Get the the Final CAP Slot.
* \returns The Final CAP Slot
*/
uint8_t GetFinalCapSlot (void) const;
/**
* Check if the Battery Life Extension bit is enabled.
* \returns true if the Battery Life Extension bit is enabled
*/
bool IsBattLifeExt (void) const;
/**
* Check if the PAN Coordinator bit is enabled.
* \returns true if the PAN Coordinator bit is enabled
*/
bool IsPanCoor (void) const;
/**
* Check if the Association Permit bit is enabled.
* \returns true if the Association Permit bit is enabled
*/
bool IsAssocPermit (void) const;
/**
@@ -150,6 +157,14 @@ private:
bool m_sspecAssocPermit; //!< Superframe Specification field Association Permit (Bit 15)
};
/**
* \brief Stream insertion operator.
*
* \param [in] os The reference to the output stream.
* \param [in] superframeField The Superframe fields.
* \returns The reference to the output stream.
*/
std::ostream &operator << (std::ostream &os, const SuperframeField &superframeField);
/**
@@ -174,12 +189,12 @@ public:
uint8_t GetGtsDirectionField (void) const;
/**
* Set the GTS Specification Field to the GTS Fields
* gtsSpec The GTS Specification Field to set.
* \param gtsSpec The GTS Specification Field to set.
*/
void SetGtsSpecField (uint8_t gtsSpec);
/**
* Set the GTS direction field to the GTS Fields
* gtsDir The GTS Direction Field to set
* \param gtsDir The GTS Direction Field to set
*/
void SetGtsDirectionField (uint8_t gtsDir);
/**
@@ -201,7 +216,9 @@ public:
Buffer::Iterator Deserialize (Buffer::Iterator i);
private:
//GTS Descriptor
/**
* GTS Descriptor
*/
struct gtsDescriptor
{
Mac16Address m_gtsDescDevShortAddr; //!< GTS Descriptor Device Short Address (Bit 0-15)
@@ -211,14 +228,23 @@ private:
//GTS specification field
uint8_t m_gtsSpecDescCount; //!< GTS specification field Descriptor Count (Bit 0-2)
//!< GTS specification field Reserved (Not necessary) (Bit 3-6)
// GTS specification field Reserved (Not necessary) (Bit 3-6)
uint8_t m_gtsSpecPermit; //!< GTS specification field GTS Permit (Bit 7)
//GTS Direction field
uint8_t m_gtsDirMask; //!< GTS Direction field Directions Mask (Bit 0-6)
//!< GTS Direction field Reserved (Not Necessary) (Bit 7)
// GTS Direction field Reserved (Not Necessary) (Bit 7)
//GTS List
gtsDescriptor m_gtsList[6]; //!< GTS List field (maximum descriptors stored == 7)
gtsDescriptor m_gtsList[7]; //!< GTS List field (maximum descriptors stored == 7)
};
/**
* \brief Stream insertion operator.
*
* \param [in] os The reference to the output stream.
* \param [in] gtsFields The GTS fields.
* \returns The reference to the output stream.
*/
std::ostream &operator << (std::ostream &os, const GtsFields &gtsFields);
@@ -290,7 +316,7 @@ public:
Buffer::Iterator Serialize (Buffer::Iterator i) const;
/**
* Deserialize the all the Pending Address Fields.
* \param start an iterator which points to where the Pending Address Fields should be read.
* \param i an iterator which points to where the Pending Address Fields should be read.
* \return an iterator.
*/
Buffer::Iterator Deserialize (Buffer::Iterator i);
@@ -306,6 +332,14 @@ private:
std::array<Mac64Address,7> m_extAddrList; //!< Pending Extended Address List
};
/**
* \brief Stream insertion operator.
*
* \param [in] os The reference to the output stream.
* \param [in] pendingAddrFields The Pending Address fields.
* \returns The reference to the output stream.
*/
std::ostream &operator << (std::ostream &os, const PendingAddrFields &pendingAddrFields);

View File

@@ -76,7 +76,7 @@ public:
* \return The GTS fields.
*/
GtsFields GetGtsFields (void) const;
/***
/**
* Get the pending address fields from the beacon payload header.
* \return The Pending Address fields.
*/
@@ -146,10 +146,12 @@ public:
/**
* Set the command frame type
* \param macCmd the command frame type
*/
void SetCommandFrameType (MacCommand macCmd);
void SetCommandFrameType (MacCommand macCmd);
/**
* Get the command frame type
* \return the command frame type
*/
MacCommand GetCommandFrameType (void) const;

View File

@@ -1058,6 +1058,8 @@ private:
* After a successful transmission of a frame (beacon, data) or an ack frame reception,
* the mac layer wait an Interframe Space (IFS) time and triggers this function
* to continue with the MAC flow.
*
* \param ifsTime IFS time
*/
void IfsWaitTimeout (Time ifsTime);
/**
@@ -1076,17 +1078,23 @@ private:
/**
* Constructs a Superframe specification field from the local information,
* the superframe Specification field is necessary to create a beacon frame.
*
* \returns the Superframe specification field
*/
SuperframeField GetSuperframeField (void);
/**
* Constructs the Guaranteed Time Slots (GTS) Fields from local information
* Constructs the Guaranteed Time Slots (GTS) Fields from local information.
* The GTS Fields are part of the beacon frame.
*
* \returns the Guaranteed Time Slots (GTS) Fields
*/
GtsFields GetGtsFields (void);
/**
* Constructs Pending Address Fields from the local information,
* the Pending Address Fields are part of the beacon frame.
*/
* Constructs Pending Address Fields from the local information,
* the Pending Address Fields are part of the beacon frame.
*
* \returns the Pending Address Fields
*/
PendingAddrFields GetPendingAddrFields (void);
/**

View File

@@ -215,7 +215,7 @@ private:
* As a consequence, here we set it to 1.
*
* \param panId The PanID
* \param shortMac The Short MAC address
* \param shortAddr The Short MAC address
* \return a Pseudo-Mac48Adress
*/
Mac48Address BuildPseudoMacAddress (uint16_t panId, Mac16Address shortAddr) const;

View File

@@ -56,12 +56,15 @@ class LrWpanAckTestCase : public TestCase
{
public:
/**
* Test modes
*/
typedef enum
{
EXTENDED_ADDRESS_UNICAST,
SHORT_ADDRESS_UNICAST,
SHORT_ADDRESS_MULTICAST,
SHORT_ADDRESS_BROADCAST,
EXTENDED_ADDRESS_UNICAST, //!< extended addresses
SHORT_ADDRESS_UNICAST, //!< short addresses, unicast
SHORT_ADDRESS_MULTICAST, //!< short addresses, multicast
SHORT_ADDRESS_BROADCAST, //!< short addresses, broadcast
} TestMode_e;
/**
@@ -74,27 +77,23 @@ public:
/**
* \brief Function called when DataIndication is hit on dev0.
* \param testCase The TestCase.
* \param params The MCPS params.
* \param p the packet.
*/
void DataIndicationDev0 (McpsDataIndicationParams params, Ptr<Packet> p);
/**
* \brief Function called when DataIndication is hit on dev1.
* \param testCase The TestCase.
* \param params The MCPS params.
* \param p the packet.
*/
void DataIndicationDev1 (McpsDataIndicationParams params, Ptr<Packet> p);
/**
* \brief Function called when DataConfirm is hit on dev0.
* \param testCase The TestCase.
* \param params The MCPS params.
*/
void DataConfirmDev0 (McpsDataConfirmParams params);
/**
* \brief Function called when DataConfirm is hit on dev1.
* \param testCase The TestCase.
* \param params The MCPS params.
*/
void DataConfirmDev1 (McpsDataConfirmParams params);

View File

@@ -51,26 +51,52 @@ public:
virtual ~LrWpanDataIfsTestCase ();
private:
/**
* \brief Function called when DataConfirm is hit.
* \param testcase pointer to the testcase
* \param dev originating NetDevice
* \param params the MCPS params
*/
static void DataConfirm (LrWpanDataIfsTestCase *testcase,
Ptr<LrWpanNetDevice> dev,
McpsDataConfirmParams params);
static void DataConfirm1 (LrWpanDataIfsTestCase *testcase,
Ptr<LrWpanNetDevice> dev,
McpsDataConfirmParams params);
static void DataReceived (LrWpanDataIfsTestCase *testcase,
Ptr<LrWpanNetDevice> dev,
Ptr<const Packet>);
/**
* \brief Function called when DataReceived is hit.
* \param testcase pointer to the testcase
* \param dev originating NetDevice
* \param p packet
*/
static void DataReceivedDev0 (LrWpanDataIfsTestCase *testcase,
Ptr<LrWpanNetDevice> dev,
Ptr<const Packet> p);
/**
* \brief Function called when PhyDataRxStart is hit.
* \param testcase pointer to the testcase
* \param dev originating NetDevice
* \param p packet
*/
static void PhyDataRxStart (LrWpanDataIfsTestCase *testcase,
Ptr<LrWpanNetDevice> dev,
Ptr<const Packet>);
Ptr<const Packet> p);
static void DataReceived2 (LrWpanDataIfsTestCase *testcase,
Ptr<LrWpanNetDevice> dev,
Ptr<const Packet>);
/**
* \brief Function called when DataConfirm is hit.
* \param testcase pointer to the testcase
* \param dev originating NetDevice
* \param p packet
*/
static void DataReceivedDev1 (LrWpanDataIfsTestCase *testcase,
Ptr<LrWpanNetDevice> dev,
Ptr<const Packet>);
/**
* \brief Function called when the IFS ends.
* \param testcase pointer to the testcase
* \param dev originating NetDevice
* \param IfsTime the IFS time
*/
static void IfsEnd (LrWpanDataIfsTestCase *testcase,
Ptr<LrWpanNetDevice> dev,
Time IfsTime);
@@ -97,19 +123,12 @@ LrWpanDataIfsTestCase::~LrWpanDataIfsTestCase ()
void
LrWpanDataIfsTestCase::DataConfirm (LrWpanDataIfsTestCase *testcase, Ptr<LrWpanNetDevice> dev, McpsDataConfirmParams params)
{
// get the end time of tranmissions from dev 0 (Node 0)
// get the end time of transmission
testcase->m_lastTxTime = Simulator::Now ();
}
void
LrWpanDataIfsTestCase::DataConfirm1 (LrWpanDataIfsTestCase *testcase, Ptr<LrWpanNetDevice> dev, McpsDataConfirmParams params)
{
// get the end time of tranmissions from dev 1 (Node 1)
testcase->m_lastTxTime = Simulator::Now ();
}
void
LrWpanDataIfsTestCase::DataReceived (LrWpanDataIfsTestCase *testcase,Ptr<LrWpanNetDevice> dev, Ptr<const Packet> p)
LrWpanDataIfsTestCase::DataReceivedDev0 (LrWpanDataIfsTestCase *testcase, Ptr<LrWpanNetDevice> dev, Ptr<const Packet> p)
{
// Callback for Data received in the Dev0
Ptr<Packet> RxPacket = p->Copy ();
@@ -136,7 +155,7 @@ LrWpanDataIfsTestCase::PhyDataRxStart (LrWpanDataIfsTestCase *testcase, Ptr<LrWp
}
void
LrWpanDataIfsTestCase::DataReceived2 (LrWpanDataIfsTestCase *testcase,Ptr<LrWpanNetDevice> dev, Ptr<const Packet> p)
LrWpanDataIfsTestCase::DataReceivedDev1 (LrWpanDataIfsTestCase *testcase, Ptr<LrWpanNetDevice> dev, Ptr<const Packet> p)
{
// Callback for Data received in the Dev1
Ptr<Packet> RxPacket = p->Copy ();
@@ -165,7 +184,7 @@ LrWpanDataIfsTestCase::DataReceived2 (LrWpanDataIfsTestCase *testcase,Ptr<LrWpan
void
LrWpanDataIfsTestCase::IfsEnd (LrWpanDataIfsTestCase *testcase,Ptr<LrWpanNetDevice> dev, Time IfsTime)
LrWpanDataIfsTestCase::IfsEnd (LrWpanDataIfsTestCase *testcase, Ptr<LrWpanNetDevice> dev, Time IfsTime)
{
// take the time of the end of the IFS
testcase->m_endIfs = Simulator::Now ();
@@ -215,9 +234,9 @@ LrWpanDataIfsTestCase::DoRun ()
// Connect to trace files in the MAC layer
dev0->GetMac ()->TraceConnectWithoutContext ("IfsEnd", MakeBoundCallback (&LrWpanDataIfsTestCase::IfsEnd, this, dev0));
dev0->GetMac ()->TraceConnectWithoutContext ("MacRx", MakeBoundCallback (&LrWpanDataIfsTestCase::DataReceived, this, dev0));
dev0->GetMac ()->TraceConnectWithoutContext ("MacRx", MakeBoundCallback (&LrWpanDataIfsTestCase::DataReceivedDev0, this, dev0));
dev0->GetPhy ()->TraceConnectWithoutContext ("PhyRxBegin", MakeBoundCallback (&LrWpanDataIfsTestCase::PhyDataRxStart, this, dev0));
dev1->GetMac ()->TraceConnectWithoutContext ("MacRx", MakeBoundCallback (&LrWpanDataIfsTestCase::DataReceived2, this, dev1));
dev1->GetMac ()->TraceConnectWithoutContext ("MacRx", MakeBoundCallback (&LrWpanDataIfsTestCase::DataReceivedDev1, this, dev1));
Ptr<ConstantPositionMobilityModel> sender0Mobility = CreateObject<ConstantPositionMobilityModel> ();
sender0Mobility->SetPosition (Vector (0,0,0));
@@ -232,7 +251,7 @@ LrWpanDataIfsTestCase::DoRun ()
dev0->GetMac ()->SetMcpsDataConfirmCallback (cb0);
McpsDataConfirmCallback cb1;
cb1 = MakeBoundCallback (&LrWpanDataIfsTestCase::DataConfirm1, this, dev1);
cb1 = MakeBoundCallback (&LrWpanDataIfsTestCase::DataConfirm, this, dev1);
dev1->GetMac ()->SetMcpsDataConfirmCallback (cb1);
Ptr<Packet> p0 = Create<Packet> (2);