A Discrete-Event Network Simulator
API
tcp-bbr.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 NITK Surathkal
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Authors: Vivek Jain <jain.vivek.anand@gmail.com>
18 * Viyom Mittal <viyommittal@gmail.com>
19 * Mohit P. Tahiliani <tahiliani@nitk.edu.in>
20 */
21
22#include "tcp-bbr.h"
23
24#include "ns3/log.h"
25#include "ns3/simulator.h"
26
27namespace ns3
28{
29
32
33const double TcpBbr::PACING_GAIN_CYCLE[] = {5.0 / 4, 3.0 / 4, 1, 1, 1, 1, 1, 1};
34
35TypeId
37{
38 static TypeId tid =
39 TypeId("ns3::TcpBbr")
41 .AddConstructor<TcpBbr>()
42 .SetGroupName("Internet")
43 .AddAttribute("Stream",
44 "Random number stream (default is set to 4 to align with Linux results)",
47 MakeUintegerChecker<uint32_t>())
48 .AddAttribute("HighGain",
49 "Value of high gain",
50 DoubleValue(2.89),
52 MakeDoubleChecker<double>())
53 .AddAttribute("BwWindowLength",
54 "Length of bandwidth windowed filter",
55 UintegerValue(10),
57 MakeUintegerChecker<uint32_t>())
58 .AddAttribute("RttWindowLength",
59 "Length of RTT windowed filter",
60 TimeValue(Seconds(10)),
63 .AddAttribute("ProbeRttDuration",
64 "Time to be spent in PROBE_RTT phase",
68 .AddAttribute("ExtraAckedRttWindowLength",
69 "Window length of extra acked window",
72 MakeUintegerChecker<uint32_t>())
73 .AddAttribute(
74 "AckEpochAckedResetThresh",
75 "Max allowed val for m_ackEpochAcked, after which sampling epoch is reset",
76 UintegerValue(1 << 12),
78 MakeUintegerChecker<uint32_t>());
79 return tid;
80}
81
84{
85 NS_LOG_FUNCTION(this);
86 m_uv = CreateObject<UniformRandomVariable>();
87}
88
90 : TcpCongestionOps(sock),
91 m_bandwidthWindowLength(sock.m_bandwidthWindowLength),
92 m_pacingGain(sock.m_pacingGain),
93 m_cWndGain(sock.m_cWndGain),
94 m_highGain(sock.m_highGain),
95 m_isPipeFilled(sock.m_isPipeFilled),
96 m_minPipeCwnd(sock.m_minPipeCwnd),
97 m_roundCount(sock.m_roundCount),
98 m_roundStart(sock.m_roundStart),
99 m_nextRoundDelivered(sock.m_nextRoundDelivered),
100 m_probeRttDuration(sock.m_probeRttDuration),
101 m_probeRtPropStamp(sock.m_probeRtPropStamp),
102 m_probeRttDoneStamp(sock.m_probeRttDoneStamp),
103 m_probeRttRoundDone(sock.m_probeRttRoundDone),
104 m_packetConservation(sock.m_packetConservation),
105 m_priorCwnd(sock.m_priorCwnd),
106 m_idleRestart(sock.m_idleRestart),
107 m_targetCWnd(sock.m_targetCWnd),
108 m_fullBandwidth(sock.m_fullBandwidth),
109 m_fullBandwidthCount(sock.m_fullBandwidthCount),
110 m_rtProp(Time::Max()),
111 m_sendQuantum(sock.m_sendQuantum),
112 m_cycleStamp(sock.m_cycleStamp),
113 m_cycleIndex(sock.m_cycleIndex),
114 m_rtPropExpired(sock.m_rtPropExpired),
115 m_rtPropFilterLen(sock.m_rtPropFilterLen),
116 m_rtPropStamp(sock.m_rtPropStamp),
117 m_isInitialized(sock.m_isInitialized),
118 m_uv(sock.m_uv),
119 m_delivered(sock.m_delivered),
120 m_appLimited(sock.m_appLimited),
121 m_txItemDelivered(sock.m_txItemDelivered),
122 m_extraAckedGain(sock.m_extraAckedGain),
123 m_extraAckedWinRtt(sock.m_extraAckedWinRtt),
124 m_extraAckedWinRttLength(sock.m_extraAckedWinRttLength),
125 m_ackEpochAckedResetThresh(sock.m_ackEpochAckedResetThresh),
126 m_extraAckedIdx(sock.m_extraAckedIdx),
127 m_ackEpochTime(sock.m_ackEpochTime),
128 m_ackEpochAcked(sock.m_ackEpochAcked),
129 m_hasSeenRtt(sock.m_hasSeenRtt)
130{
131 NS_LOG_FUNCTION(this);
132}
133
134const char* const TcpBbr::BbrModeName[BBR_PROBE_RTT + 1] = {"BBR_STARTUP",
135 "BBR_DRAIN",
136 "BBR_PROBE_BW",
137 "BBR_PROBE_RTT"};
138
139void
141{
142 NS_LOG_FUNCTION(this << stream);
143 m_uv->SetStream(stream);
144}
145
146void
148{
149 NS_LOG_FUNCTION(this);
151 m_roundStart = false;
152 m_roundCount = 0;
153}
154
155void
157{
158 NS_LOG_FUNCTION(this);
159 m_isPipeFilled = false;
160 m_fullBandwidth = 0;
162}
163
164void
166{
167 NS_LOG_FUNCTION(this << tcb);
168
169 if (!tcb->m_pacing)
170 {
171 NS_LOG_WARN("BBR must use pacing");
172 tcb->m_pacing = true;
173 }
174
175 Time rtt;
176 if (tcb->m_minRtt != Time::Max())
177 {
178 rtt = MilliSeconds(std::max<long int>(tcb->m_minRtt.GetMilliSeconds(), 1));
179 m_hasSeenRtt = true;
180 }
181 else
182 {
183 rtt = MilliSeconds(1);
184 }
185
186 DataRate nominalBandwidth(tcb->m_cWnd * 8 / rtt.GetSeconds());
187 tcb->m_pacingRate = DataRate(m_pacingGain * nominalBandwidth.GetBitRate());
189 DataRate(tcb->m_cWnd * 8 / rtt.GetSeconds()),
190 0);
191}
192
193void
195{
196 NS_LOG_FUNCTION(this);
197 SetBbrState(BbrMode_t::BBR_STARTUP);
200}
201
202void
204{
205 NS_LOG_FUNCTION(this << tcb << rs);
206 if (tcb->m_bytesInFlight.Get() == 0U && rs.m_isAppLimited)
207 {
208 m_idleRestart = true;
209 if (m_state == BbrMode_t::BBR_PROBE_BW)
210 {
211 SetPacingRate(tcb, 1);
212 }
213 }
214}
215
216void
218{
219 NS_LOG_FUNCTION(this << tcb << gain);
220 DataRate rate(gain * m_maxBwFilter.GetBest().GetBitRate());
221 rate = std::min(rate, tcb->m_maxPacingRate);
222
223 if (!m_hasSeenRtt && tcb->m_minRtt != Time::Max())
224 {
225 InitPacingRate(tcb);
226 }
227
228 if (m_isPipeFilled || rate > tcb->m_pacingRate)
229 {
230 tcb->m_pacingRate = rate;
231 }
232}
233
236{
237 NS_LOG_FUNCTION(this << tcb << gain);
238 if (m_rtProp == Time::Max())
239 {
240 return tcb->m_initialCWnd * tcb->m_segmentSize;
241 }
242 double quanta = 3 * m_sendQuantum;
243 double estimatedBdp = m_maxBwFilter.GetBest() * m_rtProp / 8.0;
244
245 if (m_state == BbrMode_t::BBR_PROBE_BW && m_cycleIndex == 0)
246 {
247 return (gain * estimatedBdp) + quanta + (2 * tcb->m_segmentSize);
248 }
249 return (gain * estimatedBdp) + quanta;
250}
251
252void
254{
255 NS_LOG_FUNCTION(this);
259}
260
261bool
263{
264 NS_LOG_FUNCTION(this << tcb << rs);
265 bool isFullLength = (Simulator::Now() - m_cycleStamp) > m_rtProp;
266 if (m_pacingGain == 1)
267 {
268 return isFullLength;
269 }
270 else if (m_pacingGain > 1)
271 {
272 return isFullLength &&
273 (rs.m_bytesLoss > 0 || rs.m_priorInFlight >= InFlight(tcb, m_pacingGain));
274 }
275 else
276 {
277 return isFullLength || rs.m_priorInFlight <= InFlight(tcb, 1);
278 }
279}
280
281void
283{
284 NS_LOG_FUNCTION(this << tcb << rs);
285 if (m_state == BbrMode_t::BBR_PROBE_BW && IsNextCyclePhase(tcb, rs))
286 {
288 }
289}
290
291void
293{
294 NS_LOG_FUNCTION(this << rs);
296 {
297 return;
298 }
299
300 /* Check if Bottleneck bandwidth is still growing*/
302 {
305 return;
306 }
307
309 if (m_fullBandwidthCount >= 3)
310 {
311 NS_LOG_DEBUG("Pipe filled");
312 m_isPipeFilled = true;
313 }
314}
315
316void
318{
319 NS_LOG_FUNCTION(this);
320 SetBbrState(BbrMode_t::BBR_DRAIN);
321 m_pacingGain = 1.0 / m_highGain;
323}
324
325void
327{
328 NS_LOG_FUNCTION(this);
329 SetBbrState(BbrMode_t::BBR_PROBE_BW);
330 m_pacingGain = 1;
331 m_cWndGain = 2;
334}
335
336void
338{
339 NS_LOG_FUNCTION(this << tcb);
340 if (m_state == BbrMode_t::BBR_STARTUP && m_isPipeFilled)
341 {
342 EnterDrain();
343 tcb->m_ssThresh = InFlight(tcb, 1);
344 }
345
346 if (m_state == BbrMode_t::BBR_DRAIN && tcb->m_bytesInFlight <= InFlight(tcb, 1))
347 {
348 EnterProbeBW();
349 }
350}
351
352void
354{
355 NS_LOG_FUNCTION(this << tcb);
357 if (tcb->m_lastRtt >= Seconds(0) && (tcb->m_lastRtt <= m_rtProp || m_rtPropExpired))
358 {
359 m_rtProp = tcb->m_lastRtt;
361 }
362}
363
364void
366{
367 NS_LOG_FUNCTION(this);
368 SetBbrState(BbrMode_t::BBR_PROBE_RTT);
369 m_pacingGain = 1;
370 m_cWndGain = 1;
371}
372
373void
375{
376 NS_LOG_FUNCTION(this << tcb);
377 if (tcb->m_congState != TcpSocketState::CA_RECOVERY && m_state != BbrMode_t::BBR_PROBE_RTT)
378 {
379 m_priorCwnd = tcb->m_cWnd;
380 }
381 else
382 {
383 m_priorCwnd = std::max(m_priorCwnd, tcb->m_cWnd.Get());
384 }
385}
386
387void
389{
390 NS_LOG_FUNCTION(this << tcb);
391 tcb->m_cWnd = std::max(m_priorCwnd, tcb->m_cWnd.Get());
392}
393
394void
396{
397 NS_LOG_FUNCTION(this);
398 if (m_isPipeFilled)
399 {
400 EnterProbeBW();
401 }
402 else
403 {
404 EnterStartup();
405 }
406}
407
408void
410{
411 NS_LOG_FUNCTION(this << tcb);
413
415 {
417 m_probeRttRoundDone = false;
419 }
420 else if (m_probeRttDoneStamp != Seconds(0))
421 {
422 if (m_roundStart)
423 {
424 m_probeRttRoundDone = true;
425 }
427 {
429 RestoreCwnd(tcb);
430 ExitProbeRTT();
431 }
432 }
433}
434
435void
437{
438 NS_LOG_FUNCTION(this << tcb);
439 if (m_state != BbrMode_t::BBR_PROBE_RTT && m_rtPropExpired && !m_idleRestart)
440 {
442 SaveCwnd(tcb);
444 }
445
446 if (m_state == BbrMode_t::BBR_PROBE_RTT)
447 {
448 HandleProbeRTT(tcb);
449 }
450
451 if (rs.m_delivered)
452 {
453 m_idleRestart = false;
454 }
455}
456
457void
459{
460 NS_LOG_FUNCTION(this << tcb);
461 m_sendQuantum = 1 * tcb->m_segmentSize;
462}
463
464void
466{
467 NS_LOG_FUNCTION(this << tcb);
469}
470
473{
474 uint32_t maxAggrBytes; // MaxBW * 0.1 secs
475 uint32_t aggrCwndBytes = 0;
476
478 {
479 maxAggrBytes = m_maxBwFilter.GetBest().GetBitRate() / (10 * 8);
480 aggrCwndBytes = m_extraAckedGain * std::max(m_extraAcked[0], m_extraAcked[1]);
481 aggrCwndBytes = std::min(aggrCwndBytes, maxAggrBytes);
482 }
483 return aggrCwndBytes;
484}
485
486void
488{
489 uint32_t expectedAcked;
490 uint32_t extraAck;
491 uint32_t epochProp;
492
493 if (!m_extraAckedGain || rs.m_ackedSacked <= 0 || rs.m_delivered < 0)
494 {
495 return;
496 }
497
498 if (m_roundStart)
499 {
500 m_extraAckedWinRtt = std::min<uint32_t>(31, m_extraAckedWinRtt + 1);
502 {
506 }
507 }
508
510 expectedAcked = m_maxBwFilter.GetBest().GetBitRate() * epochProp / 8;
511
512 if (m_ackEpochAcked <= expectedAcked ||
514 {
515 m_ackEpochAcked = 0;
517 expectedAcked = 0;
518 }
519
521 extraAck = m_ackEpochAcked - expectedAcked;
522 extraAck = std::min(extraAck, tcb->m_cWnd.Get());
523
524 if (extraAck > m_extraAcked[m_extraAckedIdx])
525 {
526 m_extraAcked[m_extraAckedIdx] = extraAck;
527 }
528}
529
530bool
532{
533 NS_LOG_FUNCTION(this << tcb << rs);
534 if (rs.m_bytesLoss > 0)
535 {
536 tcb->m_cWnd =
537 std::max((int)tcb->m_cWnd.Get() - (int)rs.m_bytesLoss, (int)tcb->m_segmentSize);
538 }
539
541 {
542 tcb->m_cWnd = std::max(tcb->m_cWnd.Get(), tcb->m_bytesInFlight.Get() + rs.m_ackedSacked);
543 return true;
544 }
545 return false;
546}
547
548void
550{
551 NS_LOG_FUNCTION(this << tcb);
552 if (m_state == BbrMode_t::BBR_PROBE_RTT)
553 {
554 tcb->m_cWnd = std::min(tcb->m_cWnd.Get(), m_minPipeCwnd);
555 }
556}
557
558void
560{
561 NS_LOG_FUNCTION(this << tcb << rs);
562
563 if (!rs.m_ackedSacked)
564 {
565 goto done;
566 }
567
569 {
570 if (ModulateCwndForRecovery(tcb, rs))
571 {
572 goto done;
573 }
574 }
575
576 UpdateTargetCwnd(tcb);
577
578 if (m_isPipeFilled)
579 {
581 }
582 else if (tcb->m_cWnd < m_targetCWnd || m_delivered < tcb->m_initialCWnd * tcb->m_segmentSize)
583 {
584 tcb->m_cWnd = tcb->m_cWnd.Get() + rs.m_ackedSacked;
585 }
586 tcb->m_cWnd = std::max(tcb->m_cWnd.Get(), m_minPipeCwnd);
587
588done:
590}
591
592void
594{
595 NS_LOG_FUNCTION(this << tcb << rs);
597 {
599 m_roundCount++;
600 m_roundStart = true;
601 m_packetConservation = false;
602 }
603 else
604 {
605 m_roundStart = false;
606 }
607}
608
609void
611{
612 NS_LOG_FUNCTION(this << tcb << rs);
613
614 if (rs.m_deliveryRate == 0)
615 {
616 return;
617 }
618
619 UpdateRound(tcb, rs);
620
622 {
624 }
625}
626
627void
629{
630 NS_LOG_FUNCTION(this << tcb << rs);
631 UpdateBtlBw(tcb, rs);
632 UpdateAckAggregation(tcb, rs);
633 CheckCyclePhase(tcb, rs);
634 CheckFullPipe(rs);
635 CheckDrain(tcb);
636 UpdateRTprop(tcb);
637 CheckProbeRTT(tcb, rs);
638}
639
640void
642{
643 NS_LOG_FUNCTION(this << tcb << rs);
645 SetSendQuantum(tcb);
646 SetCwnd(tcb, rs);
647}
648
649void
651{
652 NS_LOG_FUNCTION(this << mode);
653 NS_LOG_DEBUG(Simulator::Now() << " Changing from " << BbrModeName[m_state] << " to "
654 << BbrModeName[mode]);
655 m_state = mode;
656}
657
660{
661 NS_LOG_FUNCTION(this);
662 return m_state;
663}
664
665double
667{
668 NS_LOG_FUNCTION(this);
669 return m_cWndGain;
670}
671
672double
674{
675 NS_LOG_FUNCTION(this);
676 return m_pacingGain;
677}
678
679std::string
681{
682 return "TcpBbr";
683}
684
685bool
687{
688 NS_LOG_FUNCTION(this);
689 return true;
690}
691
692void
696{
697 NS_LOG_FUNCTION(this << tcb << rs);
700 UpdateModelAndState(tcb, rs);
702}
703
704void
706{
707 NS_LOG_FUNCTION(this << tcb << newState);
708 if (newState == TcpSocketState::CA_OPEN && !m_isInitialized)
709 {
710 NS_LOG_DEBUG("CongestionStateSet triggered to CA_OPEN :: " << newState);
711 m_rtProp = tcb->m_lastRtt.Get() != Time::Max() ? tcb->m_lastRtt.Get() : Time::Max();
713 m_priorCwnd = tcb->m_cWnd;
714 tcb->m_ssThresh = tcb->m_initialSsThresh;
715 m_targetCWnd = tcb->m_cWnd;
716 m_minPipeCwnd = 4 * tcb->m_segmentSize;
717 m_sendQuantum = 1 * tcb->m_segmentSize;
718
720 InitFullPipe();
721 EnterStartup();
722 InitPacingRate(tcb);
725 m_extraAckedIdx = 0;
726 m_ackEpochAcked = 0;
727 m_extraAcked[0] = 0;
728 m_extraAcked[1] = 0;
729 m_isInitialized = true;
730 }
731 else if (newState == TcpSocketState::CA_LOSS)
732 {
733 NS_LOG_DEBUG("CongestionStateSet triggered to CA_LOSS :: " << newState);
734 SaveCwnd(tcb);
735 m_roundStart = true;
736 }
737 else if (newState == TcpSocketState::CA_RECOVERY)
738 {
739 NS_LOG_DEBUG("CongestionStateSet triggered to CA_RECOVERY :: " << newState);
740 SaveCwnd(tcb);
741 tcb->m_cWnd =
744 }
745}
746
747void
749{
750 NS_LOG_FUNCTION(this << tcb << event);
752 {
753 NS_LOG_DEBUG("CwndEvent triggered to CA_EVENT_COMPLETE_CWR :: " << event);
754 m_packetConservation = false;
755 RestoreCwnd(tcb);
756 }
758 {
759 NS_LOG_DEBUG("CwndEvent triggered to CA_EVENT_TX_START :: " << event);
760 m_idleRestart = true;
762 m_ackEpochAcked = 0;
763 if (m_state == BbrMode_t::BBR_PROBE_BW)
764 {
765 SetPacingRate(tcb, 1);
766 }
767 else if (m_state == BbrMode_t::BBR_PROBE_RTT)
768 {
770 {
772 RestoreCwnd(tcb);
773 ExitProbeRTT();
774 }
775 }
776 }
777}
778
781{
782 NS_LOG_FUNCTION(this << tcb << bytesInFlight);
783 SaveCwnd(tcb);
784 return tcb->m_ssThresh;
785}
786
789{
790 return CopyObject<TcpBbr>(this);
791}
792
793} // namespace ns3
#define min(a, b)
Definition: 80211b.c:42
#define max(a, b)
Definition: 80211b.c:43
Class for representing data rates.
Definition: data-rate.h:90
uint64_t GetBitRate() const
Get the underlying bitrate.
Definition: data-rate.cc:305
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:42
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
static Time Now()
Return the current simulation virtual time.
Definition: simulator.cc:199
BBR congestion control algorithm.
Definition: tcp-bbr.h:45
MaxBandwidthFilter_t m_maxBwFilter
Maximum bandwidth filter.
Definition: tcp-bbr.h:351
bool m_hasSeenRtt
Have we seen RTT sample yet?
Definition: tcp-bbr.h:403
double m_cWndGain
The dynamic congestion window gain factor.
Definition: tcp-bbr.h:355
void ModulateCwndForProbeRTT(Ptr< TcpSocketState > tcb)
Modulates congestion window in BBR_PROBE_RTT.
Definition: tcp-bbr.cc:549
uint32_t m_nextRoundDelivered
Denotes the end of a packet-timed round trip.
Definition: tcp-bbr.h:362
BbrMode_t
BBR has the following 4 modes for deciding how fast to send:
Definition: tcp-bbr.h:78
uint32_t m_roundCount
Count of packet-timed round trips.
Definition: tcp-bbr.h:360
uint32_t m_priorCwnd
The last-known good congestion window.
Definition: tcp-bbr.h:370
uint32_t m_extraAckedWinRttLength
Window length of extra acked window.
Definition: tcp-bbr.h:397
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:140
TcpBbr()
Constructor.
Definition: tcp-bbr.cc:82
uint32_t m_extraAckedIdx
Current index in extra acked array.
Definition: tcp-bbr.h:400
std::string GetName() const override
Get the name of the congestion control algorithm.
Definition: tcp-bbr.cc:680
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:693
bool m_rtPropExpired
A boolean recording whether the BBR.RTprop has expired.
Definition: tcp-bbr.h:382
void CwndEvent(Ptr< TcpSocketState > tcb, const TcpSocketState::TcpCAEvent_t event) override
Trigger events/calculations on occurrence of congestion window event.
Definition: tcp-bbr.cc:748
uint32_t GetSsThresh(Ptr< const TcpSocketState > tcb, uint32_t bytesInFlight) override
Get the slow start threshold after a loss event.
Definition: tcp-bbr.cc:780
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:352
double m_highGain
A constant specifying highest gain factor, default is 2.89.
Definition: tcp-bbr.h:356
Time m_probeRttDuration
A constant specifying the minimum duration for which ProbeRTT state, default 200 millisecs.
Definition: tcp-bbr.h:363
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:282
uint32_t AckAggregationCwnd()
Find Cwnd increment based on ack aggregation.
Definition: tcp-bbr.cc:472
bool m_idleRestart
When restarting from idle, set it true.
Definition: tcp-bbr.h:371
Ptr< UniformRandomVariable > m_uv
Uniform Random Variable.
Definition: tcp-bbr.h:388
Time m_rtPropStamp
The wall clock time at which the current BBR.RTProp sample was obtained.
Definition: tcp-bbr.h:385
void UpdateBtlBw(Ptr< TcpSocketState > tcb, const TcpRateOps::TcpRateSample &rs)
Updates maximum bottleneck.
Definition: tcp-bbr.cc:610
static TypeId GetTypeId()
Get the type ID.
Definition: tcp-bbr.cc:36
uint32_t m_minPipeCwnd
The minimal congestion window value BBR tries to target, default 4 Segment size.
Definition: tcp-bbr.h:358
Ptr< TcpCongestionOps > Fork() override
Copy the congestion control algorithm across sockets.
Definition: tcp-bbr.cc:788
uint32_t GetBbrState()
Gets BBR state.
Definition: tcp-bbr.cc:659
bool HasCongControl() const override
Returns true when Congestion Control Algorithm implements CongControl.
Definition: tcp-bbr.cc:686
double GetCwndGain()
Gets current cwnd gain.
Definition: tcp-bbr.cc:666
void UpdateRound(Ptr< TcpSocketState > tcb, const TcpRateOps::TcpRateSample &rs)
Updates round counting related variables.
Definition: tcp-bbr.cc:593
BbrMode_t m_state
Current state of BBR state machine.
Definition: tcp-bbr.h:350
bool m_roundStart
A boolean that BBR sets to true once per packet-timed round trip.
Definition: tcp-bbr.h:361
void AdvanceCyclePhase()
Advances pacing gain using cycle gain algorithm, while in BBR_PROBE_BW state.
Definition: tcp-bbr.cc:253
void EnterProbeBW()
Updates variables specific to BBR_PROBE_BW state.
Definition: tcp-bbr.cc:326
double GetPacingGain()
Gets current pacing gain.
Definition: tcp-bbr.cc:673
uint64_t m_delivered
The total amount of data in bytes delivered so far.
Definition: tcp-bbr.h:389
void InitPacingRate(Ptr< TcpSocketState > tcb)
Intializes the pacing rate.
Definition: tcp-bbr.cc:165
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:262
bool m_isInitialized
Set to true after first time initializtion variables.
Definition: tcp-bbr.h:387
void RestoreCwnd(Ptr< TcpSocketState > tcb)
Helper to restore the last-known good congestion window.
Definition: tcp-bbr.cc:388
bool ModulateCwndForRecovery(Ptr< TcpSocketState > tcb, const TcpRateOps::TcpRateSample &rs)
Modulates congestion window in CA_RECOVERY.
Definition: tcp-bbr.cc:531
double m_pacingGain
The dynamic pacing gain factor.
Definition: tcp-bbr.h:354
static const char *const BbrModeName[BBR_PROBE_RTT+1]
Literal names of BBR mode for use in log messages.
Definition: tcp-bbr.h:94
void UpdateRTprop(Ptr< TcpSocketState > tcb)
Updates minimum RTT.
Definition: tcp-bbr.cc:353
void CheckDrain(Ptr< TcpSocketState > tcb)
Checks whether its time to enter BBR_DRAIN or BBR_PROBE_BW state.
Definition: tcp-bbr.cc:337
void SetBbrState(BbrMode_t state)
Sets BBR state.
Definition: tcp-bbr.cc:650
void HandleRestartFromIdle(Ptr< TcpSocketState > tcb, const TcpRateOps::TcpRateSample &rs)
Updates pacing rate if socket is restarting from idle state.
Definition: tcp-bbr.cc:203
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:56
WindowedFilter< DataRate, MaxFilter< DataRate >, uint32_t, uint32_t > MaxBandwidthFilter_t
Definition of max bandwidth filter.
Definition: tcp-bbr.h:89
bool m_isPipeFilled
A boolean that records whether BBR has filled the pipe.
Definition: tcp-bbr.h:357
void EnterStartup()
Updates variables specific to BBR_STARTUP state.
Definition: tcp-bbr.cc:194
void InitRoundCounting()
Intializes the round counting related variables.
Definition: tcp-bbr.cc:147
void InitFullPipe()
Intializes the full pipe estimator.
Definition: tcp-bbr.cc:156
void UpdateAckAggregation(Ptr< TcpSocketState > tcb, const TcpRateOps::TcpRateSample &rs)
Estimates max degree of aggregation.
Definition: tcp-bbr.cc:487
uint32_t m_txItemDelivered
The number of bytes already delivered at the time of new packet transmission.
Definition: tcp-bbr.h:392
bool m_packetConservation
Enable/Disable packet conservation mode.
Definition: tcp-bbr.h:369
uint32_t InFlight(Ptr< TcpSocketState > tcb, double gain)
Estimates the target value for congestion window.
Definition: tcp-bbr.cc:235
uint32_t m_extraAckedWinRtt
Age of extra acked in rtt.
Definition: tcp-bbr.h:396
void SetPacingRate(Ptr< TcpSocketState > tcb, double gain)
Updates pacing rate based on network model.
Definition: tcp-bbr.cc:217
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:374
void EnterDrain()
Updates variables specific to BBR_DRAIN state.
Definition: tcp-bbr.cc:317
void CongestionStateSet(Ptr< TcpSocketState > tcb, const TcpSocketState::TcpCongState_t newState) override
Trigger events/calculations specific to a congestion state.
Definition: tcp-bbr.cc:705
Time m_probeRttDoneStamp
Time to exit from BBR_PROBE_RTT state.
Definition: tcp-bbr.h:367
uint32_t m_extraAcked[2]
Maximum excess data acked in epoch.
Definition: tcp-bbr.h:395
Time m_rtProp
Estimated two-way round-trip propagation delay of the path, estimated from the windowed minimum recen...
Definition: tcp-bbr.h:375
uint32_t m_appLimited
The index of the last transmitted packet marked as application-limited.
Definition: tcp-bbr.h:390
void UpdateModelAndState(Ptr< TcpSocketState > tcb, const TcpRateOps::TcpRateSample &rs)
Updates BBR network model (Maximum bandwidth and minimum RTT).
Definition: tcp-bbr.cc:628
void UpdateControlParameters(Ptr< TcpSocketState > tcb, const TcpRateOps::TcpRateSample &rs)
Updates control parameters congestion windowm, pacing rate, send quantum.
Definition: tcp-bbr.cc:641
Time m_ackEpochTime
Starting of ACK sampling epoch time.
Definition: tcp-bbr.h:401
Time m_cycleStamp
Last time gain cycle updated.
Definition: tcp-bbr.h:380
void CheckFullPipe(const TcpRateOps::TcpRateSample &rs)
Identifies whether pipe or BDP is already full.
Definition: tcp-bbr.cc:292
void EnterProbeRTT()
Updates variables specific to BBR_PROBE_RTT state.
Definition: tcp-bbr.cc:365
DataRate m_fullBandwidth
Value of full bandwidth recorded.
Definition: tcp-bbr.h:373
void HandleProbeRTT(Ptr< TcpSocketState > tcb)
Handles the steps for BBR_PROBE_RTT state.
Definition: tcp-bbr.cc:409
Time m_rtPropFilterLen
A constant specifying the length of the RTProp min filter window, default 10 secs.
Definition: tcp-bbr.h:383
uint32_t m_targetCWnd
Target value for congestion window, adapted to the estimated BDP.
Definition: tcp-bbr.h:372
uint32_t m_sendQuantum
The maximum size of a data aggregate scheduled and transmitted together.
Definition: tcp-bbr.h:378
void SetSendQuantum(Ptr< TcpSocketState > tcb)
Updates send quantum based on the network model.
Definition: tcp-bbr.cc:458
uint32_t m_ackEpochAckedResetThresh
Max allowed val for m_ackEpochAcked, after which sampling epoch is reset.
Definition: tcp-bbr.h:398
void ExitProbeRTT()
Called on exiting from BBR_PROBE_RTT state, it eithers invoke EnterProbeBW () or EnterStartup ()
Definition: tcp-bbr.cc:395
bool m_probeRttRoundDone
True when it is time to exit BBR_PROBE_RTT.
Definition: tcp-bbr.h:368
uint32_t m_fullBandwidthCount
Count of full bandwidth recorded consistently.
Definition: tcp-bbr.h:374
void UpdateTargetCwnd(Ptr< TcpSocketState > tcb)
Updates target congestion window.
Definition: tcp-bbr.cc:465
uint32_t m_cycleIndex
Current index of gain cycle.
Definition: tcp-bbr.h:381
uint32_t m_extraAckedGain
Gain factor for adding extra ack to cwnd.
Definition: tcp-bbr.h:394
void CheckProbeRTT(Ptr< TcpSocketState > tcb, const TcpRateOps::TcpRateSample &rs)
This method handles the steps related to the ProbeRTT state.
Definition: tcp-bbr.cc:436
static const uint8_t GAIN_CYCLE_LENGTH
The number of phases in the BBR ProbeBW gain cycle.
Definition: tcp-bbr.h:50
void SetCwnd(Ptr< TcpSocketState > tcb, const TcpRateOps::TcpRateSample &rs)
Updates congestion window based on the network model.
Definition: tcp-bbr.cc:559
uint32_t m_ackEpochAcked
Bytes ACked in sampling epoch.
Definition: tcp-bbr.h:402
Congestion control abstract class.
uint32_t m_segmentSize
Segment size.
TcpCAEvent_t
Congestion avoidance events.
@ CA_EVENT_COMPLETE_CWR
end of congestion recovery
@ CA_EVENT_TX_START
first transmit when no packets in flight
Time m_minRtt
Minimum RTT observed throughout the connection.
uint32_t m_initialSsThresh
Initial Slow Start Threshold value.
TracedValue< DataRate > m_pacingRate
Current Pacing rate.
TracedValue< TcpCongState_t > m_congState
State in the Congestion state machine.
DataRate m_maxPacingRate
Max Pacing rate.
bool m_pacing
Pacing status.
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.
TracedValue< uint32_t > m_cWnd
Congestion window.
uint32_t m_initialCWnd
Initial cWnd value.
TracedValue< Time > m_lastRtt
Last RTT sample collected.
TracedValue< uint32_t > m_bytesInFlight
Bytes in flight.
uint32_t m_lastAckedSackedBytes
The number of bytes acked and sacked as indicated by the current ACK received.
TracedValue< uint32_t > m_ssThresh
Slow start threshold.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
int64_t GetMilliSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:407
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:402
static Time Max()
Maximum representable Time Not to be confused with Max(Time,Time).
Definition: nstime.h:296
AttributeValue implementation for Time.
Definition: nstime.h:1425
T Get() const
Get the underlying value.
Definition: traced-value.h:249
a unique identifier for an interface.
Definition: type-id.h:60
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:935
Hold an unsigned integer type.
Definition: uinteger.h:45
double GetValue(double min, double max)
Get the next random value, as a double in the specified range .
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.
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition: double.h:43
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Definition: nstime.h:1426
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Definition: uinteger.h:46
int64x64_t Max(const int64x64_t &a, const int64x64_t &b)
Maximum.
Definition: int64x64.h:243
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:268
#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:261
void(* DataRate)(DataRate oldValue, DataRate newValue)
TracedValue callback signature for DataRate.
Definition: data-rate.h:328
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1338
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1350
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:535
Information about the connection rate.
Definition: tcp-rate-ops.h:173
uint32_t m_txItemDelivered
The value of delivered when the acked item was sent.
Definition: tcp-rate-ops.h:180
uint64_t m_delivered
The total amount of data in bytes delivered so far.
Definition: tcp-rate-ops.h:174
Rate Sample structure.
Definition: tcp-rate-ops.h:139
bool m_isAppLimited
Indicates whether the rate sample is application-limited.
Definition: tcp-rate-ops.h:141
uint32_t m_ackedSacked
The amount of data acked and sacked in the last received ack.
Definition: tcp-rate-ops.h:154
DataRate m_deliveryRate
The delivery rate sample.
Definition: tcp-rate-ops.h:140
uint32_t m_priorInFlight
The value if bytes in flight prior to last received ack.
Definition: tcp-rate-ops.h:153
uint32_t m_priorDelivered
The delivered count of the most recent packet delivered.
Definition: tcp-rate-ops.h:145
int32_t m_delivered
The amount of data marked as delivered over the sampling interval.
Definition: tcp-rate-ops.h:143
uint32_t m_bytesLoss
The amount of data marked as lost from the most recent ack received.
Definition: tcp-rate-ops.h:151