Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 16 matching lines...) Expand all Loading... | |
| 27 FakeNetworkPipe::FakeNetworkPipe(Clock* clock, | 27 FakeNetworkPipe::FakeNetworkPipe(Clock* clock, |
| 28 const FakeNetworkPipe::Config& config, | 28 const FakeNetworkPipe::Config& config, |
| 29 uint64_t seed) | 29 uint64_t seed) |
| 30 : clock_(clock), | 30 : clock_(clock), |
| 31 packet_receiver_(NULL), | 31 packet_receiver_(NULL), |
| 32 random_(seed), | 32 random_(seed), |
| 33 config_(config), | 33 config_(config), |
| 34 dropped_packets_(0), | 34 dropped_packets_(0), |
| 35 sent_packets_(0), | 35 sent_packets_(0), |
| 36 total_packet_delay_(0), | 36 total_packet_delay_(0), |
| 37 next_process_time_(clock_->TimeInMilliseconds()) {} | 37 bursting_(false), |
| 38 next_process_time_(clock_->TimeInMilliseconds()) { | |
| 39 prob_lose_next_ = (1.0 - 1.0 / config_.avg_burst_loss_length); | |
| 40 prob_burst_loss_ = (static_cast<double>(config_.loss_percent) / | |
|
terelius
2016/05/30 14:00:29
This should probably be
config_.loss_percent / (1-
philipel
2016/05/30 14:42:42
Done.
| |
| 41 config_.avg_burst_loss_length) / | |
| 42 100.0; | |
| 43 } | |
| 38 | 44 |
| 39 FakeNetworkPipe::~FakeNetworkPipe() { | 45 FakeNetworkPipe::~FakeNetworkPipe() { |
| 40 while (!capacity_link_.empty()) { | 46 while (!capacity_link_.empty()) { |
| 41 delete capacity_link_.front(); | 47 delete capacity_link_.front(); |
| 42 capacity_link_.pop(); | 48 capacity_link_.pop(); |
| 43 } | 49 } |
| 44 while (!delay_link_.empty()) { | 50 while (!delay_link_.empty()) { |
| 45 delete *delay_link_.begin(); | 51 delete *delay_link_.begin(); |
| 46 delay_link_.erase(delay_link_.begin()); | 52 delay_link_.erase(delay_link_.begin()); |
| 47 } | 53 } |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 111 std::queue<NetworkPacket*> packets_to_deliver; | 117 std::queue<NetworkPacket*> packets_to_deliver; |
| 112 { | 118 { |
| 113 rtc::CritScope crit(&lock_); | 119 rtc::CritScope crit(&lock_); |
| 114 // Check the capacity link first. | 120 // Check the capacity link first. |
| 115 while (!capacity_link_.empty() && | 121 while (!capacity_link_.empty() && |
| 116 time_now >= capacity_link_.front()->arrival_time()) { | 122 time_now >= capacity_link_.front()->arrival_time()) { |
| 117 // Time to get this packet. | 123 // Time to get this packet. |
| 118 NetworkPacket* packet = capacity_link_.front(); | 124 NetworkPacket* packet = capacity_link_.front(); |
| 119 capacity_link_.pop(); | 125 capacity_link_.pop(); |
| 120 | 126 |
| 121 // Packets are randomly dropped after being affected by the bottleneck. | 127 // Drop packets at an average rate of |config_.loss_percent| with |
| 122 if (random_.Rand(100) < static_cast<uint32_t>(config_.loss_percent)) { | 128 // and average loss burst length of |config_.avg_burst_loss_length|. |
| 129 if (bursting_ || random_.Rand<double>() < prob_burst_loss_) { | |
|
terelius
2016/05/30 14:00:29
It would easier to model the process if it was
if
philipel
2016/05/30 14:42:42
Done.
stefan-webrtc
2016/05/30 15:15:10
Fyi, burst loss is typically modelled using a gilb
| |
| 130 bursting_ = random_.Rand<double>() < prob_lose_next_; | |
| 123 delete packet; | 131 delete packet; |
| 124 continue; | 132 continue; |
| 125 } | 133 } |
| 126 | 134 |
| 127 int arrival_time_jitter = random_.Gaussian( | 135 int arrival_time_jitter = random_.Gaussian( |
| 128 config_.queue_delay_ms, config_.delay_standard_deviation_ms); | 136 config_.queue_delay_ms, config_.delay_standard_deviation_ms); |
| 129 | 137 |
| 130 // If reordering is not allowed then adjust arrival_time_jitter | 138 // If reordering is not allowed then adjust arrival_time_jitter |
| 131 // to make sure all packets are sent in order. | 139 // to make sure all packets are sent in order. |
| 132 if (!config_.allow_reordering && !delay_link_.empty() && | 140 if (!config_.allow_reordering && !delay_link_.empty() && |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 167 int64_t FakeNetworkPipe::TimeUntilNextProcess() const { | 175 int64_t FakeNetworkPipe::TimeUntilNextProcess() const { |
| 168 rtc::CritScope crit(&lock_); | 176 rtc::CritScope crit(&lock_); |
| 169 const int64_t kDefaultProcessIntervalMs = 30; | 177 const int64_t kDefaultProcessIntervalMs = 30; |
| 170 if (capacity_link_.empty() || delay_link_.empty()) | 178 if (capacity_link_.empty() || delay_link_.empty()) |
| 171 return kDefaultProcessIntervalMs; | 179 return kDefaultProcessIntervalMs; |
| 172 return std::max<int64_t>(next_process_time_ - clock_->TimeInMilliseconds(), | 180 return std::max<int64_t>(next_process_time_ - clock_->TimeInMilliseconds(), |
| 173 0); | 181 0); |
| 174 } | 182 } |
| 175 | 183 |
| 176 } // namespace webrtc | 184 } // namespace webrtc |
| OLD | NEW |