Add replacements for all FakeNetworkPipe ctors.
Add replacements for all FakeNetworkPipe constructos, that will accept instance of NetworkSimulationInterface instead of config to be able to use any implmentation of network simulation. Bug: webrtc:9630 Change-Id: Ifceb2f0d028faf255648891ce695b3742f866044 Reviewed-on: https://webrtc-review.googlesource.com/94541 Commit-Queue: Artem Titov <titovartem@webrtc.org> Reviewed-by: Sebastian Jansson <srte@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24320}
This commit is contained in:
parent
6b1985de95
commit
b005087a8c
@ -88,20 +88,6 @@ FakeNetworkPipe::FakeNetworkPipe(Clock* clock,
|
|||||||
const FakeNetworkPipe::Config& config)
|
const FakeNetworkPipe::Config& config)
|
||||||
: FakeNetworkPipe(clock, config, nullptr, 1) {}
|
: FakeNetworkPipe(clock, config, nullptr, 1) {}
|
||||||
|
|
||||||
FakeNetworkPipe::FakeNetworkPipe(
|
|
||||||
Clock* clock,
|
|
||||||
std::unique_ptr<NetworkSimulationInterface> network_simulation)
|
|
||||||
: clock_(clock),
|
|
||||||
network_simulation_(std::move(network_simulation)),
|
|
||||||
receiver_(nullptr),
|
|
||||||
transport_(nullptr),
|
|
||||||
clock_offset_ms_(0),
|
|
||||||
dropped_packets_(0),
|
|
||||||
sent_packets_(0),
|
|
||||||
total_packet_delay_us_(0),
|
|
||||||
next_process_time_us_(clock_->TimeInMicroseconds()),
|
|
||||||
last_log_time_us_(clock_->TimeInMicroseconds()) {}
|
|
||||||
|
|
||||||
FakeNetworkPipe::FakeNetworkPipe(Clock* clock,
|
FakeNetworkPipe::FakeNetworkPipe(Clock* clock,
|
||||||
const FakeNetworkPipe::Config& config,
|
const FakeNetworkPipe::Config& config,
|
||||||
PacketReceiver* receiver)
|
PacketReceiver* receiver)
|
||||||
@ -136,6 +122,48 @@ FakeNetworkPipe::FakeNetworkPipe(Clock* clock,
|
|||||||
next_process_time_us_(clock_->TimeInMicroseconds()),
|
next_process_time_us_(clock_->TimeInMicroseconds()),
|
||||||
last_log_time_us_(clock_->TimeInMicroseconds()) {}
|
last_log_time_us_(clock_->TimeInMicroseconds()) {}
|
||||||
|
|
||||||
|
FakeNetworkPipe::FakeNetworkPipe(
|
||||||
|
Clock* clock,
|
||||||
|
std::unique_ptr<NetworkSimulationInterface> network_simulation)
|
||||||
|
: FakeNetworkPipe(clock, std::move(network_simulation), nullptr, 1) {}
|
||||||
|
|
||||||
|
FakeNetworkPipe::FakeNetworkPipe(
|
||||||
|
Clock* clock,
|
||||||
|
std::unique_ptr<NetworkSimulationInterface> network_simulation,
|
||||||
|
PacketReceiver* receiver)
|
||||||
|
: FakeNetworkPipe(clock, std::move(network_simulation), receiver, 1) {}
|
||||||
|
|
||||||
|
FakeNetworkPipe::FakeNetworkPipe(
|
||||||
|
Clock* clock,
|
||||||
|
std::unique_ptr<NetworkSimulationInterface> network_simulation,
|
||||||
|
PacketReceiver* receiver,
|
||||||
|
uint64_t seed)
|
||||||
|
: clock_(clock),
|
||||||
|
network_simulation_(std::move(network_simulation)),
|
||||||
|
receiver_(receiver),
|
||||||
|
transport_(nullptr),
|
||||||
|
clock_offset_ms_(0),
|
||||||
|
dropped_packets_(0),
|
||||||
|
sent_packets_(0),
|
||||||
|
total_packet_delay_us_(0),
|
||||||
|
next_process_time_us_(clock_->TimeInMicroseconds()),
|
||||||
|
last_log_time_us_(clock_->TimeInMicroseconds()) {}
|
||||||
|
|
||||||
|
FakeNetworkPipe::FakeNetworkPipe(
|
||||||
|
Clock* clock,
|
||||||
|
std::unique_ptr<NetworkSimulationInterface> network_simulation,
|
||||||
|
Transport* transport)
|
||||||
|
: clock_(clock),
|
||||||
|
network_simulation_(std::move(network_simulation)),
|
||||||
|
receiver_(nullptr),
|
||||||
|
transport_(transport),
|
||||||
|
clock_offset_ms_(0),
|
||||||
|
dropped_packets_(0),
|
||||||
|
sent_packets_(0),
|
||||||
|
total_packet_delay_us_(0),
|
||||||
|
next_process_time_us_(clock_->TimeInMicroseconds()),
|
||||||
|
last_log_time_us_(clock_->TimeInMicroseconds()) {}
|
||||||
|
|
||||||
FakeNetworkPipe::~FakeNetworkPipe() = default;
|
FakeNetworkPipe::~FakeNetworkPipe() = default;
|
||||||
|
|
||||||
void FakeNetworkPipe::SetReceiver(PacketReceiver* receiver) {
|
void FakeNetworkPipe::SetReceiver(PacketReceiver* receiver) {
|
||||||
|
|||||||
@ -103,31 +103,54 @@ class FakeNetworkPipe : public Transport, public PacketReceiver, public Module {
|
|||||||
public:
|
public:
|
||||||
using Config = NetworkSimulationInterface::SimulatedNetworkConfig;
|
using Config = NetworkSimulationInterface::SimulatedNetworkConfig;
|
||||||
|
|
||||||
|
// Deprecated. DO NOT USE. To be removed. Use corresponding version with
|
||||||
|
// NetworkSimulationInterface instance instead.
|
||||||
// Use these constructors if you plan to insert packets using DeliverPacket().
|
// Use these constructors if you plan to insert packets using DeliverPacket().
|
||||||
FakeNetworkPipe(Clock* clock, const FakeNetworkPipe::Config& config);
|
FakeNetworkPipe(Clock* clock, const FakeNetworkPipe::Config& config);
|
||||||
// Will keep |network_simulation| alive while pipe is alive itself.
|
// Will keep |network_simulation| alive while pipe is alive itself.
|
||||||
|
// Use these constructors if you plan to insert packets using DeliverPacket().
|
||||||
FakeNetworkPipe(
|
FakeNetworkPipe(
|
||||||
Clock* clock,
|
Clock* clock,
|
||||||
std::unique_ptr<NetworkSimulationInterface> network_simulation);
|
std::unique_ptr<NetworkSimulationInterface> network_simulation);
|
||||||
|
// Deprecated. DO NOT USE. To be removed. Use corresponding version with
|
||||||
|
// NetworkSimulationInterface instance instead.
|
||||||
FakeNetworkPipe(Clock* clock,
|
FakeNetworkPipe(Clock* clock,
|
||||||
const FakeNetworkPipe::Config& config,
|
const FakeNetworkPipe::Config& config,
|
||||||
PacketReceiver* receiver);
|
PacketReceiver* receiver);
|
||||||
|
FakeNetworkPipe(
|
||||||
|
Clock* clock,
|
||||||
|
std::unique_ptr<NetworkSimulationInterface> network_simulation,
|
||||||
|
PacketReceiver* receiver);
|
||||||
|
// Deprecated. DO NOT USE. To be removed. Use corresponding version with
|
||||||
|
// NetworkSimulationInterface instance instead.
|
||||||
FakeNetworkPipe(Clock* clock,
|
FakeNetworkPipe(Clock* clock,
|
||||||
const FakeNetworkPipe::Config& config,
|
const FakeNetworkPipe::Config& config,
|
||||||
PacketReceiver* receiver,
|
PacketReceiver* receiver,
|
||||||
uint64_t seed);
|
uint64_t seed);
|
||||||
|
FakeNetworkPipe(
|
||||||
|
Clock* clock,
|
||||||
|
std::unique_ptr<NetworkSimulationInterface> network_simulation,
|
||||||
|
PacketReceiver* receiver,
|
||||||
|
uint64_t seed);
|
||||||
|
|
||||||
|
// Deprecated. DO NOT USE. To be removed. Use corresponding version with
|
||||||
|
// NetworkSimulationInterface instance instead.
|
||||||
// Use this constructor if you plan to insert packets using SendRt[c?]p().
|
// Use this constructor if you plan to insert packets using SendRt[c?]p().
|
||||||
FakeNetworkPipe(Clock* clock,
|
FakeNetworkPipe(Clock* clock,
|
||||||
const FakeNetworkPipe::Config& config,
|
const FakeNetworkPipe::Config& config,
|
||||||
Transport* transport);
|
Transport* transport);
|
||||||
|
// Use this constructor if you plan to insert packets using SendRt[c?]p().
|
||||||
|
FakeNetworkPipe(
|
||||||
|
Clock* clock,
|
||||||
|
std::unique_ptr<NetworkSimulationInterface> network_simulation,
|
||||||
|
Transport* transport);
|
||||||
|
|
||||||
~FakeNetworkPipe() override;
|
~FakeNetworkPipe() override;
|
||||||
|
|
||||||
void SetClockOffset(int64_t offset_ms);
|
void SetClockOffset(int64_t offset_ms);
|
||||||
|
|
||||||
// DO NOT USE. Hold direct reference on NetworkSimulationInterface instead
|
// Deprecated. DO NOT USE. Hold direct reference on NetworkSimulationInterface
|
||||||
// and call SetConfig on that object directly. Will be removed soon.
|
// instead and call SetConfig on that object directly. Will be removed soon.
|
||||||
// Sets a new configuration. This won't affect packets already in the pipe.
|
// Sets a new configuration. This won't affect packets already in the pipe.
|
||||||
void SetConfig(const FakeNetworkPipe::Config& config);
|
void SetConfig(const FakeNetworkPipe::Config& config);
|
||||||
|
|
||||||
|
|||||||
@ -208,8 +208,7 @@ TEST_F(FakeNetworkPipeTest, ChangingCapacityWithEmptyPipeTest) {
|
|||||||
std::unique_ptr<SimulatedNetwork> network(new SimulatedNetwork(config));
|
std::unique_ptr<SimulatedNetwork> network(new SimulatedNetwork(config));
|
||||||
SimulatedNetwork* simulated_network = network.get();
|
SimulatedNetwork* simulated_network = network.get();
|
||||||
std::unique_ptr<FakeNetworkPipe> pipe(
|
std::unique_ptr<FakeNetworkPipe> pipe(
|
||||||
new FakeNetworkPipe(&fake_clock_, std::move(network)));
|
new FakeNetworkPipe(&fake_clock_, std::move(network), &receiver));
|
||||||
pipe->SetReceiver(&receiver);
|
|
||||||
|
|
||||||
// Add 10 packets of 1000 bytes, = 80 kb, and verify it takes one second to
|
// Add 10 packets of 1000 bytes, = 80 kb, and verify it takes one second to
|
||||||
// get through the pipe.
|
// get through the pipe.
|
||||||
@ -270,8 +269,7 @@ TEST_F(FakeNetworkPipeTest, ChangingCapacityWithPacketsInPipeTest) {
|
|||||||
std::unique_ptr<SimulatedNetwork> network(new SimulatedNetwork(config));
|
std::unique_ptr<SimulatedNetwork> network(new SimulatedNetwork(config));
|
||||||
SimulatedNetwork* simulated_network = network.get();
|
SimulatedNetwork* simulated_network = network.get();
|
||||||
std::unique_ptr<FakeNetworkPipe> pipe(
|
std::unique_ptr<FakeNetworkPipe> pipe(
|
||||||
new FakeNetworkPipe(&fake_clock_, std::move(network)));
|
new FakeNetworkPipe(&fake_clock_, std::move(network), &receiver));
|
||||||
pipe->SetReceiver(&receiver);
|
|
||||||
|
|
||||||
// Add 10 packets of 1000 bytes, = 80 kb.
|
// Add 10 packets of 1000 bytes, = 80 kb.
|
||||||
const int kNumPackets = 10;
|
const int kNumPackets = 10;
|
||||||
@ -328,8 +326,7 @@ TEST_F(FakeNetworkPipeTest, DisallowReorderingThenAllowReordering) {
|
|||||||
std::unique_ptr<SimulatedNetwork> network(new SimulatedNetwork(config));
|
std::unique_ptr<SimulatedNetwork> network(new SimulatedNetwork(config));
|
||||||
SimulatedNetwork* simulated_network = network.get();
|
SimulatedNetwork* simulated_network = network.get();
|
||||||
std::unique_ptr<FakeNetworkPipe> pipe(
|
std::unique_ptr<FakeNetworkPipe> pipe(
|
||||||
new FakeNetworkPipe(&fake_clock_, std::move(network)));
|
new FakeNetworkPipe(&fake_clock_, std::move(network), &receiver));
|
||||||
pipe->SetReceiver(&receiver);
|
|
||||||
|
|
||||||
const uint32_t kNumPackets = 100;
|
const uint32_t kNumPackets = 100;
|
||||||
const int kPacketSize = 10;
|
const int kPacketSize = 10;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user