Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(263)

Side by Side Diff: net/quic/congestion_control/send_algorithm_simulator.h

Issue 399153003: Land Recent QUIC Changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added NET_EXPORT_PRIVATE Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 // A test only class to enable simulations of send algorithms. 5 // A test only class to enable simulations of send algorithms.
6 6
7 #ifndef NET_QUIC_CONGESTION_CONTROL_SEND_ALGORITHM_SIMULATOR_H_ 7 #ifndef NET_QUIC_CONGESTION_CONTROL_SEND_ALGORITHM_SIMULATOR_H_
8 #define NET_QUIC_CONGESTION_CONTROL_SEND_ALGORITHM_SIMULATOR_H_ 8 #define NET_QUIC_CONGESTION_CONTROL_SEND_ALGORITHM_SIMULATOR_H_
9 9
10 #include <algorithm> 10 #include <algorithm>
11 #include <string>
11 #include <vector> 12 #include <vector>
12 13
13 #include "base/basictypes.h" 14 #include "base/basictypes.h"
15 #include "base/format_macros.h"
16 #include "base/strings/stringprintf.h"
14 #include "net/quic/congestion_control/send_algorithm_interface.h" 17 #include "net/quic/congestion_control/send_algorithm_interface.h"
15 #include "net/quic/quic_protocol.h" 18 #include "net/quic/quic_protocol.h"
16 #include "net/quic/quic_time.h" 19 #include "net/quic/quic_time.h"
17 #include "net/quic/test_tools/mock_clock.h" 20 #include "net/quic/test_tools/mock_clock.h"
18 #include "net/quic/test_tools/quic_test_utils.h" 21 #include "net/quic/test_tools/quic_test_utils.h"
19 22
23 using base::StringPrintf;
24
20 namespace net { 25 namespace net {
21 26
22 class SendAlgorithmSimulator { 27 class SendAlgorithmSimulator {
23 public: 28 public:
24 struct Sender { 29 struct Sender {
25 Sender(SendAlgorithmInterface* send_algorithm, RttStats* rtt_stats); 30 Sender(SendAlgorithmInterface* send_algorithm, RttStats* rtt_stats);
26 31
27 void RecordStats() { 32 void RecordStats() {
28 QuicByteCount cwnd = send_algorithm->GetCongestionWindow(); 33 QuicByteCount cwnd = send_algorithm->GetCongestionWindow();
29 max_cwnd = std::max(max_cwnd, cwnd); 34 max_cwnd = std::max(max_cwnd, cwnd);
30 min_cwnd = std::min(min_cwnd, cwnd); 35 min_cwnd = std::min(min_cwnd, cwnd);
31 if (last_cwnd > cwnd) { 36 if (last_cwnd > cwnd) {
32 max_cwnd_drop = std::max(max_cwnd_drop, last_cwnd - cwnd); 37 max_cwnd_drop = std::max(max_cwnd_drop, last_cwnd - cwnd);
33 } 38 }
34 last_cwnd = cwnd; 39 last_cwnd = cwnd;
35 } 40 }
36 41
42 std::string DebugString() {
43 return StringPrintf("observed goodput(bytes/s):%" PRId64
44 " loss rate:%f"
45 " cwnd:%" PRIu64
46 " max_cwnd:%" PRIu64 " min_cwnd:%" PRIu64
47 " max_cwnd_drop:%" PRIu64,
48 last_transfer_bandwidth.ToBytesPerSecond(),
49 last_transfer_loss_rate,
50 send_algorithm->GetCongestionWindow(),
51 max_cwnd, min_cwnd, max_cwnd_drop);
52 }
53
37 SendAlgorithmInterface* send_algorithm; 54 SendAlgorithmInterface* send_algorithm;
38 RttStats* rtt_stats; 55 RttStats* rtt_stats;
39 56
40 // Last sequence number the sender sent. 57 // Last sequence number the sender sent.
41 QuicPacketSequenceNumber last_sent; 58 QuicPacketSequenceNumber last_sent;
42 // Last packet sequence number acked. 59 // Last packet sequence number acked.
43 QuicPacketSequenceNumber last_acked; 60 QuicPacketSequenceNumber last_acked;
44 // Packet sequence number to ack up to. 61 // Packet sequence number to ack up to.
45 QuicPacketSequenceNumber next_acked; 62 QuicPacketSequenceNumber next_acked;
46 63
47 // Stats collected for understanding the congestion control. 64 // Stats collected for understanding the congestion control.
48 QuicByteCount max_cwnd; 65 QuicByteCount max_cwnd;
49 QuicByteCount min_cwnd; 66 QuicByteCount min_cwnd;
50 QuicByteCount max_cwnd_drop; 67 QuicByteCount max_cwnd_drop;
51 QuicByteCount last_cwnd; 68 QuicByteCount last_cwnd;
52 69
53 QuicBandwidth last_transfer_bandwidth; 70 QuicBandwidth last_transfer_bandwidth;
71 float last_transfer_loss_rate;
54 }; 72 };
55 73
56 struct Transfer { 74 struct Transfer {
57 Transfer(Sender* sender, QuicByteCount num_bytes, QuicTime start_time) 75 Transfer(Sender* sender, QuicByteCount num_bytes, QuicTime start_time)
58 : sender(sender), 76 : sender(sender),
59 num_bytes(num_bytes), 77 num_bytes(num_bytes),
60 bytes_acked(0), 78 bytes_acked(0),
79 bytes_lost(0),
61 bytes_in_flight(0), 80 bytes_in_flight(0),
62 start_time(start_time) {} 81 start_time(start_time) {}
63 82
64 Sender* sender; 83 Sender* sender;
65 QuicByteCount num_bytes; 84 QuicByteCount num_bytes;
66 QuicByteCount bytes_acked; 85 QuicByteCount bytes_acked;
86 QuicByteCount bytes_lost;
67 QuicByteCount bytes_in_flight; 87 QuicByteCount bytes_in_flight;
68 QuicTime start_time; 88 QuicTime start_time;
69 }; 89 };
70 90
71 struct SentPacket { 91 struct SentPacket {
72 SentPacket(QuicPacketSequenceNumber sequence_number, 92 SentPacket(QuicPacketSequenceNumber sequence_number,
73 QuicTime send_time, 93 QuicTime send_time,
74 QuicTime ack_time, 94 QuicTime ack_time,
75 Transfer* transfer) 95 Transfer* transfer)
76 : sequence_number(sequence_number), 96 : sequence_number(sequence_number),
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 QuicBandwidth bandwidth_; 196 QuicBandwidth bandwidth_;
177 QuicTime::Delta rtt_; 197 QuicTime::Delta rtt_;
178 size_t buffer_size_; // In bytes. 198 size_t buffer_size_; // In bytes.
179 199
180 DISALLOW_COPY_AND_ASSIGN(SendAlgorithmSimulator); 200 DISALLOW_COPY_AND_ASSIGN(SendAlgorithmSimulator);
181 }; 201 };
182 202
183 } // namespace net 203 } // namespace net
184 204
185 #endif // NET_QUIC_CONGESTION_CONTROL_SEND_ALGORITHM_SIMULATOR_H_ 205 #endif // NET_QUIC_CONGESTION_CONTROL_SEND_ALGORITHM_SIMULATOR_H_
OLDNEW
« no previous file with comments | « net/quic/congestion_control/send_algorithm_interface.cc ('k') | net/quic/congestion_control/send_algorithm_simulator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698