|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
26 #include "ns3/simulator.h"
40 .AddConstructor<TcpBbr> ()
41 .SetGroupName (
"Internet")
42 .AddAttribute (
"Stream",
43 "Random number stream (default is set to 4 to align with Linux results)",
46 MakeUintegerChecker<uint32_t> ())
47 .AddAttribute (
"HighGain",
51 MakeDoubleChecker<double> ())
52 .AddAttribute (
"BwWindowLength",
53 "Length of bandwidth windowed filter",
56 MakeUintegerChecker<uint32_t> ())
57 .AddAttribute (
"RttWindowLength",
58 "Length of RTT windowed filter",
62 .AddAttribute (
"ProbeRttDuration",
63 "Time to be spent in PROBE_RTT phase",
67 .AddAttribute (
"ExtraAckedRttWindowLength",
68 "Window length of extra acked window",
71 MakeUintegerChecker<uint32_t> ())
72 .AddAttribute (
"AckEpochAckedResetThresh",
73 "Max allowed val for m_ackEpochAcked, after which sampling epoch is reset",
76 MakeUintegerChecker<uint32_t> ())
85 m_uv = CreateObject<UniformRandomVariable> ();
90 m_bandwidthWindowLength (sock.m_bandwidthWindowLength),
91 m_pacingGain (sock.m_pacingGain),
92 m_cWndGain (sock.m_cWndGain),
93 m_highGain (sock.m_highGain),
94 m_isPipeFilled (sock.m_isPipeFilled),
95 m_minPipeCwnd (sock.m_minPipeCwnd),
96 m_roundCount (sock.m_roundCount),
97 m_roundStart (sock.m_roundStart),
98 m_nextRoundDelivered (sock.m_nextRoundDelivered),
99 m_probeRttDuration (sock.m_probeRttDuration),
100 m_probeRtPropStamp (sock.m_probeRtPropStamp),
101 m_probeRttDoneStamp (sock.m_probeRttDoneStamp),
102 m_probeRttRoundDone (sock.m_probeRttRoundDone),
103 m_packetConservation (sock.m_packetConservation),
104 m_priorCwnd (sock.m_priorCwnd),
105 m_idleRestart (sock.m_idleRestart),
106 m_targetCWnd (sock.m_targetCWnd),
107 m_fullBandwidth (sock.m_fullBandwidth),
108 m_fullBandwidthCount (sock.m_fullBandwidthCount),
110 m_sendQuantum (sock.m_sendQuantum),
111 m_cycleStamp (sock.m_cycleStamp),
112 m_cycleIndex (sock.m_cycleIndex),
113 m_rtPropExpired (sock.m_rtPropExpired),
114 m_rtPropFilterLen (sock.m_rtPropFilterLen),
115 m_rtPropStamp (sock.m_rtPropStamp),
116 m_isInitialized (sock.m_isInitialized),
118 m_delivered (sock.m_delivered),
119 m_appLimited (sock.m_appLimited),
120 m_txItemDelivered (sock.m_txItemDelivered),
121 m_extraAckedGain (sock.m_extraAckedGain),
122 m_extraAckedWinRtt (sock.m_extraAckedWinRtt),
123 m_extraAckedWinRttLength (sock.m_extraAckedWinRttLength),
124 m_ackEpochAckedResetThresh (sock.m_ackEpochAckedResetThresh),
125 m_extraAckedIdx (sock.m_extraAckedIdx),
126 m_ackEpochTime (sock.m_ackEpochTime),
127 m_ackEpochAcked (sock.m_ackEpochAcked),
128 m_hasSeenRtt (sock.m_hasSeenRtt)
136 "BBR_STARTUP",
"BBR_DRAIN",
"BBR_PROBE_BW",
"BBR_PROBE_RTT"
209 if (
m_state == BbrMode_t::BBR_PROBE_BW)
247 return (gain * estimatedBdp) + quanta + (2 * tcb->
m_segmentSize);
249 return (gain * estimatedBdp) + quanta;
445 if (
m_state == BbrMode_t::BBR_PROBE_RTT)
473 uint32_t maxAggrBytes;
474 uint32_t aggrCwndBytes = 0;
480 aggrCwndBytes =
std::min (aggrCwndBytes, maxAggrBytes);
482 return aggrCwndBytes;
488 uint32_t expectedAcked, extraAck;
549 if (
m_state == BbrMode_t::BBR_PROBE_RTT)
707 NS_LOG_DEBUG (
"CongestionStateSet triggered to CA_OPEN :: " << newState);
730 NS_LOG_DEBUG (
"CongestionStateSet triggered to CA_LOSS :: " << newState);
736 NS_LOG_DEBUG (
"CongestionStateSet triggered to CA_RECOVERY :: " << newState);
750 NS_LOG_DEBUG (
"CwndEvent triggered to CA_EVENT_COMPLETE_CWR :: " << event);
756 NS_LOG_DEBUG (
"CwndEvent triggered to CA_EVENT_TX_START :: " << event);
760 if (
m_state == BbrMode_t::BBR_PROBE_BW)
764 else if (
m_state == BbrMode_t::BBR_PROBE_RTT)
781 return tcb->m_ssThresh;
787 return CopyObject<TcpBbr> (
this);
void HandleProbeRTT(Ptr< TcpSocketState > tcb)
Handles the steps for BBR_PROBE_RTT state.
void EnterProbeRTT()
Updates variables specific to BBR_PROBE_RTT state.
virtual bool HasCongControl() const
Returns true when Congestion Control Algorithm implements CongControl.
a unique identifier for an interface.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
void HandleRestartFromIdle(Ptr< TcpSocketState > tcb, const TcpRateOps::TcpRateSample &rs)
Updates pacing rate if socket is restarting from idle state.
T Get(void) const
Get the underlying value.
void ExitProbeRTT()
Called on exiting from BBR_PROBE_RTT state, it eithers invoke EnterProbeBW () or EnterStartup ()
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
uint64_t m_delivered
The total amount of data in bytes delivered so far.
DataRate m_maxPacingRate
Max Pacing rate.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
void EnterProbeBW()
Updates variables specific to BBR_PROBE_BW state.
static const uint8_t GAIN_CYCLE_LENGTH
The number of phases in the BBR ProbeBW gain cycle.
uint32_t m_bytesLoss
The amount of data marked as lost from the most recent ack received.
uint32_t GetBbrState()
Gets BBR state.
void UpdateBtlBw(Ptr< TcpSocketState > tcb, const TcpRateOps::TcpRateSample &rs)
Updates maximum bottleneck.
virtual uint32_t GetSsThresh(Ptr< const TcpSocketState > tcb, uint32_t bytesInFlight)
Get the slow start threshold after a loss event.
uint32_t m_extraAckedGain
Gain factor for adding extra ack to cwnd.
bool m_hasSeenRtt
Have we seen RTT sample yet?
static Time Now(void)
Return the current simulation virtual time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void CheckFullPipe(const TcpRateOps::TcpRateSample &rs)
Identifies whether pipe or BDP is already full.
bool m_isAppLimited
Indicates whether the rate sample is application-limited.
TracedValue< DataRate > m_pacingRate
Current Pacing rate.
void UpdateRound(Ptr< TcpSocketState > tcb, const TcpRateOps::TcpRateSample &rs)
Updates round counting related variables.
uint32_t m_segmentSize
Segment size.
@ CA_OPEN
Normal state, no dubious events.
uint32_t m_extraAckedWinRtt
Age of extra acked in rtt.
Time m_rtProp
Estimated two-way round-trip propagation delay of the path, estimated from the windowed minimum recen...
uint32_t m_targetCWnd
Target value for congestion window, adapted to the estimated BDP.
uint32_t m_roundCount
Count of packet-timed round trips.
void InitFullPipe()
Intializes the full pipe estimator.
bool m_idleRestart
When restarting from idle, set it true.
uint32_t m_priorDelivered
The delivered count of the most recent packet delivered.
uint32_t m_extraAckedWinRttLength
Window length of extra acked window.
@ CA_EVENT_TX_START
first transmit when no packets in flight
TcpCongState_t
Definition of the Congestion state machine.
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
virtual std::string GetName() const
Get the name of the congestion control algorithm.
void EnterDrain()
Updates variables specific to BBR_DRAIN state.
uint32_t m_cycleIndex
Current index of gain cycle.
static TypeId GetTypeId(void)
Get the type ID.
Ptr< UniformRandomVariable > m_uv
Uniform Random Variable.
void AdvanceCyclePhase()
Advances pacing gain using cycle gain algorithm, while in BBR_PROBE_BW state.
int32_t m_delivered
The amount of data marked as delivered over the sampling interval.
virtual void CwndEvent(Ptr< TcpSocketState > tcb, const TcpSocketState::TcpCAEvent_t event)
Trigger events/calculations on occurrence of congestion window event.
uint32_t m_extraAcked[2]
Maximum excess data acked in epoch.
uint32_t m_priorInFlight
The value if bytes in flight prior to last received ack.
uint32_t m_lastAckedSackedBytes
The number of bytes acked and sacked as indicated by the current ACK received.
void Update(T new_sample, TimeT new_time)
Updates best estimates with |sample|, and expires and updates best estimates as necessary.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
virtual void SetStream(uint32_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
uint32_t m_initialSsThresh
Initial Slow Start Threshold value.
void SetBbrState(BbrMode_t state)
Sets BBR state.
uint32_t m_sendQuantum
The maximum size of a data aggregate scheduled and transmitted together.
void SetSendQuantum(Ptr< TcpSocketState > tcb)
Updates send quantum based on the network model.
Time m_rtPropFilterLen
A constant specifying the length of the RTProp min filter window, default 10 secs.
uint32_t m_ackEpochAcked
Bytes ACked in sampling epoch.
WindowedFilter< DataRate, MaxFilter< DataRate >, uint32_t, uint32_t > MaxBandwidthFilter_t
Definition of max bandwidth filter.
int64x64_t Max(const int64x64_t &a, const int64x64_t &b)
Maximum.
Class for representing data rates.
bool IsNextCyclePhase(Ptr< TcpSocketState > tcb, const TcpRateOps::TcpRateSample &rs)
Checks whether to move to next value of pacing gain while in BBR_PROBE_BW.
double m_cWndGain
The dynamic congestion window gain factor.
TracedValue< TcpCongState_t > m_congState
State in the Congestion state machine.
bool m_isPipeFilled
A boolean that records whether BBR has filled the pipe.
uint32_t m_minPipeCwnd
The minimal congestion window value BBR tries to target, default 4 Segment size.
void UpdateControlParameters(Ptr< TcpSocketState > tcb, const TcpRateOps::TcpRateSample &rs)
Updates control parameters congestion windowm, pacing rate, send quantum.
bool m_roundStart
A boolean that BBR sets to true once per packet-timed round trip.
uint32_t m_extraAckedIdx
Current index in extra acked array.
void UpdateModelAndState(Ptr< TcpSocketState > tcb, const TcpRateOps::TcpRateSample &rs)
Updates BBR network model (Maximum bandwidth and minimum RTT).
T GetBest() const
Returns Max/Min value so far among the windowed samples.
bool m_rtPropExpired
A boolean recording whether the BBR.RTprop has expired.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
uint32_t m_fullBandwidthCount
Count of full bandwidth recorded consistently.
double m_highGain
A constant specifying highest gain factor, default is 2.89.
static Time Max()
Maximum representable Time Not to be confused with Max(Time,Time).
Simulation virtual time values and global simulation resolution.
uint32_t m_txItemDelivered
The number of bytes already delivered at the time of new packet transmission.
uint32_t m_ackedSacked
The amount of data acked and sacked in the last received ack.
void RestoreCwnd(Ptr< TcpSocketState > tcb)
Helper to restore the last-known good congestion window.
uint64_t GetBitRate() const
Get the underlying bitrate.
uint32_t m_initialCWnd
Initial cWnd value.
uint32_t m_nextRoundDelivered
Denotes the end of a packet-timed round trip.
@ CA_LOSS
CWND was reduced due to RTO timeout or SACK reneging.
uint32_t m_ackEpochAckedResetThresh
Max allowed val for m_ackEpochAcked, after which sampling epoch is reset.
BbrMode_t m_state
Current state of BBR state machine.
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
DataRate m_deliveryRate
The delivery rate sample.
int64_t GetMilliSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
void UpdateRTprop(Ptr< TcpSocketState > tcb)
Updates minimum RTT.
bool ModulateCwndForRecovery(Ptr< TcpSocketState > tcb, const TcpRateOps::TcpRateSample &rs)
Modulates congestion window in CA_RECOVERY.
bool m_probeRttRoundDone
True when it is time to exit BBR_PROBE_RTT.
uint32_t m_priorCwnd
The last-known good congestion window.
uint32_t m_bandwidthWindowLength
A constant specifying the length of the BBR.BtlBw max filter window, default 10 packet-timed round tr...
double GetCwndGain()
Gets current cwnd gain.
Congestion control abstract class.
static const double PACING_GAIN_CYCLE[]
BBR uses an eight-phase cycle with the given pacing_gain value in the BBR ProbeBW gain cycle.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Time m_probeRttDuration
A constant specifying the minimum duration for which ProbeRTT state, default 200 millisecs.
void(* DataRate)(DataRate oldValue, DataRate newValue)
TracedValue callback signature for DataRate.
void ModulateCwndForProbeRTT(Ptr< TcpSocketState > tcb)
Modulates congestion window in BBR_PROBE_RTT.
Time Seconds(double value)
Construct a Time in the indicated unit.
@ CA_RECOVERY
CWND was reduced, we are fast-retransmitting.
MaxBandwidthFilter_t m_maxBwFilter
Maximum bandwidth filter.
void EnterStartup()
Updates variables specific to BBR_STARTUP state.
double m_pacingGain
The dynamic pacing gain factor.
void CheckDrain(Ptr< TcpSocketState > tcb)
Checks whether its time to enter BBR_DRAIN or BBR_PROBE_BW state.
void UpdateTargetCwnd(Ptr< TcpSocketState > tcb)
Updates target congestion window.
uint32_t InFlight(Ptr< TcpSocketState > tcb, double gain)
Estimates the target value for congestion window.
uint32_t m_appLimited
The index of the last transmitted packet marked as application-limited.
bool m_pacing
Pacing status.
void UpdateAckAggregation(Ptr< TcpSocketState > tcb, const TcpRateOps::TcpRateSample &rs)
Estimates max degree of aggregation.
AttributeValue implementation for Time.
void CheckCyclePhase(Ptr< TcpSocketState > tcb, const TcpRateOps::TcpRateSample &rs)
Checks whether to advance pacing gain in BBR_PROBE_BW state, and if allowed calls AdvanceCyclePhase (...
TcpCAEvent_t
Congestion avoidance events.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
DataRate m_fullBandwidth
Value of full bandwidth recorded.
uint64_t m_delivered
The total amount of data in bytes delivered so far.
TracedValue< uint32_t > m_bytesInFlight
Bytes in flight.
void SaveCwnd(Ptr< const TcpSocketState > tcb)
Helper to remember the last-known good congestion window or the latest congestion window unmodulated ...
bool m_packetConservation
Enable/Disable packet conservation mode.
TracedValue< uint32_t > m_cWnd
Congestion window.
virtual Ptr< TcpCongestionOps > Fork()
Copy the congestion control algorithm across sockets.
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
uint32_t AckAggregationCwnd()
Find Cwnd increment based on ack aggregation.
Hold an unsigned integer type.
Information about the connection rate.
TracedValue< Time > m_lastRtt
Last RTT sample collected.
void SetCwnd(Ptr< TcpSocketState > tcb, const TcpRateOps::TcpRateSample &rs)
Updates congestion window based on the network model.
BbrMode_t
BBR has the following 4 modes for deciding how fast to send:
Time m_ackEpochTime
Starting of ACK sampling epoch time.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
@ CA_EVENT_COMPLETE_CWR
end of congestion recovery
Time m_minRtt
Minimum RTT observed throughout the connection.
Time m_rtPropStamp
The wall clock time at which the current BBR.RTProp sample was obtained.
static const char *const BbrModeName[BBR_PROBE_RTT+1]
Literal names of BBR mode for use in log messages.
void CheckProbeRTT(Ptr< TcpSocketState > tcb, const TcpRateOps::TcpRateSample &rs)
This method handles the steps related to the ProbeRTT state.
TracedValue< uint32_t > m_ssThresh
Slow start threshold.
bool m_isInitialized
Set to true after first time initializtion variables.
virtual void CongControl(Ptr< TcpSocketState > tcb, const TcpRateOps::TcpRateConnection &rc, const TcpRateOps::TcpRateSample &rs)
Called when packets are delivered to update cwnd and pacing rate.
double GetPacingGain()
Gets current pacing gain.
Time m_cycleStamp
Last time gain cycle updated.
virtual void CongestionStateSet(Ptr< TcpSocketState > tcb, const TcpSocketState::TcpCongState_t newState)
Trigger events/calculations specific to a congestion state.
void SetPacingRate(Ptr< TcpSocketState > tcb, double gain)
Updates pacing rate based on network model.
void InitRoundCounting()
Intializes the round counting related variables.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Time m_probeRttDoneStamp
Time to exit from BBR_PROBE_RTT state.
uint32_t m_txItemDelivered
The value of delivered when the acked item was sent.
void InitPacingRate(Ptr< TcpSocketState > tcb)
Intializes the pacing rate.