Revert "Add documentation, tests and simplify webrtc::SimulatedNetwork."

This reverts commit c1d5fda22c8ae456950c5549d22d099b478c67e2.

Reason for revert: This CL created thousands of metric alerts in the perf tests. It's possible that these are all expected, but since mbonadei@ is OOO right now, I think it's better to revert, and have him re-land when he is back.

Most alerts are here: https://bugs.chromium.org/p/webrtc/issues/detail?id=14549

Original change's description:
> Add documentation, tests and simplify webrtc::SimulatedNetwork.
>
> This CL increases the test coverage for webrtc::SimualtedNetwork, adds
> some more comments to the class and the interface it implements and
> simplify the logic around capacity and delay management in the
> simulated network.
>
> More CLs will follow to continue the refactoring but this is the
> ground work to make this more modular in the future.
>
> Bug: webrtc:14525, b/243202138
> Change-Id: Ib0408cf6e2c1cdceb71f8bec3202d2960c5b4d3c
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/278042
> Reviewed-by: Artem Titov <titovartem@webrtc.org>
> Reviewed-by: Per Kjellander <perkj@webrtc.org>
> Reviewed-by: Rasmus Brandt <brandtr@webrtc.org>
> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
> Reviewed-by: Björn Terelius <terelius@webrtc.org>
> Cr-Commit-Position: refs/heads/main@{#38388}

Bug: webrtc:14525, b/243202138
Change-Id: I5bc56c954bb12e7c27cb859e838f0b7a89e006f8
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/279522
Owners-Override: Artem Titov <titovartem@webrtc.org>
Reviewed-by: Björn Terelius <terelius@webrtc.org>
Reviewed-by: Artem Titov <titovartem@webrtc.org>
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Rasmus Brandt <brandtr@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38415}
This commit is contained in:
Rasmus Brandt
2022-10-17 12:11:47 +00:00
committed by WebRTC LUCI CQ
parent 44874d1944
commit baf5c9fabd
8 changed files with 85 additions and 739 deletions

View File

@ -38,12 +38,6 @@ struct PacketDeliveryInfo {
static constexpr int kNotReceived = -1;
PacketDeliveryInfo(PacketInFlightInfo source, int64_t receive_time_us)
: receive_time_us(receive_time_us), packet_id(source.packet_id) {}
bool operator==(const PacketDeliveryInfo& other) const {
return receive_time_us == other.receive_time_us &&
packet_id == other.packet_id;
}
int64_t receive_time_us;
uint64_t packet_id;
};
@ -70,50 +64,14 @@ struct BuiltInNetworkBehaviorConfig {
int packet_overhead = 0;
};
// Interface that represents a Network behaviour.
//
// It is clients of this interface responsibility to enqueue and dequeue
// packets (based on the estimated delivery time expressed by
// NextDeliveryTimeUs).
//
// To enqueue packets, call EnqueuePacket:
// EXPECT_TRUE(network.EnqueuePacket(
// PacketInFlightInfo(/*size=*/1, /*send_time_us=*/0, /*packet_id=*/1)));
//
// To know when to call DequeueDeliverablePackets to pull packets out of the
// network, call NextDeliveryTimeUs and schedule a task to invoke
// DequeueDeliverablePackets (if not already scheduled).
//
// DequeueDeliverablePackets will return a vector of delivered packets, but this
// vector can be empty in case of extra delay. In such case, make sure to invoke
// NextDeliveryTimeUs and schedule a task to call DequeueDeliverablePackets for
// the next estimated delivery of packets.
//
// std::vector<PacketDeliveryInfo> delivered_packets =
// network.DequeueDeliverablePackets(/*receive_time_us=*/1000000);
class NetworkBehaviorInterface {
public:
// Enqueues a packet in the network and returns true if the action was
// successful, false otherwise (for example, because the network capacity has
// been saturated). If the return value is false, the packet should be
// considered as dropped and it will not be returned by future calls
// to DequeueDeliverablePackets.
// Packets enqueued will exit the network when DequeueDeliverablePackets is
// called and enough time has passed (see NextDeliveryTimeUs).
virtual bool EnqueuePacket(PacketInFlightInfo packet_info) = 0;
// Retrieves all packets that should be delivered by the given receive time.
// Not all the packets in the returned std::vector are actually delivered.
// In order to know the state of each packet it is necessary to check the
// `receive_time_us` field of each packet. If that is set to
// PacketDeliveryInfo::kNotReceived then the packet is considered lost in the
// network.
virtual std::vector<PacketDeliveryInfo> DequeueDeliverablePackets(
int64_t receive_time_us) = 0;
// Returns time in microseconds when caller should call
// DequeueDeliverablePackets to get the next set of delivered packets. It is
// possible that no packet will be delivered by that time (e.g. in case of
// random extra delay), in such case this method should be called again to get
// the updated estimated delivery time.
// DequeueDeliverablePackets to get next set of packets to deliver.
virtual absl::optional<int64_t> NextDeliveryTimeUs() const = 0;
virtual ~NetworkBehaviorInterface() = default;
};
@ -123,14 +81,10 @@ class NetworkBehaviorInterface {
// capacity introduced delay.
class SimulatedNetworkInterface : public NetworkBehaviorInterface {
public:
// Sets a new configuration.
// Sets a new configuration. This won't affect packets already in the pipe.
virtual void SetConfig(const BuiltInNetworkBehaviorConfig& config) = 0;
virtual void UpdateConfig(
std::function<void(BuiltInNetworkBehaviorConfig*)> config_modifier) = 0;
// Pauses the network until `until_us`. This affects both delivery (calling
// DequeueDeliverablePackets before `until_us` results in an empty std::vector
// of packets) and capacity (the network is paused, so packets are not
// flowing and they will restart flowing at `until_us`).
virtual void PauseTransmissionUntil(int64_t until_us) = 0;
};