8#define NS_LOG_APPEND_CONTEXT \
10 std::clog << Simulator::Now().GetSeconds() << " "; \
30 .AddConstructor<TcpCubic>()
31 .SetGroupName(
"Internet")
32 .AddAttribute(
"FastConvergence",
33 "Enable (true) or disable (false) fast convergence",
37 .AddAttribute(
"TcpFriendliness",
38 "Enable (true) or disable (false) TCP friendliness",
43 "Beta for multiplicative decrease",
47 .AddAttribute(
"HyStart",
48 "Enable (true) or disable (false) hybrid slow start algorithm",
52 .AddAttribute(
"HyStartLowWindow",
53 "Lower bound cWnd for hybrid slow start (segments)",
57 .AddAttribute(
"HyStartDetect",
58 "Hybrid Slow Start detection mechanisms:"
59 "packet train, delay, both",
68 .AddAttribute(
"HyStartMinSamples",
69 "Number of delay samples for detecting the increase of delay",
73 .AddAttribute(
"HyStartAckDelta",
74 "Spacing between ack's indicating train",
78 .AddAttribute(
"HyStartDelayMin",
79 "Minimum time for hystart algorithm",
83 .AddAttribute(
"HyStartDelayMax",
84 "Maximum time for hystart algorithm",
88 .AddAttribute(
"CubicDelta",
89 "Delta Time to wait after fast recovery before adjusting param",
93 .AddAttribute(
"CntClamp",
94 "Counter value when no losses are detected (counter is used"
95 " when incrementing cWnd in congestion avoidance, to avoid"
96 " floating point arithmetic). It is the modulo of the (avoided)"
102 "Cubic Scaling factor",
130 m_fastConvergence(sock.m_fastConvergence),
132 m_hystart(sock.m_hystart),
133 m_hystartDetect(sock.m_hystartDetect),
134 m_hystartLowWindow(sock.m_hystartLowWindow),
135 m_hystartAckDelta(sock.m_hystartAckDelta),
136 m_hystartDelayMin(sock.m_hystartDelayMin),
137 m_hystartDelayMax(sock.m_hystartDelayMax),
138 m_hystartMinSamples(sock.m_hystartMinSamples),
139 m_initialCwnd(sock.m_initialCwnd),
140 m_cntClamp(sock.m_cntClamp),
142 m_cWndCnt(sock.m_cWndCnt),
143 m_lastMaxCwnd(sock.m_lastMaxCwnd),
144 m_bicOriginPoint(sock.m_bicOriginPoint),
146 m_delayMin(sock.m_delayMin),
147 m_epochStart(sock.m_epochStart),
148 m_found(sock.m_found),
149 m_roundStart(sock.m_roundStart),
150 m_endSeq(sock.m_endSeq),
151 m_lastAck(sock.m_lastAck),
152 m_cubicDelta(sock.m_cubicDelta),
153 m_currRtt(sock.m_currRtt),
154 m_sampleCnt(sock.m_sampleCnt)
187 if (!tcb->m_isCwndLimited)
189 NS_LOG_DEBUG(
"No increase because current cwnd " << tcb->m_cWnd
190 <<
" is not limiting the flow");
194 if (tcb->m_cWnd < tcb->m_ssThresh)
209 tcb->m_cWnd += segmentsAcked * tcb->m_segmentSize;
212 NS_LOG_INFO(
"In SlowStart, updated to cwnd " << tcb->m_cWnd <<
" ssthresh "
216 if (tcb->m_cWnd >= tcb->m_ssThresh && segmentsAcked > 0)
228 tcb->m_cWnd += tcb->m_segmentSize;
230 NS_LOG_INFO(
"In CongAvoid, updated to cwnd " << tcb->m_cWnd);
234 NS_LOG_INFO(
"Not enough segments have been ACKed to increment cwnd."
251 uint32_t segCwnd = tcb->GetCwndInSegments();
263 NS_LOG_DEBUG(
"lastMaxCwnd <= m_cWnd. K=0 and origin=" << segCwnd);
290 delta =
m_c * std::pow(offs, 3);
311 if (bicTarget > segCwnd)
313 cnt = segCwnd / (bicTarget - segCwnd);
329 delta = (segCwnd * scale) >> 3;
338 maxCnt = segCwnd / delta;
348 return std::max(cnt, 2U);
369 if (
m_hystart && tcb->m_cWnd <= tcb->m_ssThresh &&
426 tcb->m_ssThresh = tcb->m_cWnd;
454 uint32_t segCwnd = tcb->GetCwndInSegments();
456 <<
" segments in flight=" << bytesInFlight / tcb->m_segmentSize);
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Hold variables of type enum.
friend Ptr< T > CopyObject(Ptr< T > object)
Copy an Object.
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.
void Init(Ptr< TcpSocketState > tcb) override
Set configuration required by congestion control algorithm.
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)
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).
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Hold an unsigned integer type.
#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 AttributeChecker > MakeUintegerChecker()
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Ptr< const AttributeChecker > MakeDoubleChecker()
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 AttributeAccessor > MakeBooleanAccessor(T1 a1)
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Ptr< const AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.