A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ns3::TcpVegas Class Reference

An implementation of TCP Vegas. More...

#include "tcp-vegas.h"

+ Inheritance diagram for ns3::TcpVegas:
+ Collaboration diagram for ns3::TcpVegas:

Public Member Functions

 TcpVegas ()
 Create an unbound tcp socket.
 
 TcpVegas (const TcpVegas &sock)
 Copy constructor.
 
 ~TcpVegas () override
 
void CongestionStateSet (Ptr< TcpSocketState > tcb, const TcpSocketState::TcpCongState_t newState) override
 Enable/disable Vegas algorithm depending on the congestion state.
 
Ptr< TcpCongestionOpsFork () override
 Copy the congestion control algorithm across sockets.
 
std::string GetName () const override
 Get the name of the congestion control algorithm.
 
uint32_t GetSsThresh (Ptr< const TcpSocketState > tcb, uint32_t bytesInFlight) override
 Get slow start threshold following Vegas principle.
 
void IncreaseWindow (Ptr< TcpSocketState > tcb, uint32_t segmentsAcked) override
 Adjust cwnd following Vegas linear increase/decrease algorithm.
 
void PktsAcked (Ptr< TcpSocketState > tcb, uint32_t segmentsAcked, const Time &rtt) override
 Compute RTTs needed to execute Vegas algorithm.
 
- Public Member Functions inherited from ns3::TcpNewReno
 TcpNewReno ()
 
 TcpNewReno (const TcpNewReno &sock)
 Copy constructor.
 
 ~TcpNewReno () override
 
Ptr< TcpCongestionOpsFork () override
 Copy the congestion control algorithm across sockets.
 
std::string GetName () const override
 Get the name of the congestion control algorithm.
 
uint32_t GetSsThresh (Ptr< const TcpSocketState > tcb, uint32_t bytesInFlight) override
 Get the slow start threshold after a loss event.
 
void IncreaseWindow (Ptr< TcpSocketState > tcb, uint32_t segmentsAcked) override
 Try to increase the cWnd following the NewReno specification.
 
- Public Member Functions inherited from ns3::TcpCongestionOps
 TcpCongestionOps ()
 
 TcpCongestionOps (const TcpCongestionOps &other)
 Copy constructor.
 
 ~TcpCongestionOps () override
 
virtual void CongControl (Ptr< TcpSocketState > tcb, const TcpRateOps::TcpRateConnection &rc, const TcpRateOps::TcpRateSample &rs)
 Called when packets are delivered to update cwnd and pacing rate.
 
virtual void CongestionStateSet (Ptr< TcpSocketState > tcb, const TcpSocketState::TcpCongState_t newState)
 Trigger events/calculations specific to a congestion state.
 
virtual void CwndEvent (Ptr< TcpSocketState > tcb, const TcpSocketState::TcpCAEvent_t event)
 Trigger events/calculations on occurrence of congestion window event.
 
virtual Ptr< TcpCongestionOpsFork ()=0
 Copy the congestion control algorithm across sockets.
 
virtual std::string GetName () const =0
 Get the name of the congestion control algorithm.
 
virtual uint32_t GetSsThresh (Ptr< const TcpSocketState > tcb, uint32_t bytesInFlight)=0
 Get the slow start threshold after a loss event.
 
virtual bool HasCongControl () const
 Returns true when Congestion Control Algorithm implements CongControl.
 
virtual void IncreaseWindow (Ptr< TcpSocketState > tcb, uint32_t segmentsAcked)
 Congestion avoidance algorithm implementation.
 
virtual void Init (Ptr< TcpSocketState > tcb)
 Set configuration required by congestion control algorithm.
 
virtual void PktsAcked (Ptr< TcpSocketState > tcb, uint32_t segmentsAcked, const Time &rtt)
 Timing information on received ACK.
 
- Public Member Functions inherited from ns3::Object
 Object ()
 Constructor.
 
 ~Object () override
 Destructor.
 
void AggregateObject (Ptr< Object > other)
 Aggregate two Objects together.
 
void Dispose ()
 Dispose of this Object.
 
AggregateIterator GetAggregateIterator () const
 Get an iterator to the Objects aggregated to this one.
 
TypeId GetInstanceTypeId () const override
 Get the most derived TypeId for this Object.
 
template<typename T >
Ptr< T > GetObject () const
 Get a pointer to the requested aggregated Object.
 
template<>
Ptr< ObjectGetObject () const
 Specialization of () for objects of type ns3::Object.
 
template<typename T >
Ptr< T > GetObject (TypeId tid) const
 Get a pointer to the requested aggregated Object by TypeId.
 
template<>
Ptr< ObjectGetObject (TypeId tid) const
 Specialization of (TypeId tid) for objects of type ns3::Object.
 
