A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
tcp-rate-ops.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 Natale Patriciello <natale.patriciello@gmail.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 */
18#ifndef TCP_RATE_OPS_H
19#define TCP_RATE_OPS_H
20
21#include "ns3/data-rate.h"
22#include "ns3/object.h"
23#include "ns3/tcp-tx-item.h"
24#include "ns3/traced-callback.h"
25#include "ns3/traced-value.h"
26
27namespace ns3
28{
29
38class TcpRateOps : public Object
39{
40 public:
41 struct TcpRateSample;
42 struct TcpRateConnection;
43
49 static TypeId GetTypeId();
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,
90 uint32_t in_flight,
92 const SequenceNumber32& tailSeq,
93 const SequenceNumber32& nextTx,
94 const uint32_t lostOut,
95 const uint32_t retransOut) = 0;
96
115 virtual const TcpRateSample& GenerateSample(uint32_t delivered,
116 uint32_t lost,
117 bool is_sack_reneg,
118 uint32_t priorInFlight,
119 const Time& minRtt) = 0;
120
126
139 {
141 bool m_isAppLimited{false};
144 0};
148 Seconds(0.0)};
150 Seconds(0.0)};
152 0};
155
160 bool IsValid() const
161 {
162 return (m_priorTime != Seconds(0.0) || m_interval != Seconds(0.0));
163 }
164 };
165
173 {
174 uint64_t m_delivered{0};
177 Seconds(0)};
179 0};
182 0};
184 Seconds(0)};
185 bool m_rateAppLimited{false};
186 };
187};
188
195{
196 public:
202 static TypeId GetTypeId();
203
204 ~TcpRateLinux() override
205 {
206 }
207
208 void SkbSent(TcpTxItem* skb, bool isStartOfTransmission) override;
209 void SkbDelivered(TcpTxItem* skb) override;
211 uint32_t in_flight,
213 const SequenceNumber32& tailSeq,
214 const SequenceNumber32& nextTx,
215 const uint32_t lostOut,
216 const uint32_t retransOut) override;
217 const TcpRateSample& GenerateSample(uint32_t delivered,
218 uint32_t lost,
219 bool is_sack_reneg,
220 uint32_t priorInFlight,
221 const Time& minRtt) override;
222
224 {
225 return m_rate;
226 }
227
235 typedef void (*TcpRateUpdated)(const TcpRateConnection& rate);
236
245 typedef void (*TcpRateSampleUpdated)(const TcpRateSample& sample);
246
247 private:
248 // Rate sample related variables
251
254};
255
262std::ostream& operator<<(std::ostream& os, const TcpRateOps::TcpRateSample& sample);
263
270std::ostream& operator<<(std::ostream& os, const TcpRateOps::TcpRateConnection& rate);
271
279
288
289} // namespace ns3
290
291#endif /* TCP_RATE_OPS_H */
Class for representing data rates.
Definition: data-rate.h:89
A base class which provides memory management and object aggregation.
Definition: object.h:89
Linux management and generation of Rate information for TCP.
Definition: tcp-rate-ops.h:195
TracedCallback< const TcpRateConnection & > m_rateTrace
Rate trace.
Definition: tcp-rate-ops.h:252
void(* TcpRateSampleUpdated)(const TcpRateSample &sample)
TracedCallback signature for tcp rate sample update events.
Definition: tcp-rate-ops.h:245
void SkbDelivered(TcpTxItem *skb) override
Update the Rate information after an item is received.
const TcpRateConnection & GetConnectionRate() override
Definition: tcp-rate-ops.h:223
TracedCallback< const TcpRateSample & > m_rateSampleTrace
Rate Sample trace.
Definition: tcp-rate-ops.h:253
TcpRateSample m_rateSample
Rate sample (continuously updated)
Definition: tcp-rate-ops.h:250
void(* TcpRateUpdated)(const TcpRateConnection &rate)
TracedCallback signature for tcp rate update events.
Definition: tcp-rate-ops.h:235
TcpRateConnection m_rate
Rate information.
Definition: tcp-rate-ops.h:249
void SkbSent(TcpTxItem *skb, bool isStartOfTransmission) override
Put the rate information inside the sent skb.
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:57
static TypeId GetTypeId()
Get the type ID.
Definition: tcp-rate-ops.cc:39
~TcpRateLinux() override
Definition: tcp-rate-ops.h:204
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.
Interface for all operations that involve a Rate monitoring for TCP.
Definition: tcp-rate-ops.h:39
static TypeId GetTypeId()
Get the type ID.
Definition: tcp-rate-ops.cc:30
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.
virtual void SkbSent(TcpTxItem *skb, bool isStartOfTransmission)=0
Put the rate information inside the sent skb.
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 const TcpRateConnection & GetConnectionRate()=0
virtual void SkbDelivered(TcpTxItem *skb)=0
Update the Rate information after an item is received.
Item that encloses the application packet and some flags for it.
Definition: tcp-tx-item.h:33
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition: type-id.h:59
uint32_t segmentSize
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1336
Every class exported by the ns3 library is enclosed in the ns3 namespace.
bool operator==(const EventId &a, const EventId &b)
Definition: event-id.h:157
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:129
Information about the connection rate.
Definition: tcp-rate-ops.h:173
uint32_t m_txItemDelivered
The value of delivered when the acked item was sent.
Definition: tcp-rate-ops.h:180
Time m_deliveredTime
Simulator time when m_delivered was last updated.
Definition: tcp-rate-ops.h:175
int32_t m_rateDelivered
The amount of data delivered considered to calculate delivery rate.
Definition: tcp-rate-ops.h:181
uint64_t m_delivered
The total amount of data in bytes delivered so far.
Definition: tcp-rate-ops.h:174
uint32_t m_appLimited
The index of the last transmitted packet marked as application-limited.
Definition: tcp-rate-ops.h:178
bool m_rateAppLimited
Was sample was taken when data is app limited?
Definition: tcp-rate-ops.h:185
Time m_firstSentTime
The send time of the packet that was most recently marked as delivered.
Definition: tcp-rate-ops.h:176
Time m_rateInterval
The value of interval considered to calculate delivery rate.
Definition: tcp-rate-ops.h:183
Rate Sample structure.
Definition: tcp-rate-ops.h:139
Time m_ackElapsed
ACK time interval calculated from the most recent packet delivered.
Definition: tcp-rate-ops.h:149
bool IsValid() const
Is the sample valid?
Definition: tcp-rate-ops.h:160
bool m_isAppLimited
Indicates whether the rate sample is application-limited.
Definition: tcp-rate-ops.h:141
uint32_t m_ackedSacked
The amount of data acked and sacked in the last received ack.
Definition: tcp-rate-ops.h:154
DataRate m_deliveryRate
The delivery rate sample.
Definition: tcp-rate-ops.h:140
uint32_t m_priorInFlight
The value if bytes in flight prior to last received ack.
Definition: tcp-rate-ops.h:153
Time m_sendElapsed
Send time interval calculated from the most recent packet delivered.
Definition: tcp-rate-ops.h:147
Time m_interval
The length of the sampling interval.
Definition: tcp-rate-ops.h:142
uint32_t m_priorDelivered
The delivered count of the most recent packet delivered.
Definition: tcp-rate-ops.h:145
int32_t m_delivered
The amount of data marked as delivered over the sampling interval.
Definition: tcp-rate-ops.h:143
uint32_t m_bytesLoss
The amount of data marked as lost from the most recent ack received.
Definition: tcp-rate-ops.h:151
Time m_priorTime
The delivered time of the most recent packet delivered.
Definition: tcp-rate-ops.h:146