28 #include "ns3/tcp-socket-base.h"
41 .AddConstructor<TcpVegas> ()
42 .SetGroupName (
"Internet")
43 .AddAttribute (
"Alpha",
"Lower bound of packets in network",
46 MakeUintegerChecker<uint32_t> ())
47 .AddAttribute (
"Beta",
"Upper bound of packets in network",
50 MakeUintegerChecker<uint32_t> ())
51 .AddAttribute (
"Gamma",
"Limit on increase",
54 MakeUintegerChecker<uint32_t> ())
67 m_doingVegasNow (true),
75 m_alpha (sock.m_alpha),
77 m_gamma (sock.m_gamma),
78 m_baseRtt (sock.m_baseRtt),
79 m_minRtt (sock.m_minRtt),
80 m_cntRtt (sock.m_cntRtt),
81 m_doingVegasNow (true),
95 return CopyObject<TcpVegas> (
this);
162 NS_LOG_LOGIC (
"Vegas is not turned on, we follow NewReno algorithm.");
170 NS_LOG_LOGIC (
"A Vegas cycle has finished, we adjust cwnd once per RTT.");
181 NS_LOG_LOGIC (
"We do not have enough RTT samples to do Vegas, so we behave like NewReno.");
186 NS_LOG_LOGIC (
"We have enough RTT samples to perform Vegas calculations");
195 uint32_t segCwnd = tcb->GetCwndInSegments ();
201 NS_LOG_DEBUG (
"Calculated targetCwnd = " << targetCwnd);
207 diff = segCwnd - targetCwnd;
210 if (diff >
m_gamma && (tcb->m_cWnd < tcb->m_ssThresh))
217 NS_LOG_LOGIC (
"We are going too fast. We need to slow down and change to linear increase/decrease mode.");
218 segCwnd =
std::min (segCwnd, (uint32_t) targetCwnd + 1);
219 tcb->m_cWnd = segCwnd * tcb->m_segmentSize;
222 NS_LOG_DEBUG (
"Updated ssthresh = " << tcb->m_ssThresh);
224 else if (tcb->m_cWnd < tcb->m_ssThresh)
226 NS_LOG_LOGIC (
"We are in slow start and diff < m_gamma, so we 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 NS_LOG_DEBUG (
"Updated 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 NS_LOG_DEBUG (
"Updated ssThresh = " << tcb->m_ssThresh);
258 tcb->m_ssThresh =
std::max (tcb->m_ssThresh, 3 * tcb->m_cWnd / 4);
259 NS_LOG_DEBUG (
"Updated ssThresh = " << tcb->m_ssThresh);
267 else if (tcb->m_cWnd < tcb->m_ssThresh)
281 uint32_t bytesInFlight)
284 return std::max (
std::min (tcb->m_ssThresh.Get (), tcb->m_cWnd.Get () - tcb->m_segmentSize), 2 * tcb->m_segmentSize);
TcpVegas(void)
Create an unbound tcp socket.
Simulation virtual time values and global simulation resolution.
Smart pointer class similar to boost::intrusive_ptr.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
Normal state, no dubious events.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
SequenceNumber32 m_begSndNxt
Right edge during last RTT.
virtual uint32_t SlowStart(Ptr< TcpSocketState > tcb, uint32_t segmentsAcked)
Tcp NewReno slow start algorithm.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
virtual void IncreaseWindow(Ptr< TcpSocketState > tcb, uint32_t segmentsAcked)
Try to increase the cWnd following the NewReno specification.
virtual Ptr< TcpCongestionOps > Fork()
Copy the congestion control algorithm across socket.
The NewReno implementation.
Time m_baseRtt
Minimum of all Vegas RTT measurements seen during connection.
static Time Max()
Maximum representable Time.
An implementation of TCP Vegas.
virtual std::string GetName() const
Get the name of the congestion control algorithm.
Hold an unsigned integer type.
int64x64_t Max(const int64x64_t &a, const int64x64_t &b)
Maximum.
Time m_minRtt
Minimum of all RTT measurements within last RTT.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
TcpCongState_t
Definition of the Congestion state machine.
static TypeId GetTypeId(void)
Get the type ID.
virtual void IncreaseWindow(Ptr< TcpSocketState > tcb, uint32_t segmentsAcked)
Adjust cwnd following Vegas linear increase/decrease algorithm.
virtual void CongestionStateSet(Ptr< TcpSocketState > tcb, const TcpSocketState::TcpCongState_t newState)
Enable/disable Vegas algorithm depending on the congestion state.
virtual void PktsAcked(Ptr< TcpSocketState > tcb, uint32_t segmentsAcked, const Time &rtt)
Compute RTTs needed to execute Vegas algorithm.
void DisableVegas()
Stop taking Vegas samples.
uint32_t m_gamma
Gamma threshold, limit on increase.
uint32_t m_beta
Beta threshold, upper bound of packets in network.
virtual uint32_t GetSsThresh(Ptr< const TcpSocketState > tcb, uint32_t bytesInFlight)
Get slow start threshold following Vegas principle.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
uint32_t m_alpha
Alpha threshold, lower bound of packets in network.
bool m_doingVegasNow
If true, do Vegas for this RTT.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
a unique identifier for an interface.
int64_t GetMilliSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
uint32_t m_cntRtt
of RTT measurements during last RTT
void EnableVegas(Ptr< TcpSocketState > tcb)
Enable Vegas algorithm to start taking Vegas samples.