void Initialize ()
 Invoke DoInitialize on all Objects aggregated to this one.
 
bool IsInitialized () const
 Check if the object has been initialized.
 
- Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
 SimpleRefCount ()
 Default constructor.
 
 SimpleRefCount (const SimpleRefCount &o)
 Copy constructor.
 
uint32_t GetReferenceCount () const
 Get the reference count of the object.
 
SimpleRefCountoperator= (const SimpleRefCount &o)
 Assignment operator.
 
void Ref () const
 Increment the reference count.
 
void Unref () const
 Decrement the reference count.
 
- Public Member Functions inherited from ns3::ObjectBase
virtual ~ObjectBase ()
 Virtual destructor.
 
void GetAttribute (std::string name, AttributeValue &value) const
 Get the value of an attribute, raising fatal errors if unsuccessful.
 
bool GetAttributeFailSafe (std::string name, AttributeValue &value) const
 Get the value of an attribute without raising errors.
 
virtual TypeId GetInstanceTypeId () const =0
 Get the most derived TypeId for this Object.
 
void SetAttribute (std::string name, const AttributeValue &value)
 Set a single attribute, raising fatal errors if unsuccessful.
 
bool SetAttributeFailSafe (std::string name, const AttributeValue &value)
 Set a single attribute without raising errors.
 
bool TraceConnect (std::string name, std::string context, const CallbackBase &cb)
 Connect a TraceSource to a Callback with a context.
 
bool TraceConnectWithoutContext (std::string name, const CallbackBase &cb)
 Connect a TraceSource to a Callback without a context.
 
