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"
57 .AddConstructor<TcpWestwood>()
58 .AddTraceSource(
"CongestionWindow",
"The TCP connection's congestion window",
60 .AddAttribute(
"FilterType",
"Use this to choose no filter or Tustin's approximation filter",
63 .AddAttribute(
"ProtocolType",
"Use this to let the code run as Westwood or WestwoodPlus",
67 .AddTraceSource(
"EstimatedBW",
"The estimated bandwidth",
90 m_ssThresh(sock.m_ssThresh),
91 m_initialCWnd(sock.m_initialCWnd),
93 m_currentBW(sock.m_currentBW),
94 m_lastSampleBW(sock.m_lastSampleBW),
95 m_lastBW(sock.m_lastBW),
96 m_minRtt(sock.m_minRtt),
97 m_lastAck(sock.m_lastAck),
98 m_prevAckNo(sock.m_prevAckNo),
99 m_accountedFor(sock.m_accountedFor),
100 m_pType(sock.m_pType),
101 m_fType(sock.m_fType),
102 m_IsCount(sock.m_IsCount)
140 return CopyObject<TcpWestwood>(
this);
147 NS_LOG_LOGIC (
"TcpWestwood receieved ACK for seq " << seq <<
168 adder = std::max(1.0, adder);
169 m_cWnd +=
static_cast<uint32_t
>(adder);
317 m_rtt->IncreaseMultiplier();
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.
keep track of time values and allow control of global simulation resolution
smart pointer class similar to boost::intrusive_ptr
#define NS_LOG_FUNCTION(parameters)
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)
TracedValue< Time > m_lastRtt
Last RTT sample collected.
SequenceNumber32 HeadSequence(void) const
Returns the first byte's sequence number.
double m_lastBW
Last bandwidth sample after being filtered.
int m_accountedFor
The number of received DUPACKs.
uint32_t m_ssThresh
Slow Start Threshold.
virtual void NewAck(SequenceNumber32 const &seq)
Update buffers w.r.t.
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
virtual void DupAck(const TcpHeader &t, uint32_t count)
Received dupack (duplicate ACK)
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.
TracedValue< TcpStates_t > m_state
TCP state.
virtual uint32_t Window(void)
Return the max possible number of unacked bytes.
#define NS_ABORT_MSG_UNLESS(cond, msg)
Abnormal program termination if cond is false.
virtual void Retransmit(void)
Halving cwnd and call DoRetransmit()
virtual int Listen(void)
Listen for incoming connections.
a polymophic address class
TcpTxBuffer m_txBuffer
Tx buffer.
double GetSeconds(void) const
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'
void Filtering(void)
Tustin filter.
virtual uint32_t GetInitialCwnd(void) const
Get the initial Congestion Window.
NS_LOG_COMPONENT_DEFINE("TcpWestwood")
virtual void SetSSThresh(uint32_t threshold)
Set the Slow Start Threshold.
A base class for implementation of a stream socket using TCP.
Ptr< RttEstimator > m_rtt
Round trip time estimator.
bool m_inFastRec
Currently in fast recovery if TRUE.
#define NS_LOG_LOGIC(msg)
void UpdateAckedSegments(int acked)
Update the total number of acknowledged packets during the current RTT.
double m_lastAck
The time last ACK was received.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
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 time".
virtual void SetSegSize(uint32_t size)
Set the segment size.
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
virtual ~TcpWestwood(void)
virtual void NewAck(SequenceNumber32 const &seq)
Update buffers w.r.t.
int m_ackedSegments
The number of segments ACKed between RTTs.
virtual void ReceivedAck(Ptr< Packet > packet, const TcpHeader &tcpHeader)
Process the newly received ACK.
bool m_connected
Connection established.
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.
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.
virtual uint32_t GetSSThresh(void) const
Get the Slow Start Threshold.
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.
An implementation of a stream socket using TCP.
enum ProtocolType m_pType
0 for Westwood, 1 for Westwood+