| 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 811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 822 DCHECK(connected_); | 822 DCHECK(connected_); |
| 823 if (debug_visitor_ != nullptr) { | 823 if (debug_visitor_ != nullptr) { |
| 824 debug_visitor_->OnPingFrame(frame); | 824 debug_visitor_->OnPingFrame(frame); |
| 825 } | 825 } |
| 826 should_last_packet_instigate_acks_ = true; | 826 should_last_packet_instigate_acks_ = true; |
| 827 return true; | 827 return true; |
| 828 } | 828 } |
| 829 | 829 |
| 830 const char* QuicConnection::ValidateAckFrame(const QuicAckFrame& incoming_ack) { | 830 const char* QuicConnection::ValidateAckFrame(const QuicAckFrame& incoming_ack) { |
| 831 if (incoming_ack.largest_observed > packet_generator_.packet_number()) { | 831 if (incoming_ack.largest_observed > packet_generator_.packet_number()) { |
| 832 LOG(WARNING) << ENDPOINT << "Peer's observed unsent packet:" | 832 DLOG(WARNING) << ENDPOINT << "Peer's observed unsent packet:" |
| 833 << incoming_ack.largest_observed << " vs " | 833 << incoming_ack.largest_observed << " vs " |
| 834 << packet_generator_.packet_number(); | 834 << packet_generator_.packet_number(); |
| 835 // We got an error for data we have not sent. Error out. | 835 // We got an error for data we have not sent. Error out. |
| 836 return "Largest observed too high."; | 836 return "Largest observed too high."; |
| 837 } | 837 } |
| 838 | 838 |
| 839 if (incoming_ack.largest_observed < | 839 if (incoming_ack.largest_observed < |
| 840 sent_packet_manager_->GetLargestObserved(incoming_ack.path_id)) { | 840 sent_packet_manager_->GetLargestObserved(incoming_ack.path_id)) { |
| 841 LOG(WARNING) << ENDPOINT << "Peer's largest_observed packet decreased:" | 841 LOG(WARNING) << ENDPOINT << "Peer's largest_observed packet decreased:" |
| 842 << incoming_ack.largest_observed << " vs " | 842 << incoming_ack.largest_observed << " vs " |
| 843 << sent_packet_manager_->GetLargestObserved( | 843 << sent_packet_manager_->GetLargestObserved( |
| 844 incoming_ack.path_id) | 844 incoming_ack.path_id) |
| (...skipping 22 matching lines...) Expand all Loading... |
| 867 LOG(WARNING) << ENDPOINT | 867 LOG(WARNING) << ENDPOINT |
| 868 << "Peer sent missing packet: " << incoming_ack.packets.Min() | 868 << "Peer sent missing packet: " << incoming_ack.packets.Min() |
| 869 << " which is smaller than least_packet_awaited_by_peer_: " | 869 << " which is smaller than least_packet_awaited_by_peer_: " |
| 870 << sent_packet_manager_->GetLeastPacketAwaitedByPeer( | 870 << sent_packet_manager_->GetLeastPacketAwaitedByPeer( |
| 871 incoming_ack.path_id); | 871 incoming_ack.path_id); |
| 872 return "Missing packet smaller than least awaited."; | 872 return "Missing packet smaller than least awaited."; |
| 873 } | 873 } |
| 874 if (!sent_entropy_manager_.IsValidEntropy(incoming_ack.largest_observed, | 874 if (!sent_entropy_manager_.IsValidEntropy(incoming_ack.largest_observed, |
| 875 incoming_ack.packets, | 875 incoming_ack.packets, |
| 876 incoming_ack.entropy_hash)) { | 876 incoming_ack.entropy_hash)) { |
| 877 LOG(WARNING) << ENDPOINT << "Peer sent invalid entropy." | 877 DLOG(WARNING) << ENDPOINT << "Peer sent invalid entropy." |
| 878 << " largest_observed:" << incoming_ack.largest_observed | 878 << " largest_observed:" << incoming_ack.largest_observed |
| 879 << " last_received:" << last_header_.packet_number; | 879 << " last_received:" << last_header_.packet_number; |
| 880 return "Invalid entropy."; | 880 return "Invalid entropy."; |
| 881 } | 881 } |
| 882 } else { | 882 } else { |
| 883 if (!incoming_ack.packets.Empty() && | 883 if (!incoming_ack.packets.Empty() && |
| 884 incoming_ack.packets.Max() != incoming_ack.largest_observed) { | 884 incoming_ack.packets.Max() != incoming_ack.largest_observed) { |
| 885 QUIC_BUG << ENDPOINT | 885 QUIC_BUG << ENDPOINT |
| 886 << "Peer last received packet: " << incoming_ack.packets.Max() | 886 << "Peer last received packet: " << incoming_ack.packets.Max() |
| 887 << " which is not equal to largest observed: " | 887 << " which is not equal to largest observed: " |
| 888 << incoming_ack.largest_observed; | 888 << incoming_ack.largest_observed; |
| 889 return "Last received packet not equal to largest observed."; | 889 return "Last received packet not equal to largest observed."; |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1058 ++num_retransmittable_packets_received_since_last_ack_sent_; | 1058 ++num_retransmittable_packets_received_since_last_ack_sent_; |
| 1059 if (ack_mode_ != TCP_ACKING && | 1059 if (ack_mode_ != TCP_ACKING && |
| 1060 last_header_.packet_number > kMinReceivedBeforeAckDecimation) { | 1060 last_header_.packet_number > kMinReceivedBeforeAckDecimation) { |
| 1061 // Ack up to 10 packets at once. | 1061 // Ack up to 10 packets at once. |
| 1062 if (num_retransmittable_packets_received_since_last_ack_sent_ >= | 1062 if (num_retransmittable_packets_received_since_last_ack_sent_ >= |
| 1063 kMaxRetransmittablePacketsBeforeAck) { | 1063 kMaxRetransmittablePacketsBeforeAck) { |
| 1064 ack_queued_ = true; | 1064 ack_queued_ = true; |
| 1065 } else if (!ack_alarm_->IsSet()) { | 1065 } else if (!ack_alarm_->IsSet()) { |
| 1066 // Wait the minimum of a quarter min_rtt and the delayed ack time. | 1066 // Wait the minimum of a quarter min_rtt and the delayed ack time. |
| 1067 QuicTime::Delta ack_delay = QuicTime::Delta::Min( | 1067 QuicTime::Delta ack_delay = QuicTime::Delta::Min( |
| 1068 DelayedAckTime(), | 1068 DelayedAckTime(), sent_packet_manager_->GetRttStats()->min_rtt() * |
| 1069 sent_packet_manager_->GetRttStats()->min_rtt().Multiply( | 1069 ack_decimation_delay_); |
| 1070 ack_decimation_delay_)); | 1070 ack_alarm_->Set(clock_->ApproximateNow() + ack_delay); |
| 1071 ack_alarm_->Set(clock_->ApproximateNow().Add(ack_delay)); | |
| 1072 } | 1071 } |
| 1073 } else { | 1072 } else { |
| 1074 // Ack with a timer or every 2 packets by default. | 1073 // Ack with a timer or every 2 packets by default. |
| 1075 if (num_retransmittable_packets_received_since_last_ack_sent_ >= | 1074 if (num_retransmittable_packets_received_since_last_ack_sent_ >= |
| 1076 kDefaultRetransmittablePacketsBeforeAck) { | 1075 kDefaultRetransmittablePacketsBeforeAck) { |
| 1077 ack_queued_ = true; | 1076 ack_queued_ = true; |
| 1078 } else if (!ack_alarm_->IsSet()) { | 1077 } else if (!ack_alarm_->IsSet()) { |
| 1079 ack_alarm_->Set(clock_->ApproximateNow().Add(DelayedAckTime())); | 1078 ack_alarm_->Set(clock_->ApproximateNow() + DelayedAckTime()); |
| 1080 } | 1079 } |
| 1081 } | 1080 } |
| 1082 | 1081 |
| 1083 // If there are new missing packets to report, send an ack immediately. | 1082 // If there are new missing packets to report, send an ack immediately. |
| 1084 if (received_packet_manager_.HasNewMissingPackets()) { | 1083 if (received_packet_manager_.HasNewMissingPackets()) { |
| 1085 if (ack_mode_ == ACK_DECIMATION_WITH_REORDERING) { | 1084 if (ack_mode_ == ACK_DECIMATION_WITH_REORDERING) { |
| 1086 // Wait the minimum of an eighth min_rtt and the existing ack time. | 1085 // Wait the minimum of an eighth min_rtt and the existing ack time. |
| 1087 QuicTime ack_time = clock_->ApproximateNow().Add( | 1086 QuicTime ack_time = |
| 1088 sent_packet_manager_->GetRttStats()->min_rtt().Multiply(0.125)); | 1087 clock_->ApproximateNow() + |
| 1088 0.125 * sent_packet_manager_->GetRttStats()->min_rtt(); |
| 1089 if (!ack_alarm_->IsSet() || ack_alarm_->deadline() > ack_time) { | 1089 if (!ack_alarm_->IsSet() || ack_alarm_->deadline() > ack_time) { |
| 1090 ack_alarm_->Cancel(); | 1090 ack_alarm_->Cancel(); |
| 1091 ack_alarm_->Set(ack_time); | 1091 ack_alarm_->Set(ack_time); |
| 1092 } | 1092 } |
| 1093 } else { | 1093 } else { |
| 1094 ack_queued_ = true; | 1094 ack_queued_ = true; |
| 1095 } | 1095 } |
| 1096 } | 1096 } |
| 1097 } | 1097 } |
| 1098 | 1098 |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1571 sent_packet_manager_->TimeUntilSend(now, retransmittable, &path_id); | 1571 sent_packet_manager_->TimeUntilSend(now, retransmittable, &path_id); |
| 1572 if (delay.IsInfinite()) { | 1572 if (delay.IsInfinite()) { |
| 1573 DCHECK_EQ(kInvalidPathId, path_id); | 1573 DCHECK_EQ(kInvalidPathId, path_id); |
| 1574 send_alarm_->Cancel(); | 1574 send_alarm_->Cancel(); |
| 1575 return false; | 1575 return false; |
| 1576 } | 1576 } |
| 1577 | 1577 |
| 1578 DCHECK_NE(kInvalidPathId, path_id); | 1578 DCHECK_NE(kInvalidPathId, path_id); |
| 1579 // If the scheduler requires a delay, then we can not send this packet now. | 1579 // If the scheduler requires a delay, then we can not send this packet now. |
| 1580 if (!delay.IsZero()) { | 1580 if (!delay.IsZero()) { |
| 1581 send_alarm_->Update(now.Add(delay), QuicTime::Delta::FromMilliseconds(1)); | 1581 send_alarm_->Update(now + delay, QuicTime::Delta::FromMilliseconds(1)); |
| 1582 DVLOG(1) << ENDPOINT << "Delaying sending " << delay.ToMilliseconds() | 1582 DVLOG(1) << ENDPOINT << "Delaying sending " << delay.ToMilliseconds() |
| 1583 << "ms"; | 1583 << "ms"; |
| 1584 return false; | 1584 return false; |
| 1585 } | 1585 } |
| 1586 return true; | 1586 return true; |
| 1587 } | 1587 } |
| 1588 | 1588 |
| 1589 bool QuicConnection::WritePacket(SerializedPacket* packet) { | 1589 bool QuicConnection::WritePacket(SerializedPacket* packet) { |
| 1590 if (packet->packet_number < | 1590 if (packet->packet_number < |
| 1591 sent_packet_manager_->GetLargestSentPacket(packet->path_id)) { | 1591 sent_packet_manager_->GetLargestSentPacket(packet->path_id)) { |
| (...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2134 } | 2134 } |
| 2135 | 2135 |
| 2136 void QuicConnection::SetNetworkTimeouts(QuicTime::Delta handshake_timeout, | 2136 void QuicConnection::SetNetworkTimeouts(QuicTime::Delta handshake_timeout, |
| 2137 QuicTime::Delta idle_timeout) { | 2137 QuicTime::Delta idle_timeout) { |
| 2138 QUIC_BUG_IF(idle_timeout > handshake_timeout) | 2138 QUIC_BUG_IF(idle_timeout > handshake_timeout) |
| 2139 << "idle_timeout:" << idle_timeout.ToMilliseconds() | 2139 << "idle_timeout:" << idle_timeout.ToMilliseconds() |
| 2140 << " handshake_timeout:" << handshake_timeout.ToMilliseconds(); | 2140 << " handshake_timeout:" << handshake_timeout.ToMilliseconds(); |
| 2141 // Adjust the idle timeout on client and server to prevent clients from | 2141 // Adjust the idle timeout on client and server to prevent clients from |
| 2142 // sending requests to servers which have already closed the connection. | 2142 // sending requests to servers which have already closed the connection. |
| 2143 if (perspective_ == Perspective::IS_SERVER) { | 2143 if (perspective_ == Perspective::IS_SERVER) { |
| 2144 idle_timeout = idle_timeout.Add(QuicTime::Delta::FromSeconds(3)); | 2144 idle_timeout = idle_timeout + QuicTime::Delta::FromSeconds(3); |
| 2145 } else if (idle_timeout > QuicTime::Delta::FromSeconds(1)) { | 2145 } else if (idle_timeout > QuicTime::Delta::FromSeconds(1)) { |
| 2146 idle_timeout = idle_timeout.Subtract(QuicTime::Delta::FromSeconds(1)); | 2146 idle_timeout = idle_timeout - QuicTime::Delta::FromSeconds(1); |
| 2147 } | 2147 } |
| 2148 handshake_timeout_ = handshake_timeout; | 2148 handshake_timeout_ = handshake_timeout; |
| 2149 idle_network_timeout_ = idle_timeout; | 2149 idle_network_timeout_ = idle_timeout; |
| 2150 | 2150 |
| 2151 SetTimeoutAlarm(); | 2151 SetTimeoutAlarm(); |
| 2152 } | 2152 } |
| 2153 | 2153 |
| 2154 void QuicConnection::CheckForTimeout() { | 2154 void QuicConnection::CheckForTimeout() { |
| 2155 QuicTime now = clock_->ApproximateNow(); | 2155 QuicTime now = clock_->ApproximateNow(); |
| 2156 QuicTime time_of_last_packet = | 2156 QuicTime time_of_last_packet = |
| 2157 max(time_of_last_received_packet_, last_send_for_timeout_); | 2157 max(time_of_last_received_packet_, last_send_for_timeout_); |
| 2158 | 2158 |
| 2159 // |delta| can be < 0 as |now| is approximate time but |time_of_last_packet| | 2159 // |delta| can be < 0 as |now| is approximate time but |time_of_last_packet| |
| 2160 // is accurate time. However, this should not change the behavior of | 2160 // is accurate time. However, this should not change the behavior of |
| 2161 // timeout handling. | 2161 // timeout handling. |
| 2162 QuicTime::Delta idle_duration = now.Subtract(time_of_last_packet); | 2162 QuicTime::Delta idle_duration = now - time_of_last_packet; |
| 2163 DVLOG(1) << ENDPOINT << "last packet " | 2163 DVLOG(1) << ENDPOINT << "last packet " |
| 2164 << time_of_last_packet.ToDebuggingValue() | 2164 << time_of_last_packet.ToDebuggingValue() |
| 2165 << " now:" << now.ToDebuggingValue() | 2165 << " now:" << now.ToDebuggingValue() |
| 2166 << " idle_duration:" << idle_duration.ToMicroseconds() | 2166 << " idle_duration:" << idle_duration.ToMicroseconds() |
| 2167 << " idle_network_timeout: " | 2167 << " idle_network_timeout: " |
| 2168 << idle_network_timeout_.ToMicroseconds(); | 2168 << idle_network_timeout_.ToMicroseconds(); |
| 2169 if (idle_duration >= idle_network_timeout_) { | 2169 if (idle_duration >= idle_network_timeout_) { |
| 2170 const string error_details = "No recent network activity."; | 2170 const string error_details = "No recent network activity."; |
| 2171 DVLOG(1) << ENDPOINT << error_details; | 2171 DVLOG(1) << ENDPOINT << error_details; |
| 2172 CloseConnection(QUIC_NETWORK_IDLE_TIMEOUT, error_details, | 2172 CloseConnection(QUIC_NETWORK_IDLE_TIMEOUT, error_details, |
| 2173 idle_timeout_connection_close_behavior_); | 2173 idle_timeout_connection_close_behavior_); |
| 2174 return; | 2174 return; |
| 2175 } | 2175 } |
| 2176 | 2176 |
| 2177 if (!handshake_timeout_.IsInfinite()) { | 2177 if (!handshake_timeout_.IsInfinite()) { |
| 2178 QuicTime::Delta connected_duration = | 2178 QuicTime::Delta connected_duration = now - stats_.connection_creation_time; |
| 2179 now.Subtract(stats_.connection_creation_time); | |
| 2180 DVLOG(1) << ENDPOINT | 2179 DVLOG(1) << ENDPOINT |
| 2181 << "connection time: " << connected_duration.ToMicroseconds() | 2180 << "connection time: " << connected_duration.ToMicroseconds() |
| 2182 << " handshake timeout: " << handshake_timeout_.ToMicroseconds(); | 2181 << " handshake timeout: " << handshake_timeout_.ToMicroseconds(); |
| 2183 if (connected_duration >= handshake_timeout_) { | 2182 if (connected_duration >= handshake_timeout_) { |
| 2184 const string error_details = "Handshake timeout expired."; | 2183 const string error_details = "Handshake timeout expired."; |
| 2185 DVLOG(1) << ENDPOINT << error_details; | 2184 DVLOG(1) << ENDPOINT << error_details; |
| 2186 CloseConnection(QUIC_HANDSHAKE_TIMEOUT, error_details, | 2185 CloseConnection(QUIC_HANDSHAKE_TIMEOUT, error_details, |
| 2187 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); | 2186 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); |
| 2188 return; | 2187 return; |
| 2189 } | 2188 } |
| 2190 } | 2189 } |
| 2191 | 2190 |
| 2192 SetTimeoutAlarm(); | 2191 SetTimeoutAlarm(); |
| 2193 } | 2192 } |
| 2194 | 2193 |
| 2195 void QuicConnection::SetTimeoutAlarm() { | 2194 void QuicConnection::SetTimeoutAlarm() { |
| 2196 QuicTime time_of_last_packet = | 2195 QuicTime time_of_last_packet = |
| 2197 max(time_of_last_received_packet_, time_of_last_sent_new_packet_); | 2196 max(time_of_last_received_packet_, time_of_last_sent_new_packet_); |
| 2198 | 2197 |
| 2199 QuicTime deadline = time_of_last_packet.Add(idle_network_timeout_); | 2198 QuicTime deadline = time_of_last_packet + idle_network_timeout_; |
| 2200 if (!handshake_timeout_.IsInfinite()) { | 2199 if (!handshake_timeout_.IsInfinite()) { |
| 2201 deadline = | 2200 deadline = |
| 2202 min(deadline, stats_.connection_creation_time.Add(handshake_timeout_)); | 2201 min(deadline, stats_.connection_creation_time + handshake_timeout_); |
| 2203 } | 2202 } |
| 2204 | 2203 |
| 2205 timeout_alarm_->Cancel(); | 2204 timeout_alarm_->Cancel(); |
| 2206 timeout_alarm_->Set(deadline); | 2205 timeout_alarm_->Set(deadline); |
| 2207 } | 2206 } |
| 2208 | 2207 |
| 2209 void QuicConnection::SetPingAlarm() { | 2208 void QuicConnection::SetPingAlarm() { |
| 2210 if (perspective_ == Perspective::IS_SERVER) { | 2209 if (perspective_ == Perspective::IS_SERVER) { |
| 2211 // Only clients send pings. | 2210 // Only clients send pings. |
| 2212 return; | 2211 return; |
| 2213 } | 2212 } |
| 2214 if (!visitor_->HasOpenDynamicStreams()) { | 2213 if (!visitor_->HasOpenDynamicStreams()) { |
| 2215 ping_alarm_->Cancel(); | 2214 ping_alarm_->Cancel(); |
| 2216 // Don't send a ping unless there are open streams. | 2215 // Don't send a ping unless there are open streams. |
| 2217 return; | 2216 return; |
| 2218 } | 2217 } |
| 2219 QuicTime::Delta ping_timeout = QuicTime::Delta::FromSeconds(kPingTimeoutSecs); | 2218 QuicTime::Delta ping_timeout = QuicTime::Delta::FromSeconds(kPingTimeoutSecs); |
| 2220 ping_alarm_->Update(clock_->ApproximateNow().Add(ping_timeout), | 2219 ping_alarm_->Update(clock_->ApproximateNow() + ping_timeout, |
| 2221 QuicTime::Delta::FromSeconds(1)); | 2220 QuicTime::Delta::FromSeconds(1)); |
| 2222 } | 2221 } |
| 2223 | 2222 |
| 2224 void QuicConnection::SetRetransmissionAlarm() { | 2223 void QuicConnection::SetRetransmissionAlarm() { |
| 2225 if (delay_setting_retransmission_alarm_) { | 2224 if (delay_setting_retransmission_alarm_) { |
| 2226 pending_retransmission_alarm_ = true; | 2225 pending_retransmission_alarm_ = true; |
| 2227 return; | 2226 return; |
| 2228 } | 2227 } |
| 2229 QuicTime retransmission_time = sent_packet_manager_->GetRetransmissionTime(); | 2228 QuicTime retransmission_time = sent_packet_manager_->GetRetransmissionTime(); |
| 2230 retransmission_alarm_->Update(retransmission_time, | 2229 retransmission_alarm_->Update(retransmission_time, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 2259 AckBundling ack_mode) | 2258 AckBundling ack_mode) |
| 2260 : connection_(connection), | 2259 : connection_(connection), |
| 2261 already_in_batch_mode_(connection != nullptr && | 2260 already_in_batch_mode_(connection != nullptr && |
| 2262 connection->packet_generator_.InBatchMode()) { | 2261 connection->packet_generator_.InBatchMode()) { |
| 2263 if (connection_ == nullptr) { | 2262 if (connection_ == nullptr) { |
| 2264 return; | 2263 return; |
| 2265 } | 2264 } |
| 2266 // Move generator into batch mode. If caller wants us to include an ack, | 2265 // Move generator into batch mode. If caller wants us to include an ack, |
| 2267 // check the delayed-ack timer to see if there's ack info to be sent. | 2266 // check the delayed-ack timer to see if there's ack info to be sent. |
| 2268 if (!already_in_batch_mode_) { | 2267 if (!already_in_batch_mode_) { |
| 2269 DVLOG(1) << "Entering Batch Mode."; | 2268 DVLOG(2) << "Entering Batch Mode."; |
| 2270 connection_->packet_generator_.StartBatchOperations(); | 2269 connection_->packet_generator_.StartBatchOperations(); |
| 2271 } | 2270 } |
| 2272 if (ShouldSendAck(ack_mode)) { | 2271 if (ShouldSendAck(ack_mode)) { |
| 2273 DVLOG(1) << "Bundling ack with outgoing packet."; | 2272 DVLOG(1) << "Bundling ack with outgoing packet."; |
| 2274 DCHECK(ack_mode == SEND_ACK || connection_->ack_frame_updated() || | 2273 DCHECK(ack_mode == SEND_ACK || connection_->ack_frame_updated() || |
| 2275 connection_->stop_waiting_count_ > 1); | 2274 connection_->stop_waiting_count_ > 1); |
| 2276 connection_->SendAck(); | 2275 connection_->SendAck(); |
| 2277 } | 2276 } |
| 2278 } | 2277 } |
| 2279 | 2278 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2292 return true; | 2291 return true; |
| 2293 } | 2292 } |
| 2294 } | 2293 } |
| 2295 | 2294 |
| 2296 QuicConnection::ScopedPacketBundler::~ScopedPacketBundler() { | 2295 QuicConnection::ScopedPacketBundler::~ScopedPacketBundler() { |
| 2297 if (connection_ == nullptr) { | 2296 if (connection_ == nullptr) { |
| 2298 return; | 2297 return; |
| 2299 } | 2298 } |
| 2300 // If we changed the generator's batch state, restore original batch state. | 2299 // If we changed the generator's batch state, restore original batch state. |
| 2301 if (!already_in_batch_mode_) { | 2300 if (!already_in_batch_mode_) { |
| 2302 DVLOG(1) << "Leaving Batch Mode."; | 2301 DVLOG(2) << "Leaving Batch Mode."; |
| 2303 connection_->packet_generator_.FinishBatchOperations(); | 2302 connection_->packet_generator_.FinishBatchOperations(); |
| 2304 } | 2303 } |
| 2305 DCHECK_EQ(already_in_batch_mode_, | 2304 DCHECK_EQ(already_in_batch_mode_, |
| 2306 connection_->packet_generator_.InBatchMode()); | 2305 connection_->packet_generator_.InBatchMode()); |
| 2307 } | 2306 } |
| 2308 | 2307 |
| 2309 QuicConnection::ScopedRetransmissionScheduler::ScopedRetransmissionScheduler( | 2308 QuicConnection::ScopedRetransmissionScheduler::ScopedRetransmissionScheduler( |
| 2310 QuicConnection* connection) | 2309 QuicConnection* connection) |
| 2311 : connection_(connection), | 2310 : connection_(connection), |
| 2312 already_delayed_(connection_->delay_setting_retransmission_alarm_) { | 2311 already_delayed_(connection_->delay_setting_retransmission_alarm_) { |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2511 // the sender and a signaling mechanism -- if the sender uses a | 2510 // the sender and a signaling mechanism -- if the sender uses a |
| 2512 // different MinRTO, we may get spurious retransmissions. May not have | 2511 // different MinRTO, we may get spurious retransmissions. May not have |
| 2513 // any benefits, but if the delayed ack becomes a significant source | 2512 // any benefits, but if the delayed ack becomes a significant source |
| 2514 // of (likely, tail) latency, then consider such a mechanism. | 2513 // of (likely, tail) latency, then consider such a mechanism. |
| 2515 const QuicTime::Delta QuicConnection::DelayedAckTime() { | 2514 const QuicTime::Delta QuicConnection::DelayedAckTime() { |
| 2516 return QuicTime::Delta::FromMilliseconds( | 2515 return QuicTime::Delta::FromMilliseconds( |
| 2517 min(kMaxDelayedAckTimeMs, kMinRetransmissionTimeMs / 2)); | 2516 min(kMaxDelayedAckTimeMs, kMinRetransmissionTimeMs / 2)); |
| 2518 } | 2517 } |
| 2519 | 2518 |
| 2520 } // namespace net | 2519 } // namespace net |
| OLD | NEW |