Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(573)

Side by Side Diff: webrtc/test/fake_network_pipe.cc

Issue 2687013005: Increase the send-time history to 60 seconds. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/test/fake_network_pipe.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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
11 #include "webrtc/test/fake_network_pipe.h" 11 #include "webrtc/test/fake_network_pipe.h"
12 12
13 #include <assert.h> 13 #include <assert.h>
14 #include <math.h> 14 #include <math.h>
15 #include <string.h> 15 #include <string.h>
16 16
17 #include <algorithm> 17 #include <algorithm>
18 #include <cmath> 18 #include <cmath>
19 19
20 #include "webrtc/base/logging.h"
20 #include "webrtc/call/call.h" 21 #include "webrtc/call/call.h"
21 #include "webrtc/system_wrappers/include/clock.h" 22 #include "webrtc/system_wrappers/include/clock.h"
22 23
23 namespace webrtc { 24 namespace webrtc {
24 25
25 FakeNetworkPipe::FakeNetworkPipe(Clock* clock, 26 FakeNetworkPipe::FakeNetworkPipe(Clock* clock,
26 const FakeNetworkPipe::Config& config) 27 const FakeNetworkPipe::Config& config)
27 : FakeNetworkPipe(clock, config, 1) {} 28 : FakeNetworkPipe(clock, config, 1) {}
28 29
29 FakeNetworkPipe::FakeNetworkPipe(Clock* clock, 30 FakeNetworkPipe::FakeNetworkPipe(Clock* clock,
30 const FakeNetworkPipe::Config& config, 31 const FakeNetworkPipe::Config& config,
31 uint64_t seed) 32 uint64_t seed)
32 : clock_(clock), 33 : clock_(clock),
33 packet_receiver_(NULL), 34 packet_receiver_(NULL),
34 random_(seed), 35 random_(seed),
35 config_(config), 36 config_(config),
36 dropped_packets_(0), 37 dropped_packets_(0),
37 sent_packets_(0), 38 sent_packets_(0),
38 total_packet_delay_(0), 39 total_packet_delay_(0),
39 bursting_(false), 40 bursting_(false),
40 next_process_time_(clock_->TimeInMilliseconds()) { 41 next_process_time_(clock_->TimeInMilliseconds()),
42 last_log_time_(clock_->TimeInMilliseconds()) {
41 double prob_loss = config.loss_percent / 100.0; 43 double prob_loss = config.loss_percent / 100.0;
42 if (config_.avg_burst_loss_length == -1) { 44 if (config_.avg_burst_loss_length == -1) {
43 // Uniform loss 45 // Uniform loss
44 prob_loss_bursting_ = prob_loss; 46 prob_loss_bursting_ = prob_loss;
45 prob_start_bursting_ = prob_loss; 47 prob_start_bursting_ = prob_loss;
46 } else { 48 } else {
47 // Lose packets according to a gilbert-elliot model. 49 // Lose packets according to a gilbert-elliot model.
48 int avg_burst_loss_length = config.avg_burst_loss_length; 50 int avg_burst_loss_length = config.avg_burst_loss_length;
49 int min_avg_burst_loss_length = std::ceil(prob_loss / (1 - prob_loss)); 51 int min_avg_burst_loss_length = std::ceil(prob_loss / (1 - prob_loss));
50 52
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 129
128 return static_cast<int>(total_packet_delay_ / 130 return static_cast<int>(total_packet_delay_ /
129 static_cast<int64_t>(sent_packets_)); 131 static_cast<int64_t>(sent_packets_));
130 } 132 }
131 133
132 void FakeNetworkPipe::Process() { 134 void FakeNetworkPipe::Process() {
133 int64_t time_now = clock_->TimeInMilliseconds(); 135 int64_t time_now = clock_->TimeInMilliseconds();
134 std::queue<NetworkPacket*> packets_to_deliver; 136 std::queue<NetworkPacket*> packets_to_deliver;
135 { 137 {
136 rtc::CritScope crit(&lock_); 138 rtc::CritScope crit(&lock_);
139 if (time_now - last_log_time_ > 5000) {
140 int64_t queueing_delay_ms = 0;
141 if (!capacity_link_.empty()) {
142 queueing_delay_ms = time_now - capacity_link_.front()->send_time();
143 }
144 LOG(LS_INFO) << "Network queue: " << queueing_delay_ms << " ms.";
145 last_log_time_ = time_now;
146 }
137 // Check the capacity link first. 147 // Check the capacity link first.
138 while (!capacity_link_.empty() && 148 while (!capacity_link_.empty() &&
139 time_now >= capacity_link_.front()->arrival_time()) { 149 time_now >= capacity_link_.front()->arrival_time()) {
140 // Time to get this packet. 150 // Time to get this packet.
141 NetworkPacket* packet = capacity_link_.front(); 151 NetworkPacket* packet = capacity_link_.front();
142 capacity_link_.pop(); 152 capacity_link_.pop();
143 153
144 // Drop packets at an average rate of |config_.loss_percent| with 154 // Drop packets at an average rate of |config_.loss_percent| with
145 // and average loss burst length of |config_.avg_burst_loss_length|. 155 // and average loss burst length of |config_.avg_burst_loss_length|.
146 if ((bursting_ && random_.Rand<double>() < prob_loss_bursting_) || 156 if ((bursting_ && random_.Rand<double>() < prob_loss_bursting_) ||
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 int64_t FakeNetworkPipe::TimeUntilNextProcess() const { 205 int64_t FakeNetworkPipe::TimeUntilNextProcess() const {
196 rtc::CritScope crit(&lock_); 206 rtc::CritScope crit(&lock_);
197 const int64_t kDefaultProcessIntervalMs = 5; 207 const int64_t kDefaultProcessIntervalMs = 5;
198 if (capacity_link_.empty() || delay_link_.empty()) 208 if (capacity_link_.empty() || delay_link_.empty())
199 return kDefaultProcessIntervalMs; 209 return kDefaultProcessIntervalMs;
200 return std::max<int64_t>(next_process_time_ - clock_->TimeInMilliseconds(), 210 return std::max<int64_t>(next_process_time_ - clock_->TimeInMilliseconds(),
201 0); 211 0);
202 } 212 }
203 213
204 } // namespace webrtc 214 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/test/fake_network_pipe.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698