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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 IPEndPoint address, | 239 IPEndPoint address, |
240 QuicConnectionHelperInterface* helper, | 240 QuicConnectionHelperInterface* helper, |
241 QuicPacketWriter* writer, | 241 QuicPacketWriter* writer, |
242 bool owns_writer, | 242 bool owns_writer, |
243 Perspective perspective, | 243 Perspective perspective, |
244 const QuicVersionVector& supported_versions) | 244 const QuicVersionVector& supported_versions) |
245 : framer_(supported_versions, | 245 : framer_(supported_versions, |
246 helper->GetClock()->ApproximateNow(), | 246 helper->GetClock()->ApproximateNow(), |
247 perspective), | 247 perspective), |
248 helper_(helper), | 248 helper_(helper), |
| 249 per_packet_options_(nullptr), |
249 writer_(writer), | 250 writer_(writer), |
250 owns_writer_(owns_writer), | 251 owns_writer_(owns_writer), |
251 encryption_level_(ENCRYPTION_NONE), | 252 encryption_level_(ENCRYPTION_NONE), |
252 has_forward_secure_encrypter_(false), | 253 has_forward_secure_encrypter_(false), |
253 first_required_forward_secure_packet_(0), | 254 first_required_forward_secure_packet_(0), |
254 clock_(helper->GetClock()), | 255 clock_(helper->GetClock()), |
255 random_generator_(helper->GetRandomGenerator()), | 256 random_generator_(helper->GetRandomGenerator()), |
256 connection_id_(connection_id), | 257 connection_id_(connection_id), |
257 peer_address_(address), | 258 peer_address_(address), |
258 migrating_peer_port_(0), | 259 migrating_peer_port_(0), |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 | 396 |
396 if (config.HasClientSentConnectionOption(kMTUH, perspective_)) { | 397 if (config.HasClientSentConnectionOption(kMTUH, perspective_)) { |
397 SetMtuDiscoveryTarget(kMtuDiscoveryTargetPacketSizeHigh); | 398 SetMtuDiscoveryTarget(kMtuDiscoveryTargetPacketSizeHigh); |
398 } | 399 } |
399 if (config.HasClientSentConnectionOption(kMTUL, perspective_)) { | 400 if (config.HasClientSentConnectionOption(kMTUL, perspective_)) { |
400 SetMtuDiscoveryTarget(kMtuDiscoveryTargetPacketSizeLow); | 401 SetMtuDiscoveryTarget(kMtuDiscoveryTargetPacketSizeLow); |
401 } | 402 } |
402 if (debug_visitor_ != nullptr) { | 403 if (debug_visitor_ != nullptr) { |
403 debug_visitor_->OnSetFromConfig(config); | 404 debug_visitor_->OnSetFromConfig(config); |
404 } | 405 } |
405 if (FLAGS_quic_ack_decimation && | 406 if (config.HasClientSentConnectionOption(kACKD, perspective_)) { |
406 config.HasClientSentConnectionOption(kACKD, perspective_)) { | |
407 ack_decimation_enabled_ = true; | 407 ack_decimation_enabled_ = true; |
408 } | 408 } |
409 } | 409 } |
410 | 410 |
411 void QuicConnection::OnSendConnectionState( | 411 void QuicConnection::OnSendConnectionState( |
412 const CachedNetworkParameters& cached_network_params) { | 412 const CachedNetworkParameters& cached_network_params) { |
413 if (debug_visitor_ != nullptr) { | 413 if (debug_visitor_ != nullptr) { |
414 debug_visitor_->OnSendConnectionState(cached_network_params); | 414 debug_visitor_->OnSendConnectionState(cached_network_params); |
415 } | 415 } |
416 } | 416 } |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 } | 688 } |
689 if (frame.stream_id != kCryptoStreamId && | 689 if (frame.stream_id != kCryptoStreamId && |
690 last_decrypted_packet_level_ == ENCRYPTION_NONE) { | 690 last_decrypted_packet_level_ == ENCRYPTION_NONE) { |
691 DLOG(WARNING) << ENDPOINT | 691 DLOG(WARNING) << ENDPOINT |
692 << "Received an unencrypted data frame: closing connection"; | 692 << "Received an unencrypted data frame: closing connection"; |
693 SendConnectionCloseWithDetails(QUIC_UNENCRYPTED_STREAM_DATA, | 693 SendConnectionCloseWithDetails(QUIC_UNENCRYPTED_STREAM_DATA, |
694 "Unencrypted stream data seen"); | 694 "Unencrypted stream data seen"); |
695 return false; | 695 return false; |
696 } | 696 } |
697 visitor_->OnStreamFrame(frame); | 697 visitor_->OnStreamFrame(frame); |
| 698 visitor_->PostProcessAfterData(); |
698 stats_.stream_bytes_received += frame.frame_length; | 699 stats_.stream_bytes_received += frame.frame_length; |
699 should_last_packet_instigate_acks_ = true; | 700 should_last_packet_instigate_acks_ = true; |
700 return connected_; | 701 return connected_; |
701 } | 702 } |
702 | 703 |
703 bool QuicConnection::OnAckFrame(const QuicAckFrame& incoming_ack) { | 704 bool QuicConnection::OnAckFrame(const QuicAckFrame& incoming_ack) { |
704 DCHECK(connected_); | 705 DCHECK(connected_); |
705 if (debug_visitor_ != nullptr) { | 706 if (debug_visitor_ != nullptr) { |
706 debug_visitor_->OnAckFrame(incoming_ack); | 707 debug_visitor_->OnAckFrame(incoming_ack); |
707 } | 708 } |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 LOG(WARNING) << ENDPOINT << "Peer sent missing packet: " | 822 LOG(WARNING) << ENDPOINT << "Peer sent missing packet: " |
822 << incoming_ack.missing_packets.Min() | 823 << incoming_ack.missing_packets.Min() |
823 << " which is smaller than least_packet_awaited_by_peer_: " | 824 << " which is smaller than least_packet_awaited_by_peer_: " |
824 << sent_packet_manager_.least_packet_awaited_by_peer(); | 825 << sent_packet_manager_.least_packet_awaited_by_peer(); |
825 return "Missing packet smaller than least awaited"; | 826 return "Missing packet smaller than least awaited"; |
826 } | 827 } |
827 | 828 |
828 if (!sent_entropy_manager_.IsValidEntropy(incoming_ack.largest_observed, | 829 if (!sent_entropy_manager_.IsValidEntropy(incoming_ack.largest_observed, |
829 incoming_ack.missing_packets, | 830 incoming_ack.missing_packets, |
830 incoming_ack.entropy_hash)) { | 831 incoming_ack.entropy_hash)) { |
831 LOG(WARNING) << ENDPOINT << "Peer sent invalid entropy."; | 832 LOG(WARNING) << ENDPOINT << "Peer sent invalid entropy." |
| 833 << " largest_observed:" << incoming_ack.largest_observed |
| 834 << " last_received:" << last_header_.packet_number; |
832 return "Invalid entropy"; | 835 return "Invalid entropy"; |
833 } | 836 } |
834 | 837 |
835 if (incoming_ack.latest_revived_packet != 0 && | 838 if (incoming_ack.latest_revived_packet != 0 && |
836 !incoming_ack.missing_packets.Contains( | 839 !incoming_ack.missing_packets.Contains( |
837 incoming_ack.latest_revived_packet)) { | 840 incoming_ack.latest_revived_packet)) { |
838 LOG(WARNING) << ENDPOINT | 841 LOG(WARNING) << ENDPOINT |
839 << "Peer specified revived packet which was not missing."; | 842 << "Peer specified revived packet which was not missing." |
| 843 << " revived_packet:" << incoming_ack.latest_revived_packet; |
840 return "Invalid revived packet"; | 844 return "Invalid revived packet"; |
841 } | 845 } |
842 return nullptr; | 846 return nullptr; |
843 } | 847 } |
844 | 848 |
845 const char* QuicConnection::ValidateStopWaitingFrame( | 849 const char* QuicConnection::ValidateStopWaitingFrame( |
846 const QuicStopWaitingFrame& stop_waiting) { | 850 const QuicStopWaitingFrame& stop_waiting) { |
847 if (stop_waiting.least_unacked < | 851 if (stop_waiting.least_unacked < |
848 received_packet_manager_.peer_least_packet_awaiting_ack()) { | 852 received_packet_manager_.peer_least_packet_awaiting_ack()) { |
849 DLOG(ERROR) << ENDPOINT << "Peer's sent low least_unacked: " | 853 DLOG(ERROR) << ENDPOINT << "Peer's sent low least_unacked: " |
(...skipping 26 matching lines...) Expand all Loading... |
876 bool QuicConnection::OnRstStreamFrame(const QuicRstStreamFrame& frame) { | 880 bool QuicConnection::OnRstStreamFrame(const QuicRstStreamFrame& frame) { |
877 DCHECK(connected_); | 881 DCHECK(connected_); |
878 if (debug_visitor_ != nullptr) { | 882 if (debug_visitor_ != nullptr) { |
879 debug_visitor_->OnRstStreamFrame(frame); | 883 debug_visitor_->OnRstStreamFrame(frame); |
880 } | 884 } |
881 DVLOG(1) << ENDPOINT | 885 DVLOG(1) << ENDPOINT |
882 << "RST_STREAM_FRAME received for stream: " << frame.stream_id | 886 << "RST_STREAM_FRAME received for stream: " << frame.stream_id |
883 << " with error: " | 887 << " with error: " |
884 << QuicUtils::StreamErrorToString(frame.error_code); | 888 << QuicUtils::StreamErrorToString(frame.error_code); |
885 visitor_->OnRstStream(frame); | 889 visitor_->OnRstStream(frame); |
| 890 visitor_->PostProcessAfterData(); |
886 should_last_packet_instigate_acks_ = true; | 891 should_last_packet_instigate_acks_ = true; |
887 return connected_; | 892 return connected_; |
888 } | 893 } |
889 | 894 |
890 bool QuicConnection::OnConnectionCloseFrame( | 895 bool QuicConnection::OnConnectionCloseFrame( |
891 const QuicConnectionCloseFrame& frame) { | 896 const QuicConnectionCloseFrame& frame) { |
892 DCHECK(connected_); | 897 DCHECK(connected_); |
893 if (debug_visitor_ != nullptr) { | 898 if (debug_visitor_ != nullptr) { |
894 debug_visitor_->OnConnectionCloseFrame(frame); | 899 debug_visitor_->OnConnectionCloseFrame(frame); |
895 } | 900 } |
(...skipping 10 matching lines...) Expand all Loading... |
906 if (debug_visitor_ != nullptr) { | 911 if (debug_visitor_ != nullptr) { |
907 debug_visitor_->OnGoAwayFrame(frame); | 912 debug_visitor_->OnGoAwayFrame(frame); |
908 } | 913 } |
909 DVLOG(1) << ENDPOINT << "GOAWAY_FRAME received with last good stream: " | 914 DVLOG(1) << ENDPOINT << "GOAWAY_FRAME received with last good stream: " |
910 << frame.last_good_stream_id | 915 << frame.last_good_stream_id |
911 << " and error: " << QuicUtils::ErrorToString(frame.error_code) | 916 << " and error: " << QuicUtils::ErrorToString(frame.error_code) |
912 << " and reason: " << frame.reason_phrase; | 917 << " and reason: " << frame.reason_phrase; |
913 | 918 |
914 goaway_received_ = true; | 919 goaway_received_ = true; |
915 visitor_->OnGoAway(frame); | 920 visitor_->OnGoAway(frame); |
| 921 visitor_->PostProcessAfterData(); |
916 should_last_packet_instigate_acks_ = true; | 922 should_last_packet_instigate_acks_ = true; |
917 return connected_; | 923 return connected_; |
918 } | 924 } |
919 | 925 |
920 bool QuicConnection::OnWindowUpdateFrame(const QuicWindowUpdateFrame& frame) { | 926 bool QuicConnection::OnWindowUpdateFrame(const QuicWindowUpdateFrame& frame) { |
921 DCHECK(connected_); | 927 DCHECK(connected_); |
922 if (debug_visitor_ != nullptr) { | 928 if (debug_visitor_ != nullptr) { |
923 debug_visitor_->OnWindowUpdateFrame(frame); | 929 debug_visitor_->OnWindowUpdateFrame(frame); |
924 } | 930 } |
925 DVLOG(1) << ENDPOINT | 931 DVLOG(1) << ENDPOINT |
926 << "WINDOW_UPDATE_FRAME received for stream: " << frame.stream_id | 932 << "WINDOW_UPDATE_FRAME received for stream: " << frame.stream_id |
927 << " with byte offset: " << frame.byte_offset; | 933 << " with byte offset: " << frame.byte_offset; |
928 visitor_->OnWindowUpdateFrame(frame); | 934 visitor_->OnWindowUpdateFrame(frame); |
| 935 visitor_->PostProcessAfterData(); |
929 should_last_packet_instigate_acks_ = true; | 936 should_last_packet_instigate_acks_ = true; |
930 return connected_; | 937 return connected_; |
931 } | 938 } |
932 | 939 |
933 bool QuicConnection::OnBlockedFrame(const QuicBlockedFrame& frame) { | 940 bool QuicConnection::OnBlockedFrame(const QuicBlockedFrame& frame) { |
934 DCHECK(connected_); | 941 DCHECK(connected_); |
935 if (debug_visitor_ != nullptr) { | 942 if (debug_visitor_ != nullptr) { |
936 debug_visitor_->OnBlockedFrame(frame); | 943 debug_visitor_->OnBlockedFrame(frame); |
937 } | 944 } |
938 DVLOG(1) << ENDPOINT | 945 DVLOG(1) << ENDPOINT |
939 << "BLOCKED_FRAME received for stream: " << frame.stream_id; | 946 << "BLOCKED_FRAME received for stream: " << frame.stream_id; |
940 visitor_->OnBlockedFrame(frame); | 947 visitor_->OnBlockedFrame(frame); |
| 948 visitor_->PostProcessAfterData(); |
941 should_last_packet_instigate_acks_ = true; | 949 should_last_packet_instigate_acks_ = true; |
942 return connected_; | 950 return connected_; |
943 } | 951 } |
944 | 952 |
945 bool QuicConnection::OnPathCloseFrame(const QuicPathCloseFrame& frame) { | 953 bool QuicConnection::OnPathCloseFrame(const QuicPathCloseFrame& frame) { |
946 DCHECK(connected_); | 954 DCHECK(connected_); |
947 if (debug_visitor_ != nullptr) { | 955 if (debug_visitor_ != nullptr) { |
948 debug_visitor_->OnPathCloseFrame(frame); | 956 debug_visitor_->OnPathCloseFrame(frame); |
949 } | 957 } |
950 DVLOG(1) << ENDPOINT | 958 DVLOG(1) << ENDPOINT |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1104 pending_version_negotiation_packet_ = true; | 1112 pending_version_negotiation_packet_ = true; |
1105 if (writer_->IsWriteBlocked()) { | 1113 if (writer_->IsWriteBlocked()) { |
1106 visitor_->OnWriteBlocked(); | 1114 visitor_->OnWriteBlocked(); |
1107 return; | 1115 return; |
1108 } | 1116 } |
1109 DVLOG(1) << ENDPOINT << "Sending version negotiation packet: {" | 1117 DVLOG(1) << ENDPOINT << "Sending version negotiation packet: {" |
1110 << QuicVersionVectorToString(framer_.supported_versions()) << "}"; | 1118 << QuicVersionVectorToString(framer_.supported_versions()) << "}"; |
1111 scoped_ptr<QuicEncryptedPacket> version_packet( | 1119 scoped_ptr<QuicEncryptedPacket> version_packet( |
1112 packet_generator_.SerializeVersionNegotiationPacket( | 1120 packet_generator_.SerializeVersionNegotiationPacket( |
1113 framer_.supported_versions())); | 1121 framer_.supported_versions())); |
1114 WriteResult result = | 1122 WriteResult result = writer_->WritePacket( |
1115 writer_->WritePacket(version_packet->data(), version_packet->length(), | 1123 version_packet->data(), version_packet->length(), |
1116 self_address().address().bytes(), peer_address()); | 1124 self_address().address().bytes(), peer_address(), per_packet_options_); |
1117 | 1125 |
1118 if (result.status == WRITE_STATUS_ERROR) { | 1126 if (result.status == WRITE_STATUS_ERROR) { |
1119 OnWriteError(result.error_code); | 1127 OnWriteError(result.error_code); |
1120 return; | 1128 return; |
1121 } | 1129 } |
1122 if (result.status == WRITE_STATUS_BLOCKED) { | 1130 if (result.status == WRITE_STATUS_BLOCKED) { |
1123 visitor_->OnWriteBlocked(); | 1131 visitor_->OnWriteBlocked(); |
1124 if (writer_->IsWriteBlockedDataBuffered()) { | 1132 if (writer_->IsWriteBlockedDataBuffered()) { |
1125 pending_version_negotiation_packet_ = false; | 1133 pending_version_negotiation_packet_ = false; |
1126 } | 1134 } |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1326 // or the congestion manager to prohibit sending. If we've sent everything | 1334 // or the congestion manager to prohibit sending. If we've sent everything |
1327 // we had queued and we're still not blocked, let the visitor know it can | 1335 // we had queued and we're still not blocked, let the visitor know it can |
1328 // write more. | 1336 // write more. |
1329 if (!CanWrite(HAS_RETRANSMITTABLE_DATA)) { | 1337 if (!CanWrite(HAS_RETRANSMITTABLE_DATA)) { |
1330 return; | 1338 return; |
1331 } | 1339 } |
1332 | 1340 |
1333 { // Limit the scope of the bundler. ACK inclusion happens elsewhere. | 1341 { // Limit the scope of the bundler. ACK inclusion happens elsewhere. |
1334 ScopedPacketBundler bundler(this, NO_ACK); | 1342 ScopedPacketBundler bundler(this, NO_ACK); |
1335 visitor_->OnCanWrite(); | 1343 visitor_->OnCanWrite(); |
| 1344 visitor_->PostProcessAfterData(); |
1336 } | 1345 } |
1337 | 1346 |
1338 // After the visitor writes, it may have caused the socket to become write | 1347 // After the visitor writes, it may have caused the socket to become write |
1339 // blocked or the congestion manager to prohibit sending, so check again. | 1348 // blocked or the congestion manager to prohibit sending, so check again. |
1340 if (visitor_->WillingAndAbleToWrite() && !resume_writes_alarm_->IsSet() && | 1349 if (visitor_->WillingAndAbleToWrite() && !resume_writes_alarm_->IsSet() && |
1341 CanWrite(HAS_RETRANSMITTABLE_DATA)) { | 1350 CanWrite(HAS_RETRANSMITTABLE_DATA)) { |
1342 // We're not write blocked, but some stream didn't write out all of its | 1351 // We're not write blocked, but some stream didn't write out all of its |
1343 // bytes. Register for 'immediate' resumption so we'll keep writing after | 1352 // bytes. Register for 'immediate' resumption so we'll keep writing after |
1344 // other connections and events have had a chance to use the thread. | 1353 // other connections and events have had a chance to use the thread. |
1345 resume_writes_alarm_->Set(clock_->ApproximateNow()); | 1354 resume_writes_alarm_->Set(clock_->ApproximateNow()); |
1346 } | 1355 } |
1347 } | 1356 } |
1348 | 1357 |
1349 void QuicConnection::WriteIfNotBlocked() { | 1358 void QuicConnection::WriteIfNotBlocked() { |
1350 if (!writer_->IsWriteBlocked()) { | 1359 if (!writer_->IsWriteBlocked()) { |
1351 OnCanWrite(); | 1360 OnCanWrite(); |
1352 } | 1361 } |
1353 } | 1362 } |
1354 | 1363 |
1355 bool QuicConnection::ProcessValidatedPacket(const QuicPacketHeader& header) { | 1364 bool QuicConnection::ProcessValidatedPacket(const QuicPacketHeader& header) { |
1356 if (self_ip_changed_ || self_port_changed_) { | 1365 if (self_ip_changed_ || self_port_changed_) { |
1357 SendConnectionCloseWithDetails(QUIC_ERROR_MIGRATING_ADDRESS, | 1366 SendConnectionCloseWithDetails(QUIC_ERROR_MIGRATING_ADDRESS, |
1358 "Self address migration is not supported."); | 1367 "Self address migration is not supported."); |
1359 return false; | 1368 return false; |
1360 } | 1369 } |
1361 | 1370 |
1362 PeerAddressChangeType type = NO_CHANGE; | |
1363 if (peer_ip_changed_ || peer_port_changed_) { | |
1364 type = DeterminePeerAddressChangeType(); | |
1365 if (FLAGS_quic_disable_non_nat_address_migration && type != PORT_CHANGE && | |
1366 type != IPV4_SUBNET_CHANGE) { | |
1367 SendConnectionCloseWithDetails(QUIC_ERROR_MIGRATING_ADDRESS, | |
1368 "Invalid peer address migration."); | |
1369 return false; | |
1370 } | |
1371 } | |
1372 | |
1373 if (!Near(header.packet_number, last_header_.packet_number)) { | 1371 if (!Near(header.packet_number, last_header_.packet_number)) { |
1374 DVLOG(1) << ENDPOINT << "Packet " << header.packet_number | 1372 DVLOG(1) << ENDPOINT << "Packet " << header.packet_number |
1375 << " out of bounds. Discarding"; | 1373 << " out of bounds. Discarding"; |
1376 SendConnectionCloseWithDetails(QUIC_INVALID_PACKET_HEADER, | 1374 SendConnectionCloseWithDetails(QUIC_INVALID_PACKET_HEADER, |
1377 "packet number out of bounds"); | 1375 "packet number out of bounds"); |
1378 return false; | 1376 return false; |
1379 } | 1377 } |
1380 | 1378 |
1381 // If this packet has already been seen, or the sender has told us that it | 1379 // If this packet has already been seen, or the sender has told us that it |
1382 // will not be retransmitted, then stop processing the packet. | 1380 // will not be retransmitted, then stop processing the packet. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1417 visitor_->OnSuccessfulVersionNegotiation(version()); | 1415 visitor_->OnSuccessfulVersionNegotiation(version()); |
1418 if (debug_visitor_ != nullptr) { | 1416 if (debug_visitor_ != nullptr) { |
1419 debug_visitor_->OnSuccessfulVersionNegotiation(version()); | 1417 debug_visitor_->OnSuccessfulVersionNegotiation(version()); |
1420 } | 1418 } |
1421 } | 1419 } |
1422 } | 1420 } |
1423 | 1421 |
1424 DCHECK_EQ(NEGOTIATED_VERSION, version_negotiation_state_); | 1422 DCHECK_EQ(NEGOTIATED_VERSION, version_negotiation_state_); |
1425 | 1423 |
1426 if (peer_ip_changed_ || peer_port_changed_) { | 1424 if (peer_ip_changed_ || peer_port_changed_) { |
| 1425 PeerAddressChangeType type = DeterminePeerAddressChangeType(); |
1427 IPEndPoint old_peer_address = peer_address_; | 1426 IPEndPoint old_peer_address = peer_address_; |
1428 peer_address_ = IPEndPoint( | 1427 peer_address_ = IPEndPoint( |
1429 peer_ip_changed_ ? migrating_peer_ip_ : peer_address_.address().bytes(), | 1428 peer_ip_changed_ ? migrating_peer_ip_ : peer_address_.address().bytes(), |
1430 peer_port_changed_ ? migrating_peer_port_ : peer_address_.port()); | 1429 peer_port_changed_ ? migrating_peer_port_ : peer_address_.port()); |
1431 | 1430 |
1432 DVLOG(1) << ENDPOINT << "Peer's ip:port changed from " | 1431 DVLOG(1) << ENDPOINT << "Peer's ip:port changed from " |
1433 << old_peer_address.ToString() << " to " | 1432 << old_peer_address.ToString() << " to " |
1434 << peer_address_.ToString() << ", migrating connection."; | 1433 << peer_address_.ToString() << ", migrating connection."; |
1435 | 1434 |
1436 visitor_->OnConnectionMigration(); | 1435 visitor_->OnConnectionMigration(); |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1637 << ", encryption level: " | 1636 << ", encryption level: " |
1638 << QuicUtils::EncryptionLevelToString(packet->encryption_level) | 1637 << QuicUtils::EncryptionLevelToString(packet->encryption_level) |
1639 << ", encrypted length:" << encrypted->length(); | 1638 << ", encrypted length:" << encrypted->length(); |
1640 DVLOG(2) << ENDPOINT << "packet(" << packet_number << "): " << std::endl | 1639 DVLOG(2) << ENDPOINT << "packet(" << packet_number << "): " << std::endl |
1641 << QuicUtils::StringToHexASCIIDump(encrypted->AsStringPiece()); | 1640 << QuicUtils::StringToHexASCIIDump(encrypted->AsStringPiece()); |
1642 | 1641 |
1643 // Measure the RTT from before the write begins to avoid underestimating the | 1642 // Measure the RTT from before the write begins to avoid underestimating the |
1644 // min_rtt_, especially in cases where the thread blocks or gets swapped out | 1643 // min_rtt_, especially in cases where the thread blocks or gets swapped out |
1645 // during the WritePacket below. | 1644 // during the WritePacket below. |
1646 QuicTime packet_send_time = clock_->Now(); | 1645 QuicTime packet_send_time = clock_->Now(); |
1647 WriteResult result = | 1646 WriteResult result = writer_->WritePacket( |
1648 writer_->WritePacket(encrypted->data(), encrypted->length(), | 1647 encrypted->data(), encrypted->length(), self_address().address().bytes(), |
1649 self_address().address().bytes(), peer_address()); | 1648 peer_address(), per_packet_options_); |
1650 if (result.error_code == ERR_IO_PENDING) { | 1649 if (result.error_code == ERR_IO_PENDING) { |
1651 DCHECK_EQ(WRITE_STATUS_BLOCKED, result.status); | 1650 DCHECK_EQ(WRITE_STATUS_BLOCKED, result.status); |
1652 } | 1651 } |
1653 | 1652 |
1654 if (result.status == WRITE_STATUS_BLOCKED) { | 1653 if (result.status == WRITE_STATUS_BLOCKED) { |
1655 visitor_->OnWriteBlocked(); | 1654 visitor_->OnWriteBlocked(); |
1656 // If the socket buffers the the data, then the packet should not | 1655 // If the socket buffers the the data, then the packet should not |
1657 // be queued and sent again, which would result in an unnecessary | 1656 // be queued and sent again, which would result in an unnecessary |
1658 // duplicate packet being sent. The helper must call OnCanWrite | 1657 // duplicate packet being sent. The helper must call OnCanWrite |
1659 // when the write completes, and OnWriteError if an error occurs. | 1658 // when the write completes, and OnWriteError if an error occurs. |
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2449 void QuicConnection::OnPathClosed(QuicPathId path_id) { | 2448 void QuicConnection::OnPathClosed(QuicPathId path_id) { |
2450 // Stop receiving packets on this path. | 2449 // Stop receiving packets on this path. |
2451 framer_.OnPathClosed(path_id); | 2450 framer_.OnPathClosed(path_id); |
2452 } | 2451 } |
2453 | 2452 |
2454 bool QuicConnection::ack_frame_updated() const { | 2453 bool QuicConnection::ack_frame_updated() const { |
2455 return received_packet_manager_.ack_frame_updated(); | 2454 return received_packet_manager_.ack_frame_updated(); |
2456 } | 2455 } |
2457 | 2456 |
2458 } // namespace net | 2457 } // namespace net |
OLD | NEW |