OLD | NEW |
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> |
(...skipping 22 matching lines...) Expand all Loading... |
33 QuicByteCount cwnd = send_algorithm->GetCongestionWindow(); | 33 QuicByteCount cwnd = send_algorithm->GetCongestionWindow(); |
34 max_cwnd = std::max(max_cwnd, cwnd); | 34 max_cwnd = std::max(max_cwnd, cwnd); |
35 min_cwnd = std::min(min_cwnd, cwnd); | 35 min_cwnd = std::min(min_cwnd, cwnd); |
36 if (last_cwnd > cwnd) { | 36 if (last_cwnd > cwnd) { |
37 max_cwnd_drop = std::max(max_cwnd_drop, last_cwnd - cwnd); | 37 max_cwnd_drop = std::max(max_cwnd_drop, last_cwnd - cwnd); |
38 } | 38 } |
39 last_cwnd = cwnd; | 39 last_cwnd = cwnd; |
40 } | 40 } |
41 | 41 |
42 std::string DebugString() { | 42 std::string DebugString() { |
43 return StringPrintf("observed goodput(bytes/s):%" PRId64 " cwnd:%" PRIu64 | 43 return StringPrintf("observed goodput(bytes/s):%" PRId64 |
| 44 " loss rate:%f" |
| 45 " cwnd:%" PRIu64 |
44 " max_cwnd:%" PRIu64 " min_cwnd:%" PRIu64 | 46 " max_cwnd:%" PRIu64 " min_cwnd:%" PRIu64 |
45 " max_cwnd_drop:%" PRIu64, | 47 " max_cwnd_drop:%" PRIu64, |
46 last_transfer_bandwidth.ToBytesPerSecond(), | 48 last_transfer_bandwidth.ToBytesPerSecond(), |
| 49 last_transfer_loss_rate, |
47 send_algorithm->GetCongestionWindow(), | 50 send_algorithm->GetCongestionWindow(), |
48 max_cwnd, min_cwnd, max_cwnd_drop); | 51 max_cwnd, min_cwnd, max_cwnd_drop); |
49 } | 52 } |
50 | 53 |
51 SendAlgorithmInterface* send_algorithm; | 54 SendAlgorithmInterface* send_algorithm; |
52 RttStats* rtt_stats; | 55 RttStats* rtt_stats; |
53 | 56 |
54 // Last sequence number the sender sent. | 57 // Last sequence number the sender sent. |
55 QuicPacketSequenceNumber last_sent; | 58 QuicPacketSequenceNumber last_sent; |
56 // Last packet sequence number acked. | 59 // Last packet sequence number acked. |
57 QuicPacketSequenceNumber last_acked; | 60 QuicPacketSequenceNumber last_acked; |
58 // Packet sequence number to ack up to. | 61 // Packet sequence number to ack up to. |
59 QuicPacketSequenceNumber next_acked; | 62 QuicPacketSequenceNumber next_acked; |
60 | 63 |
61 // Stats collected for understanding the congestion control. | 64 // Stats collected for understanding the congestion control. |
62 QuicByteCount max_cwnd; | 65 QuicByteCount max_cwnd; |
63 QuicByteCount min_cwnd; | 66 QuicByteCount min_cwnd; |
64 QuicByteCount max_cwnd_drop; | 67 QuicByteCount max_cwnd_drop; |
65 QuicByteCount last_cwnd; | 68 QuicByteCount last_cwnd; |
66 | 69 |
67 QuicBandwidth last_transfer_bandwidth; | 70 QuicBandwidth last_transfer_bandwidth; |
| 71 float last_transfer_loss_rate; |
68 }; | 72 }; |
69 | 73 |
70 struct Transfer { | 74 struct Transfer { |
71 Transfer(Sender* sender, QuicByteCount num_bytes, QuicTime start_time) | 75 Transfer(Sender* sender, QuicByteCount num_bytes, QuicTime start_time) |
72 : sender(sender), | 76 : sender(sender), |
73 num_bytes(num_bytes), | 77 num_bytes(num_bytes), |
74 bytes_acked(0), | 78 bytes_acked(0), |
| 79 bytes_lost(0), |
75 bytes_in_flight(0), | 80 bytes_in_flight(0), |
76 start_time(start_time) {} | 81 start_time(start_time) {} |
77 | 82 |
78 Sender* sender; | 83 Sender* sender; |
79 QuicByteCount num_bytes; | 84 QuicByteCount num_bytes; |
80 QuicByteCount bytes_acked; | 85 QuicByteCount bytes_acked; |
| 86 QuicByteCount bytes_lost; |
81 QuicByteCount bytes_in_flight; | 87 QuicByteCount bytes_in_flight; |
82 QuicTime start_time; | 88 QuicTime start_time; |
83 }; | 89 }; |
84 | 90 |
85 struct SentPacket { | 91 struct SentPacket { |
86 SentPacket(QuicPacketSequenceNumber sequence_number, | 92 SentPacket(QuicPacketSequenceNumber sequence_number, |
87 QuicTime send_time, | 93 QuicTime send_time, |
88 QuicTime ack_time, | 94 QuicTime ack_time, |
89 Transfer* transfer) | 95 Transfer* transfer) |
90 : sequence_number(sequence_number), | 96 : sequence_number(sequence_number), |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 QuicBandwidth bandwidth_; | 196 QuicBandwidth bandwidth_; |
191 QuicTime::Delta rtt_; | 197 QuicTime::Delta rtt_; |
192 size_t buffer_size_; // In bytes. | 198 size_t buffer_size_; // In bytes. |
193 | 199 |
194 DISALLOW_COPY_AND_ASSIGN(SendAlgorithmSimulator); | 200 DISALLOW_COPY_AND_ASSIGN(SendAlgorithmSimulator); |
195 }; | 201 }; |
196 | 202 |
197 } // namespace net | 203 } // namespace net |
198 | 204 |
199 #endif // NET_QUIC_CONGESTION_CONTROL_SEND_ALGORITHM_SIMULATOR_H_ | 205 #endif // NET_QUIC_CONGESTION_CONTROL_SEND_ALGORITHM_SIMULATOR_H_ |
OLD | NEW |