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",
49 "Beta for multiplicative decrease",
52 MakeDoubleChecker<double>(0.0))
53 .AddAttribute(
"HyStart",
54 "Enable (true) or disable (false) hybrid slow start algorithm",
58 .AddAttribute(
"HyStartLowWindow",
59 "Lower bound cWnd for hybrid slow start (segments)",
62 MakeUintegerChecker<uint32_t>())
63 .AddAttribute(
"HyStartDetect",
64 "Hybrid Slow Start detection mechanisms:"
65 "packet train, delay, both",
74 .AddAttribute(
"HyStartMinSamples",
75 "Number of delay samples for detecting the increase of delay",
78 MakeUintegerChecker<uint8_t>())
79 .AddAttribute(
"HyStartAckDelta",
80 "Spacing between ack's indicating train",
84 .AddAttribute(
"HyStartDelayMin",
85 "Minimum time for hystart algorithm",
89 .AddAttribute(
"HyStartDelayMax",
90 "Maximum time for hystart algorithm",
94 .AddAttribute(
"CubicDelta",
95 "Delta Time to wait after fast recovery before adjusting param",
99 .AddAttribute(
"CntClamp",
100 "Counter value when no losses are detected (counter is used"
101 " when incrementing cWnd in congestion avoidance, to avoid"
102 " floating point arithmetic). It is the modulo of the (avoided)"
106 MakeUintegerChecker<uint8_t>())
108 "Cubic Scaling factor",
111 MakeDoubleChecker<double>(0.0));
136 m_fastConvergence(sock.m_fastConvergence),
138 m_hystart(sock.m_hystart),
139 m_hystartDetect(sock.m_hystartDetect),
140 m_hystartLowWindow(sock.m_hystartLowWindow),
141 m_hystartAckDelta(sock.m_hystartAckDelta),
142 m_hystartDelayMin(sock.m_hystartDelayMin),
143 m_hystartDelayMax(sock.m_hystartDelayMax),
144 m_hystartMinSamples(sock.m_hystartMinSamples),
145 m_initialCwnd(sock.m_initialCwnd),
146 m_cntClamp(sock.m_cntClamp),
148 m_cWndCnt(sock.m_cWndCnt),
149 m_lastMaxCwnd(sock.m_lastMaxCwnd),
150 m_bicOriginPoint(sock.m_bicOriginPoint),
152 m_delayMin(sock.m_delayMin),
153 m_epochStart(sock.m_epochStart),
154 m_found(sock.m_found),
155 m_roundStart(sock.m_roundStart),
156 m_endSeq(sock.m_endSeq),
157 m_lastAck(sock.m_lastAck),
158 m_cubicDelta(sock.m_cubicDelta),
159 m_currRtt(sock.m_currRtt),
160 m_sampleCnt(sock.m_sampleCnt)
187 if (tcb->m_cWnd < tcb->m_ssThresh)
202 tcb->m_cWnd += segmentsAcked * tcb->m_segmentSize;
205 NS_LOG_INFO(
"In SlowStart, updated to cwnd " << tcb->m_cWnd <<
" ssthresh "
209 if (tcb->m_cWnd >= tcb->m_ssThresh && segmentsAcked > 0)
221 tcb->m_cWnd += tcb->m_segmentSize;
223 NS_LOG_INFO(
"In CongAvoid, updated to cwnd " << tcb->m_cWnd);
227 NS_LOG_INFO(
"Not enough segments have been ACKed to increment cwnd."
243 uint32_t segCwnd = tcb->GetCwndInSegments();
251 NS_LOG_DEBUG(
"lastMaxCwnd <= m_cWnd. K=0 and origin=" << segCwnd);
278 delta =
m_c * std::pow(offs, 3);
299 if (bicTarget > segCwnd)
301 cnt = segCwnd / (bicTarget - segCwnd);
316 return std::max(cnt, 2U);
337 if (
m_hystart && tcb->m_cWnd <= tcb->m_ssThresh &&
394 tcb->m_ssThresh = tcb->m_cWnd;
422 uint32_t segCwnd = tcb->GetCwndInSegments();
424 <<
" segments in flight=" << bytesInFlight / tcb->m_segmentSize);
474 return CopyObject<TcpCubic>(
this);
AttributeValue implementation for Boolean.
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.
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 Update(Ptr< TcpSocketState > tcb)
Cubic window update after a new ack received.
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.
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.
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.
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.
@ DELAY
Detection by delay value.
@ PACKET_TRAIN
Detection by trains of packet.
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.
TcpCongState_t
Definition of the Congestion state machine.
@ CA_LOSS
CWND was reduced due to RTO timeout or SACK reneging.
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).
AttributeValue implementation for Time.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Hold an unsigned integer type.
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Ptr< const AttributeChecker > MakeBooleanChecker()
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Ptr< const AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
#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 > MakeEnumChecker(int v, std::string n, Ts... args)
Make an EnumChecker pre-configured with a set of allowed values by name.