32 .AddConstructor<TcpVegas>()
33 .SetGroupName(
"Internet")
34 .AddAttribute(
"Alpha",
35 "Lower bound of packets in network",
40 "Upper bound of packets in network",
44 .AddAttribute(
"Gamma",
60 m_doingVegasNow(true),
68 m_alpha(sock.m_alpha),
70 m_gamma(sock.m_gamma),
71 m_baseRtt(sock.m_baseRtt),
72 m_minRtt(sock.m_minRtt),
73 m_cntRtt(sock.m_cntRtt),
74 m_doingVegasNow(true),
153 NS_LOG_LOGIC(
"Vegas is not turned on, we follow NewReno algorithm.");
161 NS_LOG_LOGIC(
"A Vegas cycle has finished, we adjust cwnd once per RTT.");
173 "We do not have enough RTT samples to do Vegas, so we behave like NewReno.");
178 NS_LOG_LOGIC(
"We have enough RTT samples to perform Vegas calculations");
187 uint32_t segCwnd = tcb->GetCwndInSegments();
198 targetCwnd =
static_cast<uint32_t>(segCwnd * tmp);
206 diff = segCwnd - targetCwnd;
209 if (diff >
m_gamma && (tcb->m_cWnd < tcb->m_ssThresh))
216 NS_LOG_LOGIC(
"We are going too fast. We need to slow down and "
217 "change to linear increase/decrease mode.");
218 segCwnd = std::min(segCwnd, targetCwnd + 1);
219 tcb->m_cWnd = segCwnd * tcb->m_segmentSize;
221 NS_LOG_DEBUG(
"Updated cwnd = " << tcb->m_cWnd <<
" ssthresh=" << tcb->m_ssThresh);
223 else if (tcb->m_cWnd < tcb->m_ssThresh)
225 NS_LOG_LOGIC(
"We are in slow start and diff < m_gamma, so we "
226 "follow NewReno slow start");
231 NS_LOG_LOGIC(
"We are in linear increase/decrease mode");
235 NS_LOG_LOGIC(
"We are going too fast, so we slow down by decrementing cwnd");
237 tcb->m_cWnd = segCwnd * tcb->m_segmentSize;
240 <<
" ssthresh=" << tcb->m_ssThresh);
246 NS_LOG_LOGIC(
"We are going too slow, so we speed up by incrementing cwnd");
248 tcb->m_cWnd = segCwnd * tcb->m_segmentSize;
250 <<
" ssthresh=" << tcb->m_ssThresh);
258 tcb->m_ssThresh = std::max(tcb->m_ssThresh, 3 * tcb->m_cWnd / 4);
266 else if (tcb->m_cWnd < tcb->m_ssThresh)
282 return std::max(std::min(tcb->m_ssThresh.Get(), tcb->m_cWnd.Get() - tcb->m_segmentSize),
283 2 * tcb->m_segmentSize);
friend Ptr< T > CopyObject(Ptr< T > object)
Copy an Object.
Smart pointer class similar to boost::intrusive_ptr.
The NewReno implementation.
virtual uint32_t SlowStart(Ptr< TcpSocketState > tcb, uint32_t segmentsAcked)
Tcp NewReno slow start algorithm.
void IncreaseWindow(Ptr< TcpSocketState > tcb, uint32_t segmentsAcked) override
Try to increase the cWnd following the NewReno specification.
TcpCongState_t
Definition of the Congestion state machine.
@ CA_OPEN
Normal state, no dubious events.
An implementation of TCP Vegas.
uint32_t GetSsThresh(Ptr< const TcpSocketState > tcb, uint32_t bytesInFlight) override
Get slow start threshold following Vegas principle.
void DisableVegas()
Stop taking Vegas samples.
uint32_t m_cntRtt
Number of RTT measurements during last RTT.
std::string GetName() const override
Get the name of the congestion control algorithm.
Ptr< TcpCongestionOps > Fork() override
Copy the congestion control algorithm across sockets.
uint32_t m_alpha
Alpha threshold, lower bound of packets in network.
uint32_t m_beta
Beta threshold, upper bound of packets in network.
void IncreaseWindow(Ptr< TcpSocketState > tcb, uint32_t segmentsAcked) override
Adjust cwnd following Vegas linear increase/decrease algorithm.
bool m_doingVegasNow
If true, do Vegas for this RTT.
void EnableVegas(Ptr< TcpSocketState > tcb)
Enable Vegas algorithm to start taking Vegas samples.
Time m_minRtt
Minimum of all RTT measurements within last RTT.
void PktsAcked(Ptr< TcpSocketState > tcb, uint32_t segmentsAcked, const Time &rtt) override
Compute RTTs needed to execute Vegas algorithm.
void CongestionStateSet(Ptr< TcpSocketState > tcb, const TcpSocketState::TcpCongState_t newState) override
Enable/disable Vegas algorithm depending on the congestion state.
TcpVegas()
Create an unbound tcp socket.
Time m_baseRtt
Minimum of all Vegas RTT measurements seen during connection.
uint32_t m_gamma
Gamma threshold, limit on increase.
static TypeId GetTypeId()
Get the type ID.
SequenceNumber32 m_begSndNxt
Right edge during last RTT.
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 Max()
Maximum representable Time Not to be confused with Max(Time,Time).
bool IsZero() const
Exactly equivalent to t == 0.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Hold an unsigned integer type.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#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_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeUintegerChecker()
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)