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