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

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

Issue 3010653002: Keep track of the capacity delay error in the FakeNetworkPipe. (Closed)
Patch Set: Created 3 years, 3 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
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 capacity_link_.size() >= config_.queue_length_packets) { 125 capacity_link_.size() >= config_.queue_length_packets) {
126 // Too many packet on the link, drop this one. 126 // Too many packet on the link, drop this one.
127 ++dropped_packets_; 127 ++dropped_packets_;
128 return; 128 return;
129 } 129 }
130 130
131 int64_t time_now = clock_->TimeInMilliseconds(); 131 int64_t time_now = clock_->TimeInMilliseconds();
132 132
133 // Delay introduced by the link capacity. 133 // Delay introduced by the link capacity.
134 int64_t capacity_delay_ms = 0; 134 int64_t capacity_delay_ms = 0;
135 if (config_.link_capacity_kbps > 0) 135 if (config_.link_capacity_kbps > 0) {
136 capacity_delay_ms = data_length / (config_.link_capacity_kbps / 8); 136 // To round to closest millisecond we add half a milliseconds worth of bytes
philipel 2017/08/30 09:00:42 To round to the
137 // to the delay calculation.
138 const int offset_bytes = config_.link_capacity_kbps / 8 / 2;
terelius 2017/08/29 15:02:16 foo = config_.link_capacity_kbps / 8; capacity_del
139
140 capacity_delay_ms =
141 (data_length + capacity_delay_error_bytes_ + offset_bytes) /
142 (config_.link_capacity_kbps / 8);
143 capacity_delay_error_bytes_ +=
144 data_length - capacity_delay_ms * (config_.link_capacity_kbps / 8);
145 }
137 int64_t network_start_time = time_now; 146 int64_t network_start_time = time_now;
138 147
139 // Check if there already are packets on the link and change network start 148 // Check if there already are packets on the link and change network start
140 // time forward if there is. 149 // time forward if there is.
141 if (!capacity_link_.empty() && 150 if (!capacity_link_.empty() &&
142 network_start_time < capacity_link_.back()->arrival_time()) 151 network_start_time < capacity_link_.back()->arrival_time())
143 network_start_time = capacity_link_.back()->arrival_time(); 152 network_start_time = capacity_link_.back()->arrival_time();
144 153
145 int64_t arrival_time = network_start_time + capacity_delay_ms; 154 int64_t arrival_time = network_start_time + capacity_delay_ms;
146 NetworkPacket* packet = new NetworkPacket(data, data_length, time_now, 155 NetworkPacket* packet = new NetworkPacket(data, data_length, time_now,
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 : time_now + kDefaultProcessIntervalMs; 247 : time_now + kDefaultProcessIntervalMs;
239 } 248 }
240 249
241 int64_t FakeNetworkPipe::TimeUntilNextProcess() const { 250 int64_t FakeNetworkPipe::TimeUntilNextProcess() const {
242 rtc::CritScope crit(&lock_); 251 rtc::CritScope crit(&lock_);
243 return std::max<int64_t>(next_process_time_ - clock_->TimeInMilliseconds(), 252 return std::max<int64_t>(next_process_time_ - clock_->TimeInMilliseconds(),
244 0); 253 0);
245 } 254 }
246 255
247 } // namespace webrtc 256 } // 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