OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
72 uint32_t delay_mean() const { return delay_mean_; } | 72 uint32_t delay_mean() const { return delay_mean_; } |
73 uint32_t delay_stddev() const { return delay_stddev_; } | 73 uint32_t delay_stddev() const { return delay_stddev_; } |
74 uint32_t delay_samples() const { return delay_samples_; } | 74 uint32_t delay_samples() const { return delay_samples_; } |
75 void set_delay_mean(uint32_t delay_mean) { delay_mean_ = delay_mean; } | 75 void set_delay_mean(uint32_t delay_mean) { delay_mean_ = delay_mean; } |
76 void set_delay_stddev(uint32_t delay_stddev) { delay_stddev_ = delay_stddev; } | 76 void set_delay_stddev(uint32_t delay_stddev) { delay_stddev_ = delay_stddev; } |
77 void set_delay_samples(uint32_t delay_samples) { | 77 void set_delay_samples(uint32_t delay_samples) { |
78 delay_samples_ = delay_samples; | 78 delay_samples_ = delay_samples; |
79 } | 79 } |
80 | 80 |
81 // If the (transit) delay parameters are modified, this method should be | 81 // If the (transit) delay parameters are modified, this method should be |
82 // called to recompute the new distribution. | 82 // called to recompute the new distribution for the transit delay. |
83 // If |delay_dist_ipv6_| is set, that will be used for the delay distribution | |
Taylor Brandstetter
2016/09/15 00:43:17
nit: Since delay_dist_ is an implementation detail
honghaiz3
2016/09/16 01:41:29
This change has been reverted.
| |
84 // of IPv6 sockets. | |
83 void UpdateDelayDistribution(); | 85 void UpdateDelayDistribution(); |
86 // Computes a new delay distribution for IPv6 sockets using the current | |
87 // delay parameters. If this was not called to create a delay distribution | |
88 // for IPv6 sockets, IPv6 sockets use the same delay distribution as | |
89 // |delay_dist_| set by UpdateDelayDistribution(). | |
90 void UpdateDelayDistributionForIPv6(); | |
Taylor Brandstetter
2016/09/15 00:43:17
I think this is good, but another idea would to ha
honghaiz3
2016/09/16 01:41:29
I changed to set the delay for source socket addre
Taylor Brandstetter
2016/09/16 17:21:17
Sounds good; after thinking about it a bit I agree
| |
84 | 91 |
85 // Controls the (uniform) probability that any sent packet is dropped. This | 92 // Controls the (uniform) probability that any sent packet is dropped. This |
86 // is separate from calculations to drop based on queue size. | 93 // is separate from calculations to drop based on queue size. |
87 double drop_probability() { return drop_prob_; } | 94 double drop_probability() { return drop_prob_; } |
88 void set_drop_probability(double drop_prob) { | 95 void set_drop_probability(double drop_prob) { |
89 assert((0 <= drop_prob) && (drop_prob <= 1)); | 96 assert((0 <= drop_prob) && (drop_prob <= 1)); |
90 drop_prob_ = drop_prob; | 97 drop_prob_ = drop_prob; |
91 } | 98 } |
92 | 99 |
93 // If |blocked| is true, subsequent attempts to send will result in -1 being | 100 // If |blocked| is true, subsequent attempts to send will result in -1 being |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
188 size_t header_size, | 195 size_t header_size, |
189 bool ordered); | 196 bool ordered); |
190 | 197 |
191 // Removes stale packets from the network | 198 // Removes stale packets from the network |
192 void PurgeNetworkPackets(VirtualSocket* socket, int64_t cur_time); | 199 void PurgeNetworkPackets(VirtualSocket* socket, int64_t cur_time); |
193 | 200 |
194 // Computes the number of milliseconds required to send a packet of this size. | 201 // Computes the number of milliseconds required to send a packet of this size. |
195 uint32_t SendDelay(uint32_t size); | 202 uint32_t SendDelay(uint32_t size); |
196 | 203 |
197 // Returns a random transit delay chosen from the appropriate distribution. | 204 // Returns a random transit delay chosen from the appropriate distribution. |
198 uint32_t GetRandomTransitDelay(); | 205 uint32_t GetRandomTransitDelay(Socket* socket); |
199 | 206 |
200 // Basic operations on functions. Those that return a function also take | 207 // Basic operations on functions. Those that return a function also take |
201 // ownership of the function given (and hence, may modify or delete it). | 208 // ownership of the function given (and hence, may modify or delete it). |
202 static Function* Accumulate(Function* f); | 209 static Function* Accumulate(Function* f); |
203 static Function* Invert(Function* f); | 210 static Function* Invert(Function* f); |
204 static Function* Resample(Function* f, | 211 static Function* Resample(Function* f, |
205 double x1, | 212 double x1, |
206 double x2, | 213 double x2, |
207 uint32_t samples); | 214 uint32_t samples); |
208 static double Evaluate(Function* f, double x); | 215 static double Evaluate(Function* f, double x); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
253 IPAddress default_route_v4_; | 260 IPAddress default_route_v4_; |
254 IPAddress default_route_v6_; | 261 IPAddress default_route_v6_; |
255 | 262 |
256 uint32_t bandwidth_; | 263 uint32_t bandwidth_; |
257 uint32_t network_capacity_; | 264 uint32_t network_capacity_; |
258 uint32_t send_buffer_capacity_; | 265 uint32_t send_buffer_capacity_; |
259 uint32_t recv_buffer_capacity_; | 266 uint32_t recv_buffer_capacity_; |
260 uint32_t delay_mean_; | 267 uint32_t delay_mean_; |
261 uint32_t delay_stddev_; | 268 uint32_t delay_stddev_; |
262 uint32_t delay_samples_; | 269 uint32_t delay_samples_; |
263 Function* delay_dist_; | 270 std::unique_ptr<Function> delay_dist_; |
271 std::unique_ptr<Function> delay_dist_ipv6_; | |
272 | |
264 CriticalSection delay_crit_; | 273 CriticalSection delay_crit_; |
265 | 274 |
266 double drop_prob_; | 275 double drop_prob_; |
267 bool sending_blocked_ = false; | 276 bool sending_blocked_ = false; |
268 RTC_DISALLOW_COPY_AND_ASSIGN(VirtualSocketServer); | 277 RTC_DISALLOW_COPY_AND_ASSIGN(VirtualSocketServer); |
269 }; | 278 }; |
270 | 279 |
271 // Implements the socket interface using the virtual network. Packets are | 280 // Implements the socket interface using the virtual network. Packets are |
272 // passed as messages using the message queue of the socket server. | 281 // passed as messages using the message queue of the socket server. |
273 class VirtualSocket : public AsyncSocket, | 282 class VirtualSocket : public AsyncSocket, |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
375 | 384 |
376 // Store the options that are set | 385 // Store the options that are set |
377 OptionsMap options_map_; | 386 OptionsMap options_map_; |
378 | 387 |
379 friend class VirtualSocketServer; | 388 friend class VirtualSocketServer; |
380 }; | 389 }; |
381 | 390 |
382 } // namespace rtc | 391 } // namespace rtc |
383 | 392 |
384 #endif // WEBRTC_BASE_VIRTUALSOCKETSERVER_H_ | 393 #endif // WEBRTC_BASE_VIRTUALSOCKETSERVER_H_ |
OLD | NEW |