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

Unified Diff: net/quic/core/congestion_control/simulation/port.h

Issue 2323963002: Implement an event-based simulator for QuicConnection (Closed)
Patch Set: Adding missing files. Created 4 years, 3 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
Index: net/quic/core/congestion_control/simulation/port.h
diff --git a/net/quic/core/congestion_control/simulation/port.h b/net/quic/core/congestion_control/simulation/port.h
new file mode 100644
index 0000000000000000000000000000000000000000..44409876e37238f75c7c0a06b2c2083d5e1318dd
--- /dev/null
+++ b/net/quic/core/congestion_control/simulation/port.h
@@ -0,0 +1,60 @@
+#ifndef NET_QUIC_CORE_CONGESTION_CONTROL_SIMULATION_PORT_H_
+#define NET_QUIC_CORE_CONGESTION_CONTROL_SIMULATION_PORT_H_
+
+#include <std::string>
+#include <utility>
+
+#include "net/quic/core/congestion_control/simulation/actor.h"
+#include "net/quic/core/quic_protocol.h"
+
+namespace net {
+namespace simulation {
+
+struct Packet {
+ std::std::string source;
+ std::std::string destination;
+ QuicTime tx_timestamp;
+
+ std::std::string contents;
+ QuicByteCount size;
+
+ Packet();
+};
+
+// An interface for anything that accepts packets at arbitrary rate.
+class UnconstrainedPortInterface {
+ public:
+ virtual ~UnconstrainedPortInterface() {}
+ virtual void AcceptPacket(std::unique_ptr<Packet> packet) = 0;
+};
+
+// An interface for any device that accepts packets at a specific rate.
+// Typically one would use a Queue object in order to write into a constrained
+// port.
+class ConstrainedPortInterface {
+ public:
+ virtual ~ConstrainedPortInterface() {}
+
+ // Accept a packet for a port. TimeUntilAvailable() must be zero before this
+ // method is called.
+ virtual void AcceptPacket(std::unique_ptr<Packet> packet) = 0;
+
+ // Time until write for the next port is available. Cannot be infinite.
+ virtual QuicTime::Delta TimeUntilAvailable() = 0;
+};
+
+// A convenience class for any network endpoints, i.e. the objects which can
+// both accept and send packets.
+class Endpoint : public Actor {
+ public:
+ virtual UnconstrainedPortInterface* GetRxPort() = 0;
+ virtual void SetTxPort(ConstrainedPortInterface* port) = 0;
+
+ protected:
+ Endpoint(Simulator* simulator, std::std::string name);
+};
+
+} // namespace simulation
+} // namespace net
+
+#endif // NET_QUIC_CORE_CONGESTION_CONTROL_SIMULATION_PORT_H_

Powered by Google App Engine
This is Rietveld 408576698