| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef NET_QUIC_TEST_TOOLS_SIMULATOR_QUIC_ENDPOINT_H_ | 5 #ifndef NET_QUIC_TEST_TOOLS_SIMULATOR_QUIC_ENDPOINT_H_ |
| 6 #define NET_QUIC_TEST_TOOLS_SIMULATOR_QUIC_ENDPOINT_H_ | 6 #define NET_QUIC_TEST_TOOLS_SIMULATOR_QUIC_ENDPOINT_H_ |
| 7 | 7 |
| 8 #include "net/quic/core/crypto/null_decrypter.h" | 8 #include "net/quic/core/crypto/null_decrypter.h" |
| 9 #include "net/quic/core/crypto/null_encrypter.h" | 9 #include "net/quic/core/crypto/null_encrypter.h" |
| 10 #include "net/quic/core/quic_connection.h" | 10 #include "net/quic/core/quic_connection.h" |
| 11 #include "net/quic/core/quic_packets.h" | 11 #include "net/quic/core/quic_packets.h" |
| 12 #include "net/quic/test_tools/simple_data_producer.h" |
| 12 #include "net/quic/test_tools/simulator/link.h" | 13 #include "net/quic/test_tools/simulator/link.h" |
| 13 #include "net/quic/test_tools/simulator/queue.h" | 14 #include "net/quic/test_tools/simulator/queue.h" |
| 14 #include "net/tools/quic/quic_default_packet_writer.h" | 15 #include "net/tools/quic/quic_default_packet_writer.h" |
| 15 | 16 |
| 16 namespace net { | 17 namespace net { |
| 17 namespace simulator { | 18 namespace simulator { |
| 18 | 19 |
| 19 // Size of the TX queue used by the kernel/NIC. 1000 is the Linux | 20 // Size of the TX queue used by the kernel/NIC. 1000 is the Linux |
| 20 // kernel default. | 21 // kernel default. |
| 21 const QuicByteCount kTxQueueSize = 1000; | 22 const QuicByteCount kTxQueueSize = 1000; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 void OnConnectionClosed(QuicErrorCode error, | 84 void OnConnectionClosed(QuicErrorCode error, |
| 84 const std::string& error_details, | 85 const std::string& error_details, |
| 85 ConnectionCloseSource source) override {} | 86 ConnectionCloseSource source) override {} |
| 86 void OnWriteBlocked() override {} | 87 void OnWriteBlocked() override {} |
| 87 void OnSuccessfulVersionNegotiation(const QuicVersion& version) override {} | 88 void OnSuccessfulVersionNegotiation(const QuicVersion& version) override {} |
| 88 void OnCongestionWindowChange(QuicTime now) override {} | 89 void OnCongestionWindowChange(QuicTime now) override {} |
| 89 void OnConnectionMigration(PeerAddressChangeType type) override {} | 90 void OnConnectionMigration(PeerAddressChangeType type) override {} |
| 90 void OnPathDegrading() override {} | 91 void OnPathDegrading() override {} |
| 91 void PostProcessAfterData() override {} | 92 void PostProcessAfterData() override {} |
| 92 void OnAckNeedsRetransmittableFrame() override {} | 93 void OnAckNeedsRetransmittableFrame() override {} |
| 94 void SaveStreamData(QuicStreamId id, |
| 95 QuicIOVector iov, |
| 96 size_t iov_offset, |
| 97 QuicStreamOffset offset, |
| 98 QuicByteCount data_length) override; |
| 99 bool WriteStreamData(QuicStreamId id, |
| 100 QuicStreamOffset offset, |
| 101 QuicByteCount data_length, |
| 102 QuicDataWriter* writer) override; |
| 93 // End QuicConnectionVisitorInterface implementation. | 103 // End QuicConnectionVisitorInterface implementation. |
| 94 | 104 |
| 95 private: | 105 private: |
| 96 // A Writer object that writes into the |nic_tx_queue_|. | 106 // A Writer object that writes into the |nic_tx_queue_|. |
| 97 class Writer : public QuicPacketWriter { | 107 class Writer : public QuicPacketWriter { |
| 98 public: | 108 public: |
| 99 explicit Writer(QuicEndpoint* endpoint); | 109 explicit Writer(QuicEndpoint* endpoint); |
| 100 ~Writer() override; | 110 ~Writer() override; |
| 101 | 111 |
| 102 WriteResult WritePacket(const char* buffer, | 112 WriteResult WritePacket(const char* buffer, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 133 QuicByteCount bytes_transferred_; | 143 QuicByteCount bytes_transferred_; |
| 134 | 144 |
| 135 // Counts the number of times the writer became write-blocked. | 145 // Counts the number of times the writer became write-blocked. |
| 136 size_t write_blocked_count_; | 146 size_t write_blocked_count_; |
| 137 | 147 |
| 138 // Set to true if the endpoint receives stream data different from what it | 148 // Set to true if the endpoint receives stream data different from what it |
| 139 // expects. | 149 // expects. |
| 140 bool wrong_data_received_; | 150 bool wrong_data_received_; |
| 141 | 151 |
| 142 std::unique_ptr<char[]> transmission_buffer_; | 152 std::unique_ptr<char[]> transmission_buffer_; |
| 153 |
| 154 test::SimpleDataProducer producer_; |
| 143 }; | 155 }; |
| 144 | 156 |
| 145 // Multiplexes multiple connections at the same host on the network. | 157 // Multiplexes multiple connections at the same host on the network. |
| 146 class QuicEndpointMultiplexer : public Endpoint, | 158 class QuicEndpointMultiplexer : public Endpoint, |
| 147 public UnconstrainedPortInterface { | 159 public UnconstrainedPortInterface { |
| 148 public: | 160 public: |
| 149 QuicEndpointMultiplexer(std::string name, | 161 QuicEndpointMultiplexer(std::string name, |
| 150 std::initializer_list<QuicEndpoint*> endpoints); | 162 std::initializer_list<QuicEndpoint*> endpoints); |
| 151 ~QuicEndpointMultiplexer() override; | 163 ~QuicEndpointMultiplexer() override; |
| 152 | 164 |
| 153 // Receives a packet and passes it to the specified endpoint if that endpoint | 165 // Receives a packet and passes it to the specified endpoint if that endpoint |
| 154 // is one of the endpoints being multiplexed, otherwise ignores the packet. | 166 // is one of the endpoints being multiplexed, otherwise ignores the packet. |
| 155 void AcceptPacket(std::unique_ptr<Packet> packet) override; | 167 void AcceptPacket(std::unique_ptr<Packet> packet) override; |
| 156 UnconstrainedPortInterface* GetRxPort() override; | 168 UnconstrainedPortInterface* GetRxPort() override; |
| 157 | 169 |
| 158 // Sets the egress port for all the endpoints being multiplexed. | 170 // Sets the egress port for all the endpoints being multiplexed. |
| 159 void SetTxPort(ConstrainedPortInterface* port) override; | 171 void SetTxPort(ConstrainedPortInterface* port) override; |
| 160 | 172 |
| 161 void Act() override {} | 173 void Act() override {} |
| 162 | 174 |
| 163 private: | 175 private: |
| 164 std::unordered_map<std::string, QuicEndpoint*> mapping_; | 176 std::unordered_map<std::string, QuicEndpoint*> mapping_; |
| 165 }; | 177 }; |
| 166 | 178 |
| 167 } // namespace simulator | 179 } // namespace simulator |
| 168 } // namespace net | 180 } // namespace net |
| 169 | 181 |
| 170 #endif // NET_QUIC_TEST_TOOLS_SIMULATOR_QUIC_ENDPOINT_H_ | 182 #endif // NET_QUIC_TEST_TOOLS_SIMULATOR_QUIC_ENDPOINT_H_ |
| OLD | NEW |