Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 35 additions & 36 deletions model/quic-bbr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ void
QuicBbr::EnterStartup ()
{
NS_LOG_FUNCTION (this);
SetBbrState (BbrMode_t::BBR_STARTUP);
SetBbrState (Mode::STARTUP);
m_pacingGain = m_highGain;
m_cWndGain = m_highGain;
}
Expand All @@ -173,7 +173,7 @@ QuicBbr::HandleRestartFromIdle (Ptr<QuicSocketState> tcb, const RateSample * rs)
if (tcb->m_bytesInFlight.Get () == 0U && rs->m_isAppLimited)
{
m_idleRestart = true;
if (m_state.Get () == BbrMode_t::BBR_PROBE_BW)
if (m_state.Get () == Mode::PROBE_BW)
{
SetPacingRate (tcb, 1);
}
Expand Down Expand Up @@ -237,7 +237,7 @@ void
QuicBbr::CheckCyclePhase (Ptr<QuicSocketState> tcb, const struct RateSample * rs)
{
NS_LOG_FUNCTION (this << tcb << rs);
if (m_state.Get () == BbrMode_t::BBR_PROBE_BW && IsNextCyclePhase (tcb, rs))
if (m_state.Get () == Mode::PROBE_BW && IsNextCyclePhase (tcb, rs))
{
AdvanceCyclePhase ();
}
Expand Down Expand Up @@ -272,7 +272,7 @@ void
QuicBbr::EnterDrain ()
{
NS_LOG_FUNCTION (this);
SetBbrState (BbrMode_t::BBR_DRAIN);
SetBbrState (Mode::DRAIN);
m_pacingGain = 1.0 / m_highGain;
m_cWndGain = m_highGain;
}
Expand All @@ -281,7 +281,7 @@ void
QuicBbr::EnterProbeBW ()
{
NS_LOG_FUNCTION (this);
SetBbrState (BbrMode_t::BBR_PROBE_BW);
SetBbrState (Mode::PROBE_BW);
m_pacingGain = 1;
m_cWndGain = 2;
m_cycleIndex = GAIN_CYCLE_LENGTH - 1 - (int) m_uv->GetValue (0, 8);
Expand All @@ -292,12 +292,12 @@ void
QuicBbr::CheckDrain (Ptr<QuicSocketState> tcb)
{
NS_LOG_FUNCTION (this << tcb);
if (m_state.Get () == BbrMode_t::BBR_STARTUP && m_isPipeFilled)
if (m_state.Get () == Mode::STARTUP && m_isPipeFilled)
{
EnterDrain ();
}

if (m_state.Get () == BbrMode_t::BBR_DRAIN && tcb->m_bytesInFlight <= InFlight (tcb, 1))
if (m_state.Get () == Mode::DRAIN && tcb->m_bytesInFlight <= InFlight (tcb, 1))
{
EnterProbeBW ();
}
Expand All @@ -319,7 +319,7 @@ void
QuicBbr::EnterProbeRTT ()
{
NS_LOG_FUNCTION (this);
SetBbrState (BbrMode_t::BBR_PROBE_RTT);
SetBbrState (Mode::PROBE_RTT);
m_pacingGain = 1;
m_cWndGain = 1;
}
Expand All @@ -328,7 +328,7 @@ void
QuicBbr::SaveCwnd (Ptr<const QuicSocketState> tcb)
{
NS_LOG_FUNCTION (this << tcb);
if (tcb->m_congState != TcpSocketState::CA_RECOVERY && m_state.Get () != BbrMode_t::BBR_PROBE_RTT)
if (tcb->m_congState != TcpSocketState::CA_RECOVERY && m_state.Get () != Mode::PROBE_RTT)
{
m_priorCwnd = tcb->m_cWnd;
}
Expand Down Expand Up @@ -391,17 +391,17 @@ void
QuicBbr::CheckProbeRTT (Ptr<QuicSocketState> tcb)
{
NS_LOG_FUNCTION (this << tcb);
NS_LOG_DEBUG (Simulator::Now () << "WhichState " << WhichState (m_state.Get ())
NS_LOG_DEBUG (Simulator::Now () << "WhichState " << m_state.Get ()
<< " m_rtPropExpired " << m_rtPropExpired << " !m_idleRestart "
<< !m_idleRestart);
if (m_state.Get () != BbrMode_t::BBR_PROBE_RTT && m_rtPropExpired && !m_idleRestart)
if (m_state.Get () != Mode::PROBE_RTT && m_rtPropExpired && !m_idleRestart)
{
EnterProbeRTT ();
SaveCwnd (tcb);
m_probeRttDoneStamp = Seconds (0);
}

if (m_state.Get () == BbrMode_t::BBR_PROBE_RTT)
if (m_state.Get () == Mode::PROBE_RTT)
{
HandleProbeRTT (tcb);
}
Expand Down Expand Up @@ -456,7 +456,7 @@ void
QuicBbr::ModulateCwndForProbeRTT (Ptr<QuicSocketState> tcb)
{
NS_LOG_FUNCTION (this << tcb);
if (m_state.Get () == BbrMode_t::BBR_PROBE_RTT)
if (m_state.Get () == Mode::PROBE_RTT)
{
tcb->m_cWnd = std::min (tcb->m_cWnd.Get (), m_minPipeCwnd);
}
Expand Down Expand Up @@ -548,34 +548,15 @@ QuicBbr::UpdateControlParameters (Ptr<QuicSocketState> tcb, const struct RateSam
SetCwnd (tcb, rs);
}

std::string
QuicBbr::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";
default:
NS_ABORT_MSG ("Invalid BBR state");
return "";
}
}

void
QuicBbr::SetBbrState (BbrMode_t mode)
QuicBbr::SetBbrState (Mode 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 " << m_state << " to " << mode);
m_state = mode;
}

uint32_t
QuicBbr::Mode
QuicBbr::GetBbrState ()
{
NS_LOG_FUNCTION (this);
Expand Down Expand Up @@ -680,7 +661,7 @@ QuicBbr::CwndEvent (Ptr<TcpSocketState> tcb,
if (tcbd->m_bytesInFlight.Get () == 0 && tcbd->m_appLimitedUntil > tcbd->m_delivered)
{
m_idleRestart = true;
if (m_state.Get () == BbrMode_t::BBR_PROBE_BW && tcbd->m_appLimitedUntil > tcbd->m_delivered)
if (m_state.Get () == Mode::PROBE_BW && tcbd->m_appLimitedUntil > tcbd->m_delivered)
{
SetPacingRate (tcbd, 1);
}
Expand Down Expand Up @@ -818,4 +799,22 @@ QuicBbr::Fork (void)
return CopyObject<QuicBbr> (this);
}

std::ostream&
operator<<(std::ostream& os, QuicBbr::Mode mode)
{
switch (mode)
{
case QuicBbr::Mode::STARTUP:
return os << "STARTUP";
case QuicBbr::Mode::DRAIN:
return os << "DRAIN";
case QuicBbr::Mode::PROBE_BW:
return os << "PROBE_BW";
case QuicBbr::Mode::PROBE_RTT:
return os << "PROBE_RTT";
};
NS_ABORT_MSG ("Invalid BBR state");
return os << "UNKNOWN(" << static_cast<uint32_t>(mode) << ")";
}

} // namespace ns3
52 changes: 27 additions & 25 deletions model/quic-bbr.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ class QuicBbr : public QuicCongestionOps
QuicBbr (const QuicBbr &sock);

/* BBR has the following modes for deciding how fast to send: */
typedef enum
enum class Mode
{
BBR_STARTUP, /* ramp up sending rate rapidly to fill pipe */
BBR_DRAIN, /* drain any queue created during startup */
BBR_PROBE_BW, /* discover, share bw: pace around estimated bw */
BBR_PROBE_RTT, /* cut inflight to min to probe min_rtt */
} BbrMode_t;
STARTUP, /* ramp up sending rate rapidly to fill pipe */
DRAIN, /* drain any queue created during startup */
PROBE_BW, /* discover, share bw: pace around estimated bw */
PROBE_RTT, /* cut inflight to min to probe min_rtt */
};

typedef WindowedFilter<DataRate,
MaxFilter<DataRate>,
Expand Down Expand Up @@ -137,20 +137,20 @@ class QuicBbr : public QuicCongestionOps
friend class QuicBbrCheckGainValuesTest;

/**
* \brief Advances pacing gain using cycle gain algorithm, while in BBR_PROBE_BW state
* \brief Advances pacing gain using cycle gain algorithm, while in Mode::PROBE_BW state
*/
void AdvanceCyclePhase ();

/**
* \brief Checks whether to advance pacing gain in BBR_PROBE_BW state,
* \brief Checks whether to advance pacing gain in Mode::PROBE_BW state,
* and if allowed calls AdvanceCyclePhase ()
* \param tcb the socket state.
* \param rs rate sample
*/
void CheckCyclePhase (Ptr<QuicSocketState> tcb, const struct RateSample * rs);

/**
* \brief Checks whether its time to enter BBR_DRAIN or BBR_PROBE_BW state
* \brief Checks whether its time to enter Mode::DRAIN or Mode::PROBE_BW state
* \param tcb the socket state.
*/
void CheckDrain (Ptr<QuicSocketState> tcb);
Expand All @@ -168,35 +168,35 @@ class QuicBbr : public QuicCongestionOps
void CheckProbeRTT (Ptr<QuicSocketState> tcb);

/**
* \brief Updates variables specific to BBR_DRAIN state
* \brief Updates variables specific to Mode::DRAIN state
*/
void EnterDrain ();

/**
* \brief Updates variables specific to BBR_PROBE_BW state
* \brief Updates variables specific to Mode::PROBE_BW state
*/
void EnterProbeBW ();

/**
* \brief Updates variables specific to BBR_PROBE_RTT state
* \brief Updates variables specific to Mode::PROBE_RTT state
*/
void EnterProbeRTT ();

/**
* \brief Updates variables specific to BBR_STARTUP state
* \brief Updates variables specific to Mode::STARTUP state
*/
void EnterStartup ();

/**
* \brief Called on exiting from BBR_PROBE_RTT state, it eithers invoke EnterProbeBW () or EnterStartup ()
* \brief Called on exiting from Mode::PROBE_RTT state, it eithers invoke EnterProbeBW () or EnterStartup ()
*/
void ExitProbeRTT ();

/**
* \brief Gets BBR state.
* \return returns BBR state.
*/
uint32_t GetBbrState ();
Mode GetBbrState();

/**
* \brief Gets current pacing gain.
Expand All @@ -211,7 +211,7 @@ class QuicBbr : public QuicCongestionOps
double GetCwndGain ();

/**
* \brief Handles the steps for BBR_PROBE_RTT state.
* \brief Handles the steps for Mode::PROBE_RTT state.
* \param tcb the socket state.
*/
void HandleProbeRTT (Ptr<QuicSocketState> tcb);
Expand Down Expand Up @@ -247,15 +247,15 @@ class QuicBbr : public QuicCongestionOps
void InitRoundCounting ();

/**
* \brief Checks whether to move to next value of pacing gain while in BBR_PROBE_BW.
* \brief Checks whether to move to next value of pacing gain while in Mode::PROBE_BW.
* \param tcb the socket state.
* \param rs rate sample
* \returns true if want to move to next value otherwise false.
*/
bool IsNextCyclePhase (Ptr<QuicSocketState> tcb, const struct RateSample * rs);

/**
* \brief Modulates congestion window in BBR_PROBE_RTT.
* \brief Modulates congestion window in Mode::PROBE_RTT.
* \param tcb the socket state
*/
void ModulateCwndForProbeRTT (Ptr<QuicSocketState> tcb);
Expand Down Expand Up @@ -344,16 +344,16 @@ class QuicBbr : public QuicCongestionOps
* \brief Sets BBR state.
* \param state BBR state.
*/
void SetBbrState (BbrMode_t state);
void SetBbrState (Mode state);

/**
* \brief Maps mode into string.
* \return string translation of mode value.
*/
std::string WhichState (BbrMode_t state) const;
std::string WhichState (Mode state) const;

private:
TracedValue<BbrMode_t> m_state {BbrMode_t::BBR_STARTUP}; //!< Current state of BBR state machine
TracedValue<Mode> m_state {Mode::STARTUP}; //!< Current state of BBR state machine
MaxBandwidthFilter_t m_maxBwFilter; //!< Maximum bandwidth filter
uint32_t m_bandwidthWindowLength {0}; //!< A constant specifying the length of the BBR.BtlBw max filter window, default 10 packet-timed round trips.
double m_pacingGain {0}; //!< The dynamic pacing gain factor
Expand All @@ -366,8 +366,8 @@ class QuicBbr : public QuicCongestionOps
uint32_t m_nextRoundDelivered {0}; //!< Denotes the end of a packet-timed round trip
Time m_probeRttDuration {MilliSeconds (200)};//!< A constant specifying the minimum duration for which ProbeRTT state, default 200 millisecs
Time m_probeRtPropStamp {Seconds (0)}; //!< The wall clock time at which the current BBR.RTProp sample was obtained.
Time m_probeRttDoneStamp {Seconds (0)}; //!< Time to exit from BBR_PROBE_RTT state
bool m_probeRttRoundDone {false}; //!< True when it is time to exit BBR_PROBE_RTT
Time m_probeRttDoneStamp {Seconds (0)}; //!< Time to exit from Mode::PROBE_RTT state
bool m_probeRttRoundDone {false}; //!< True when it is time to exit Mode::PROBE_RTT
bool m_packetConservation {false}; //!<
uint32_t m_priorCwnd {0}; //!< The last-known good congestion window
bool m_idleRestart {false}; //!< When restarting from idle, set it true
Expand All @@ -392,7 +392,9 @@ class QuicBbr : public QuicCongestionOps
* \param [in] oldValue original value of the traced variable
* \param [in] newValue new value of the traced variable
*/
typedef void (*BbrStatesTracedValueCallback) (const QuicBbr::BbrMode_t oldValue,
const QuicBbr::BbrMode_t newValue);
typedef void (*BbrStatesTracedValueCallback) (const QuicBbr::Mode oldValue,
const QuicBbr::Mode newValue);

std::ostream& operator<<(std::ostream& os, QuicBbr::Mode mode);

} // namespace ns3
Loading