lr-wpan: Remove {Get,Set}UnitBackoffPeriod() functions

Move the corresponding constant to lr-wpan-constants.h
This commit is contained in:
Eduardo Almeida
2022-12-09 16:29:12 +00:00
parent 514ca83092
commit 5a4b72fa3d
5 changed files with 15 additions and 44 deletions

View File

@@ -30,6 +30,7 @@ Changes from ns-3.37 to ns-3.38
* (internet) `TcpCubic` attribute `HyStartDetect` changed from `int` to `enum HybridSSDetectionMode`.
* (internet-apps) Classes `v4Ping` and `Ping6` will be deprecated and removed in the future, replaced by the new `Ping` class.
* (lr-wpan) Add file `src/lr-wpan/model/lr-wpan-constants.h` with common constants of the LR-WPAN module.
* (lr-wpan) Remove the functions `LrWpanCsmaCa::GetUnitBackoffPeriod()` and `LrWpanCsmaCa::SetUnitBackoffPeriod()`, and move the constant `m_aUnitBackoffPeriod` to `src/lr-wpan/model/lr-wpan-constants.h`.
### Changes to build system

View File

@@ -96,6 +96,11 @@ constexpr uint32_t aMaxPhyPacketSize{127};
*/
constexpr uint32_t aTurnaroundTime{12};
/**
* Number of symbols per CSMA/CA time unit, default 20 symbols.
*/
constexpr uint32_t aUnitBackoffPeriod{20};
/** @} */
} // namespace lrwpan

View File

@@ -61,7 +61,6 @@ LrWpanCsmaCa::LrWpanCsmaCa()
m_macMinBE = 3;
m_macMaxBE = 5;
m_macMaxCSMABackoffs = 4;
m_aUnitBackoffPeriod = 20; // symbols
m_random = CreateObject<UniformRandomVariable>();
m_BE = m_macMinBE;
m_ccaRequestRunning = false;
@@ -171,20 +170,6 @@ LrWpanCsmaCa::GetMacMaxCSMABackoffs() const
return m_macMaxCSMABackoffs;
}
void
LrWpanCsmaCa::SetUnitBackoffPeriod(uint64_t unitBackoffPeriod)
{
NS_LOG_FUNCTION(this << unitBackoffPeriod);
m_aUnitBackoffPeriod = unitBackoffPeriod;
}
uint64_t
LrWpanCsmaCa::GetUnitBackoffPeriod() const
{
NS_LOG_FUNCTION(this);
return m_aUnitBackoffPeriod;
}
Time
LrWpanCsmaCa::GetTimeToNextSlot() const
{
@@ -221,8 +206,8 @@ LrWpanCsmaCa::GetTimeToNextSlot() const
// get a close value to the the boundary in symbols
elapsedSuperframeSymbols = elapsedSuperframe.GetSeconds() * symbolRate;
symbolsToBoundary =
m_aUnitBackoffPeriod - std::fmod((double)elapsedSuperframeSymbols, m_aUnitBackoffPeriod);
symbolsToBoundary = lrwpan::aUnitBackoffPeriod -
std::fmod((double)elapsedSuperframeSymbols, lrwpan::aUnitBackoffPeriod);
timeAtBoundary = Seconds((double)(elapsedSuperframeSymbols + symbolsToBoundary) / symbolRate);
@@ -310,7 +295,7 @@ LrWpanCsmaCa::RandomBackoffDelay()
}
randomBackoff =
Seconds((double)(m_randomBackoffPeriodsLeft * GetUnitBackoffPeriod()) / symbolRate);
Seconds((double)(m_randomBackoffPeriodsLeft * lrwpan::aUnitBackoffPeriod) / symbolRate);
if (IsUnSlottedCsmaCa())
{
@@ -332,14 +317,14 @@ LrWpanCsmaCa::RandomBackoffDelay()
<< randomBackoff.As(Time::S) << ")");
NS_LOG_DEBUG("Backoff periods left in CAP: "
<< ((timeLeftInCap.GetSeconds() * symbolRate) / m_aUnitBackoffPeriod) << " ("
<< (timeLeftInCap.GetSeconds() * symbolRate) << " symbols or "
<< ((timeLeftInCap.GetSeconds() * symbolRate) / lrwpan::aUnitBackoffPeriod)
<< " (" << (timeLeftInCap.GetSeconds() * symbolRate) << " symbols or "
<< timeLeftInCap.As(Time::S) << ")");
if (randomBackoff >= timeLeftInCap)
{
uint64_t usedBackoffs =
(double)(timeLeftInCap.GetSeconds() * symbolRate) / m_aUnitBackoffPeriod;
(double)(timeLeftInCap.GetSeconds() * symbolRate) / lrwpan::aUnitBackoffPeriod;
m_randomBackoffPeriodsLeft -= usedBackoffs;
NS_LOG_DEBUG("No time in CAP to complete backoff delay, deferring to the next CAP");
m_endCapEvent =

View File

@@ -149,22 +149,6 @@ class LrWpanCsmaCa : public Object
* \return the maximum number of backoffs
*/
uint8_t GetMacMaxCSMABackoffs() const;
/**
* Set the number of symbols forming the basic time period used by the
* CSMA-CA algorithm.
* See IEEE 802.15.4-2006, section 7.4.1, Table 85.
*
* \param unitBackoffPeriod the period length in symbols
*/
void SetUnitBackoffPeriod(uint64_t unitBackoffPeriod);
/**
* Get the number of symbols forming the basic time period used by the
* CSMA-CA algorithm.
* See IEEE 802.15.4-2006, section 7.4.1, Table 85.
*
* \return the period length in symbols
*/
uint64_t GetUnitBackoffPeriod() const;
/**
* Locates the time to the next backoff period boundary in the SUPERFRAME
* and returns the amount of time left to this moment.
@@ -277,7 +261,7 @@ class LrWpanCsmaCa : public Object
*/
bool m_isSlotted;
/**
* The MAC instance for which this CSMA/CA implemenation is configured.
* The MAC instance for which this CSMA/CA implementation is configured.
*/
Ptr<LrWpanMac> m_mac;
/**
@@ -299,7 +283,7 @@ class LrWpanCsmaCa : public Object
/**
* Minimum backoff exponent. 0 - macMaxBE, default 3
*/
uint8_t m_macMinBE; //
uint8_t m_macMinBE;
/**
* Maximum backoff exponent. 3 - 8, default 5
*/
@@ -308,10 +292,6 @@ class LrWpanCsmaCa : public Object
* Maximum number of backoffs. 0 - 5, default 4
*/
uint8_t m_macMaxCSMABackoffs;
/**
* Number of symbols per CSMA/CA time unit, default 20 symbols.
*/
uint64_t m_aUnitBackoffPeriod;
/**
* Count the number of remaining random backoff periods left to delay.
*/

View File

@@ -3435,7 +3435,7 @@ LrWpanMac::ChangeMacState(LrWpanMacState newState)
uint64_t
LrWpanMac::GetMacAckWaitDuration() const
{
return m_csmaCa->GetUnitBackoffPeriod() + lrwpan::aTurnaroundTime + m_phy->GetPhySHRDuration() +
return lrwpan::aUnitBackoffPeriod + lrwpan::aTurnaroundTime + m_phy->GetPhySHRDuration() +
ceil(6 * m_phy->GetPhySymbolsPerOctet());
}