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

Unified Diff: webrtc/test/fake_network_pipe.cc

Issue 1606183002: Allow packets to be reordered in the fake network pipe. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
« webrtc/test/fake_network_pipe.h ('K') | « webrtc/test/fake_network_pipe.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/test/fake_network_pipe.cc
diff --git a/webrtc/test/fake_network_pipe.cc b/webrtc/test/fake_network_pipe.cc
index 4e431222dac108bafcfc8dc4003c4c08b688d3d1..9cc235df705ffbf854f45554b2cbd00aa8645a03 100644
--- a/webrtc/test/fake_network_pipe.cc
+++ b/webrtc/test/fake_network_pipe.cc
@@ -36,40 +36,6 @@ static bool UniformLoss(int loss_percent) {
return outcome < loss_percent;
}
-class NetworkPacket {
- public:
- NetworkPacket(const uint8_t* data, size_t length, int64_t send_time,
- int64_t arrival_time)
- : data_(NULL),
- data_length_(length),
- send_time_(send_time),
- arrival_time_(arrival_time) {
- data_ = new uint8_t[length];
- memcpy(data_, data, length);
- }
- ~NetworkPacket() {
- delete [] data_;
- }
-
- uint8_t* data() const { return data_; }
- size_t data_length() const { return data_length_; }
- int64_t send_time() const { return send_time_; }
- int64_t arrival_time() const { return arrival_time_; }
- void IncrementArrivalTime(int64_t extra_delay) {
- arrival_time_+= extra_delay;
- }
-
- private:
- // The packet data.
- uint8_t* data_;
- // Length of data_.
- size_t data_length_;
- // The time the packet was sent out on the network.
- const int64_t send_time_;
- // The time the packet should arrive at the reciver.
- int64_t arrival_time_;
-};
-
FakeNetworkPipe::FakeNetworkPipe(Clock* clock,
const FakeNetworkPipe::Config& config)
: clock_(clock),
@@ -86,8 +52,8 @@ FakeNetworkPipe::~FakeNetworkPipe() {
capacity_link_.pop();
}
while (!delay_link_.empty()) {
- delete delay_link_.front();
- delay_link_.pop();
+ delete *delay_link_.begin();
+ delay_link_.erase(delay_link_.begin());
}
}
@@ -171,25 +137,26 @@ void FakeNetworkPipe::Process() {
// earlier than the last packet in the queue.
stefan-webrtc 2016/01/20 10:57:33 Half of this comment should be moved down to line
philipel 2016/01/20 14:22:57 Done.
int extra_delay = GaussianRandom(config_.queue_delay_ms,
stefan-webrtc 2016/01/20 10:57:33 I think it would be good to rename this random_jit
philipel 2016/01/20 14:22:57 Renamed to arrival_time_jitter.
config_.delay_standard_deviation_ms);
- if (delay_link_.size() > 0 &&
+ if (!config_.allow_reordering &&
+ delay_link_.size() > 0 &&
stefan-webrtc 2016/01/20 10:57:33 !delay_link_.empty()
philipel 2016/01/20 14:22:56 Done.
packet->arrival_time() + extra_delay <
- delay_link_.back()->arrival_time()) {
- extra_delay = delay_link_.back()->arrival_time() -
+ (*delay_link_.rbegin())->arrival_time()) {
+ extra_delay = (*delay_link_.rbegin())->arrival_time() -
packet->arrival_time();
}
packet->IncrementArrivalTime(extra_delay);
if (packet->arrival_time() < next_process_time_)
next_process_time_ = packet->arrival_time();
- delay_link_.push(packet);
+ delay_link_.insert(packet);
}
// Check the extra delay queue.
while (delay_link_.size() > 0 &&
- time_now >= delay_link_.front()->arrival_time()) {
+ time_now >= (*delay_link_.begin())->arrival_time()) {
// Deliver this packet.
- NetworkPacket* packet = delay_link_.front();
+ NetworkPacket* packet = *delay_link_.begin();
packets_to_deliver.push(packet);
- delay_link_.pop();
+ delay_link_.erase(delay_link_.begin());
// |time_now| might be later than when the packet should have arrived, due
// to NetworkProcess being called too late. For stats, use the time it
// should have been on the link.
« webrtc/test/fake_network_pipe.h ('K') | « webrtc/test/fake_network_pipe.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698