In QUIC simulator:
1) Allow the bandwidth of OneWayLink/SymmetricLink to change after construction.
2) Change QuicEndpointMultiplexer's constructor from taking a std::initializer_list to a std::vector.
gfe-relnote: (n/a) Test utility refactor.
PiperOrigin-RevId: 252722327
Change-Id: Id2eb88ab5a8436480dce40ca6188393ba5d0f4e9
diff --git a/quic/test_tools/simulator/link.h b/quic/test_tools/simulator/link.h
index 531eff6..5621e1b 100644
--- a/quic/test_tools/simulator/link.h
+++ b/quic/test_tools/simulator/link.h
@@ -8,6 +8,7 @@
#include <utility>
#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h"
+#include "net/third_party/quiche/src/quic/core/quic_bandwidth.h"
#include "net/third_party/quiche/src/quic/test_tools/simulator/actor.h"
#include "net/third_party/quiche/src/quic/test_tools/simulator/port.h"
@@ -33,6 +34,9 @@
void Act() override;
inline QuicBandwidth bandwidth() const { return bandwidth_; }
+ inline void set_bandwidth(QuicBandwidth new_bandwidth) {
+ bandwidth_ = new_bandwidth;
+ }
protected:
// Get the value of a random delay imposed on each packet. By default, this
@@ -58,7 +62,7 @@
UnconstrainedPortInterface* sink_;
QuicDeque<QueuedPacket> packets_in_transit_;
- const QuicBandwidth bandwidth_;
+ QuicBandwidth bandwidth_;
const QuicTime::Delta propagation_delay_;
QuicTime next_write_at_;
@@ -82,6 +86,10 @@
SymmetricLink& operator=(const SymmetricLink&) = delete;
inline QuicBandwidth bandwidth() { return a_to_b_link_.bandwidth(); }
+ inline void set_bandwidth(QuicBandwidth new_bandwidth) {
+ a_to_b_link_.set_bandwidth(new_bandwidth);
+ b_to_a_link_.set_bandwidth(new_bandwidth);
+ }
private:
OneWayLink a_to_b_link_;
diff --git a/quic/test_tools/simulator/quic_endpoint.cc b/quic/test_tools/simulator/quic_endpoint.cc
index 78cc302..ba9d206 100644
--- a/quic/test_tools/simulator/quic_endpoint.cc
+++ b/quic/test_tools/simulator/quic_endpoint.cc
@@ -401,7 +401,7 @@
QuicEndpointMultiplexer::QuicEndpointMultiplexer(
std::string name,
- std::initializer_list<QuicEndpoint*> endpoints)
+ const std::vector<QuicEndpoint*>& endpoints)
: Endpoint((*endpoints.begin())->simulator(), name) {
for (QuicEndpoint* endpoint : endpoints) {
mapping_.insert(std::make_pair(endpoint->name(), endpoint));
diff --git a/quic/test_tools/simulator/quic_endpoint.h b/quic/test_tools/simulator/quic_endpoint.h
index 8efef0e..53bff3a 100644
--- a/quic/test_tools/simulator/quic_endpoint.h
+++ b/quic/test_tools/simulator/quic_endpoint.h
@@ -213,7 +213,7 @@
public UnconstrainedPortInterface {
public:
QuicEndpointMultiplexer(std::string name,
- std::initializer_list<QuicEndpoint*> endpoints);
+ const std::vector<QuicEndpoint*>& endpoints);
~QuicEndpointMultiplexer() override;
// Receives a packet and passes it to the specified endpoint if that endpoint