tcp: trace BBR mode using literal array

This commit is contained in:
Vivek Jain
2021-06-19 03:45:27 +00:00
committed by Tom Henderson
parent b2050ae19a
commit 779fe3d42b
2 changed files with 12 additions and 25 deletions

View File

@@ -130,6 +130,12 @@ TcpBbr::TcpBbr (const TcpBbr &sock)
NS_LOG_FUNCTION (this);
}
const char* const
TcpBbr::BbrModeName[BBR_PROBE_RTT + 1] =
{
"BBR_STARTUP", "BBR_DRAIN", "BBR_PROBE_BW", "BBR_PROBE_RTT"
};
void
TcpBbr::SetStream (uint32_t stream)
{
@@ -637,29 +643,11 @@ TcpBbr::UpdateControlParameters (Ptr<TcpSocketState> tcb, const TcpRateOps::TcpR
SetCwnd (tcb, rs);
}
std::string
TcpBbr::WhichState (BbrMode_t mode) const
{
switch (mode)
{
case 0:
return "BBR_STARTUP";
case 1:
return "BBR_DRAIN";
case 2:
return "BBR_PROBE_BW";
case 3:
return "BBR_PROBE_RTT";
}
NS_ASSERT (false);
return "";
}
void
TcpBbr::SetBbrState (BbrMode_t mode)
{
NS_LOG_FUNCTION (this << mode);
NS_LOG_DEBUG (Simulator::Now () << " Changing from " << WhichState (m_state) << " to " << WhichState (mode));
NS_LOG_DEBUG (Simulator::Now () << " Changing from " << BbrModeName[m_state] << " to " << BbrModeName[mode]);
m_state = mode;
}

View File

@@ -78,6 +78,11 @@ public:
uint32_t>
MaxBandwidthFilter_t;
/**
* \brief Literal names of BBR mode for use in log messages
*/
static const char* const BbrModeName[BBR_PROBE_RTT + 1];
/**
* Assign a fixed random variable stream number to the random variables
* used by this model.
@@ -316,12 +321,6 @@ protected:
*/
void SetBbrState (BbrMode_t state);
/**
* \brief Maps mode into string.
* \return string translation of mode value.
*/
std::string WhichState (BbrMode_t state) const;
/**
* \brief Find Cwnd increment based on ack aggregation.
* \return uint32_t aggregate cwnd.