A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
tcp-westwood.h
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013 ResiliNets, ITTC, University of Kansas
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Authors: Siddharth Gangadhar <siddharth@ittc.ku.edu>, Truc Anh N. Nguyen <annguyen@ittc.ku.edu>,
19  * and Greeshma Umapathi
20  *
21  * James P.G. Sterbenz <jpgs@ittc.ku.edu>, director
22  * ResiliNets Research Group http://wiki.ittc.ku.edu/resilinets
23  * Information and Telecommunication Technology Center (ITTC)
24  * and Department of Electrical Engineering and Computer Science
25  * The University of Kansas Lawrence, KS USA.
26  *
27  * Work supported in part by NSF FIND (Future Internet Design) Program
28  * under grant CNS-0626918 (Postmodern Internet Architecture),
29  * NSF grant CNS-1050226 (Multilayer Network Resilience Analysis and Experimentation on GENI),
30  * US Department of Defense (DoD), and ITTC at The University of Kansas.
31  */
32 
33 #ifndef TCP_WESTWOOD_H
34 #define TCP_WESTWOOD_H
35 
36 #include "tcp-socket-base.h"
37 #include "ns3/packet.h"
38 
39 namespace ns3 {
40 
62 class TcpWestwood : public TcpSocketBase
63 {
64 public:
65  static TypeId GetTypeId (void);
66 
67  TcpWestwood (void);
68  TcpWestwood (const TcpWestwood& sock);
69  virtual ~TcpWestwood (void);
70 
71  enum ProtocolType
72  {
73  WESTWOOD,
74  WESTWOODPLUS
75  };
76 
77  enum FilterType
78  {
79  NONE,
80  TUSTIN
81  };
82 
83  // From TcpSocketBase
84  virtual int Connect (const Address &address);
85  virtual int Listen (void);
86 
87 protected:
93  virtual uint32_t Window (void);
94 
98  virtual Ptr<TcpSocketBase> Fork (void);
99 
106  virtual void ReceivedAck (Ptr<Packet> packet, const TcpHeader& tcpHeader);
107 
114  virtual void NewAck (SequenceNumber32 const& seq);
115 
123  virtual void DupAck (const TcpHeader& header, uint32_t count);
124 
129  virtual void Retransmit (void);
130 
135  virtual void EstimateRtt (const TcpHeader& header);
136 
137  // Implementing ns3::TcpSocket -- Attribute get/set
141  virtual void SetSegSize (uint32_t size);
142 
146  virtual void SetSSThresh (uint32_t threshold);
147 
151  virtual uint32_t GetSSThresh (void) const;
152 
156  virtual void SetInitialCwnd (uint32_t cwnd);
157 
161  virtual uint32_t GetInitialCwnd (void) const;
162 
163 private:
167  void InitializeCwnd (void);
168 
175  int CountAck (const TcpHeader& tcpHeader);
176 
182  void UpdateAckedSegments (int acked);
183 
191  void EstimateBW (int acked, const TcpHeader& tcpHeader, Time rtt);
192 
196  void Filtering (void);
197 
198 protected:
199  TracedValue<uint32_t> m_cWnd; //< Congestion window
200  uint32_t m_ssThresh; //< Slow Start Threshold
201  uint32_t m_initialCWnd; //< Initial cWnd value
202  bool m_inFastRec; //< Currently in fast recovery if TRUE
203 
204  TracedValue<double> m_currentBW; //< Current value of the estimated BW
205  double m_lastSampleBW; //< Last bandwidth sample
206  double m_lastBW; //< Last bandwidth sample after being filtered
207  Time m_minRtt; //< Minimum RTT
208  double m_lastAck; //< The time last ACK was received
209  SequenceNumber32 m_prevAckNo; //< Previously received ACK number
210  int m_accountedFor; //< The number of received DUPACKs
211  enum ProtocolType m_pType; //< 0 for Westwood, 1 for Westwood+
212  enum FilterType m_fType; //< 0 for none, 1 for Tustin
213 
214  int m_ackedSegments; //< The number of segments ACKed between RTTs
215  bool m_IsCount; //< Start keeping track of m_ackedSegments for Westwood+ if TRUE
216  EventId m_bwEstimateEvent; //< The BW estimation event for Westwood+
217 
218 };
219 
220 } // namespace ns3
221 
222 #endif /* TCP_WESTWOOD_H */
void InitializeCwnd(void)
int CountAck(const TcpHeader &tcpHeader)
keep track of time unit.
Definition: nstime.h:149
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
virtual void NewAck(SequenceNumber32 const &seq)
virtual uint32_t Window(void)
virtual void Retransmit(void)
virtual int Listen(void)
a polymophic address class
Definition: address.h:86
void Filtering(void)
virtual uint32_t GetInitialCwnd(void) const
virtual void SetSSThresh(uint32_t threshold)
virtual void DupAck(const TcpHeader &header, uint32_t count)
A base class for implementation of a stream socket using TCP.
void UpdateAckedSegments(int acked)
Header for the Transmission Control Protocol.
Definition: tcp-header.h:43
virtual void SetSegSize(uint32_t size)
virtual void ReceivedAck(Ptr< Packet > packet, const TcpHeader &tcpHeader)
virtual void SetInitialCwnd(uint32_t cwnd)
virtual Ptr< TcpSocketBase > Fork(void)
an identifier for simulation events.
Definition: event-id.h:46
void EstimateBW(int acked, const TcpHeader &tcpHeader, Time rtt)
virtual uint32_t GetSSThresh(void) const
virtual int Connect(const Address &address)
a unique identifier for an interface.
Definition: type-id.h:44
virtual void EstimateRtt(const TcpHeader &header)
An implementation of a stream socket using TCP.
Definition: tcp-westwood.h:62