33 #define NS_LOG_APPEND_CONTEXT \
34 if (m_node) { std::clog << Simulator::Now ().GetSeconds () << " [node " << m_node->GetId () << "] "; }
38 #include "ns3/trace-source-accessor.h"
39 #include "ns3/simulator.h"
40 #include "ns3/abort.h"
42 #include "ns3/sequence-number.h"
56 .AddConstructor<TcpWestwood>()
57 .AddTraceSource(
"CongestionWindow",
"The TCP connection's congestion window",
59 "ns3::TracedValue::Uint32Callback")
60 .AddTraceSource (
"SlowStartThreshold",
61 "TCP slow start threshold (bytes)",
63 "ns3::TracedValue::Uint32Callback")
64 .AddAttribute(
"FilterType",
"Use this to choose no filter or Tustin's approximation filter",
67 .AddAttribute(
"ProtocolType",
"Use this to let the code run as Westwood or WestwoodPlus",
71 .AddTraceSource(
"EstimatedBW",
"The estimated bandwidth",
73 "ns3::TracedValue::DoubleCallback");
95 m_ssThresh(sock.m_ssThresh),
96 m_initialCWnd(sock.m_initialCWnd),
97 m_initialSsThresh (sock.m_initialSsThresh),
99 m_currentBW(sock.m_currentBW),
100 m_lastSampleBW(sock.m_lastSampleBW),
101 m_lastBW(sock.m_lastBW),
102 m_minRtt(sock.m_minRtt),
103 m_lastAck(sock.m_lastAck),
104 m_prevAckNo(sock.m_prevAckNo),
105 m_accountedFor(sock.m_accountedFor),
106 m_pType(sock.m_pType),
107 m_fType(sock.m_fType),
108 m_IsCount(sock.m_IsCount)
146 return CopyObject<TcpWestwood>(
this);
153 NS_LOG_LOGIC (
"TcpWestwood receieved ACK for seq " << seq <<
174 adder = std::max(1.0, adder);
175 m_cWnd +=
static_cast<uint32_t
>(adder);
void InitializeCwnd(void)
Initialize cwnd at the beginning of a connection.
EventId m_bwEstimateEvent
The BW estimation event for Westwood+.
int CountAck(const TcpHeader &tcpHeader)
Calculate the number of acknowledged packets upon the receipt of an ACK packet.
virtual int Listen(void)
Listen for incoming connections.
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 "...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
TracedValue< Time > m_lastRtt
Last RTT sample collected.
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
double m_lastBW
Last bandwidth sample after being filtered.
int m_accountedFor
The number of received DUPACKs.
virtual void NewAck(SequenceNumber32 const &seq)
Update buffers w.r.t.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
virtual void DupAck(const TcpHeader &t, uint32_t count)
Received dupack (duplicate ACK)
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
uint32_t m_segmentSize
Segment size.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
TracedValue< SequenceNumber32 > m_nextTxSequence
Next seqnum to be sent (SND.NXT), ReTx pushes it back.
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached.
virtual void ReceivedAck(Ptr< Packet > packet, const TcpHeader &tcpHeader)
Received an ACK packet.
T Get(void) const
Get the underlying value.
TracedValue< TcpStates_t > m_state
TCP state.
virtual uint32_t Window(void)
Return the max possible number of unacked bytes.
virtual void Retransmit(void)
Halving cwnd and call DoRetransmit()
virtual int Listen(void)
Listen for incoming connections.
a polymophic address class
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
TracedValue< uint32_t > m_cWnd
Congestion window.
enum FilterType m_fType
0 for none, 1 for Tustin
virtual void EstimateRtt(const TcpHeader &tcpHeader)
Take into account the packet for RTT estimation.
Hold variables of type enum.
Ptr< TcpTxBuffer > m_txBuffer
Tx buffer.
void Filtering(void)
Tustin filter.
virtual uint32_t GetInitialCwnd(void) const
Get the initial Congestion Window.
A base class for implementation of a stream socket using TCP.
bool m_inFastRec
Currently in fast recovery if TRUE.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
void UpdateAckedSegments(int acked)
Update the total number of acknowledged packets during the current RTT.
double m_lastAck
The time last ACK was received.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
SequenceNumber32 m_prevAckNo
Previously received ACK number.
virtual int Connect(const Address &address)
Initiate a connection to a remote host.
static TypeId GetTypeId(void)
Get the type ID.
static Time Now(void)
Return the current simulation virtual time.
TracedValue< uint32_t > m_ssThresh
Slow Start Threshold.
virtual void SetSegSize(uint32_t size)
Set the segment size.
virtual ~TcpWestwood(void)
virtual void NewAck(SequenceNumber32 const &seq)
Update buffers w.r.t.
Ptr< const AttributeChecker > MakeEnumChecker(int v1, std::string n1, int v2, std::string n2, int v3, std::string n3, int v4, std::string n4, int v5, std::string n5, int v6, std::string n6, int v7, std::string n7, int v8, std::string n8, int v9, std::string n9, int v10, std::string n10, int v11, std::string n11, int v12, std::string n12, int v13, std::string n13, int v14, std::string n14, int v15, std::string n15, int v16, std::string n16, int v17, std::string n17, int v18, std::string n18, int v19, std::string n19, int v20, std::string n20, int v21, std::string n21, int v22, std::string n22)
Make an EnumChecker pre-configured with a set of allowed values by name.
int m_ackedSegments
The number of segments ACKed between RTTs.
uint32_t m_initialSsThresh
Initial Slow Start Threshold value.
virtual void ReceivedAck(Ptr< Packet > packet, const TcpHeader &tcpHeader)
Process the newly received ACK.
bool m_connected
Connection established.
#define NS_ABORT_MSG_UNLESS(cond, msg)
Abnormal program termination if a condition is false, with a message.
virtual void SetInitialCwnd(uint32_t cwnd)
Set the initial Congestion Window.
virtual Ptr< TcpSocketBase > Fork(void)
Call CopyObject<> to clone me.
double m_lastSampleBW
Last bandwidth sample.
virtual uint32_t GetInitialSSThresh(void) const
Get the initial Slow Start Threshold.
TracedValue< double > m_currentBW
Current value of the estimated BW.
bool m_IsCount
Start keeping track of m_ackedSegments for Westwood+ if TRUE.
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
void EstimateBW(int acked, const TcpHeader &tcpHeader, Time rtt)
Estimate the network's bandwidth.
uint32_t m_initialCWnd
Initial cWnd value.
Time m_minRtt
Minimum RTT.
virtual int Connect(const Address &address)
Initiate a connection to a remote host.
a unique identifier for an interface.
virtual void EstimateRtt(const TcpHeader &header)
Estimate the RTT, record the minimum value, and run a clock on the RTT to trigger Westwood+ bandwidth...
TypeId SetParent(TypeId tid)
bool SendPendingData(bool withAck=false)
Send as much pending data as possible according to the Tx window.
TracedValue< uint32_t > m_rWnd
Flow control window at remote side.
virtual void DoRetransmit(void)
Retransmit the oldest packet.
virtual void SetInitialSSThresh(uint32_t threshold)
Set the initial Slow Start Threshold.
An implementation of a stream socket using TCP.
enum ProtocolType m_pType
0 for Westwood, 1 for Westwood+