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 #include "net/quic/quic_connection.h" | 5 #include "net/quic/quic_connection.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 #include <sys/types.h> | 8 #include <sys/types.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 // This will likely have to be tuned. | 54 // This will likely have to be tuned. |
55 const QuicPacketSequenceNumber kMaxPacketGap = 5000; | 55 const QuicPacketSequenceNumber kMaxPacketGap = 5000; |
56 | 56 |
57 // Limit the number of FEC groups to two. If we get enough out of order packets | 57 // Limit the number of FEC groups to two. If we get enough out of order packets |
58 // that this becomes limiting, we can revisit. | 58 // that this becomes limiting, we can revisit. |
59 const size_t kMaxFecGroups = 2; | 59 const size_t kMaxFecGroups = 2; |
60 | 60 |
61 // Maximum number of acks received before sending an ack in response. | 61 // Maximum number of acks received before sending an ack in response. |
62 const QuicPacketCount kMaxPacketsReceivedBeforeAckSend = 20; | 62 const QuicPacketCount kMaxPacketsReceivedBeforeAckSend = 20; |
63 | 63 |
| 64 // Maximum number of tracked packets. |
| 65 const QuicPacketCount kMaxTrackedPackets = 5 * kMaxTcpCongestionWindow; |
| 66 |
64 bool Near(QuicPacketSequenceNumber a, QuicPacketSequenceNumber b) { | 67 bool Near(QuicPacketSequenceNumber a, QuicPacketSequenceNumber b) { |
65 QuicPacketSequenceNumber delta = (a > b) ? a - b : b - a; | 68 QuicPacketSequenceNumber delta = (a > b) ? a - b : b - a; |
66 return delta <= kMaxPacketGap; | 69 return delta <= kMaxPacketGap; |
67 } | 70 } |
68 | 71 |
69 // An alarm that is scheduled to send an ack if a timeout occurs. | 72 // An alarm that is scheduled to send an ack if a timeout occurs. |
70 class AckAlarm : public QuicAlarm::Delegate { | 73 class AckAlarm : public QuicAlarm::Delegate { |
71 public: | 74 public: |
72 explicit AckAlarm(QuicConnection* connection) | 75 explicit AckAlarm(QuicConnection* connection) |
73 : connection_(connection) { | 76 : connection_(connection) { |
(...skipping 1037 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1111 delegate); | 1114 delegate); |
1112 } | 1115 } |
1113 | 1116 |
1114 void QuicConnection::SendRstStream(QuicStreamId id, | 1117 void QuicConnection::SendRstStream(QuicStreamId id, |
1115 QuicRstStreamErrorCode error, | 1118 QuicRstStreamErrorCode error, |
1116 QuicStreamOffset bytes_written) { | 1119 QuicStreamOffset bytes_written) { |
1117 // Opportunistically bundle an ack with this outgoing packet. | 1120 // Opportunistically bundle an ack with this outgoing packet. |
1118 ScopedPacketBundler ack_bundler(this, BUNDLE_PENDING_ACK); | 1121 ScopedPacketBundler ack_bundler(this, BUNDLE_PENDING_ACK); |
1119 packet_generator_.AddControlFrame(QuicFrame(new QuicRstStreamFrame( | 1122 packet_generator_.AddControlFrame(QuicFrame(new QuicRstStreamFrame( |
1120 id, AdjustErrorForVersion(error, version()), bytes_written))); | 1123 id, AdjustErrorForVersion(error, version()), bytes_written))); |
| 1124 if (!FLAGS_quic_do_not_retransmit_for_reset_streams) { |
| 1125 return; |
| 1126 } |
| 1127 |
| 1128 sent_packet_manager_.CancelRetransmissionsForStream(id); |
| 1129 // Remove all queued packets which only contain data for the reset stream. |
| 1130 QueuedPacketList::iterator packet_iterator = queued_packets_.begin(); |
| 1131 while (packet_iterator != queued_packets_.end()) { |
| 1132 RetransmittableFrames* retransmittable_frames = |
| 1133 packet_iterator->serialized_packet.retransmittable_frames; |
| 1134 if (!retransmittable_frames) { |
| 1135 ++packet_iterator; |
| 1136 continue; |
| 1137 } |
| 1138 retransmittable_frames->RemoveFramesForStream(id); |
| 1139 if (!retransmittable_frames->frames().empty()) { |
| 1140 ++packet_iterator; |
| 1141 continue; |
| 1142 } |
| 1143 delete packet_iterator->serialized_packet.retransmittable_frames; |
| 1144 delete packet_iterator->serialized_packet.packet; |
| 1145 packet_iterator->serialized_packet.retransmittable_frames = nullptr; |
| 1146 packet_iterator->serialized_packet.packet = nullptr; |
| 1147 packet_iterator = queued_packets_.erase(packet_iterator); |
| 1148 } |
1121 } | 1149 } |
1122 | 1150 |
1123 void QuicConnection::SendWindowUpdate(QuicStreamId id, | 1151 void QuicConnection::SendWindowUpdate(QuicStreamId id, |
1124 QuicStreamOffset byte_offset) { | 1152 QuicStreamOffset byte_offset) { |
1125 // Opportunistically bundle an ack with this outgoing packet. | 1153 // Opportunistically bundle an ack with this outgoing packet. |
1126 ScopedPacketBundler ack_bundler(this, BUNDLE_PENDING_ACK); | 1154 ScopedPacketBundler ack_bundler(this, BUNDLE_PENDING_ACK); |
1127 packet_generator_.AddControlFrame( | 1155 packet_generator_.AddControlFrame( |
1128 QuicFrame(new QuicWindowUpdateFrame(id, byte_offset))); | 1156 QuicFrame(new QuicWindowUpdateFrame(id, byte_offset))); |
1129 } | 1157 } |
1130 | 1158 |
(...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2092 } | 2120 } |
2093 for (const QuicFrame& frame : retransmittable_frames->frames()) { | 2121 for (const QuicFrame& frame : retransmittable_frames->frames()) { |
2094 if (frame.type == CONNECTION_CLOSE_FRAME) { | 2122 if (frame.type == CONNECTION_CLOSE_FRAME) { |
2095 return true; | 2123 return true; |
2096 } | 2124 } |
2097 } | 2125 } |
2098 return false; | 2126 return false; |
2099 } | 2127 } |
2100 | 2128 |
2101 } // namespace net | 2129 } // namespace net |
OLD | NEW |