bool TraceDisconnect (std::string name, std::string context, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected with a context.
 
bool TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected without a context.
 

Static Public Member Functions

static TypeId GetTypeId ()
 Get the type ID.
 
- Static Public Member Functions inherited from ns3::TcpNewReno
static TypeId GetTypeId ()
 Get the type ID.
 
- Static Public Member Functions inherited from ns3::TcpCongestionOps
static TypeId GetTypeId ()
 Get the type ID.
 
- Static Public Member Functions inherited from ns3::Object
static TypeId GetTypeId ()
 Register this type.
 
- Static Public Member Functions inherited from ns3::ObjectBase
static TypeId GetTypeId ()
 Get the type ID.
 

Private Member Functions

void DisableVegas ()
 Stop taking Vegas samples.
 
void EnableVegas (Ptr< TcpSocketState > tcb)
 Enable Vegas algorithm to start taking Vegas samples.
 

Private Attributes

uint32_t m_alpha
 Alpha threshold, lower bound of packets in network.
 
Time m_baseRtt
 Minimum of all Vegas RTT measurements seen during connection.
 
SequenceNumber32 m_begSndNxt
 Right edge during last RTT.
 
uint32_t m_beta
 Beta threshold, upper bound of packets in network.
 
uint32_t m_cntRtt
 Number of RTT measurements during last RTT.
 
bool m_doingVegasNow
 If true, do Vegas for this RTT.
 
uint32_t m_gamma
 Gamma threshold, limit on increase.
 
Time m_minRtt
 Minimum of all RTT measurements within last RTT.
 

Additional Inherited Members

- Protected Member Functions inherited from ns3::TcpNewReno
virtual void CongestionAvoidance (Ptr< TcpSocketState > tcb, uint32_t segmentsAcked)
 NewReno congestion avoidance.
 
virtual uint32_t SlowStart (Ptr< TcpSocketState > tcb, uint32_t segmentsAcked)
 Tcp NewReno slow start algorithm.
 
- Protected Member Functions inherited from ns3::Object
 Object (const Object &o)
 Copy an Object.
 
virtual void DoDispose ()
 Destructor implementation.
 
virtual void DoInitialize ()
 Initialize() implementation.
 
virtual void NotifyNewAggregate ()
 Notify all Objects aggregated to this one of a new Object being aggregated.
 
- Protected Member Functions inherited from ns3::ObjectBase
void ConstructSelf (const AttributeConstructionList &attributes)
 Complete construction of ObjectBase; invoked by derived classes.
 
virtual void NotifyConstructionCompleted ()
 Notifier called once the ObjectBase is fully constructed.
 

Detailed Description

An implementation of TCP Vegas.

TCP Vegas is a pure delay-based congestion control algorithm implementing a proactive scheme that tries to prevent packet drops by maintaining a small backlog at the bottleneck queue.

Vegas continuously measures the actual throughput a connection achieves as shown in Equation (1) and compares it with the expected throughput calculated in Equation (2). The difference between these 2 sending rates in Equation (3) reflects the amount of extra packets being queued at the bottleneck.

         actual = cwnd / RTT        (1)
         expected = cwnd / BaseRTT  (2)
         diff = expected - actual   (3)

To avoid congestion, Vegas linearly increases/decreases its congestion window to ensure the diff value fall between the 2 predefined thresholds, alpha and beta. diff and another threshold, gamma, are used to determine when Vegas should change from its slow-start mode to linear increase/decrease mode.

Following the implementation of Vegas in Linux, we use 2, 4, and 1 as the default values of alpha, beta, and gamma, respectively.

More information: http://dx.doi.org/10.1109/49.464716

Config Paths

ns3::TcpVegas is accessible through the following paths with Config::Set and Config::Connect:

  • "/NodeList/[i]/$ns3::TcpL4Protocol/SocketList/[i]/CongestionOps/$ns3::TcpNewReno/$ns3::TcpVegas"
  • "/NodeList/[i]/$ns3::TcpL4Protocol/SocketList/[i]/CongestionOps/$ns3::TcpVegas"

Attributes

  • Alpha: Lower bound of packets in network
    • Set with class: ns3::UintegerValue
    • Underlying type: uint32_t 0:4294967295
    • Initial value: 2
    • Flags: constructwriteread
  • Beta: Upper bound of packets in network
    • Set with class: ns3::UintegerValue
    • Underlying type: uint32_t 0:4294967295
    • Initial value: 4
    • Flags: constructwriteread
  • Gamma: Limit on increase
    • Set with class: ns3::UintegerValue
    • Underlying type: uint32_t 0:4294967295
    • Initial value: 1
    • Flags: constructwriteread

No TraceSources are defined for this type.
Size of this type is 72 bytes (on a 64-bit architecture).

Definition at line 65 of file tcp-vegas.h.

Constructor & Destructor Documentation

◆ TcpVegas() [1/2]

ns3::TcpVegas::TcpVegas ( )

Create an unbound tcp socket.

Definition at line 63 of file tcp-vegas.cc.

References NS_LOG_FUNCTION.

◆ TcpVegas() [2/2]

ns3::TcpVegas::TcpVegas ( const TcpVegas sock)

Copy constructor.

Parameters
sockthe object to copy

Definition at line 77 of file tcp-vegas.cc.

References NS_LOG_FUNCTION.

◆ ~TcpVegas()

ns3::TcpVegas::~TcpVegas ( )
override

Definition at line 91 of file tcp-vegas.cc.

References NS_LOG_FUNCTION.

Member Function Documentation

◆ CongestionStateSet()

void ns3::TcpVegas::CongestionStateSet ( Ptr< TcpSocketState tcb,
const TcpSocketState::TcpCongState_t  newState 
)
overridevirtual

Enable/disable Vegas algorithm depending on the congestion state.

We only start a Vegas cycle when we are in normal congestion state (CA_OPEN state).

Parameters
tcbinternal congestion state
newStatenew congestion state to which the TCP is going to switch

Reimplemented from ns3::TcpCongestionOps.

Definition at line 143 of file tcp-vegas.cc.

References ns3::TcpSocketState::CA_OPEN, DisableVegas(), EnableVegas(), and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

◆ DisableVegas()

void ns3::TcpVegas::DisableVegas ( )
private

Stop taking Vegas samples.

Definition at line 135 of file tcp-vegas.cc.

References m_doingVegasNow, and NS_LOG_FUNCTION.

Referenced by CongestionStateSet().

+ Here is the caller graph for this function:

◆ EnableVegas()

void ns3::TcpVegas::EnableVegas ( Ptr< TcpSocketState tcb)
private

Enable Vegas algorithm to start taking Vegas samples.

Vegas algorithm is enabled in the following situations:

  1. at the establishment of a connection
  2. after an RTO
  3. after fast recovery
  4. when an idle connection is restarted
Parameters
tcbinternal congestion state

Definition at line 124 of file tcp-vegas.cc.

References m_begSndNxt, m_cntRtt, m_doingVegasNow, m_minRtt, ns3::Time::Max(), and NS_LOG_FUNCTION.

Referenced by CongestionStateSet().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Fork()

Ptr< TcpCongestionOps > ns3::TcpVegas::Fork ( )
overridevirtual

Copy the congestion control algorithm across sockets.

Returns
a pointer of the copied object

Reimplemented from ns3::TcpNewReno.

Definition at line 97 of file tcp-vegas.cc.

◆ GetName()

std::string ns3::TcpVegas::GetName ( ) const
overridevirtual

Get the name of the congestion control algorithm.

Returns
A string identifying the name

Reimplemented from ns3::TcpNewReno.

Definition at line 284 of file tcp-vegas.cc.

◆ GetSsThresh()

uint32_t ns3::TcpVegas::GetSsThresh ( Ptr< const TcpSocketState tcb,
uint32_t  bytesInFlight 
)
overridevirtual

Get slow start threshold following Vegas principle.

Parameters
tcbinternal congestion state
bytesInFlightbytes in flight
Returns
the slow start threshold value

Reimplemented from ns3::TcpNewReno.

Definition at line 290 of file tcp-vegas.cc.

References NS_LOG_FUNCTION.

Referenced by IncreaseWindow().

+ Here is the caller graph for this function:

◆ GetTypeId()

TypeId ns3::TcpVegas::GetTypeId ( )
static

Get the type ID.

Returns
the object TypeId

Definition at line 39 of file tcp-vegas.cc.

References m_alpha, m_beta, m_gamma, ns3::MakeUintegerAccessor(), and ns3::TypeId::SetParent().

+ Here is the call graph for this function:

◆ IncreaseWindow()

void ns3::TcpVegas::IncreaseWindow ( Ptr< TcpSocketState tcb,
uint32_t  segmentsAcked 
)
overridevirtual

Adjust cwnd following Vegas linear increase/decrease algorithm.

Parameters
tcbinternal congestion state
segmentsAckedcount of segments ACKed

Reimplemented from ns3::TcpNewReno.

Definition at line 157 of file tcp-vegas.cc.

References ns3::Time::GetSeconds(), GetSsThresh(), ns3::TcpNewReno::IncreaseWindow(), m_alpha, m_baseRtt, m_begSndNxt, m_beta, m_cntRtt, m_doingVegasNow, m_gamma, m_minRtt, ns3::Time::Max(), NS_ASSERT, NS_LOG_DEBUG, NS_LOG_FUNCTION, NS_LOG_LOGIC, and ns3::TcpNewReno::SlowStart().

+ Here is the call graph for this function:

◆ PktsAcked()

void ns3::TcpVegas::PktsAcked ( Ptr< TcpSocketState tcb,
uint32_t  segmentsAcked,
const Time rtt 
)
overridevirtual

Compute RTTs needed to execute Vegas algorithm.

The function filters RTT samples from the last RTT to find the current smallest propagation delay + queueing delay (minRtt). We take the minimum to avoid the effects of delayed ACKs.

The function also min-filters all RTT measurements seen to find the propagation delay (baseRtt).

Parameters
tcbinternal congestion state
segmentsAckedcount of segments ACKed
rttlast RTT

Reimplemented from ns3::TcpCongestionOps.

Definition at line 103 of file tcp-vegas.cc.

References ns3::Time::IsZero(), m_baseRtt, m_cntRtt, m_minRtt, NS_LOG_DEBUG, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

Member Data Documentation

◆ m_alpha

uint32_t ns3::TcpVegas::m_alpha
private

Alpha threshold, lower bound of packets in network.

Definition at line 157 of file tcp-vegas.h.

Referenced by GetTypeId(), and IncreaseWindow().

◆ m_baseRtt

Time ns3::TcpVegas::m_baseRtt
private

Minimum of all Vegas RTT measurements seen during connection.

Definition at line 160 of file tcp-vegas.h.

Referenced by IncreaseWindow(), and PktsAcked().

◆ m_begSndNxt

SequenceNumber32 ns3::TcpVegas::m_begSndNxt
private

Right edge during last RTT.

Definition at line 164 of file tcp-vegas.h.

Referenced by EnableVegas(), and IncreaseWindow().

◆ m_beta

uint32_t ns3::TcpVegas::m_beta
private

Beta threshold, upper bound of packets in network.

Definition at line 158 of file tcp-vegas.h.

Referenced by GetTypeId(), and IncreaseWindow().

◆ m_cntRtt

uint32_t ns3::TcpVegas::m_cntRtt
private

Number of RTT measurements during last RTT.

Definition at line 162 of file tcp-vegas.h.

Referenced by EnableVegas(), IncreaseWindow(), and PktsAcked().

◆ m_doingVegasNow

bool ns3::TcpVegas::m_doingVegasNow
private

If true, do Vegas for this RTT.

Definition at line 163 of file tcp-vegas.h.

Referenced by DisableVegas(), EnableVegas(), and IncreaseWindow().

◆ m_gamma

uint32_t ns3::TcpVegas::m_gamma
private

Gamma threshold, limit on increase.

Definition at line 159 of file tcp-vegas.h.

Referenced by GetTypeId(), and IncreaseWindow().

◆ m_minRtt

Time ns3::TcpVegas::m_minRtt
private

Minimum of all RTT measurements within last RTT.

Definition at line 161 of file tcp-vegas.h.

Referenced by EnableVegas(), IncreaseWindow(), and PktsAcked().


The documentation for this class was generated from the following files: