// 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 "quiche/quic/test_tools/simulator/simulator.h" #include <memory> #include <string> #include <utility> #include <vector> #include "absl/container/node_hash_map.h" #include "quiche/quic/platform/api/quic_logging.h" #include "quiche/quic/platform/api/quic_test.h" #include "quiche/quic/test_tools/quic_test_utils.h" #include "quiche/quic/test_tools/simulator/alarm_factory.h" #include "quiche/quic/test_tools/simulator/link.h" #include "quiche/quic/test_tools/simulator/packet_filter.h" #include "quiche/quic/test_tools/simulator/queue.h" #include "quiche/quic/test_tools/simulator/switch.h" #include "quiche/quic/test_tools/simulator/traffic_policer.h" _; Return; StrictMock; namespace quic { namespace simulator { // A simple counter that increments its value by 1 every specified period. class Counter : public Actor { … }; class SimulatorTest : public quic::test::QuicTest { … }; // Test that the basic event handling works, and that Actors can be created and // destroyed mid-simulation. TEST_F(SimulatorTest, Counters) { … } // A port which counts the number of packets received on it, both total and // per-destination. class CounterPort : public UnconstrainedPortInterface { … }; // Sends the packet to the specified destination at the uplink rate. Provides a // CounterPort as an Rx interface. class LinkSaturator : public Endpoint { … }; // Saturate a symmetric link and verify that the number of packets sent and // received is correct. TEST_F(SimulatorTest, DirectLinkSaturation) { … } // Accepts packets and stores them internally. class PacketAcceptor : public ConstrainedPortInterface { … }; // Ensure the queue behaves correctly with accepting packets. TEST_F(SimulatorTest, Queue) { … } // Simulate a situation where the bottleneck link is 10 times slower than the // uplink, and they are separated by a queue. TEST_F(SimulatorTest, QueueBottleneck) { … } // Verify that the queue of exactly one packet allows the transmission to // actually go through. TEST_F(SimulatorTest, OnePacketQueue) { … } // Simulate a network where three endpoints are connected to a switch and they // are sending traffic in circle (1 -> 2, 2 -> 3, 3 -> 1). TEST_F(SimulatorTest, SwitchedNetwork) { … } // Toggle an alarm on and off at the specified interval. Assumes that alarm is // initially set and unsets it almost immediately after the object is // instantiated. class AlarmToggler : public Actor { … }; // Counts the number of times an alarm has fired. class CounterDelegate : public QuicAlarm::DelegateWithoutContext { … }; // Verifies that the alarms work correctly, even when they are repeatedly // toggled. TEST_F(SimulatorTest, Alarms) { … } // Verifies that a cancelled alarm is never fired. TEST_F(SimulatorTest, AlarmCancelling) { … } // Verifies that alarms can be scheduled into the past. TEST_F(SimulatorTest, AlarmInPast) { … } // Tests Simulator::RunUntilOrTimeout() interface. TEST_F(SimulatorTest, RunUntilOrTimeout) { … } // Tests Simulator::RunFor() interface. TEST_F(SimulatorTest, RunFor) { … } class MockPacketFilter : public PacketFilter { … }; // Set up two trivial packet filters, one allowing any packets, and one dropping // all of them. TEST_F(SimulatorTest, PacketFilter) { … } // Set up a traffic policer in one direction that throttles at 25% of link // bandwidth, and put two link saturators at each endpoint. TEST_F(SimulatorTest, TrafficPolicer) { … } // Ensure that a larger burst is allowed when the policed saturator exits // quiescence. TEST_F(SimulatorTest, TrafficPolicerBurst) { … } // Test that the packet aggregation support in queues work. TEST_F(SimulatorTest, PacketAggregation) { … } } // namespace simulator } // namespace quic