blob: 5cd4a7f1988783fd29b5b0c814fb68eea6116549 [file] [log] [blame]
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <string>
#include <utility>
#include "net/third_party/quiche/src/quic/core/quic_packets.h"
#include "net/third_party/quiche/src/quic/test_tools/simulator/actor.h"
namespace quic {
namespace simulator {
struct Packet {
Packet(const Packet& packet);
QuicString source;
QuicString destination;
QuicTime tx_timestamp;
QuicString contents;
QuicByteCount size;
// An interface for anything that accepts packets at arbitrary rate.
class UnconstrainedPortInterface {
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 {
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 {
virtual UnconstrainedPortInterface* GetRxPort() = 0;
virtual void SetTxPort(ConstrainedPortInterface* port) = 0;
Endpoint(Simulator* simulator, QuicString name);
} // namespace simulator
} // namespace quic