A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
tcp-bbr.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 NITK Surathkal
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Authors: Vivek Jain <jain.vivek.anand@gmail.com>
7 * Viyom Mittal <viyommittal@gmail.com>
8 * Mohit P. Tahiliani <tahiliani@nitk.edu.in>
9 */
10
11#include "tcp-bbr.h"
12
13#include "ns3/log.h"
14#include "ns3/simulator.h"
15
16namespace ns3
17{
18
21
22const double TcpBbr::PACING_GAIN_CYCLE[] = {5.0 / 4, 3.0 / 4, 1, 1, 1, 1, 1, 1};
23
24TypeId
26{
27 static TypeId tid =
28 TypeId("ns3::TcpBbr")
30 .AddConstructor<TcpBbr>()
31 .SetGroupName("Internet")
32 .AddAttribute("Stream",
33 "Random number stream (default is set to 4 to align with Linux results)",
37 .AddAttribute("HighGain",
38 "Value of high gain",
39 DoubleValue(2.89),
42 .AddAttribute("BwWindowLength",
43 "Length of bandwidth windowed filter",
44 UintegerValue(10),
47 .AddAttribute("RttWindowLength",
48 "Length of RTT windowed filter",
49 TimeValue(Seconds(10)),
52 .AddAttribute("ProbeRttDuration",
53 "Time to be spent in PROBE_RTT phase",
57 .AddAttribute("ExtraAckedRttWindowLength",
58 "Window length of extra acked window",
62 .AddAttribute(
63 "AckEpochAckedResetThresh",
64 "Max allowed val for m_ackEpochAcked, after which sampling epoch is reset",
65 UintegerValue(1 << 12),
68 .AddTraceSource("MinRtt",
69 "Estimated two-way round-trip propagation delay of the path, estimated "
70 "from the windowed minimum recent round-trip delay sample",
72 "ns3::TracedValueCallback::Time")
73 .AddTraceSource("PacingGain",
74 "The dynamic pacing gain factor",
76 "ns3::TracedValueCallback::Double")
77 .AddTraceSource("CwndGain",
78 "The dynamic congestion window gain factor",
80 "ns3::TracedValueCallback::Double");
81 return tid;
82}
83
90
92 : TcpCongestionOps(sock),
93 m_bandwidthWindowLength(sock.m_bandwidthWindowLength),
94 m_pacingGain(sock.m_pacingGain),
95 m_cWndGain(sock.m_cWndGain),
96 m_highGain(sock.m_highGain),
97 m_isPipeFilled(sock.m_isPipeFilled),
98 m_minPipeCwnd(sock.m_minPipeCwnd),
99 m_roundCount(sock.m_roundCount),
100 m_roundStart(sock.m_roundStart),
101 m_nextRoundDelivered(sock.m_nextRoundDelivered),
102 m_probeRttDuration(sock.m_probeRttDuration),
103 m_probeRtPropStamp(sock.m_probeRtPropStamp),
104 m_probeRttDoneStamp(sock.m_probeRttDoneStamp),
105 m_probeRttRoundDone(sock.m_probeRttRoundDone),
106 m_packetConservation(sock.m_packetConservation),
107 m_priorCwnd(sock.m_priorCwnd),
108 m_idleRestart(sock.m_idleRestart),
109 m_targetCWnd(sock.m_targetCWnd),
110 m_fullBandwidth(sock.m_fullBandwidth),
111 m_fullBandwidthCount(sock.m_fullBandwidthCount),
112 m_minRtt(Time::Max()),
113 m_sendQuantum(sock.m_sendQuantum),
114 m_cycleStamp(sock.m_cycleStamp),
115 m_cycleIndex(sock.m_cycleIndex),
116 m_minRttExpired(sock.m_minRttExpired),
117 m_minRttFilterLen(sock.m_minRttFilterLen),
118 m_minRttStamp(sock.m_minRttStamp),
119 m_isInitialized(sock.m_isInitialized),
120 m_uv(sock.m_uv),
121 m_delivered(sock.m_delivered),
122 m_appLimited(sock.m_appLimited),
123 m_extraAckedGain(sock.m_extraAckedGain),
124 m_extraAckedWinRtt(sock.m_extraAckedWinRtt),
125 m_extraAckedWinRttLength(sock.m_extraAckedWinRttLength),
126 m_ackEpochAckedResetThresh(sock.m_ackEpochAckedResetThresh),
127 m_extraAckedIdx(sock.m_extraAckedIdx),
128 m_ackEpochTime(sock.m_ackEpochTime),
129 m_ackEpochAcked(sock.m_ackEpochAcked),
130 m_hasSeenRtt(sock.m_hasSeenRtt)
131{
132 NS_LOG_FUNCTION(this);
133}
134
135const char* const TcpBbr::BbrModeName[BBR_PROBE_RTT + 1] = {
136 "BBR_STARTUP",
137 "BBR_DRAIN",
138 "BBR_PROBE_BW",
139 "BBR_PROBE_RTT",
140};
141
142void
144{
145 NS_LOG_FUNCTION(this << stream);
146 m_uv->SetStream(stream);
147}
148
149void
151{
152 NS_LOG_FUNCTION(this);
154 m_roundStart = false;
155 m_roundCount = 0;
156}
157
158void
160{
161 NS_LOG_FUNCTION(this);
162 m_isPipeFilled = false;
163 m_fullBandwidth = 0;
165}
166
167void
169{
170 NS_LOG_FUNCTION(this << tcb);
171
172 if (!tcb->m_pacing)
173 {
174 NS_LOG_WARN("BBR must use pacing");
175 tcb->m_pacing = true;
176 }
177
178 Time rtt;
179 if (tcb->m_minRtt != Time::Max())
180 {
181 rtt = MilliSeconds(std::max<long int>(tcb->m_minRtt.GetMilliSeconds(), 1));
182 m_hasSeenRtt = true;
183 }
184 else
185 {
186 rtt = MilliSeconds(1);
187 }
188
189 DataRate nominalBandwidth(tcb->m_cWnd * 8 / rtt.GetSeconds());
190 tcb->m_pacingRate = DataRate(m_pacingGain * nominalBandwidth.GetBitRate());
192 DataRate(tcb->m_cWnd * 8 / rtt.GetSeconds()),
193 0);
194}
195
196void
204
205void
207{
208 NS_LOG_FUNCTION(this << tcb << rs);
209 if (tcb->m_bytesInFlight.Get() == 0U && rs.m_isAppLimited)
210 {
211 m_idleRestart = true;
213 {
214 SetPacingRate(tcb, 1);
215 }
216 }
217}
218
219void
221{
222 NS_LOG_FUNCTION(this << tcb << gain);
223 DataRate rate(gain * m_maxBwFilter.GetBest().GetBitRate());
224 rate *= (1.f - m_pacingMargin);
225 rate = std::min(rate, tcb->m_maxPacingRate);
226
227 if (!m_hasSeenRtt && tcb->m_minRtt != Time::Max())
228 {
229 InitPacingRate(tcb);
230 }
231
232 if (m_isPipeFilled || rate > tcb->m_pacingRate)
233 {
234 tcb->m_pacingRate = rate;
235 NS_LOG_DEBUG("Pacing rate updated. New value: " << tcb->m_pacingRate);
236 }
237}
238
241{
242 NS_LOG_FUNCTION(this << tcb << gain);
243 if (m_minRtt == Time::Max())
244 {
245 return tcb->m_initialCWnd * tcb->m_segmentSize;
246 }
247 double quanta = 3 * m_sendQuantum;
248 double estimatedBdp = m_maxBwFilter.GetBest() * m_minRtt / 8.0;
249
251 {
252 return (gain * estimatedBdp) + quanta + (2 * tcb->m_segmentSize);
253 }
254 return (gain * estimatedBdp) + quanta;
255}
256
257void
265
266bool
268{
269 NS_LOG_FUNCTION(this << tcb << rs);
270 bool isFullLength = (Simulator::Now() - m_cycleStamp) > m_minRtt;
271 if (m_pacingGain == 1)
272 {
273 return isFullLength;
274 }
275 else if (m_pacingGain > 1)
276 {
277 return isFullLength &&
278 (rs.m_bytesLoss > 0 || rs.m_priorInFlight >= InFlight(tcb, m_pacingGain));
279 }
280 else
281 {
282 return isFullLength || rs.m_priorInFlight <= InFlight(tcb, 1);
283 }
284}
285
286void
288{
289 NS_LOG_FUNCTION(this << tcb << rs);
291 {
293 }
294}
295
296void
298{
299 NS_LOG_FUNCTION(this << rs);
301 {
302 return;
303 }
304
305 /* Check if Bottleneck bandwidth is still growing*/
307 {
310 return;
311 }
312
314 if (m_fullBandwidthCount >= 3)
315 {
316 NS_LOG_DEBUG("Pipe filled");
317 m_isPipeFilled = true;
318 }
319}
320
321void
329
330void
332{
333 NS_LOG_FUNCTION(this);
335 m_pacingGain = 1;
336 m_cWndGain = 2;
337 m_cycleIndex = GAIN_CYCLE_LENGTH - 1 - (int)m_uv->GetValue(0, 6);
339}
340
341void
343{
344 NS_LOG_FUNCTION(this << tcb);
346 {
347 EnterDrain();
348 tcb->m_ssThresh = InFlight(tcb, 1);
349 }
350
351 if (m_state == BbrMode_t::BBR_DRAIN && tcb->m_bytesInFlight <= InFlight(tcb, 1))
352 {
353 EnterProbeBW();
354 }
355}
356
357void
359{
360 NS_LOG_FUNCTION(this << tcb);
362 if (tcb->m_lastRtt >= Seconds(0) && (tcb->m_lastRtt <= m_minRtt || m_minRttExpired))
363 {
364 m_minRtt = tcb->m_lastRtt;
366 }
367}
368
369void
377
378void
380{
381 NS_LOG_FUNCTION(this << tcb);
383 {
384 m_priorCwnd = tcb->m_cWnd;
385 }
386 else
387 {
388 m_priorCwnd = std::max(m_priorCwnd, tcb->m_cWnd.Get());
389 }
390}
391
392void
394{
395 NS_LOG_FUNCTION(this << tcb);
396 tcb->m_cWnd = std::max(m_priorCwnd, tcb->m_cWnd.Get());
397}
398
399void
401{
402 NS_LOG_FUNCTION(this);
403 if (m_isPipeFilled)
404 {
405 EnterProbeBW();
406 }
407 else
408 {
409 EnterStartup();
410 }
411}
412
413void
415{
416 NS_LOG_FUNCTION(this << tcb);
417
418 uint32_t totalBytes = m_delivered + tcb->m_bytesInFlight.Get();
419 m_appLimited = (totalBytes > 0 ? totalBytes : 1);
420
421 if (m_probeRttDoneStamp == Seconds(0) && tcb->m_bytesInFlight <= m_minPipeCwnd)
422 {
424 m_probeRttRoundDone = false;
426 }
427 else if (m_probeRttDoneStamp != Seconds(0))
428 {
429 if (m_roundStart)
430 {
431 m_probeRttRoundDone = true;
432 }
434 {
436 RestoreCwnd(tcb);
437 ExitProbeRTT();
438 }
439 }
440}
441
442void
444{
445 NS_LOG_FUNCTION(this << tcb);
447 {
449 SaveCwnd(tcb);
451 }
452
454 {
455 HandleProbeRTT(tcb);
456 }
457
458 if (rs.m_delivered)
459 {
460 m_idleRestart = false;
461 }
462}
463
464void
466{
467 NS_LOG_FUNCTION(this << tcb);
468 m_sendQuantum = 1 * tcb->m_segmentSize;
469}
470
471void
477
480{
481 NS_LOG_FUNCTION(this);
482 uint32_t maxAggrBytes; // MaxBW * 0.1 secs
483 uint32_t aggrCwndBytes = 0;
484
486 {
487 maxAggrBytes = m_maxBwFilter.GetBest().GetBitRate() / (10 * 8);
488 aggrCwndBytes = m_extraAckedGain * std::max(m_extraAcked[0], m_extraAcked[1]);
489 aggrCwndBytes = std::min(aggrCwndBytes, maxAggrBytes);
490 }
491 return aggrCwndBytes;
492}
493
494void
496{
497 NS_LOG_FUNCTION(this << tcb << rs);
498 uint32_t expectedAcked;
499 uint32_t extraAck;
500 uint32_t epochProp;
501
502 if (!m_extraAckedGain || rs.m_ackedSacked <= 0 || rs.m_delivered < 0)
503 {
504 return;
505 }
506
507 if (m_roundStart)
508 {
509 m_extraAckedWinRtt = std::min<uint32_t>(31, m_extraAckedWinRtt + 1);
511 {
515 }
516 }
517
519 expectedAcked = m_maxBwFilter.GetBest().GetBitRate() * epochProp / 8;
520
521 if (m_ackEpochAcked <= expectedAcked ||
523 {
524 m_ackEpochAcked = 0;
526 expectedAcked = 0;
527 }
528
530 extraAck = m_ackEpochAcked - expectedAcked;
531 extraAck = std::min(extraAck, tcb->m_cWnd.Get());
532
533 if (extraAck > m_extraAcked[m_extraAckedIdx])
534 {
535 m_extraAcked[m_extraAckedIdx] = extraAck;
536 }
537}
538
539bool
541{
542 NS_LOG_FUNCTION(this << tcb << rs);
543 if (rs.m_bytesLoss > 0)
544 {
545 tcb->m_cWnd =
546 std::max((int)tcb->m_cWnd.Get() - (int)rs.m_bytesLoss, (int)tcb->m_segmentSize);
547 }
548
550 {
551 tcb->m_cWnd = std::max(tcb->m_cWnd.Get(), tcb->m_bytesInFlight.Get() + rs.m_ackedSacked);
552 return true;
553 }
554 return false;
555}
556
557void
559{
560 NS_LOG_FUNCTION(this << tcb);
562 {
563 tcb->m_cWnd = std::min(tcb->m_cWnd.Get(), m_minPipeCwnd);
564 }
565}
566
567void
569{
570 NS_LOG_FUNCTION(this << tcb << rs);
571
572 if (!rs.m_ackedSacked)
573 {
574 goto done;
575 }
576
577 if (tcb->m_congState == TcpSocketState::CA_RECOVERY)
578 {
579 if (ModulateCwndForRecovery(tcb, rs))
580 {
581 goto done;
582 }
583 }
584
585 UpdateTargetCwnd(tcb);
586
587 if (m_isPipeFilled)
588 {
589 tcb->m_cWnd = std::min(tcb->m_cWnd.Get() + (uint32_t)rs.m_ackedSacked, m_targetCWnd);
590 }
591 else if (tcb->m_cWnd < m_targetCWnd || m_delivered < tcb->m_initialCWnd * tcb->m_segmentSize)
592 {
593 tcb->m_cWnd = tcb->m_cWnd.Get() + rs.m_ackedSacked;
594 }
595 tcb->m_cWnd = std::max(tcb->m_cWnd.Get(), m_minPipeCwnd);
596 NS_LOG_DEBUG("Congestion window updated. New value:" << tcb->m_cWnd);
597
598done:
600}
601
602void
604{
605 NS_LOG_FUNCTION(this << tcb << rs);
607 {
609 m_roundCount++;
610 m_roundStart = true;
611 m_packetConservation = false;
612 }
613 else
614 {
615 m_roundStart = false;
616 }
617}
618
619void
621{
622 NS_LOG_FUNCTION(this << tcb << rs);
623
624 if (rs.m_delivered < 0 || rs.m_interval.IsZero())
625 {
626 return;
627 }
628
629 UpdateRound(tcb, rs);
630
632 {
634 }
635}
636
637void
639{
640 NS_LOG_FUNCTION(this << tcb << rs);
642 UpdateAckAggregation(tcb, rs);
643 CheckCyclePhase(tcb, rs);
644 CheckFullPipe(rs);
645 CheckDrain(tcb);
646 UpdateRTprop(tcb);
647 CheckProbeRTT(tcb, rs);
648}
649
650void
658
659void
661{
662 NS_LOG_FUNCTION(this << mode);
663 NS_LOG_DEBUG(Simulator::Now() << " Changing from " << BbrModeName[m_state] << " to "
664 << BbrModeName[mode]);
665 m_state = mode;
666}
667
670{
671 NS_LOG_FUNCTION(this);
672 return m_state;
673}
674
675double
677{
678 NS_LOG_FUNCTION(this);
679 return m_cWndGain;
680}
681
682double
684{
685 NS_LOG_FUNCTION(this);
686 return m_pacingGain;
687}
688
689std::string
691{
692 return "TcpBbr";
693}
694
695bool
697{
698 NS_LOG_FUNCTION(this);
699 return true;
700}
701
702void
706{
707 NS_LOG_FUNCTION(this << tcb << rs);
708 m_delivered = rc.m_delivered;
709 UpdateModelAndState(tcb, rs);
711}
712
713void
715{
716 NS_LOG_FUNCTION(this << tcb << newState);
717 if (newState == TcpSocketState::CA_OPEN && !m_isInitialized)
718 {
719 NS_LOG_DEBUG("CongestionStateSet triggered to CA_OPEN :: " << newState);
720 m_minRtt = tcb->m_srtt.Get() != Time::Max() ? tcb->m_srtt.Get() : Time::Max();
722 m_priorCwnd = tcb->m_cWnd;
723 tcb->m_ssThresh = tcb->m_initialSsThresh;
724 m_targetCWnd = tcb->m_cWnd;
725 m_minPipeCwnd = 4 * tcb->m_segmentSize;
726 m_sendQuantum = 1 * tcb->m_segmentSize;
727
729 InitFullPipe();
730 EnterStartup();
731 InitPacingRate(tcb);
734 m_extraAckedIdx = 0;
735 m_ackEpochAcked = 0;
736 m_extraAcked[0] = 0;
737 m_extraAcked[1] = 0;
738 m_isInitialized = true;
739 }
740 else if (newState == TcpSocketState::CA_LOSS)
741 {
742 NS_LOG_DEBUG("CongestionStateSet triggered to CA_LOSS :: " << newState);
743 SaveCwnd(tcb);
744 m_roundStart = true;
745 }
746 else if (newState == TcpSocketState::CA_RECOVERY)
747 {
748 NS_LOG_DEBUG("CongestionStateSet triggered to CA_RECOVERY :: " << newState);
749 SaveCwnd(tcb);
750 tcb->m_cWnd =
751 tcb->m_bytesInFlight.Get() + std::max(tcb->m_lastAckedSackedBytes, tcb->m_segmentSize);
753 }
754}
755
756void
758{
759 NS_LOG_FUNCTION(this << tcb << event);
761 {
762 NS_LOG_DEBUG("CwndEvent triggered to CA_EVENT_COMPLETE_CWR :: " << event);
763 m_packetConservation = false;
764 RestoreCwnd(tcb);
765 }
767 {
768 NS_LOG_DEBUG("CwndEvent triggered to CA_EVENT_TX_START :: " << event);
769 m_idleRestart = true;
771 m_ackEpochAcked = 0;
773 {
774 SetPacingRate(tcb, 1);
775 }
777 {
779 {
781 RestoreCwnd(tcb);
782 ExitProbeRTT();
783 }
784 }
785 }
786}
787
790{
791 NS_LOG_FUNCTION(this << tcb << bytesInFlight);
792 SaveCwnd(tcb);
793 return tcb->m_ssThresh;
794}
795
798{
799 return CopyObject<TcpBbr>(this);
800}
801
802} // namespace ns3
#define Max(a, b)
Class for representing data rates.
Definition data-rate.h:78
uint64_t GetBitRate() const
Get the underlying bitrate.
Definition data-rate.cc:234
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition double.h:31
friend Ptr< T > CopyObject(Ptr< T > object)
Copy an Object.
Definition object.h:581
Smart pointer class similar to boost::intrusive_ptr.
static Time Now()
Return the current simulation virtual time.
Definition simulator.cc:197
BBR congestion control algorithm.
Definition tcp-bbr.h:35
MaxBandwidthFilter_t m_maxBwFilter
Maximum bandwidth filter.
Definition tcp-bbr.h:341
bool m_hasSeenRtt
Have we seen RTT sample yet?
Definition tcp-bbr.h:391
Time m_minRttFilterLen
A constant specifying the length of the RTProp min filter window, default 10 secs.
Definition tcp-bbr.h:373
void ModulateCwndForProbeRTT(Ptr< TcpSocketState > tcb)
Modulates congestion window in BBR_PROBE_RTT.
Definition tcp-bbr.cc:558
uint32_t m_nextRoundDelivered
Denotes the end of a packet-timed round trip.
Definition tcp-bbr.h:352
BbrMode_t
BBR has the following 4 modes for deciding how fast to send:
Definition tcp-bbr.h:68
@ BBR_PROBE_RTT
Cut inflight to min to probe min_rtt.
Definition tcp-bbr.h:72
@ BBR_DRAIN
Drain any queue created during startup.
Definition tcp-bbr.h:70
@ BBR_STARTUP
Ramp up sending rate rapidly to fill pipe.
Definition tcp-bbr.h:69
@ BBR_PROBE_BW
Discover, share bw: pace around estimated bw.
Definition tcp-bbr.h:71
uint32_t m_roundCount
Count of packet-timed round trips.
Definition tcp-bbr.h:350
uint32_t m_priorCwnd
The last-known good congestion window.
Definition tcp-bbr.h:360
uint32_t m_extraAckedWinRttLength
Window length of extra acked window.
Definition tcp-bbr.h:385
bool m_minRttExpired
A boolean recording whether the BBR.RTprop has expired.
Definition tcp-bbr.h:372
virtual void SetStream(uint32_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Definition tcp-bbr.cc:143
TcpBbr()
Constructor.
Definition tcp-bbr.cc:84
uint32_t m_extraAckedIdx
Current index in extra acked array.
Definition tcp-bbr.h:388
std::string GetName() const override
Get the name of the congestion control algorithm.
Definition tcp-bbr.cc:690
void CongControl(Ptr< TcpSocketState > tcb, const TcpRateOps::TcpRateConnection &rc, const TcpRateOps::TcpRateSample &rs) override
Called when packets are delivered to update cwnd and pacing rate.
Definition tcp-bbr.cc:703
void CwndEvent(Ptr< TcpSocketState > tcb, const TcpSocketState::TcpCAEvent_t event) override
Trigger events/calculations on occurrence of congestion window event.
Definition tcp-bbr.cc:757
uint32_t GetSsThresh(Ptr< const TcpSocketState > tcb, uint32_t bytesInFlight) override
Get the slow start threshold after a loss event.
Definition tcp-bbr.cc:789
uint32_t m_bandwidthWindowLength
A constant specifying the length of the BBR.BtlBw max filter window, default 10 packet-timed round tr...
Definition tcp-bbr.h:342
double m_highGain
A constant specifying highest gain factor, default is 2.89.
Definition tcp-bbr.h:346
Time m_probeRttDuration
A constant specifying the minimum duration for which ProbeRTT state, default 200 millisecs.
Definition tcp-bbr.h:353
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 (...
Definition tcp-bbr.cc:287
uint32_t AckAggregationCwnd()
Find Cwnd increment based on ack aggregation.
Definition tcp-bbr.cc:479
bool m_idleRestart
When restarting from idle, set it true.
Definition tcp-bbr.h:361
Ptr< UniformRandomVariable > m_uv
Uniform Random Variable.
Definition tcp-bbr.h:378
static TypeId GetTypeId()
Get the type ID.
Definition tcp-bbr.cc:25
uint32_t m_minPipeCwnd
The minimal congestion window value BBR tries to target, default 4 Segment size.
Definition tcp-bbr.h:348
Ptr< TcpCongestionOps > Fork() override
Copy the congestion control algorithm across sockets.
Definition tcp-bbr.cc:797
uint32_t GetBbrState()
Gets BBR state.
Definition tcp-bbr.cc:669
bool HasCongControl() const override
Returns true when Congestion Control Algorithm implements CongControl.
Definition tcp-bbr.cc:696
TracedValue< double > m_cWndGain
The dynamic congestion window gain factor.
Definition tcp-bbr.h:345
double GetCwndGain()
Gets current cwnd gain.
Definition tcp-bbr.cc:676
void UpdateRound(Ptr< TcpSocketState > tcb, const TcpRateOps::TcpRateSample &rs)
Updates round counting related variables.
Definition tcp-bbr.cc:603
BbrMode_t m_state
Current state of BBR state machine.
Definition tcp-bbr.h:340
bool m_roundStart
A boolean that BBR sets to true once per packet-timed round trip.
Definition tcp-bbr.h:351
void AdvanceCyclePhase()
Advances pacing gain using cycle gain algorithm, while in BBR_PROBE_BW state.
Definition tcp-bbr.cc:258
double m_pacingMargin
BBR intentionally reduces the pacing rate by 1% to drain any standing queues.
Definition tcp-bbr.h:392
void EnterProbeBW()
Updates variables specific to BBR_PROBE_BW state.
Definition tcp-bbr.cc:331
double GetPacingGain()
Gets current pacing gain.
Definition tcp-bbr.cc:683
uint64_t m_delivered
The total amount of data in bytes delivered so far.
Definition tcp-bbr.h:379
void InitPacingRate(Ptr< TcpSocketState > tcb)
Initializes the pacing rate.
Definition tcp-bbr.cc:168
bool IsNextCyclePhase(Ptr< TcpSocketState > tcb, const TcpRateOps::TcpRateSample &rs)
Checks whether to move to next value of pacing gain while in BBR_PROBE_BW.
Definition tcp-bbr.cc:267
bool m_isInitialized
Set to true after first time initialization variables.
Definition tcp-bbr.h:377
void RestoreCwnd(Ptr< TcpSocketState > tcb)
Helper to restore the last-known good congestion window.
Definition tcp-bbr.cc:393
bool ModulateCwndForRecovery(Ptr< TcpSocketState > tcb, const TcpRateOps::TcpRateSample &rs)
Modulates congestion window in CA_RECOVERY.
Definition tcp-bbr.cc:540
static const char *const BbrModeName[BBR_PROBE_RTT+1]
Literal names of BBR mode for use in log messages.
Definition tcp-bbr.h:84
void UpdateRTprop(Ptr< TcpSocketState > tcb)
Updates minimum RTT.
Definition tcp-bbr.cc:358
void CheckDrain(Ptr< TcpSocketState > tcb)
Checks whether its time to enter BBR_DRAIN or BBR_PROBE_BW state.
Definition tcp-bbr.cc:342
void SetBbrState(BbrMode_t state)
Sets BBR state.
Definition tcp-bbr.cc:660
void UpdateBottleneckBandwidth(Ptr< TcpSocketState > tcb, const TcpRateOps::TcpRateSample &rs)
Updates maximum bottleneck.
Definition tcp-bbr.cc:620
void HandleRestartFromIdle(Ptr< TcpSocketState > tcb, const TcpRateOps::TcpRateSample &rs)
Updates pacing rate if socket is restarting from idle state.
Definition tcp-bbr.cc:206
static const double PACING_GAIN_CYCLE[]
BBR uses an eight-phase cycle with the given pacing_gain value in the BBR ProbeBW gain cycle.
Definition tcp-bbr.h:46
WindowedFilter< DataRate, MaxFilter< DataRate >, uint32_t, uint32_t > MaxBandwidthFilter_t
Definition of max bandwidth filter.
Definition tcp-bbr.h:79
bool m_isPipeFilled
A boolean that records whether BBR has filled the pipe.
Definition tcp-bbr.h:347
void EnterStartup()
Updates variables specific to BBR_STARTUP state.
Definition tcp-bbr.cc:197
void InitRoundCounting()
Initializes the round counting related variables.
Definition tcp-bbr.cc:150
void InitFullPipe()
Initializes the full pipe estimator.
Definition tcp-bbr.cc:159
void UpdateAckAggregation(Ptr< TcpSocketState > tcb, const TcpRateOps::TcpRateSample &rs)
Estimates max degree of aggregation.
Definition tcp-bbr.cc:495
bool m_packetConservation
Enable/Disable packet conservation mode.
Definition tcp-bbr.h:359
uint32_t InFlight(Ptr< TcpSocketState > tcb, double gain)
Estimates the target value for congestion window.
Definition tcp-bbr.cc:240
uint32_t m_extraAckedWinRtt
Age of extra acked in rtt.
Definition tcp-bbr.h:384
void SetPacingRate(Ptr< TcpSocketState > tcb, double gain)
Updates pacing rate based on network model.
Definition tcp-bbr.cc:220
void SaveCwnd(Ptr< const TcpSocketState > tcb)
Helper to remember the last-known good congestion window or the latest congestion window unmodulated ...
Definition tcp-bbr.cc:379
void EnterDrain()
Updates variables specific to BBR_DRAIN state.
Definition tcp-bbr.cc:322
void CongestionStateSet(Ptr< TcpSocketState > tcb, const TcpSocketState::TcpCongState_t newState) override
Trigger events/calculations specific to a congestion state.
Definition tcp-bbr.cc:714
Time m_probeRttDoneStamp
Time to exit from BBR_PROBE_RTT state.
Definition tcp-bbr.h:357
uint32_t m_extraAcked[2]
Maximum excess data acked in epoch.
Definition tcp-bbr.h:383
uint32_t m_appLimited
The index of the last transmitted packet marked as application-limited.
Definition tcp-bbr.h:380
void UpdateModelAndState(Ptr< TcpSocketState > tcb, const TcpRateOps::TcpRateSample &rs)
Updates BBR network model (Maximum bandwidth and minimum RTT).
Definition tcp-bbr.cc:638
Time m_minRttStamp
The wall clock time at which the current BBR.RTProp sample was obtained.
Definition tcp-bbr.h:375
void UpdateControlParameters(Ptr< TcpSocketState > tcb, const TcpRateOps::TcpRateSample &rs)
Updates control parameters congestion windowm, pacing rate, send quantum.
Definition tcp-bbr.cc:651
Time m_ackEpochTime
Starting of ACK sampling epoch time.
Definition tcp-bbr.h:389
Time m_cycleStamp
Last time gain cycle updated.
Definition tcp-bbr.h:370
void CheckFullPipe(const TcpRateOps::TcpRateSample &rs)
Identifies whether pipe or BDP is already full.
Definition tcp-bbr.cc:297
TracedValue< Time > m_minRtt
Estimated two-way round-trip propagation delay of the path, estimated from the windowed minimum recen...
Definition tcp-bbr.h:365
void EnterProbeRTT()
Updates variables specific to BBR_PROBE_RTT state.
Definition tcp-bbr.cc:370
DataRate m_fullBandwidth
Value of full bandwidth recorded.
Definition tcp-bbr.h:363
void HandleProbeRTT(Ptr< TcpSocketState > tcb)
Handles the steps for BBR_PROBE_RTT state.
Definition tcp-bbr.cc:414
uint32_t m_targetCWnd
Target value for congestion window, adapted to the estimated BDP.
Definition tcp-bbr.h:362
uint32_t m_sendQuantum
The maximum size of a data aggregate scheduled and transmitted together.
Definition tcp-bbr.h:368
void SetSendQuantum(Ptr< TcpSocketState > tcb)
Updates send quantum based on the network model.
Definition tcp-bbr.cc:465
uint32_t m_ackEpochAckedResetThresh
Max allowed val for m_ackEpochAcked, after which sampling epoch is reset.
Definition tcp-bbr.h:386
void ExitProbeRTT()
Called on exiting from BBR_PROBE_RTT state, it eithers invoke EnterProbeBW () or EnterStartup ()
Definition tcp-bbr.cc:400
bool m_probeRttRoundDone
True when it is time to exit BBR_PROBE_RTT.
Definition tcp-bbr.h:358
uint32_t m_fullBandwidthCount
Count of full bandwidth recorded consistently.
Definition tcp-bbr.h:364
void UpdateTargetCwnd(Ptr< TcpSocketState > tcb)
Updates target congestion window.
Definition tcp-bbr.cc:472
uint32_t m_cycleIndex
Current index of gain cycle.
Definition tcp-bbr.h:371
uint32_t m_extraAckedGain
Gain factor for adding extra ack to cwnd.
Definition tcp-bbr.h:382
void CheckProbeRTT(Ptr< TcpSocketState > tcb, const TcpRateOps::TcpRateSample &rs)
This method handles the steps related to the ProbeRTT state.
Definition tcp-bbr.cc:443
static const uint8_t GAIN_CYCLE_LENGTH
The number of phases in the BBR ProbeBW gain cycle.
Definition tcp-bbr.h:40
void SetCwnd(Ptr< TcpSocketState > tcb, const TcpRateOps::TcpRateSample &rs)
Updates congestion window based on the network model.
Definition tcp-bbr.cc:568
TracedValue< double > m_pacingGain
The dynamic pacing gain factor.
Definition tcp-bbr.h:344
uint32_t m_ackEpochAcked
Bytes ACked in sampling epoch.
Definition tcp-bbr.h:390
Congestion control abstract class.
TcpCAEvent_t
Congestion avoidance events.
@ CA_EVENT_COMPLETE_CWR
end of congestion recovery
@ CA_EVENT_TX_START
first transmit when no packets in flight
TcpCongState_t
Definition of the Congestion state machine.
@ CA_RECOVERY
CWND was reduced, we are fast-retransmitting.
@ CA_LOSS
CWND was reduced due to RTO timeout or SACK reneging.
@ CA_OPEN
Normal state, no dubious events.
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Definition nstime.h:392
static Time Max()
Maximum representable Time Not to be confused with Max(Time,Time).
Definition nstime.h:286
bool IsZero() const
Exactly equivalent to t == 0.
Definition nstime.h:304
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
Hold an unsigned integer type.
Definition uinteger.h:34
void Update(T new_sample, TimeT new_time)
Updates best estimates with |sample|, and expires and updates best estimates as necessary.
T GetBest() const
Returns Max/Min value so far among the windowed samples.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition log.h:257
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition log.h:250
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1308
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition nstime.h:1320
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeUintegerChecker()
Definition uinteger.h:85
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Definition nstime.h:1396
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Definition uinteger.h:35
Ptr< const AttributeChecker > MakeDoubleChecker()
Definition double.h:82
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition double.h:32
Ptr< const AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.
Definition nstime.h:1416
Information about the connection rate.
Rate Sample structure.
bool m_isAppLimited
Indicates whether the rate sample is application-limited.
uint32_t m_ackedSacked
The amount of data acked and sacked in the last received ack.
DataRate m_deliveryRate
The delivery rate sample.
uint32_t m_priorInFlight
The value if bytes in flight prior to last received ack.
Time m_interval
The length of the sampling interval.
uint32_t m_priorDelivered
The delivered count of the most recent packet delivered.
int32_t m_delivered
The amount of data marked as delivered over the sampling interval.
uint32_t m_bytesLoss
The amount of data marked as lost from the most recent ack received.