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 #include <algorithm> | 9 #include <algorithm> |
10 #include <iterator> | 10 #include <iterator> |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 received_packet_manager_(kTCP, &stats_), | 212 received_packet_manager_(kTCP, &stats_), |
213 ack_queued_(false), | 213 ack_queued_(false), |
214 stop_waiting_count_(0), | 214 stop_waiting_count_(0), |
215 ack_alarm_(helper->CreateAlarm(new AckAlarm(this))), | 215 ack_alarm_(helper->CreateAlarm(new AckAlarm(this))), |
216 retransmission_alarm_(helper->CreateAlarm(new RetransmissionAlarm(this))), | 216 retransmission_alarm_(helper->CreateAlarm(new RetransmissionAlarm(this))), |
217 send_alarm_(helper->CreateAlarm(new SendAlarm(this))), | 217 send_alarm_(helper->CreateAlarm(new SendAlarm(this))), |
218 resume_writes_alarm_(helper->CreateAlarm(new SendAlarm(this))), | 218 resume_writes_alarm_(helper->CreateAlarm(new SendAlarm(this))), |
219 timeout_alarm_(helper->CreateAlarm(new TimeoutAlarm(this))), | 219 timeout_alarm_(helper->CreateAlarm(new TimeoutAlarm(this))), |
220 ping_alarm_(helper->CreateAlarm(new PingAlarm(this))), | 220 ping_alarm_(helper->CreateAlarm(new PingAlarm(this))), |
221 debug_visitor_(NULL), | 221 debug_visitor_(NULL), |
222 packet_creator_(connection_id_, &framer_, random_generator_, is_server), | 222 packet_generator_(connection_id_, &framer_, random_generator_, this), |
223 packet_generator_(this, NULL, &packet_creator_), | |
224 idle_network_timeout_( | 223 idle_network_timeout_( |
225 QuicTime::Delta::FromSeconds(kDefaultInitialTimeoutSecs)), | 224 QuicTime::Delta::FromSeconds(kDefaultInitialTimeoutSecs)), |
226 overall_connection_timeout_(QuicTime::Delta::Infinite()), | 225 overall_connection_timeout_(QuicTime::Delta::Infinite()), |
227 time_of_last_received_packet_(clock_->ApproximateNow()), | 226 time_of_last_received_packet_(clock_->ApproximateNow()), |
228 time_of_last_sent_new_packet_(clock_->ApproximateNow()), | 227 time_of_last_sent_new_packet_(clock_->ApproximateNow()), |
229 sequence_number_of_last_sent_packet_(0), | 228 sequence_number_of_last_sent_packet_(0), |
230 sent_packet_manager_( | 229 sent_packet_manager_( |
231 is_server, clock_, &stats_, kTCP, | 230 is_server, clock_, &stats_, kTCP, |
232 FLAGS_quic_use_time_loss_detection ? kTime : kNack), | 231 FLAGS_quic_use_time_loss_detection ? kTime : kNack), |
233 version_negotiation_state_(START_NEGOTIATION), | 232 version_negotiation_state_(START_NEGOTIATION), |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 } else { | 470 } else { |
472 DCHECK_EQ(1u, header.public_header.versions.size()); | 471 DCHECK_EQ(1u, header.public_header.versions.size()); |
473 DCHECK_EQ(header.public_header.versions[0], version()); | 472 DCHECK_EQ(header.public_header.versions[0], version()); |
474 version_negotiation_state_ = NEGOTIATED_VERSION; | 473 version_negotiation_state_ = NEGOTIATED_VERSION; |
475 visitor_->OnSuccessfulVersionNegotiation(version()); | 474 visitor_->OnSuccessfulVersionNegotiation(version()); |
476 } | 475 } |
477 } else { | 476 } else { |
478 DCHECK(!header.public_header.version_flag); | 477 DCHECK(!header.public_header.version_flag); |
479 // If the client gets a packet without the version flag from the server | 478 // If the client gets a packet without the version flag from the server |
480 // it should stop sending version since the version negotiation is done. | 479 // it should stop sending version since the version negotiation is done. |
481 packet_creator_.StopSendingVersion(); | 480 packet_generator_.StopSendingVersion(); |
482 version_negotiation_state_ = NEGOTIATED_VERSION; | 481 version_negotiation_state_ = NEGOTIATED_VERSION; |
483 visitor_->OnSuccessfulVersionNegotiation(version()); | 482 visitor_->OnSuccessfulVersionNegotiation(version()); |
484 } | 483 } |
485 } | 484 } |
486 | 485 |
487 DCHECK_EQ(NEGOTIATED_VERSION, version_negotiation_state_); | 486 DCHECK_EQ(NEGOTIATED_VERSION, version_negotiation_state_); |
488 | 487 |
489 --stats_.packets_dropped; | 488 --stats_.packets_dropped; |
490 DVLOG(1) << ENDPOINT << "Received packet header: " << header; | 489 DVLOG(1) << ENDPOINT << "Received packet header: " << header; |
491 last_header_ = header; | 490 last_header_ = header; |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 bool QuicConnection::OnPingFrame(const QuicPingFrame& frame) { | 608 bool QuicConnection::OnPingFrame(const QuicPingFrame& frame) { |
610 DCHECK(connected_); | 609 DCHECK(connected_); |
611 if (debug_visitor_) { | 610 if (debug_visitor_) { |
612 debug_visitor_->OnPingFrame(frame); | 611 debug_visitor_->OnPingFrame(frame); |
613 } | 612 } |
614 return true; | 613 return true; |
615 } | 614 } |
616 | 615 |
617 bool QuicConnection::ValidateAckFrame(const QuicAckFrame& incoming_ack) { | 616 bool QuicConnection::ValidateAckFrame(const QuicAckFrame& incoming_ack) { |
618 if (incoming_ack.received_info.largest_observed > | 617 if (incoming_ack.received_info.largest_observed > |
619 packet_creator_.sequence_number()) { | 618 packet_generator_.sequence_number()) { |
620 DLOG(ERROR) << ENDPOINT << "Peer's observed unsent packet:" | 619 DLOG(ERROR) << ENDPOINT << "Peer's observed unsent packet:" |
621 << incoming_ack.received_info.largest_observed << " vs " | 620 << incoming_ack.received_info.largest_observed << " vs " |
622 << packet_creator_.sequence_number(); | 621 << packet_generator_.sequence_number(); |
623 // We got an error for data we have not sent. Error out. | 622 // We got an error for data we have not sent. Error out. |
624 return false; | 623 return false; |
625 } | 624 } |
626 | 625 |
627 if (incoming_ack.received_info.largest_observed < | 626 if (incoming_ack.received_info.largest_observed < |
628 received_packet_manager_.peer_largest_observed_packet()) { | 627 received_packet_manager_.peer_largest_observed_packet()) { |
629 DLOG(ERROR) << ENDPOINT << "Peer's largest_observed packet decreased:" | 628 DLOG(ERROR) << ENDPOINT << "Peer's largest_observed packet decreased:" |
630 << incoming_ack.received_info.largest_observed << " vs " | 629 << incoming_ack.received_info.largest_observed << " vs " |
631 << received_packet_manager_.peer_largest_observed_packet(); | 630 << received_packet_manager_.peer_largest_observed_packet(); |
632 // A new ack has a diminished largest_observed value. Error out. | 631 // A new ack has a diminished largest_observed value. Error out. |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
931 *last_ack_frames_.back().received_info.missing_packets.begin()) { | 930 *last_ack_frames_.back().received_info.missing_packets.begin()) { |
932 ++stop_waiting_count_; | 931 ++stop_waiting_count_; |
933 } else { | 932 } else { |
934 stop_waiting_count_ = 0; | 933 stop_waiting_count_ = 0; |
935 } | 934 } |
936 } | 935 } |
937 | 936 |
938 QuicPacketSequenceNumber QuicConnection::GetLeastUnacked() const { | 937 QuicPacketSequenceNumber QuicConnection::GetLeastUnacked() const { |
939 return sent_packet_manager_.HasUnackedPackets() ? | 938 return sent_packet_manager_.HasUnackedPackets() ? |
940 sent_packet_manager_.GetLeastUnackedSentPacket() : | 939 sent_packet_manager_.GetLeastUnackedSentPacket() : |
941 packet_creator_.sequence_number() + 1; | 940 packet_generator_.sequence_number() + 1; |
942 } | 941 } |
943 | 942 |
944 void QuicConnection::MaybeSendInResponseToPacket() { | 943 void QuicConnection::MaybeSendInResponseToPacket() { |
945 if (!connected_) { | 944 if (!connected_) { |
946 return; | 945 return; |
947 } | 946 } |
948 ScopedPacketBundler bundler(this, ack_queued_ ? SEND_ACK : NO_ACK); | 947 ScopedPacketBundler bundler(this, ack_queued_ ? SEND_ACK : NO_ACK); |
949 | 948 |
950 // Now that we have received an ack, we might be able to send packets which | 949 // Now that we have received an ack, we might be able to send packets which |
951 // are queued locally, or drain streams which are blocked. | 950 // are queued locally, or drain streams which are blocked. |
952 if (CanWrite(HAS_RETRANSMITTABLE_DATA)) { | 951 if (CanWrite(HAS_RETRANSMITTABLE_DATA)) { |
953 OnCanWrite(); | 952 OnCanWrite(); |
954 } | 953 } |
955 } | 954 } |
956 | 955 |
957 void QuicConnection::SendVersionNegotiationPacket() { | 956 void QuicConnection::SendVersionNegotiationPacket() { |
958 // TODO(alyssar): implement zero server state negotiation. | 957 // TODO(alyssar): implement zero server state negotiation. |
959 pending_version_negotiation_packet_ = true; | 958 pending_version_negotiation_packet_ = true; |
960 if (writer_->IsWriteBlocked()) { | 959 if (writer_->IsWriteBlocked()) { |
961 visitor_->OnWriteBlocked(); | 960 visitor_->OnWriteBlocked(); |
962 return; | 961 return; |
963 } | 962 } |
964 scoped_ptr<QuicEncryptedPacket> version_packet( | 963 scoped_ptr<QuicEncryptedPacket> version_packet( |
965 packet_creator_.SerializeVersionNegotiationPacket( | 964 packet_generator_.SerializeVersionNegotiationPacket( |
966 framer_.supported_versions())); | 965 framer_.supported_versions())); |
967 WriteResult result = writer_->WritePacket( | 966 WriteResult result = writer_->WritePacket( |
968 version_packet->data(), version_packet->length(), | 967 version_packet->data(), version_packet->length(), |
969 self_address().address(), peer_address()); | 968 self_address().address(), peer_address()); |
970 | 969 |
971 if (result.status == WRITE_STATUS_ERROR) { | 970 if (result.status == WRITE_STATUS_ERROR) { |
972 // We can't send an error as the socket is presumably borked. | 971 // We can't send an error as the socket is presumably borked. |
973 CloseConnection(QUIC_PACKET_WRITE_ERROR, false); | 972 CloseConnection(QUIC_PACKET_WRITE_ERROR, false); |
974 return; | 973 return; |
975 } | 974 } |
976 if (result.status == WRITE_STATUS_BLOCKED) { | 975 if (result.status == WRITE_STATUS_BLOCKED) { |
977 visitor_->OnWriteBlocked(); | 976 visitor_->OnWriteBlocked(); |
978 if (writer_->IsWriteBlockedDataBuffered()) { | 977 if (writer_->IsWriteBlockedDataBuffered()) { |
979 pending_version_negotiation_packet_ = false; | 978 pending_version_negotiation_packet_ = false; |
980 } | 979 } |
981 return; | 980 return; |
982 } | 981 } |
983 | 982 |
984 pending_version_negotiation_packet_ = false; | 983 pending_version_negotiation_packet_ = false; |
985 } | 984 } |
986 | 985 |
987 QuicConsumedData QuicConnection::SendStreamData( | 986 QuicConsumedData QuicConnection::SendStreamData( |
988 QuicStreamId id, | 987 QuicStreamId id, |
989 const IOVector& data, | 988 const IOVector& data, |
990 QuicStreamOffset offset, | 989 QuicStreamOffset offset, |
991 bool fin, | 990 bool fin, |
| 991 FecProtection fec_protection, |
992 QuicAckNotifier::DelegateInterface* delegate) { | 992 QuicAckNotifier::DelegateInterface* delegate) { |
993 if (!fin && data.Empty()) { | 993 if (!fin && data.Empty()) { |
994 LOG(DFATAL) << "Attempt to send empty stream frame"; | 994 LOG(DFATAL) << "Attempt to send empty stream frame"; |
995 } | 995 } |
996 | 996 |
997 // This notifier will be owned by the AckNotifierManager (or deleted below if | 997 // This notifier will be owned by the AckNotifierManager (or deleted below if |
998 // no data or FIN was consumed). | 998 // no data or FIN was consumed). |
999 QuicAckNotifier* notifier = NULL; | 999 QuicAckNotifier* notifier = NULL; |
1000 if (delegate) { | 1000 if (delegate) { |
1001 notifier = new QuicAckNotifier(delegate); | 1001 notifier = new QuicAckNotifier(delegate); |
1002 } | 1002 } |
1003 | 1003 |
1004 // Opportunistically bundle an ack with every outgoing packet. | 1004 // Opportunistically bundle an ack with every outgoing packet. |
1005 // Particularly, we want to bundle with handshake packets since we don't know | 1005 // Particularly, we want to bundle with handshake packets since we don't know |
1006 // which decrypter will be used on an ack packet following a handshake | 1006 // which decrypter will be used on an ack packet following a handshake |
1007 // packet (a handshake packet from client to server could result in a REJ or a | 1007 // packet (a handshake packet from client to server could result in a REJ or a |
1008 // SHLO from the server, leading to two different decrypters at the server.) | 1008 // SHLO from the server, leading to two different decrypters at the server.) |
1009 // | 1009 // |
1010 // TODO(jri): Note that ConsumeData may cause a response packet to be sent. | 1010 // TODO(jri): Note that ConsumeData may cause a response packet to be sent. |
1011 // We may end up sending stale ack information if there are undecryptable | 1011 // We may end up sending stale ack information if there are undecryptable |
1012 // packets hanging around and/or there are revivable packets which may get | 1012 // packets hanging around and/or there are revivable packets which may get |
1013 // handled after this packet is sent. Change ScopedPacketBundler to do the | 1013 // handled after this packet is sent. Change ScopedPacketBundler to do the |
1014 // right thing: check ack_queued_, and then check undecryptable packets and | 1014 // right thing: check ack_queued_, and then check undecryptable packets and |
1015 // also if there is possibility of revival. Only bundle an ack if there's no | 1015 // also if there is possibility of revival. Only bundle an ack if there's no |
1016 // processing left that may cause received_info_ to change. | 1016 // processing left that may cause received_info_ to change. |
1017 ScopedPacketBundler ack_bundler(this, BUNDLE_PENDING_ACK); | 1017 ScopedPacketBundler ack_bundler(this, BUNDLE_PENDING_ACK); |
1018 QuicConsumedData consumed_data = | 1018 QuicConsumedData consumed_data = |
1019 packet_generator_.ConsumeData(id, data, offset, fin, notifier); | 1019 packet_generator_.ConsumeData(id, data, offset, fin, fec_protection, |
| 1020 notifier); |
1020 | 1021 |
1021 if (notifier && | 1022 if (notifier && |
1022 (consumed_data.bytes_consumed == 0 && !consumed_data.fin_consumed)) { | 1023 (consumed_data.bytes_consumed == 0 && !consumed_data.fin_consumed)) { |
1023 // No data was consumed, nor was a fin consumed, so delete the notifier. | 1024 // No data was consumed, nor was a fin consumed, so delete the notifier. |
1024 delete notifier; | 1025 delete notifier; |
1025 } | 1026 } |
1026 | 1027 |
1027 return consumed_data; | 1028 return consumed_data; |
1028 } | 1029 } |
1029 | 1030 |
(...skipping 22 matching lines...) Expand all Loading... |
1052 | 1053 |
1053 const QuicConnectionStats& QuicConnection::GetStats() { | 1054 const QuicConnectionStats& QuicConnection::GetStats() { |
1054 // Update rtt and estimated bandwidth. | 1055 // Update rtt and estimated bandwidth. |
1055 stats_.min_rtt_us = | 1056 stats_.min_rtt_us = |
1056 sent_packet_manager_.GetRttStats()->min_rtt().ToMicroseconds(); | 1057 sent_packet_manager_.GetRttStats()->min_rtt().ToMicroseconds(); |
1057 stats_.srtt_us = | 1058 stats_.srtt_us = |
1058 sent_packet_manager_.GetRttStats()->SmoothedRtt().ToMicroseconds(); | 1059 sent_packet_manager_.GetRttStats()->SmoothedRtt().ToMicroseconds(); |
1059 stats_.estimated_bandwidth = | 1060 stats_.estimated_bandwidth = |
1060 sent_packet_manager_.BandwidthEstimate().ToBytesPerSecond(); | 1061 sent_packet_manager_.BandwidthEstimate().ToBytesPerSecond(); |
1061 stats_.congestion_window = sent_packet_manager_.GetCongestionWindow(); | 1062 stats_.congestion_window = sent_packet_manager_.GetCongestionWindow(); |
1062 stats_.max_packet_size = packet_creator_.max_packet_length(); | 1063 stats_.max_packet_size = packet_generator_.max_packet_length(); |
1063 return stats_; | 1064 return stats_; |
1064 } | 1065 } |
1065 | 1066 |
1066 void QuicConnection::ProcessUdpPacket(const IPEndPoint& self_address, | 1067 void QuicConnection::ProcessUdpPacket(const IPEndPoint& self_address, |
1067 const IPEndPoint& peer_address, | 1068 const IPEndPoint& peer_address, |
1068 const QuicEncryptedPacket& packet) { | 1069 const QuicEncryptedPacket& packet) { |
1069 if (!connected_) { | 1070 if (!connected_) { |
1070 return; | 1071 return; |
1071 } | 1072 } |
1072 if (debug_visitor_) { | 1073 if (debug_visitor_) { |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1182 << peer_address_.port() << " to " << migrating_peer_port_ | 1183 << peer_address_.port() << " to " << migrating_peer_port_ |
1183 << ", migrating connection."; | 1184 << ", migrating connection."; |
1184 peer_address_ = IPEndPoint(peer_address_.address(), migrating_peer_port_); | 1185 peer_address_ = IPEndPoint(peer_address_.address(), migrating_peer_port_); |
1185 } | 1186 } |
1186 | 1187 |
1187 time_of_last_received_packet_ = clock_->Now(); | 1188 time_of_last_received_packet_ = clock_->Now(); |
1188 DVLOG(1) << ENDPOINT << "time of last received packet: " | 1189 DVLOG(1) << ENDPOINT << "time of last received packet: " |
1189 << time_of_last_received_packet_.ToDebuggingValue(); | 1190 << time_of_last_received_packet_.ToDebuggingValue(); |
1190 | 1191 |
1191 if (is_server_ && encryption_level_ == ENCRYPTION_NONE && | 1192 if (is_server_ && encryption_level_ == ENCRYPTION_NONE && |
1192 last_size_ > packet_creator_.max_packet_length()) { | 1193 last_size_ > packet_generator_.max_packet_length()) { |
1193 packet_creator_.set_max_packet_length(last_size_); | 1194 packet_generator_.set_max_packet_length(last_size_); |
1194 } | 1195 } |
1195 return true; | 1196 return true; |
1196 } | 1197 } |
1197 | 1198 |
1198 void QuicConnection::WriteQueuedPackets() { | 1199 void QuicConnection::WriteQueuedPackets() { |
1199 DCHECK(!writer_->IsWriteBlocked()); | 1200 DCHECK(!writer_->IsWriteBlocked()); |
1200 | 1201 |
1201 if (pending_version_negotiation_packet_) { | 1202 if (pending_version_negotiation_packet_) { |
1202 SendVersionNegotiationPacket(); | 1203 SendVersionNegotiationPacket(); |
1203 } | 1204 } |
(...skipping 24 matching lines...) Expand all Loading... |
1228 } | 1229 } |
1229 | 1230 |
1230 // Re-packetize the frames with a new sequence number for retransmission. | 1231 // Re-packetize the frames with a new sequence number for retransmission. |
1231 // Retransmitted data packets do not use FEC, even when it's enabled. | 1232 // Retransmitted data packets do not use FEC, even when it's enabled. |
1232 // Retransmitted packets use the same sequence number length as the | 1233 // Retransmitted packets use the same sequence number length as the |
1233 // original. | 1234 // original. |
1234 // Flush the packet creator before making a new packet. | 1235 // Flush the packet creator before making a new packet. |
1235 // TODO(ianswett): Implement ReserializeAllFrames as a separate path that | 1236 // TODO(ianswett): Implement ReserializeAllFrames as a separate path that |
1236 // does not require the creator to be flushed. | 1237 // does not require the creator to be flushed. |
1237 Flush(); | 1238 Flush(); |
1238 SerializedPacket serialized_packet = packet_creator_.ReserializeAllFrames( | 1239 SerializedPacket serialized_packet = packet_generator_.ReserializeAllFrames( |
1239 pending.retransmittable_frames.frames(), | 1240 pending.retransmittable_frames.frames(), |
1240 pending.sequence_number_length); | 1241 pending.sequence_number_length); |
1241 | 1242 |
1242 DVLOG(1) << ENDPOINT << "Retransmitting " << pending.sequence_number | 1243 DVLOG(1) << ENDPOINT << "Retransmitting " << pending.sequence_number |
1243 << " as " << serialized_packet.sequence_number; | 1244 << " as " << serialized_packet.sequence_number; |
1244 if (debug_visitor_) { | 1245 if (debug_visitor_) { |
1245 debug_visitor_->OnPacketRetransmitted( | 1246 debug_visitor_->OnPacketRetransmitted( |
1246 pending.sequence_number, serialized_packet.sequence_number); | 1247 pending.sequence_number, serialized_packet.sequence_number); |
1247 } | 1248 } |
1248 sent_packet_manager_.OnRetransmittedPacket( | 1249 sent_packet_manager_.OnRetransmittedPacket( |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1352 // Return true to stop processing. | 1353 // Return true to stop processing. |
1353 if (writer_->IsWriteBlocked()) { | 1354 if (writer_->IsWriteBlocked()) { |
1354 visitor_->OnWriteBlocked(); | 1355 visitor_->OnWriteBlocked(); |
1355 return true; | 1356 return true; |
1356 } | 1357 } |
1357 } else { | 1358 } else { |
1358 encrypted_deleter.reset(encrypted); | 1359 encrypted_deleter.reset(encrypted); |
1359 } | 1360 } |
1360 | 1361 |
1361 LOG_IF(DFATAL, encrypted->length() > | 1362 LOG_IF(DFATAL, encrypted->length() > |
1362 packet_creator_.max_packet_length()) | 1363 packet_generator_.max_packet_length()) |
1363 << "Writing an encrypted packet larger than max_packet_length:" | 1364 << "Writing an encrypted packet larger than max_packet_length:" |
1364 << packet_creator_.max_packet_length() << " encrypted length: " | 1365 << packet_generator_.max_packet_length() << " encrypted length: " |
1365 << encrypted->length(); | 1366 << encrypted->length(); |
1366 DVLOG(1) << ENDPOINT << "Sending packet " << sequence_number | 1367 DVLOG(1) << ENDPOINT << "Sending packet " << sequence_number |
1367 << " : " << (packet.packet->is_fec_packet() ? "FEC " : | 1368 << " : " << (packet.packet->is_fec_packet() ? "FEC " : |
1368 (packet.retransmittable == HAS_RETRANSMITTABLE_DATA | 1369 (packet.retransmittable == HAS_RETRANSMITTABLE_DATA |
1369 ? "data bearing " : " ack only ")) | 1370 ? "data bearing " : " ack only ")) |
1370 << ", encryption level: " | 1371 << ", encryption level: " |
1371 << QuicUtils::EncryptionLevelToString(packet.encryption_level) | 1372 << QuicUtils::EncryptionLevelToString(packet.encryption_level) |
1372 << ", length:" << packet.packet->length() << ", encrypted length:" | 1373 << ", length:" << packet.packet->length() << ", encrypted length:" |
1373 << encrypted->length(); | 1374 << encrypted->length(); |
1374 DVLOG(2) << ENDPOINT << "packet(" << sequence_number << "): " << std::endl | 1375 DVLOG(2) << ENDPOINT << "packet(" << sequence_number << "): " << std::endl |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1482 QuicTime now = clock_->Now(); | 1483 QuicTime now = clock_->Now(); |
1483 if (transmission_type == NOT_RETRANSMISSION) { | 1484 if (transmission_type == NOT_RETRANSMISSION) { |
1484 time_of_last_sent_new_packet_ = now; | 1485 time_of_last_sent_new_packet_ = now; |
1485 } | 1486 } |
1486 SetPingAlarm(); | 1487 SetPingAlarm(); |
1487 DVLOG(1) << ENDPOINT << "time of last sent packet: " | 1488 DVLOG(1) << ENDPOINT << "time of last sent packet: " |
1488 << now.ToDebuggingValue(); | 1489 << now.ToDebuggingValue(); |
1489 | 1490 |
1490 // TODO(ianswett): Change the sequence number length and other packet creator | 1491 // TODO(ianswett): Change the sequence number length and other packet creator |
1491 // options by a more explicit API than setting a struct value directly. | 1492 // options by a more explicit API than setting a struct value directly. |
1492 packet_creator_.UpdateSequenceNumberLength( | 1493 packet_generator_.UpdateSequenceNumberLength( |
1493 received_packet_manager_.least_packet_awaited_by_peer(), | 1494 received_packet_manager_.least_packet_awaited_by_peer(), |
1494 sent_packet_manager_.GetCongestionWindow()); | 1495 sent_packet_manager_.GetCongestionWindow()); |
1495 | 1496 |
1496 bool reset_retransmission_alarm = | 1497 bool reset_retransmission_alarm = |
1497 sent_packet_manager_.OnPacketSent(sequence_number, now, length, | 1498 sent_packet_manager_.OnPacketSent(sequence_number, now, length, |
1498 transmission_type, retransmittable); | 1499 transmission_type, retransmittable); |
1499 | 1500 |
1500 if (reset_retransmission_alarm || !retransmission_alarm_->IsSet()) { | 1501 if (reset_retransmission_alarm || !retransmission_alarm_->IsSet()) { |
1501 retransmission_alarm_->Cancel(); | 1502 retransmission_alarm_->Cancel(); |
1502 QuicTime retransmission_time = sent_packet_manager_.GetRetransmissionTime(); | 1503 QuicTime retransmission_time = sent_packet_manager_.GetRetransmissionTime(); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1563 if (retransmission_alarm_->IsSet()) { | 1564 if (retransmission_alarm_->IsSet()) { |
1564 return; | 1565 return; |
1565 } | 1566 } |
1566 if (version() <= QUIC_VERSION_17) { | 1567 if (version() <= QUIC_VERSION_17) { |
1567 // TODO(rch): remove this when we remove version 17. | 1568 // TODO(rch): remove this when we remove version 17. |
1568 // This is a horrible hideous hack which we should not support. | 1569 // This is a horrible hideous hack which we should not support. |
1569 IOVector data; | 1570 IOVector data; |
1570 char c_data[] = "C"; | 1571 char c_data[] = "C"; |
1571 data.Append(c_data, 1); | 1572 data.Append(c_data, 1); |
1572 QuicConsumedData consumed_data = | 1573 QuicConsumedData consumed_data = |
1573 packet_generator_.ConsumeData(kCryptoStreamId, data, 0, false, NULL); | 1574 packet_generator_.ConsumeData(kCryptoStreamId, data, 0, false, |
| 1575 MAY_FEC_PROTECT, NULL); |
1574 if (consumed_data.bytes_consumed == 0) { | 1576 if (consumed_data.bytes_consumed == 0) { |
1575 DLOG(ERROR) << "Unable to send ping!?"; | 1577 DLOG(ERROR) << "Unable to send ping!?"; |
1576 } | 1578 } |
1577 } else { | 1579 } else { |
1578 packet_generator_.AddControlFrame(QuicFrame(new QuicPingFrame)); | 1580 packet_generator_.AddControlFrame(QuicFrame(new QuicPingFrame)); |
1579 } | 1581 } |
1580 } | 1582 } |
1581 | 1583 |
1582 void QuicConnection::SendAck() { | 1584 void QuicConnection::SendAck() { |
1583 ack_alarm_->Cancel(); | 1585 ack_alarm_->Cancel(); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1625 QuicEncrypter* encrypter) { | 1627 QuicEncrypter* encrypter) { |
1626 framer_.SetEncrypter(level, encrypter); | 1628 framer_.SetEncrypter(level, encrypter); |
1627 } | 1629 } |
1628 | 1630 |
1629 const QuicEncrypter* QuicConnection::encrypter(EncryptionLevel level) const { | 1631 const QuicEncrypter* QuicConnection::encrypter(EncryptionLevel level) const { |
1630 return framer_.encrypter(level); | 1632 return framer_.encrypter(level); |
1631 } | 1633 } |
1632 | 1634 |
1633 void QuicConnection::SetDefaultEncryptionLevel(EncryptionLevel level) { | 1635 void QuicConnection::SetDefaultEncryptionLevel(EncryptionLevel level) { |
1634 encryption_level_ = level; | 1636 encryption_level_ = level; |
1635 packet_creator_.set_encryption_level(level); | 1637 packet_generator_.set_encryption_level(level); |
1636 } | 1638 } |
1637 | 1639 |
1638 void QuicConnection::SetDecrypter(QuicDecrypter* decrypter, | 1640 void QuicConnection::SetDecrypter(QuicDecrypter* decrypter, |
1639 EncryptionLevel level) { | 1641 EncryptionLevel level) { |
1640 framer_.SetDecrypter(decrypter, level); | 1642 framer_.SetDecrypter(decrypter, level); |
1641 } | 1643 } |
1642 | 1644 |
1643 void QuicConnection::SetAlternativeDecrypter(QuicDecrypter* decrypter, | 1645 void QuicConnection::SetAlternativeDecrypter(QuicDecrypter* decrypter, |
1644 EncryptionLevel level, | 1646 EncryptionLevel level, |
1645 bool latch_once_used) { | 1647 bool latch_once_used) { |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1816 QuicFecGroup* fec_group = it->second; | 1818 QuicFecGroup* fec_group = it->second; |
1817 DCHECK(!fec_group->CanRevive()); | 1819 DCHECK(!fec_group->CanRevive()); |
1818 FecGroupMap::iterator next = it; | 1820 FecGroupMap::iterator next = it; |
1819 ++next; | 1821 ++next; |
1820 group_map_.erase(it); | 1822 group_map_.erase(it); |
1821 delete fec_group; | 1823 delete fec_group; |
1822 it = next; | 1824 it = next; |
1823 } | 1825 } |
1824 } | 1826 } |
1825 | 1827 |
| 1828 size_t QuicConnection::max_packet_length() const { |
| 1829 return packet_generator_.max_packet_length(); |
| 1830 } |
| 1831 |
| 1832 void QuicConnection::set_max_packet_length(size_t length) { |
| 1833 return packet_generator_.set_max_packet_length(length); |
| 1834 } |
| 1835 |
1826 void QuicConnection::Flush() { | 1836 void QuicConnection::Flush() { |
1827 packet_generator_.FlushAllQueuedFrames(); | 1837 packet_generator_.FlushAllQueuedFrames(); |
1828 } | 1838 } |
1829 | 1839 |
1830 bool QuicConnection::HasQueuedData() const { | 1840 bool QuicConnection::HasQueuedData() const { |
1831 return pending_version_negotiation_packet_ || | 1841 return pending_version_negotiation_packet_ || |
1832 !queued_packets_.empty() || packet_generator_.HasQueuedFrames(); | 1842 !queued_packets_.empty() || packet_generator_.HasQueuedFrames(); |
1833 } | 1843 } |
1834 | 1844 |
1835 bool QuicConnection::CanWriteStreamData() { | 1845 bool QuicConnection::CanWriteStreamData() { |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1962 // If we changed the generator's batch state, restore original batch state. | 1972 // If we changed the generator's batch state, restore original batch state. |
1963 if (!already_in_batch_mode_) { | 1973 if (!already_in_batch_mode_) { |
1964 DVLOG(1) << "Leaving Batch Mode."; | 1974 DVLOG(1) << "Leaving Batch Mode."; |
1965 connection_->packet_generator_.FinishBatchOperations(); | 1975 connection_->packet_generator_.FinishBatchOperations(); |
1966 } | 1976 } |
1967 DCHECK_EQ(already_in_batch_mode_, | 1977 DCHECK_EQ(already_in_batch_mode_, |
1968 connection_->packet_generator_.InBatchMode()); | 1978 connection_->packet_generator_.InBatchMode()); |
1969 } | 1979 } |
1970 | 1980 |
1971 } // namespace net | 1981 } // namespace net |
OLD | NEW |