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 
28 namespace ns3 {
29 
30 NS_LOG_COMPONENT_DEFINE ("TcpBbr");
32 
33 const double TcpBbr::PACING_GAIN_CYCLE [] = {5.0 / 4, 3.0 / 4, 1, 1, 1, 1, 1, 1};
34 
35 TypeId
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)),
61  MakeTimeChecker ())
62  .AddAttribute ("ProbeRttDuration",
63  "Time to be spent in PROBE_RTT phase",
64  TimeValue (MilliSeconds (200)),
66  MakeTimeChecker ())
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 
82  : TcpCongestionOps ()
83 {
84  NS_LOG_FUNCTION (this);
85  m_uv = CreateObject<UniformRandomVariable> ();
86 }
87 
88 TcpBbr::TcpBbr (const TcpBbr &sock)
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 
133 const char* const
134 TcpBbr::BbrModeName[BBR_PROBE_RTT + 1] =
135 {
136  "BBR_STARTUP", "BBR_DRAIN", "BBR_PROBE_BW", "BBR_PROBE_RTT"
137 };
138 
139 void
140 TcpBbr::SetStream (uint32_t stream)
141 {
142  NS_LOG_FUNCTION (this << stream);
143  m_uv->SetStream (stream);
144 }
145 
146 void
148 {
149  NS_LOG_FUNCTION (this);
151  m_roundStart = false;
152  m_roundCount = 0;
153 }
154 
155 void
157 {
158  NS_LOG_FUNCTION (this);
159  m_isPipeFilled = false;
160  m_fullBandwidth = 0;
162 }
163 
164 void
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 
193 void
195 {
196  NS_LOG_FUNCTION (this);
197  SetBbrState (BbrMode_t::BBR_STARTUP);
200 }
201 
202 void
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 
216 void
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 
234 uint32_t
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 
252 void
254 {
255  NS_LOG_FUNCTION (this);
259 }
260 
261 bool
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 
280 void
282 {
283  NS_LOG_FUNCTION (this << tcb << rs);
284  if (m_state == BbrMode_t::BBR_PROBE_BW && IsNextCyclePhase (tcb, rs))
285  {
287  }
288 }
289 
290 void
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 
315 void
317 {
318  NS_LOG_FUNCTION (this);
319  SetBbrState (BbrMode_t::BBR_DRAIN);
320  m_pacingGain = 1.0 / m_highGain;
322 }
323 
324 void
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 
335 void
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 
351 void
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 
363 void
365 {
366  NS_LOG_FUNCTION (this);
367  SetBbrState (BbrMode_t::BBR_PROBE_RTT);
368  m_pacingGain = 1;
369  m_cWndGain = 1;
370 }
371 
372 void
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 
386 void
388 {
389  NS_LOG_FUNCTION (this << tcb);
390  tcb->m_cWnd = std::max (m_priorCwnd, tcb->m_cWnd.Get ());
391 }
392 
393 void
395 {
396  NS_LOG_FUNCTION (this);
397  if (m_isPipeFilled)
398  {
399  EnterProbeBW ();
400  }
401  else
402  {
403  EnterStartup ();
404  }
405 }
406 
407 void
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 
434 void
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 
456 void
458 {
459  NS_LOG_FUNCTION (this << tcb);
460  m_sendQuantum = 1 * tcb->m_segmentSize;
461 }
462 
463 void
465 {
466  NS_LOG_FUNCTION (this << tcb);
468 }
469 
470 uint32_t
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 
485 void
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  {
501  m_extraAckedWinRtt = 0;
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 
528 bool
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 
545 void
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 
555 void
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  {
577  tcb->m_cWnd = std::min (tcb->m_cWnd.Get () + (uint32_t) rs.m_ackedSacked, m_targetCWnd);
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 
585 done:
587 }
588 
589 void
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 
606 void
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 
624 void
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 
637 void
639 {
640  NS_LOG_FUNCTION (this << tcb << rs);
642  SetSendQuantum (tcb);
643  SetCwnd (tcb, rs);
644 }
645 
646 void
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 
654 uint32_t
656 {
657  NS_LOG_FUNCTION (this);
658  return m_state;
659 }
660 
661 double
663 {
664  NS_LOG_FUNCTION (this);
665  return m_cWndGain;
666 }
667 
668 double
670 {
671  NS_LOG_FUNCTION (this);
672  return m_pacingGain;
673 }
674 
675 std::string
677 {
678  return "TcpBbr";
679 }
680 
681 bool
683 {
684  NS_LOG_FUNCTION (this);
685  return true;
686 }
687 
688 void
691  const TcpRateOps::TcpRateSample &rs)
692 {
693  NS_LOG_FUNCTION (this << tcb << rs);
696  UpdateModelAndState (tcb, rs);
697  UpdateControlParameters (tcb, rs);
698 }
699 
700 void
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);
721  m_extraAckedWinRtt = 0;
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);
739  m_packetConservation = true;
740  }
741 }
742 
743 void
745  const TcpSocketState::TcpCAEvent_t event)
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  }
754  else if (event == TcpSocketState::CA_EVENT_TX_START && m_appLimited )
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 
776 uint32_t
777 TcpBbr::GetSsThresh (Ptr<const TcpSocketState> tcb, uint32_t bytesInFlight)
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
Time m_rtPropStamp
The wall clock time at which the current BBR.RTProp sample was obtained.
Definition: tcp-bbr.h:370
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
uint32_t m_targetCWnd
Target value for congestion window, adapted to the estimated BDP.
Definition: tcp-bbr.h:361
Normal state, no dubious events.
MaxBandwidthFilter_t m_maxBwFilter
Maximum bandwidth filter.
Definition: tcp-bbr.h:344
uint32_t m_lastAckedSackedBytes
The number of bytes acked and sacked as indicated by the current ACK received.
CWND was reduced, we are fast-retransmitting.
void RestoreCwnd(Ptr< TcpSocketState > tcb)
Helper to restore the last-known good congestion window.
Definition: tcp-bbr.cc:387
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
virtual std::string GetName() const
Get the name of the congestion control algorithm.
Definition: tcp-bbr.cc:676
void EnterProbeRTT()
Updates variables specific to BBR_PROBE_RTT state.
Definition: tcp-bbr.cc:364
bool m_pacing
Pacing status.
Time m_rtProp
Estimated two-way round-trip propagation delay of the path, estimated from the windowed minimum recen...
Definition: tcp-bbr.h:364
uint32_t m_cycleIndex
Current index of gain cycle.
Definition: tcp-bbr.h:367
#define min(a, b)
Definition: 80211b.c:42
bool m_packetConservation
Enable/Disable packet conservation mode.
Definition: tcp-bbr.h:358
uint32_t m_extraAckedWinRttLength
Window length of extra acked window.
Definition: tcp-bbr.h:379
bool m_isPipeFilled
A boolean that records whether BBR has filled the pipe.
Definition: tcp-bbr.h:349
TcpCAEvent_t
Congestion avoidance events.
uint32_t m_initialSsThresh
Initial Slow Start Threshold value.
uint32_t m_priorDelivered
The delivered count of the most recent packet delivered.
Definition: tcp-rate-ops.h:139
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:380
static const uint8_t GAIN_CYCLE_LENGTH
The number of phases in the BBR ProbeBW gain cycle.
Definition: tcp-bbr.h:42
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
bool m_hasSeenRtt
Have we seen RTT sample yet?
Definition: tcp-bbr.h:384
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
uint32_t m_priorCwnd
The last-known good congestion window.
Definition: tcp-bbr.h:359
static TypeId GetTypeId(void)
Get the type ID.
Definition: tcp-bbr.cc:36
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1297
double m_highGain
A constant specifying highest gain factor, default is 2.89.
Definition: tcp-bbr.h:348
uint32_t m_segmentSize
Segment size.
void CheckFullPipe(const TcpRateOps::TcpRateSample &rs)
Identifies whether pipe or BDP is already full.
Definition: tcp-bbr.cc:291
uint32_t m_initialCWnd
Initial cWnd value.
Time m_probeRttDuration
A constant specifying the minimum duration for which ProbeRTT state, default 200 millisecs.
Definition: tcp-bbr.h:354
void ModulateCwndForProbeRTT(Ptr< TcpSocketState > tcb)
Modulates congestion window in BBR_PROBE_RTT.
Definition: tcp-bbr.cc:546
void UpdateBtlBw(Ptr< TcpSocketState > tcb, const TcpRateOps::TcpRateSample &rs)
Updates maximum bottleneck.
Definition: tcp-bbr.cc:607
T GetBest() const
Returns Max/Min value so far among the windowed samples.
void Update(T new_sample, TimeT new_time)
Updates best estimates with |sample|, and expires and updates best estimates as necessary.
uint32_t GetBbrState()
Gets BBR state.
Definition: tcp-bbr.cc:655
uint32_t m_priorInFlight
The value if bytes in flight prior to last received ack.
Definition: tcp-rate-ops.h:144
uint32_t m_ackEpochAcked
Bytes ACked in sampling epoch.
Definition: tcp-bbr.h:383
uint32_t m_txItemDelivered
The number of bytes already delivered at the time of new packet transmission.
Definition: tcp-bbr.h:375
uint32_t InFlight(Ptr< TcpSocketState > tcb, double gain)
Estimates the target value for congestion window.
Definition: tcp-bbr.cc:235
uint32_t m_txItemDelivered
The value of delivered when the acked item was sent.
Definition: tcp-rate-ops.h:168
uint64_t GetBitRate() const
Get the underlying bitrate.
Definition: data-rate.cc:287
bool m_isAppLimited
Indicates whether the rate sample is application-limited.
Definition: tcp-rate-ops.h:136
void InitFullPipe()
Intializes the full pipe estimator.
Definition: tcp-bbr.cc:156
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
virtual Ptr< TcpCongestionOps > Fork()
Copy the congestion control algorithm across sockets.
Definition: tcp-bbr.cc:785
void HandleProbeRTT(Ptr< TcpSocketState > tcb)
Handles the steps for BBR_PROBE_RTT state.
Definition: tcp-bbr.cc:408
Class for representing data rates.
Definition: data-rate.h:88
uint32_t m_extraAckedIdx
Current index in extra acked array.
Definition: tcp-bbr.h:381
static Time Max()
Maximum representable Time Not to be confused with Max(Time,Time).
Definition: nstime.h:283
uint32_t AckAggregationCwnd()
Find Cwnd increment based on ack aggregation.
Definition: tcp-bbr.cc:471
void EnterDrain()
Updates variables specific to BBR_DRAIN state.
Definition: tcp-bbr.cc:316
void SetCwnd(Ptr< TcpSocketState > tcb, const TcpRateOps::TcpRateSample &rs)
Updates congestion window based on the network model.
Definition: tcp-bbr.cc:556
Rate Sample structure.
Definition: tcp-rate-ops.h:133
void UpdateModelAndState(Ptr< TcpSocketState > tcb, const TcpRateOps::TcpRateSample &rs)
Updates BBR network model (Maximum bandwidth and minimum RTT).
Definition: tcp-bbr.cc:625
uint32_t m_fullBandwidthCount
Count of full bandwidth recorded consistently.
Definition: tcp-bbr.h:363
Time m_ackEpochTime
Starting of ACK sampling epoch time.
Definition: tcp-bbr.h:382
#define max(a, b)
Definition: 80211b.c:43
AttributeValue implementation for Time.
Definition: nstime.h:1353
TracedValue< DataRate > m_pacingRate
Current Pacing rate.
int32_t m_delivered
The amount of data marked as delivered over the sampling interval.
Definition: tcp-rate-ops.h:138
void CheckProbeRTT(Ptr< TcpSocketState > tcb, const TcpRateOps::TcpRateSample &rs)
This method handles the steps related to the ProbeRTT state.
Definition: tcp-bbr.cc:435
Hold an unsigned integer type.
Definition: uinteger.h:44
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
Time m_rtPropFilterLen
A constant specifying the length of the RTProp min filter window, default 10 secs.
Definition: tcp-bbr.h:369
static const char *const BbrModeName[BBR_PROBE_RTT+1]
Literal names of BBR mode for use in log messages.
Definition: tcp-bbr.h:86
uint32_t m_extraAckedGain
Gain factor for adding extra ack to cwnd.
Definition: tcp-bbr.h:376
virtual void CongestionStateSet(Ptr< TcpSocketState > tcb, const TcpSocketState::TcpCongState_t newState)
Trigger events/calculations specific to a congestion state.
Definition: tcp-bbr.cc:701
void SetBbrState(BbrMode_t state)
Sets BBR state.
Definition: tcp-bbr.cc:647
int64x64_t Max(const int64x64_t &a, const int64x64_t &b)
Maximum.
Definition: int64x64.h:230
void UpdateTargetCwnd(Ptr< TcpSocketState > tcb)
Updates target congestion window.
Definition: tcp-bbr.cc:464
bool m_isInitialized
Set to true after first time initializtion variables.
Definition: tcp-bbr.h:371
uint32_t m_appLimited
The index of the last transmitted packet marked as application-limited.
Definition: tcp-bbr.h:374
void UpdateRound(Ptr< TcpSocketState > tcb, const TcpRateOps::TcpRateSample &rs)
Updates round counting related variables.
Definition: tcp-bbr.cc:590
uint32_t m_extraAckedWinRtt
Age of extra acked in rtt.
Definition: tcp-bbr.h:378
DataRate m_deliveryRate
The delivery rate sample.
Definition: tcp-rate-ops.h:135
bool m_idleRestart
When restarting from idle, set it true.
Definition: tcp-bbr.h:360
bool m_roundStart
A boolean that BBR sets to true once per packet-timed round trip.
Definition: tcp-bbr.h:352
TracedValue< uint32_t > m_bytesInFlight
Bytes in flight.
TracedValue< uint32_t > m_ssThresh
Slow start threshold.
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
TcpCongState_t
Definition of the Congestion state machine.
BbrMode_t
BBR has the following 4 modes for deciding how fast to send:
Definition: tcp-bbr.h:69
void ExitProbeRTT()
Called on exiting from BBR_PROBE_RTT state, it eithers invoke EnterProbeBW () or EnterStartup () ...
Definition: tcp-bbr.cc:394
bool ModulateCwndForRecovery(Ptr< TcpSocketState > tcb, const TcpRateOps::TcpRateSample &rs)
Modulates congestion window in CA_RECOVERY.
Definition: tcp-bbr.cc:529
uint32_t m_ackEpochAckedResetThresh
Max allowed val for m_ackEpochAcked, after which sampling epoch is reset.
Definition: tcp-bbr.h:380
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void AdvanceCyclePhase()
Advances pacing gain using cycle gain algorithm, while in BBR_PROBE_BW state.
Definition: tcp-bbr.cc:253
BbrMode_t m_state
Current state of BBR state machine.
Definition: tcp-bbr.h:343
TracedValue< TcpCongState_t > m_congState
State in the Congestion state machine.
void UpdateRTprop(Ptr< TcpSocketState > tcb)
Updates minimum RTT.
Definition: tcp-bbr.cc:352
Congestion control abstract class.
double GetValue(double min, double max)
Get the next random value, as a double in the specified range .
double GetPacingGain()
Gets current pacing gain.
Definition: tcp-bbr.cc:669
void CheckDrain(Ptr< TcpSocketState > tcb)
Checks whether its time to enter BBR_DRAIN or BBR_PROBE_BW state.
Definition: tcp-bbr.cc:336
void SetPacingRate(Ptr< TcpSocketState > tcb, double gain)
Updates pacing rate based on network model.
Definition: tcp-bbr.cc:217
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: nstime.h:1354
uint32_t m_ackedSacked
The amount of data acked and sacked in the last received ack.
Definition: tcp-rate-ops.h:145
void InitRoundCounting()
Intializes the round counting related variables.
Definition: tcp-bbr.cc:147
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:195
void SetSendQuantum(Ptr< TcpSocketState > tcb)
Updates send quantum based on the network model.
Definition: tcp-bbr.cc:457
void UpdateAckAggregation(Ptr< TcpSocketState > tcb, const TcpRateOps::TcpRateSample &rs)
Estimates max degree of aggregation.
Definition: tcp-bbr.cc:486
Time m_probeRttDoneStamp
Time to exit from BBR_PROBE_RTT state.
Definition: tcp-bbr.h:356
TracedValue< uint32_t > m_cWnd
Congestion window.
uint32_t m_nextRoundDelivered
Denotes the end of a packet-timed round trip.
Definition: tcp-bbr.h:353
Information about the connection rate.
Definition: tcp-rate-ops.h:162
uint64_t m_delivered
The total amount of data in bytes delivered so far.
Definition: tcp-rate-ops.h:164
virtual bool HasCongControl() const
Returns true when Congestion Control Algorithm implements CongControl.
Definition: tcp-bbr.cc:682
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: double.h:42
DataRate m_fullBandwidth
Value of full bandwidth recorded.
Definition: tcp-bbr.h:362
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition: log.h:265
TracedValue< Time > m_lastRtt
Last RTT sample collected.
int64_t GetMilliSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:384
bool m_probeRttRoundDone
True when it is time to exit BBR_PROBE_RTT.
Definition: tcp-bbr.h:357
Ptr< UniformRandomVariable > m_uv
Uniform Random Variable.
Definition: tcp-bbr.h:372
CWND was reduced due to RTO timeout or SACK reneging.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:273
T Get(void) const
Get the underlying value.
Definition: traced-value.h:229
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1289
Time m_minRtt
Minimum RTT observed throughout the connection.
uint32_t m_extraAcked[2]
Maximum excess data acked in epoch.
Definition: tcp-bbr.h:377
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
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:345
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:48
Time m_cycleStamp
Last time gain cycle updated.
Definition: tcp-bbr.h:366
uint32_t m_sendQuantum
The maximum size of a data aggregate scheduled and transmitted together.
Definition: tcp-bbr.h:365
first transmit when no packets in flight
double m_pacingGain
The dynamic pacing gain factor.
Definition: tcp-bbr.h:346
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:533
uint32_t m_roundCount
Count of packet-timed round trips.
Definition: tcp-bbr.h:351
void EnterStartup()
Updates variables specific to BBR_STARTUP state.
Definition: tcp-bbr.cc:194
TcpBbr()
Constructor.
Definition: tcp-bbr.cc:81
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
WindowedFilter< DataRate, MaxFilter< DataRate >, uint32_t, uint32_t > MaxBandwidthFilter_t
Definition of max bandwidth filter.
Definition: tcp-bbr.h:81
double m_cWndGain
The dynamic congestion window gain factor.
Definition: tcp-bbr.h:347
DataRate m_maxPacingRate
Max Pacing rate.
uint64_t m_delivered
The total amount of data in bytes delivered so far.
Definition: tcp-bbr.h:373
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 m_minPipeCwnd
The minimal congestion window value BBR tries to target, default 4 Segment size.
Definition: tcp-bbr.h:350
This class can be used to hold variables of floating point type such as &#39;double&#39; or &#39;float&#39;...
Definition: double.h:41
void HandleRestartFromIdle(Ptr< TcpSocketState > tcb, const TcpRateOps::TcpRateSample &rs)
Updates pacing rate if socket is restarting from idle state.
Definition: tcp-bbr.cc:203
void InitPacingRate(Ptr< TcpSocketState > tcb)
Intializes the pacing rate.
Definition: tcp-bbr.cc:165
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: uinteger.h:45
void UpdateControlParameters(Ptr< TcpSocketState > tcb, const TcpRateOps::TcpRateSample &rs)
Updates control parameters congestion windowm, pacing rate, send quantum.
Definition: tcp-bbr.cc:638
a unique identifier for an interface.
Definition: type-id.h:58
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:923
void(* DataRate)(DataRate oldValue, DataRate newValue)
TracedValue callback signature for DataRate.
Definition: data-rate.h:329
uint32_t m_bytesLoss
The amount of data marked as lost from the most recent ack received.
Definition: tcp-rate-ops.h:143
bool m_rtPropExpired
A boolean recording whether the BBR.RTprop has expired.
Definition: tcp-bbr.h:368
void EnterProbeBW()
Updates variables specific to BBR_PROBE_BW state.
Definition: tcp-bbr.cc:325
double GetCwndGain()
Gets current cwnd gain.
Definition: tcp-bbr.cc:662