A Discrete-Event Network Simulator
API
tcp-rate-ops.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2018 Natale Patriciello <natale.patriciello@gmail.com>
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  */
19 #ifndef TCP_RATE_OPS_H
20 #define TCP_RATE_OPS_H
21 
22 #include "ns3/object.h"
23 #include "ns3/tcp-tx-item.h"
24 #include "ns3/traced-callback.h"
25 #include "ns3/data-rate.h"
26 #include "ns3/traced-value.h"
27 
28 namespace ns3 {
29 
38 class TcpRateOps : public Object
39 {
40 public:
41  struct TcpRateSample;
42  struct TcpRateConnection;
43 
49  static TypeId GetTypeId (void);
60  virtual void SkbSent (TcpTxItem *skb, bool isStartOfTransmission) = 0;
61 
74  virtual void SkbDelivered (TcpTxItem * skb) = 0;
75 
89  virtual void CalculateAppLimited (uint32_t cWnd, uint32_t in_flight,
90  uint32_t segmentSize, const SequenceNumber32 &tailSeq,
91  const SequenceNumber32 &nextTx, const uint32_t lostOut,
92  const uint32_t retransOut) = 0;
93 
111  virtual const TcpRateSample & GenerateSample (uint32_t delivered, uint32_t lost,
112  bool is_sack_reneg, uint32_t priorInFlight,
113  const Time &minRtt) = 0;
114 
119  virtual const TcpRateConnection & GetConnectionRate () = 0;
120 
133  {
135  bool m_isAppLimited {false};
137  int32_t m_delivered {0};
138  uint32_t m_priorDelivered {0};
142  uint32_t m_bytesLoss {0};
143  uint32_t m_priorInFlight {0};
144  uint32_t m_ackedSacked {0};
145 
149  bool IsValid () const
150  {
151  return (m_priorTime != Seconds (0.0) || m_interval != Seconds (0.0));
152  }
153  };
154 
162  {
163  uint64_t m_delivered {0};
166  uint32_t m_appLimited {0};
167  uint32_t m_txItemDelivered {0};
168  int32_t m_rateDelivered {0};
170  bool m_rateAppLimited {false};
171  };
172 };
173 
179 class TcpRateLinux : public TcpRateOps
180 {
181 public:
187  static TypeId GetTypeId (void);
188  virtual ~TcpRateLinux () override
189  {
190  }
191 
192  virtual void SkbSent (TcpTxItem *skb, bool isStartOfTransmission) override;
193  virtual void SkbDelivered (TcpTxItem * skb) override;
194  virtual void CalculateAppLimited (uint32_t cWnd, uint32_t in_flight,
195  uint32_t segmentSize, const SequenceNumber32 &tailSeq,
196  const SequenceNumber32 &nextTx, const uint32_t lostOut,
197  const uint32_t retransOut) override;
198  virtual const TcpRateSample & GenerateSample (uint32_t delivered, uint32_t lost,
199  bool is_sack_reneg, uint32_t priorInFlight,
200  const Time &minRtt) override;
201  virtual const TcpRateConnection & GetConnectionRate () override
202  {
203  return m_rate;
204  }
205 
213  typedef void (* TcpRateUpdated)(const TcpRateConnection &rate);
214 
223  typedef void (* TcpRateSampleUpdated)(const TcpRateSample &sample);
224 
225 private:
226  // Rate sample related variables
229 
232 };
233 
240 std::ostream & operator<< (std::ostream & os, TcpRateLinux::TcpRateSample const & sample);
241 
248 std::ostream & operator<< (std::ostream & os, TcpRateLinux::TcpRateConnection const & rate);
249 
256 bool operator== (TcpRateLinux::TcpRateSample const & lhs, TcpRateLinux::TcpRateSample const & rhs);
257 
265 
266 } //namespace ns3
267 
268 #endif /* TCP_RATE_OPS_H */
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
Time m_sendElapsed
Send time interval calculated from the most recent packet delivered.
Definition: tcp-rate-ops.h:140
virtual const TcpRateConnection & GetConnectionRate() override
Definition: tcp-rate-ops.h:201
Interface for all operations that involve a Rate monitoring for TCP.
Definition: tcp-rate-ops.h:38
static TypeId GetTypeId(void)
Get the type ID.
Definition: tcp-rate-ops.cc:29
uint32_t m_priorDelivered
The delivered count of the most recent packet delivered.
Definition: tcp-rate-ops.h:138
Forward calls to a chain of Callback.
uint32_t segmentSize
Time m_ackElapsed
ACK time interval calculated from the most recent packet delivered.
Definition: tcp-rate-ops.h:141
Linux management and generation of Rate information for TCP.
Definition: tcp-rate-ops.h:179
uint32_t m_priorInFlight
The value if bytes in flight prior to last received ack.
Definition: tcp-rate-ops.h:143
TracedCallback< const TcpRateSample & > m_rateSampleTrace
Rate Sample trace.
Definition: tcp-rate-ops.h:231
bool IsValid() const
Is the sample valid?
Definition: tcp-rate-ops.h:149
uint32_t m_txItemDelivered
The value of delivered when the acked item was sent.
Definition: tcp-rate-ops.h:167
bool m_isAppLimited
Indicates whether the rate sample is application-limited.
Definition: tcp-rate-ops.h:135
TcpRateConnection m_rate
Rate information.
Definition: tcp-rate-ops.h:227
Time m_priorTime
The delivered time of the most recent packet delivered.
Definition: tcp-rate-ops.h:139
TcpRateSample m_rateSample
Rate sample (continuosly updated)
Definition: tcp-rate-ops.h:228
Class for representing data rates.
Definition: data-rate.h:88
virtual void CalculateAppLimited(uint32_t cWnd, uint32_t in_flight, uint32_t segmentSize, const SequenceNumber32 &tailSeq, const SequenceNumber32 &nextTx, const uint32_t lostOut, const uint32_t retransOut)=0
If a gap is detected between sends, it means we are app-limited.
virtual ~TcpRateLinux() override
Definition: tcp-rate-ops.h:188
Item that encloses the application packet and some flags for it.
Definition: tcp-tx-item.h:32
Rate Sample structure.
Definition: tcp-rate-ops.h:132
void(* TcpRateUpdated)(const TcpRateConnection &rate)
TracedCallback signature for tcp rate update events.
Definition: tcp-rate-ops.h:213
void(* TcpRateSampleUpdated)(const TcpRateSample &sample)
TracedCallback signature for tcp rate sample update events.
Definition: tcp-rate-ops.h:223
int32_t m_delivered
The amount of data marked as delivered over the sampling interval.
Definition: tcp-rate-ops.h:137
virtual const TcpRateSample & GenerateSample(uint32_t delivered, uint32_t lost, bool is_sack_reneg, uint32_t priorInFlight, const Time &minRtt) override
Generate a TcpRateSample to feed a congestion avoidance algorithm.
Definition: tcp-rate-ops.cc:59
virtual void SkbDelivered(TcpTxItem *skb)=0
Update the Rate information after an item is received.
DataRate m_deliveryRate
The delivery rate sample.
Definition: tcp-rate-ops.h:134
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
Definition: angles.cc:42
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Time m_rateInterval
The value of interval considered to calculate delivery rate.
Definition: tcp-rate-ops.h:169
bool m_rateAppLimited
Was sample was taken when data is app limited?
Definition: tcp-rate-ops.h:170
uint32_t m_ackedSacked
The amount of data acked and sacked in the last received ack.
Definition: tcp-rate-ops.h:144
static TypeId GetTypeId(void)
Get the type ID.
Definition: tcp-rate-ops.cc:41
Time m_interval
The length of the sampling interval.
Definition: tcp-rate-ops.h:136
uint32_t m_appLimited
The index of the last transmitted packet marked as application-limited.
Definition: tcp-rate-ops.h:166
Information about the connection rate.
Definition: tcp-rate-ops.h:161
TracedCallback< const TcpRateConnection & > m_rateTrace
Rate trace.
Definition: tcp-rate-ops.h:230
uint64_t m_delivered
The total amount of data in bytes delivered so far.
Definition: tcp-rate-ops.h:163
virtual const TcpRateConnection & GetConnectionRate()=0
virtual void CalculateAppLimited(uint32_t cWnd, uint32_t in_flight, uint32_t segmentSize, const SequenceNumber32 &tailSeq, const SequenceNumber32 &nextTx, const uint32_t lostOut, const uint32_t retransOut) override
If a gap is detected between sends, it means we are app-limited.
virtual void SkbSent(TcpTxItem *skb, bool isStartOfTransmission) override
Put the rate information inside the sent skb.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1278
bool operator==(const EventId &a, const EventId &b)
Definition: event-id.h:142
virtual const TcpRateSample & GenerateSample(uint32_t delivered, uint32_t lost, bool is_sack_reneg, uint32_t priorInFlight, const Time &minRtt)=0
Generate a TcpRateSample to feed a congestion avoidance algorithm.
Time m_firstSentTime
The send time of the packet that was most recently marked as delivered.
Definition: tcp-rate-ops.h:165
virtual void SkbDelivered(TcpTxItem *skb) override
Update the Rate information after an item is received.
A base class which provides memory management and object aggregation.
Definition: object.h:87
int32_t m_rateDelivered
The amount of data delivered considered to calculate delivery rate.
Definition: tcp-rate-ops.h:168
a unique identifier for an interface.
Definition: type-id.h:58
void(* DataRate)(DataRate oldValue, DataRate newValue)
TracedValue callback signature for DataRate.
Definition: data-rate.h:260
uint32_t m_bytesLoss
The amount of data marked as lost from the most recent ack received.
Definition: tcp-rate-ops.h:142
Time m_deliveredTime
Simulator time when m_delivered was last updated.
Definition: tcp-rate-ops.h:164
virtual void SkbSent(TcpTxItem *skb, bool isStartOfTransmission)=0
Put the rate information inside the sent skb.