Chromium Code Reviews| Index: webrtc/test/fake_network_pipe.cc |
| diff --git a/webrtc/test/fake_network_pipe.cc b/webrtc/test/fake_network_pipe.cc |
| index ea4e551f7ba7a52046bb3856d0266a639ce3a4dc..1c05a393b0b4de0ce874b2c54cd35ff6b6a1ebc7 100644 |
| --- a/webrtc/test/fake_network_pipe.cc |
| +++ b/webrtc/test/fake_network_pipe.cc |
| @@ -34,7 +34,13 @@ FakeNetworkPipe::FakeNetworkPipe(Clock* clock, |
| dropped_packets_(0), |
| sent_packets_(0), |
| total_packet_delay_(0), |
| - next_process_time_(clock_->TimeInMilliseconds()) {} |
| + bursting_(false), |
| + next_process_time_(clock_->TimeInMilliseconds()) { |
| + prob_lose_next_ = (1.0 - 1.0 / config_.avg_burst_loss_length); |
| + 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.
|
| + config_.avg_burst_loss_length) / |
| + 100.0; |
| +} |
| FakeNetworkPipe::~FakeNetworkPipe() { |
| while (!capacity_link_.empty()) { |
| @@ -118,8 +124,10 @@ void FakeNetworkPipe::Process() { |
| NetworkPacket* packet = capacity_link_.front(); |
| capacity_link_.pop(); |
| - // Packets are randomly dropped after being affected by the bottleneck. |
| - if (random_.Rand(100) < static_cast<uint32_t>(config_.loss_percent)) { |
| + // Drop packets at an average rate of |config_.loss_percent| with |
| + // and average loss burst length of |config_.avg_burst_loss_length|. |
| + 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
|
| + bursting_ = random_.Rand<double>() < prob_lose_next_; |
| delete packet; |
| continue; |
| } |