OLD | NEW |
(Empty) | |
| 1 #ifndef NET_QUIC_CORE_CONGESTION_CONTROL_SIMULATION_PORT_H_ |
| 2 #define NET_QUIC_CORE_CONGESTION_CONTROL_SIMULATION_PORT_H_ |
| 3 |
| 4 #include <std::string> |
| 5 #include <utility> |
| 6 |
| 7 #include "net/quic/core/congestion_control/simulation/actor.h" |
| 8 #include "net/quic/core/quic_protocol.h" |
| 9 |
| 10 namespace net { |
| 11 namespace simulation { |
| 12 |
| 13 struct Packet { |
| 14 std::std::string source; |
| 15 std::std::string destination; |
| 16 QuicTime tx_timestamp; |
| 17 |
| 18 std::std::string contents; |
| 19 QuicByteCount size; |
| 20 |
| 21 Packet(); |
| 22 }; |
| 23 |
| 24 // An interface for anything that accepts packets at arbitrary rate. |
| 25 class UnconstrainedPortInterface { |
| 26 public: |
| 27 virtual ~UnconstrainedPortInterface() {} |
| 28 virtual void AcceptPacket(std::unique_ptr<Packet> packet) = 0; |
| 29 }; |
| 30 |
| 31 // An interface for any device that accepts packets at a specific rate. |
| 32 // Typically one would use a Queue object in order to write into a constrained |
| 33 // port. |
| 34 class ConstrainedPortInterface { |
| 35 public: |
| 36 virtual ~ConstrainedPortInterface() {} |
| 37 |
| 38 // Accept a packet for a port. TimeUntilAvailable() must be zero before this |
| 39 // method is called. |
| 40 virtual void AcceptPacket(std::unique_ptr<Packet> packet) = 0; |
| 41 |
| 42 // Time until write for the next port is available. Cannot be infinite. |
| 43 virtual QuicTime::Delta TimeUntilAvailable() = 0; |
| 44 }; |
| 45 |
| 46 // A convenience class for any network endpoints, i.e. the objects which can |
| 47 // both accept and send packets. |
| 48 class Endpoint : public Actor { |
| 49 public: |
| 50 virtual UnconstrainedPortInterface* GetRxPort() = 0; |
| 51 virtual void SetTxPort(ConstrainedPortInterface* port) = 0; |
| 52 |
| 53 protected: |
| 54 Endpoint(Simulator* simulator, std::std::string name); |
| 55 }; |
| 56 |
| 57 } // namespace simulation |
| 58 } // namespace net |
| 59 |
| 60 #endif // NET_QUIC_CORE_CONGESTION_CONTROL_SIMULATION_PORT_H_ |
OLD | NEW |