19 #define NS_LOG_APPEND_CONTEXT \
21 std::clog << Simulator::Now().GetSeconds() << " "; \
41 .AddConstructor<TcpCubic>()
42 .SetGroupName(
"Internet")
43 .AddAttribute(
"FastConvergence",
44 "Enable (true) or disable (false) fast convergence",
48 .AddAttribute(
"TcpFriendliness",
49 "Enable (true) or disable (false) TCP friendliness",
54 "Beta for multiplicative decrease",
57 MakeDoubleChecker<double>(0.0))
58 .AddAttribute(
"HyStart",
59 "Enable (true) or disable (false) hybrid slow start algorithm",
63 .AddAttribute(
"HyStartLowWindow",
64 "Lower bound cWnd for hybrid slow start (segments)",
67 MakeUintegerChecker<uint32_t>())
68 .AddAttribute(
"HyStartDetect",
69 "Hybrid Slow Start detection mechanisms:"
70 "packet train, delay, both",
77 HybridSSDetectionMode::BOTH,
79 .AddAttribute(
"HyStartMinSamples",
80 "Number of delay samples for detecting the increase of delay",
83 MakeUintegerChecker<uint8_t>())
84 .AddAttribute(
"HyStartAckDelta",
85 "Spacing between ack's indicating train",
89 .AddAttribute(
"HyStartDelayMin",
90 "Minimum time for hystart algorithm",
94 .AddAttribute(
"HyStartDelayMax",
95 "Maximum time for hystart algorithm",
99 .AddAttribute(
"CubicDelta",
100 "Delta Time to wait after fast recovery before adjusting param",
104 .AddAttribute(
"CntClamp",
105 "Counter value when no losses are detected (counter is used"
106 " when incrementing cWnd in congestion avoidance, to avoid"
107 " floating point arithmetic). It is the modulo of the (avoided)"
111 MakeUintegerChecker<uint8_t>())
113 "Cubic Scaling factor",
116 MakeDoubleChecker<double>(0.0));
141 m_fastConvergence(sock.m_fastConvergence),
143 m_hystart(sock.m_hystart),
144 m_hystartDetect(sock.m_hystartDetect),
145 m_hystartLowWindow(sock.m_hystartLowWindow),
146 m_hystartAckDelta(sock.m_hystartAckDelta),
147 m_hystartDelayMin(sock.m_hystartDelayMin),
148 m_hystartDelayMax(sock.m_hystartDelayMax),
149 m_hystartMinSamples(sock.m_hystartMinSamples),
150 m_initialCwnd(sock.m_initialCwnd),
151 m_cntClamp(sock.m_cntClamp),
153 m_cWndCnt(sock.m_cWndCnt),
154 m_lastMaxCwnd(sock.m_lastMaxCwnd),
155 m_bicOriginPoint(sock.m_bicOriginPoint),
157 m_delayMin(sock.m_delayMin),
158 m_epochStart(sock.m_epochStart),
159 m_found(sock.m_found),
160 m_roundStart(sock.m_roundStart),
161 m_endSeq(sock.m_endSeq),
162 m_lastAck(sock.m_lastAck),
163 m_cubicDelta(sock.m_cubicDelta),
164 m_currRtt(sock.m_currRtt),
165 m_sampleCnt(sock.m_sampleCnt)
217 uint32_t cnt =
Update(tcb, segmentsAcked);
232 NS_LOG_INFO(
"Not enough segments have been ACKed to increment cwnd."
261 NS_LOG_DEBUG(
"lastMaxCwnd <= m_cWnd. K=0 and origin=" << segCwnd);
309 if (bicTarget > segCwnd)
311 cnt = segCwnd / (bicTarget - segCwnd);
326 auto scale =
static_cast<uint32_t
>(8 * (1024 +
m_beta * 1024) / 3 / (1024 -
m_beta * 1024));
327 delta = (segCwnd * scale) >> 3;
336 maxCnt = segCwnd /
delta;
452 uint32_t segCwnd = tcb->GetCwndInSegments();
454 <<
" segments in flight=" << bytesInFlight / tcb->m_segmentSize);
469 uint32_t ssThresh =
std::max(
static_cast<uint32_t
>(segCwnd *
m_beta), 2U) * tcb->m_segmentSize;
506 return CopyObject<TcpCubic>(
this);
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Hold variables of type enum.
Smart pointer class similar to boost::intrusive_ptr.
static Time Now()
Return the current simulation virtual time.
Congestion control abstract class.
The Cubic Congestion Control Algorithm.
Time m_currRtt
Current Rtt.
void HystartReset(Ptr< const TcpSocketState > tcb)
Reset HyStart parameters.
uint32_t m_ackCnt
Count the number of ACKed packets.
Time m_hystartDelayMax
Maximum time for hystart algorithm.
Time m_cubicDelta
Time to wait after recovery before update.
uint32_t m_bicOriginPoint
Origin point of bic function.
uint32_t m_sampleCnt
Count of samples for HyStart.
uint32_t GetSsThresh(Ptr< const TcpSocketState > tcb, uint32_t bytesInFlight) override
Get the slow start threshold after a loss event.
std::string GetName() const override
Get the name of the congestion control algorithm.
uint32_t Update(Ptr< TcpSocketState > tcb, uint32_t segmentsAcked)
Cubic window update after a new ack received.
Ptr< TcpCongestionOps > Fork() override
Copy the congestion control algorithm across sockets.
bool m_hystart
Enable or disable HyStart algorithm.
double m_bicK
Time to origin point from the beginning.
uint32_t m_tcpCwnd
Estimated tcp cwnd (for Reno-friendliness)
void PktsAcked(Ptr< TcpSocketState > tcb, uint32_t segmentsAcked, const Time &rtt) override
Timing information on received ACK.
uint32_t m_cWndCnt
cWnd integer-to-float counter
Time m_hystartDelayMin
Minimum time for hystart algorithm.
bool m_found
The exit point is found?
SequenceNumber32 m_endSeq
End sequence of the round.
void IncreaseWindow(Ptr< TcpSocketState > tcb, uint32_t segmentsAcked) override
Congestion avoidance algorithm implementation.
double m_beta
Beta for cubic multiplicative increase.
Time m_lastAck
Last time when the ACK spacing is close.
void CongestionStateSet(Ptr< TcpSocketState > tcb, const TcpSocketState::TcpCongState_t newState) override
Trigger events/calculations specific to a congestion state.
static TypeId GetTypeId()
Get the type ID.
bool m_tcpFriendliness
Enable or disable TCP-friendliness heuristic.
Time m_hystartAckDelta
Spacing between ack's indicating train.
bool m_fastConvergence
Enable or disable fast convergence algorithm.
Time m_delayMin
Min delay.
Time m_roundStart
Beginning of each round.
Time m_epochStart
Beginning of an epoch.
HybridSSDetectionMode m_hystartDetect
Detect way for HyStart algorithm.
uint8_t m_cntClamp
Modulo of the (avoided) float division for cWnd.
void HystartUpdate(Ptr< TcpSocketState > tcb, const Time &delay)
Update HyStart parameters.
double m_c
Cubic Scaling factor.
void CubicReset(Ptr< const TcpSocketState > tcb)
Reset Cubic parameters.
uint32_t m_lastMaxCwnd
Last maximum cWnd.
Time HystartDelayThresh(const Time &t) const
Clamp time value in a range.
uint8_t m_hystartMinSamples
Number of delay samples for detecting the increase of delay.
uint32_t m_hystartLowWindow
Lower bound cWnd for hybrid slow start (segments)
A base class for implementation of a stream socket using TCP.
uint32_t m_segmentSize
Segment size.
uint32_t GetCwndInSegments() const
Get cwnd in segments rather than bytes.
TcpCongState_t
Definition of the Congestion state machine.
@ CA_LOSS
CWND was reduced due to RTO timeout or SACK reneging.
SequenceNumber32 m_lastAckedSeq
Last sequence ACKed.
TracedValue< uint32_t > m_cWnd
Congestion window.
TracedValue< uint32_t > m_ssThresh
Slow start threshold.
Simulation virtual time values and global simulation resolution.
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
static Time Min()
Minimum representable Time Not to be confused with Min(Time,Time).
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Hold an unsigned integer type.
int64x64_t Min(const int64x64_t &a, const int64x64_t &b)
Minimum.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeBooleanChecker()
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Ptr< const AttributeChecker > MakeEnumChecker(T v, std::string n, Ts... args)
Make an EnumChecker pre-configured with a set of allowed values by name.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
#define DELAY(time)
Gets the delay between a given time and the current time.