1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
|
/*
* Copyright (c) 2021 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <hicn/transport/utils/chrono_typedefs.h>
#include <utils/min_filter.h>
#include <chrono>
#include <climits>
#include <iostream>
#define TIMEOUT_SMOOTHER 0.1
#define TIMEOUT_RATIO 10
#define ALPHA 0.8
namespace transport {
namespace protocol {
class RaaqmDataPath {
public:
RaaqmDataPath(double drop_factor, double minimum_drop_probability,
unsigned new_timer, unsigned int samples,
const utils::SteadyTime::Milliseconds &new_rtt =
utils::SteadyTime::Milliseconds(1000),
const utils::SteadyTime::Milliseconds &new_rtt_min =
utils::SteadyTime::Milliseconds(1000),
const utils::SteadyTime::Milliseconds &new_rtt_max =
utils::SteadyTime::Milliseconds(1000),
unsigned new_pd = UINT_MAX);
public:
/*
* @brief Add a new RTT to the RTT queue of the path, check if RTT queue is
* full, and thus need overwrite. Also it maintains the validity of min and
* max of RTT.
* @param new_rtt is the value of the new RTT
*/
RaaqmDataPath &insertNewRtt(const utils::SteadyTime::Microseconds &new_rtt,
const utils::SteadyTime::TimePoint &now);
/**
* @brief Update the path statistics
* @param packet_size the size of the packet received, including the ICN
* header
* @param data_size the size of the data received, without the ICN header
*/
RaaqmDataPath &updateReceivedStats(std::size_t packet_size,
std::size_t data_size);
/**
* @brief Get the value of the drop factor parameter
*/
double getDropFactor();
/**
* @brief Get the value of the drop probability
*/
double getDropProb();
/**
* @brief Set the value pf the drop probability
* @param drop_prob is the value of the drop probability
*/
RaaqmDataPath &setDropProb(double drop_prob);
/**
* @brief Get the minimum drop probability
*/
double getMinimumDropProbability();
/**
* @brief Get last RTT
*/
double getRtt();
/**
* @brief Get average RTT
*/
double getAverageRtt();
/**
* @brief Get the current m_timer value
*/
double getTimer();
/**
* @brief Smooth he value of the m_timer accordingly with the last RTT
* measured
*/
RaaqmDataPath &smoothTimer();
/**
* @brief Get the maximum RTT among the last samples
*/
double getRttMax();
/**
* @brief Get the minimum RTT among the last samples
*/
double getRttMin();
/**
* @brief Get the number of saved samples
*/
unsigned getSampleValue();
/**
* @brief Get the size og the RTT queue
*/
unsigned getRttQueueSize();
/*
* @brief Change drop probability according to RTT statistics
* Invoked in RAAQM(), before control window size update.
*/
RaaqmDataPath &updateDropProb();
void setAlpha(double alpha);
/**
* @brief Returns the smallest RTT registered so far for this path
*/
unsigned int getPropagationDelay();
bool newPropagationDelayAvailable();
bool isStale();
private:
/**
* The value of the drop factor
*/
double drop_factor_;
/**
* The minumum drop probability
*/
double minimum_drop_probability_;
/**
* The timer, expressed in milliseconds
*/
double timer_;
/**
* The number of samples to store for computing the protocol measurements
*/
const unsigned int samples_;
/**
* The last, the minimum and the maximum value of the RTT (among the last
* m_samples samples)
*/
uint64_t rtt_, rtt_min_, rtt_max_, prop_delay_;
bool new_prop_delay_;
/**
* The current drop probability
*/
double drop_prob_;
/**
* The number of packets received in this path
*/
intmax_t packets_received_;
/**
* The first packet received after the statistics print
*/
intmax_t last_packets_received_;
/**
* Total number of bytes received including the ICN header
*/
intmax_t m_packets_bytes_received_;
/**
* The amount of packet bytes received at the last path summary computation
*/
intmax_t last_packets_bytes_received_;
/**
* Total number of bytes received without including the ICN header
*/
intmax_t raw_data_bytes_received_;
/**
* The amount of raw dat bytes received at the last path summary computation
*/
intmax_t last_raw_data_bytes_received_;
class byArrival;
class byOrder;
/**
* Double ended queue for the RTTs
*/
typedef utils::MinFilter<uint64_t> RTTQueue;
RTTQueue rtt_samples_;
/**
* Time of the last call to the path reporter method
*/
utils::SteadyTime::TimePoint last_received_pkt_;
double average_rtt_;
double alpha_;
};
} // end namespace protocol
} // end namespace transport
|