A Discrete-Event Network Simulator
API
tcp-bbr.cc
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2018 NITK Surathkal
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Authors: Vivek Jain <jain.vivek.anand@gmail.com>
19 * Viyom Mittal <viyommittal@gmail.com>
20 * Mohit P. Tahiliani <tahiliani@nitk.edu.in>
21 */
22
23#include "tcp-bbr.h"
24
25#include "ns3/log.h"
26#include "ns3/simulator.h"
27
28namespace ns3 {
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 = TypeId ("ns3::TcpBbr")
40 .AddConstructor<TcpBbr> ()
41 .SetGroupName ("Internet")
42 .AddAttribute ("Stream",
43 "Random number stream (default is set to 4 to align with Linux results)",
44 UintegerValue (4),
46 MakeUintegerChecker<uint32_t> ())
47 .AddAttribute ("HighGain",
48 "Value of high gain",
49 DoubleValue (2.89),
51 MakeDoubleChecker<double> ())
52 .AddAttribute ("BwWindowLength",
53 "Length of bandwidth windowed filter",
54 UintegerValue (10),
56 MakeUintegerChecker<uint32_t> ())
57 .AddAttribute ("RttWindowLength",
58 "Length of RTT windowed filter",
59 TimeValue (Seconds (10)),
62 .AddAttribute ("ProbeRttDuration",
63 "Time to be spent in PROBE_RTT phase",
64 TimeValue (MilliSeconds (200)),
67 .AddAttribute ("ExtraAckedRttWindowLength",
68 "Window length of extra acked window",
69 UintegerValue (5),
71 MakeUintegerChecker<uint32_t> ())
72 .AddAttribute ("AckEpochAckedResetThresh",
73 "Max allowed val for m_ackEpochAcked, after which sampling epoch is reset",
74 UintegerValue (1 << 12),
76 MakeUintegerChecker<uint32_t> ())
77 ;
78 return tid;
79}
80
83{
84 NS_LOG_FUNCTION (this);
85 m_uv = CreateObject<UniformRandomVariable> ();
86}
87
89 : TcpCongestionOps (sock),
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),
109 m_rtProp (Time::Max ()),
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),
117 m_uv (sock.m_uv),
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)
129{
130 NS_LOG_FUNCTION (this);
131}
132
133const char* const
134TcpBbr::BbrModeName[BBR_PROBE_RTT + 1] =
135{
136 "BBR_STARTUP", "BBR_DRAIN", "BBR_PROBE_BW", "BBR_PROBE_RTT"
137};
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 && (rs.m_bytesLoss > 0 || rs.m_priorInFlight >= InFlight (tcb, m_pacingGain));
273 }
274 else
275 {
276 return isFullLength || rs.m_priorInFlight <= InFlight (tcb, 1);
277 }
278}
279
280void
282{
283 NS_LOG_FUNCTION (this << tcb << rs);
284 if (m_state == BbrMode_t::BBR_PROBE_BW && IsNextCyclePhase (tcb, rs))
285 {
287 }
288}
289
290void
292{
293 NS_LOG_FUNCTION (this << rs);
295 {
296 return;
297 }
298
299 /* Check if Bottleneck bandwidth is still growing*/
301 {
304 return;
305 }
306
308 if (m_fullBandwidthCount >= 3)
309 {
310 NS_LOG_DEBUG ("Pipe filled");
311 m_isPipeFilled = true;
312 }
313}
314
315void
317{
318 NS_LOG_FUNCTION (this);
319 SetBbrState (BbrMode_t::BBR_DRAIN);
320 m_pacingGain = 1.0 / m_highGain;
322}
323
324void
326{
327 NS_LOG_FUNCTION (this);
328 SetBbrState (BbrMode_t::BBR_PROBE_BW);
329 m_pacingGain = 1;
330 m_cWndGain = 2;
331 m_cycleIndex = GAIN_CYCLE_LENGTH - 1 - (int) m_uv->GetValue (0, 6);
333}
334
335void
337{
338 NS_LOG_FUNCTION (this << tcb);
339 if (m_state == BbrMode_t::BBR_STARTUP && m_isPipeFilled)
340 {
341 EnterDrain ();
342 tcb->m_ssThresh = InFlight (tcb, 1);
343 }
344
345 if (m_state == BbrMode_t::BBR_DRAIN && tcb->m_bytesInFlight <= InFlight (tcb, 1))
346 {
347 EnterProbeBW ();
348 }
349}
350
351void
353{
354 NS_LOG_FUNCTION (this << tcb);
356 if (tcb->m_lastRtt >= Seconds (0) && (tcb->m_lastRtt <= m_rtProp || m_rtPropExpired))
357 {
358 m_rtProp = tcb->m_lastRtt;
360 }
361}
362
363void
365{
366 NS_LOG_FUNCTION (this);
367 SetBbrState (BbrMode_t::BBR_PROBE_RTT);
368 m_pacingGain = 1;
369 m_cWndGain = 1;
370}
371
372void
374{
375 NS_LOG_FUNCTION (this << tcb);
376 if (tcb->m_congState != TcpSocketState::CA_RECOVERY && m_state != BbrMode_t::BBR_PROBE_RTT)
377 {
378 m_priorCwnd = tcb->m_cWnd;
379 }
380 else
381 {
382 m_priorCwnd = std::max (m_priorCwnd, tcb->m_cWnd.Get ());
383 }
384}
385
386void
388{
389 NS_LOG_FUNCTION (this << tcb);
390 tcb->m_cWnd = std::max (m_priorCwnd, tcb->m_cWnd.Get ());
391}
392
393void
395{
396 NS_LOG_FUNCTION (this);
397 if (m_isPipeFilled)
398 {
399 EnterProbeBW ();
400 }
401 else
402 {
403 EnterStartup ();
404 }
405}
406
407void
409{
410 NS_LOG_FUNCTION (this << tcb);
411 m_appLimited = (m_delivered + tcb->m_bytesInFlight.Get ()) ? : 1;
412
414 {
416 m_probeRttRoundDone = false;
418 }
419 else if (m_probeRttDoneStamp != Seconds (0))
420 {
421 if (m_roundStart)
422 {
423 m_probeRttRoundDone = true;
424 }
426 {
428 RestoreCwnd (tcb);
429 ExitProbeRTT ();
430 }
431 }
432}
433
434void
436{
437 NS_LOG_FUNCTION (this << tcb);
438 if (m_state != BbrMode_t::BBR_PROBE_RTT && m_rtPropExpired && !m_idleRestart)
439 {
440 EnterProbeRTT ();
441 SaveCwnd (tcb);
443 }
444
445 if (m_state == BbrMode_t::BBR_PROBE_RTT)
446 {
447 HandleProbeRTT (tcb);
448 }
449
450 if (rs.m_delivered)
451 {
452 m_idleRestart = false;
453 }
454}
455
456void
458{
459 NS_LOG_FUNCTION (this << tcb);
460 m_sendQuantum = 1 * tcb->m_segmentSize;
461}
462
463void
465{
466 NS_LOG_FUNCTION (this << tcb);
468}
469
472{
473 uint32_t maxAggrBytes; // MaxBW * 0.1 secs
474 uint32_t aggrCwndBytes = 0;
475
477 {
478 maxAggrBytes = m_maxBwFilter.GetBest ().GetBitRate () / (10 * 8);
479 aggrCwndBytes = m_extraAckedGain * std::max (m_extraAcked[0], m_extraAcked[1]);
480 aggrCwndBytes = std::min (aggrCwndBytes, maxAggrBytes);
481 }
482 return aggrCwndBytes;
483}
484
485void
487{
488 uint32_t expectedAcked, extraAck;
489 uint32_t epochProp;
490
491 if (!m_extraAckedGain || rs.m_ackedSacked <= 0 || rs.m_delivered < 0)
492 {
493 return;
494 }
495
496 if (m_roundStart)
497 {
498 m_extraAckedWinRtt = std::min<uint32_t> (31, m_extraAckedWinRtt + 1);
500 {
504 }
505 }
506
507 epochProp = Simulator::Now ().GetSeconds () - m_ackEpochTime.GetSeconds ();
508 expectedAcked = m_maxBwFilter.GetBest ().GetBitRate () * epochProp / 8;
509
510 if (m_ackEpochAcked <= expectedAcked ||
512 {
513 m_ackEpochAcked = 0;
515 expectedAcked = 0;
516 }
517
519 extraAck = m_ackEpochAcked - expectedAcked;
520 extraAck = std::min (extraAck, tcb->m_cWnd.Get ());
521
522 if (extraAck > m_extraAcked[m_extraAckedIdx])
523 {
524 m_extraAcked[m_extraAckedIdx] = extraAck;
525 }
526}
527
528bool
530{
531 NS_LOG_FUNCTION (this << tcb << rs);
532 if (rs.m_bytesLoss > 0)
533 {
534 tcb->m_cWnd = std::max ((int) tcb->m_cWnd.Get () - (int) rs.m_bytesLoss, (int) tcb->m_segmentSize);
535 }
536
538 {
539 tcb->m_cWnd = std::max (tcb->m_cWnd.Get (), tcb->m_bytesInFlight.Get () + rs.m_ackedSacked);
540 return true;
541 }
542 return false;
543}
544
545void
547{
548 NS_LOG_FUNCTION (this << tcb);
549 if (m_state == BbrMode_t::BBR_PROBE_RTT)
550 {
551 tcb->m_cWnd = std::min (tcb->m_cWnd.Get (), m_minPipeCwnd);
552 }
553}
554
555void
557{
558 NS_LOG_FUNCTION (this << tcb << rs);
559
560 if (!rs.m_ackedSacked)
561 {
562 goto done;
563 }
564
566 {
567 if (ModulateCwndForRecovery (tcb, rs))
568 {
569 goto done;
570 }
571 }
572
573 UpdateTargetCwnd (tcb);
574
575 if (m_isPipeFilled)
576 {
578 }
579 else if (tcb->m_cWnd < m_targetCWnd || m_delivered < tcb->m_initialCWnd * tcb->m_segmentSize)
580 {
581 tcb->m_cWnd = tcb->m_cWnd.Get () + rs.m_ackedSacked;
582 }
583 tcb->m_cWnd = std::max (tcb->m_cWnd.Get (), m_minPipeCwnd);
584
585done:
587}
588
589void
591{
592 NS_LOG_FUNCTION (this << tcb << rs);
594 {
596 m_roundCount++;
597 m_roundStart = true;
598 m_packetConservation = false;
599 }
600 else
601 {
602 m_roundStart = false;
603 }
604}
605
606void
608{
609 NS_LOG_FUNCTION (this << tcb << rs);
610
611 if (rs.m_deliveryRate == 0)
612 {
613 return;
614 }
615
616 UpdateRound (tcb, rs);
617
619 {
621 }
622}
623
624void
626{
627 NS_LOG_FUNCTION (this << tcb << rs);
628 UpdateBtlBw (tcb, rs);
629 UpdateAckAggregation (tcb, rs);
630 CheckCyclePhase (tcb, rs);
631 CheckFullPipe (rs);
632 CheckDrain (tcb);
633 UpdateRTprop (tcb);
634 CheckProbeRTT (tcb, rs);
635}
636
637void
639{
640 NS_LOG_FUNCTION (this << tcb << rs);
642 SetSendQuantum (tcb);
643 SetCwnd (tcb, rs);
644}
645
646void
648{
649 NS_LOG_FUNCTION (this << mode);
650 NS_LOG_DEBUG (Simulator::Now () << " Changing from " << BbrModeName[m_state] << " to " << BbrModeName[mode]);
651 m_state = mode;
652}
653
656{
657 NS_LOG_FUNCTION (this);
658 return m_state;
659}
660
661double
663{
664 NS_LOG_FUNCTION (this);
665 return m_cWndGain;
666}
667
668double
670{
671 NS_LOG_FUNCTION (this);
672 return m_pacingGain;
673}
674
675std::string
677{
678 return "TcpBbr";
679}
680
681bool
683{
684 NS_LOG_FUNCTION (this);
685 return true;
686}
687
688void
692{
693 NS_LOG_FUNCTION (this << tcb << rs);
696 UpdateModelAndState (tcb, rs);
697 UpdateControlParameters (tcb, rs);
698}
699
700void
702 const TcpSocketState::TcpCongState_t newState)
703{
704 NS_LOG_FUNCTION (this << tcb << newState);
705 if (newState == TcpSocketState::CA_OPEN && !m_isInitialized)
706 {
707 NS_LOG_DEBUG ("CongestionStateSet triggered to CA_OPEN :: " << newState);
708 m_rtProp = tcb->m_lastRtt.Get () != Time::Max () ? tcb->m_lastRtt.Get () : Time::Max ();
710 m_priorCwnd = tcb->m_cWnd;
711 tcb->m_ssThresh = tcb->m_initialSsThresh;
712 m_targetCWnd = tcb->m_cWnd;
713 m_minPipeCwnd = 4 * tcb->m_segmentSize;
714 m_sendQuantum = 1 * tcb->m_segmentSize;
715
717 InitFullPipe ();
718 EnterStartup ();
719 InitPacingRate (tcb);
722 m_extraAckedIdx = 0;
723 m_ackEpochAcked = 0;
724 m_extraAcked[0] = 0;
725 m_extraAcked[1] = 0;
726 m_isInitialized = true;
727 }
728 else if (newState == TcpSocketState::CA_LOSS)
729 {
730 NS_LOG_DEBUG ("CongestionStateSet triggered to CA_LOSS :: " << newState);
731 SaveCwnd (tcb);
732 m_roundStart = true;
733 }
734 else if (newState == TcpSocketState::CA_RECOVERY)
735 {
736 NS_LOG_DEBUG ("CongestionStateSet triggered to CA_RECOVERY :: " << newState);
737 SaveCwnd (tcb);
740 }
741}
742
743void
746{
747 NS_LOG_FUNCTION (this << tcb << event);
749 {
750 NS_LOG_DEBUG ("CwndEvent triggered to CA_EVENT_COMPLETE_CWR :: " << event);
751 m_packetConservation = false;
752 RestoreCwnd (tcb);
753 }
755 {
756 NS_LOG_DEBUG ("CwndEvent triggered to CA_EVENT_TX_START :: " << event);
757 m_idleRestart = true;
759 m_ackEpochAcked = 0;
760 if (m_state == BbrMode_t::BBR_PROBE_BW)
761 {
762 SetPacingRate (tcb, 1);
763 }
764 else if (m_state == BbrMode_t::BBR_PROBE_RTT)
765 {
767 {
769 RestoreCwnd (tcb);
770 ExitProbeRTT ();
771 }
772 }
773 }
774}
775
778{
779 NS_LOG_FUNCTION (this << tcb << bytesInFlight);
780 SaveCwnd (tcb);
781 return tcb->m_ssThresh;
782}
783
786{
787 return CopyObject<TcpBbr> (this);
788}
789
790} // 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:89
uint64_t GetBitRate() const
Get the underlying bitrate.
Definition: data-rate.cc:287
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:41
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:195
BBR congestion control algorithm.
Definition: tcp-bbr.h:45
MaxBandwidthFilter_t m_maxBwFilter
Maximum bandwidth filter.
Definition: tcp-bbr.h:352
bool m_hasSeenRtt
Have we seen RTT sample yet?
Definition: tcp-bbr.h:392
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:546
uint32_t m_nextRoundDelivered
Denotes the end of a packet-timed round trip.
Definition: tcp-bbr.h:361
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:359
uint32_t m_priorCwnd
The last-known good congestion window.
Definition: tcp-bbr.h:367
uint32_t m_extraAckedWinRttLength
Window length of extra acked window.
Definition: tcp-bbr.h:387
virtual void CwndEvent(Ptr< TcpSocketState > tcb, const TcpSocketState::TcpCAEvent_t event)
Trigger events/calculations on occurrence of congestion window event.
Definition: tcp-bbr.cc:744
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:81
uint32_t m_extraAckedIdx
Current index in extra acked array.
Definition: tcp-bbr.h:389
bool m_rtPropExpired
A boolean recording whether the BBR.RTprop has expired.
Definition: tcp-bbr.h:376
virtual std::string GetName() const
Get the name of the congestion control algorithm.
Definition: tcp-bbr.cc:676
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:353
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:362
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:281
uint32_t AckAggregationCwnd()
Find Cwnd increment based on ack aggregation.
Definition: tcp-bbr.cc:471
bool m_idleRestart
When restarting from idle, set it true.
Definition: tcp-bbr.h:368
Ptr< UniformRandomVariable > m_uv
Uniform Random Variable.
Definition: tcp-bbr.h:380
static TypeId GetTypeId(void)
Get the type ID.
Definition: tcp-bbr.cc:36
Time m_rtPropStamp
The wall clock time at which the current BBR.RTProp sample was obtained.
Definition: tcp-bbr.h:378
virtual uint32_t GetSsThresh(Ptr< const TcpSocketState > tcb, uint32_t bytesInFlight)
Get the slow start threshold after a loss event.
Definition: tcp-bbr.cc:777
void UpdateBtlBw(Ptr< TcpSocketState > tcb, const TcpRateOps::TcpRateSample &rs)
Updates maximum bottleneck.
Definition: tcp-bbr.cc:607
uint32_t m_minPipeCwnd
The minimal congestion window value BBR tries to target, default 4 Segment size.
Definition: tcp-bbr.h:358
uint32_t GetBbrState()
Gets BBR state.
Definition: tcp-bbr.cc:655
double GetCwndGain()
Gets current cwnd gain.
Definition: tcp-bbr.cc:662
void UpdateRound(Ptr< TcpSocketState > tcb, const TcpRateOps::TcpRateSample &rs)
Updates round counting related variables.
Definition: tcp-bbr.cc:590
virtual void CongestionStateSet(Ptr< TcpSocketState > tcb, const TcpSocketState::TcpCongState_t newState)
Trigger events/calculations specific to a congestion state.
Definition: tcp-bbr.cc:701
BbrMode_t m_state
Current state of BBR state machine.
Definition: tcp-bbr.h:351
bool m_roundStart
A boolean that BBR sets to true once per packet-timed round trip.
Definition: tcp-bbr.h:360
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:325
double GetPacingGain()
Gets current pacing gain.
Definition: tcp-bbr.cc:669
uint64_t m_delivered
The total amount of data in bytes delivered so far.
Definition: tcp-bbr.h:381
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:379
void RestoreCwnd(Ptr< TcpSocketState > tcb)
Helper to restore the last-known good congestion window.
Definition: tcp-bbr.cc:387
bool ModulateCwndForRecovery(Ptr< TcpSocketState > tcb, const TcpRateOps::TcpRateSample &rs)
Modulates congestion window in CA_RECOVERY.
Definition: tcp-bbr.cc:529
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:352
void CheckDrain(Ptr< TcpSocketState > tcb)
Checks whether its time to enter BBR_DRAIN or BBR_PROBE_BW state.
Definition: tcp-bbr.cc:336
void SetBbrState(BbrMode_t state)
Sets BBR state.
Definition: tcp-bbr.cc:647
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:486
uint32_t m_txItemDelivered
The number of bytes already delivered at the time of new packet transmission.
Definition: tcp-bbr.h:383
bool m_packetConservation
Enable/Disable packet conservation mode.
Definition: tcp-bbr.h:366
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:386
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:373
void EnterDrain()
Updates variables specific to BBR_DRAIN state.
Definition: tcp-bbr.cc:316
Time m_probeRttDoneStamp
Time to exit from BBR_PROBE_RTT state.
Definition: tcp-bbr.h:364
uint32_t m_extraAcked[2]
Maximum excess data acked in epoch.
Definition: tcp-bbr.h:385
Time m_rtProp
Estimated two-way round-trip propagation delay of the path, estimated from the windowed minimum recen...
Definition: tcp-bbr.h:372
virtual Ptr< TcpCongestionOps > Fork()
Copy the congestion control algorithm across sockets.
Definition: tcp-bbr.cc:785
uint32_t m_appLimited
The index of the last transmitted packet marked as application-limited.
Definition: tcp-bbr.h:382
void UpdateModelAndState(Ptr< TcpSocketState > tcb, const TcpRateOps::TcpRateSample &rs)
Updates BBR network model (Maximum bandwidth and minimum RTT).
Definition: tcp-bbr.cc:625
void UpdateControlParameters(Ptr< TcpSocketState > tcb, const TcpRateOps::TcpRateSample &rs)
Updates control parameters congestion windowm, pacing rate, send quantum.
Definition: tcp-bbr.cc:638
Time m_ackEpochTime
Starting of ACK sampling epoch time.
Definition: tcp-bbr.h:390
Time m_cycleStamp
Last time gain cycle updated.
Definition: tcp-bbr.h:374
void CheckFullPipe(const TcpRateOps::TcpRateSample &rs)
Identifies whether pipe or BDP is already full.
Definition: tcp-bbr.cc:291
void EnterProbeRTT()
Updates variables specific to BBR_PROBE_RTT state.
Definition: tcp-bbr.cc:364
DataRate m_fullBandwidth
Value of full bandwidth recorded.
Definition: tcp-bbr.h:370
void HandleProbeRTT(Ptr< TcpSocketState > tcb)
Handles the steps for BBR_PROBE_RTT state.
Definition: tcp-bbr.cc:408
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.
Definition: tcp-bbr.cc:689
Time m_rtPropFilterLen
A constant specifying the length of the RTProp min filter window, default 10 secs.
Definition: tcp-bbr.h:377
uint32_t m_targetCWnd
Target value for congestion window, adapted to the estimated BDP.
Definition: tcp-bbr.h:369
uint32_t m_sendQuantum
The maximum size of a data aggregate scheduled and transmitted together.
Definition: tcp-bbr.h:373
void SetSendQuantum(Ptr< TcpSocketState > tcb)
Updates send quantum based on the network model.
Definition: tcp-bbr.cc:457
uint32_t m_ackEpochAckedResetThresh
Max allowed val for m_ackEpochAcked, after which sampling epoch is reset.
Definition: tcp-bbr.h:388
void ExitProbeRTT()
Called on exiting from BBR_PROBE_RTT state, it eithers invoke EnterProbeBW () or EnterStartup ()
Definition: tcp-bbr.cc:394
bool m_probeRttRoundDone
True when it is time to exit BBR_PROBE_RTT.
Definition: tcp-bbr.h:365
uint32_t m_fullBandwidthCount
Count of full bandwidth recorded consistently.
Definition: tcp-bbr.h:371
void UpdateTargetCwnd(Ptr< TcpSocketState > tcb)
Updates target congestion window.
Definition: tcp-bbr.cc:464
uint32_t m_cycleIndex
Current index of gain cycle.
Definition: tcp-bbr.h:375
uint32_t m_extraAckedGain
Gain factor for adding extra ack to cwnd.
Definition: tcp-bbr.h:384
void CheckProbeRTT(Ptr< TcpSocketState > tcb, const TcpRateOps::TcpRateSample &rs)
This method handles the steps related to the ProbeRTT state.
Definition: tcp-bbr.cc:435
static const uint8_t GAIN_CYCLE_LENGTH
The number of phases in the BBR ProbeBW gain cycle.
Definition: tcp-bbr.h:50
virtual bool HasCongControl() const
Returns true when Congestion Control Algorithm implements CongControl.
Definition: tcp-bbr.cc:682
void SetCwnd(Ptr< TcpSocketState > tcb, const TcpRateOps::TcpRateSample &rs)
Updates congestion window based on the network model.
Definition: tcp-bbr.cc:556
uint32_t m_ackEpochAcked
Bytes ACked in sampling epoch.
Definition: tcp-bbr.h:391
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:103
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:379
int64_t GetMilliSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:383
static Time Max()
Maximum representable Time Not to be confused with Max(Time,Time).
Definition: nstime.h:282
AttributeValue implementation for Time.
Definition: nstime.h:1308
T Get(void) const
Get the underlying value.
Definition: traced-value.h:232
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
Hold an unsigned integer type.
Definition: uinteger.h:44
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:42
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Definition: nstime.h:1309
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Definition: uinteger.h:45
int64x64_t Max(const int64x64_t &a, const int64x64_t &b)
Maximum.
Definition: int64x64.h:230
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:273
#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:265
void(* DataRate)(DataRate oldValue, DataRate newValue)
TracedValue callback signature for DataRate.
Definition: data-rate.h:329
#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:1244
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1252
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:536
Information about the connection rate.
Definition: tcp-rate-ops.h:163
uint32_t m_txItemDelivered
The value of delivered when the acked item was sent.
Definition: tcp-rate-ops.h:168
uint64_t m_delivered
The total amount of data in bytes delivered so far.
Definition: tcp-rate-ops.h:164
Rate Sample structure.
Definition: tcp-rate-ops.h:134
bool m_isAppLimited
Indicates whether the rate sample is application-limited.
Definition: tcp-rate-ops.h:136
uint32_t m_ackedSacked
The amount of data acked and sacked in the last received ack.
Definition: tcp-rate-ops.h:145
DataRate m_deliveryRate
The delivery rate sample.
Definition: tcp-rate-ops.h:135
uint32_t m_priorInFlight
The value if bytes in flight prior to last received ack.
Definition: tcp-rate-ops.h:144
uint32_t m_priorDelivered
The delivered count of the most recent packet delivered.
Definition: tcp-rate-ops.h:139
int32_t m_delivered
The amount of data marked as delivered over the sampling interval.
Definition: tcp-rate-ops.h:138
uint32_t m_bytesLoss
The amount of data marked as lost from the most recent ack received.
Definition: tcp-rate-ops.h:143