Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(386)

Side by Side Diff: net/quic/quic_connection.cc

Issue 424003002: Inline the members of QUIC's ReceivedPacketInfo into QuicAckFrame now (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove_FixRate_congestion_type_71746617
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | net/quic/quic_connection_logger.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 SendConnectionClose(QUIC_INVALID_ACK_DATA); 542 SendConnectionClose(QUIC_INVALID_ACK_DATA);
543 return false; 543 return false;
544 } 544 }
545 545
546 last_ack_frames_.push_back(incoming_ack); 546 last_ack_frames_.push_back(incoming_ack);
547 return connected_; 547 return connected_;
548 } 548 }
549 549
550 void QuicConnection::ProcessAckFrame(const QuicAckFrame& incoming_ack) { 550 void QuicConnection::ProcessAckFrame(const QuicAckFrame& incoming_ack) {
551 largest_seen_packet_with_ack_ = last_header_.packet_sequence_number; 551 largest_seen_packet_with_ack_ = last_header_.packet_sequence_number;
552 received_packet_manager_.UpdatePacketInformationReceivedByPeer( 552 received_packet_manager_.UpdatePacketInformationReceivedByPeer(incoming_ack);
553 incoming_ack.received_info);
554 553
555 sent_entropy_manager_.ClearEntropyBefore( 554 sent_entropy_manager_.ClearEntropyBefore(
556 received_packet_manager_.least_packet_awaited_by_peer() - 1); 555 received_packet_manager_.least_packet_awaited_by_peer() - 1);
557 556
558 sent_packet_manager_.OnIncomingAck(incoming_ack.received_info, 557 sent_packet_manager_.OnIncomingAck(incoming_ack,
559 time_of_last_received_packet_); 558 time_of_last_received_packet_);
560 if (sent_packet_manager_.HasPendingRetransmissions()) { 559 if (sent_packet_manager_.HasPendingRetransmissions()) {
561 WriteIfNotBlocked(); 560 WriteIfNotBlocked();
562 } 561 }
563 562
564 // Always reset the retransmission alarm when an ack comes in, since we now 563 // Always reset the retransmission alarm when an ack comes in, since we now
565 // have a better estimate of the current rtt than when it was set. 564 // have a better estimate of the current rtt than when it was set.
566 retransmission_alarm_->Cancel(); 565 retransmission_alarm_->Cancel();
567 QuicTime retransmission_time = 566 QuicTime retransmission_time =
568 sent_packet_manager_.GetRetransmissionTime(); 567 sent_packet_manager_.GetRetransmissionTime();
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 612
614 bool QuicConnection::OnPingFrame(const QuicPingFrame& frame) { 613 bool QuicConnection::OnPingFrame(const QuicPingFrame& frame) {
615 DCHECK(connected_); 614 DCHECK(connected_);
616 if (debug_visitor_) { 615 if (debug_visitor_) {
617 debug_visitor_->OnPingFrame(frame); 616 debug_visitor_->OnPingFrame(frame);
618 } 617 }
619 return true; 618 return true;
620 } 619 }
621 620
622 bool QuicConnection::ValidateAckFrame(const QuicAckFrame& incoming_ack) { 621 bool QuicConnection::ValidateAckFrame(const QuicAckFrame& incoming_ack) {
623 if (incoming_ack.received_info.largest_observed > 622 if (incoming_ack.largest_observed > packet_generator_.sequence_number()) {
624 packet_generator_.sequence_number()) {
625 DLOG(ERROR) << ENDPOINT << "Peer's observed unsent packet:" 623 DLOG(ERROR) << ENDPOINT << "Peer's observed unsent packet:"
626 << incoming_ack.received_info.largest_observed << " vs " 624 << incoming_ack.largest_observed << " vs "
627 << packet_generator_.sequence_number(); 625 << packet_generator_.sequence_number();
628 // We got an error for data we have not sent. Error out. 626 // We got an error for data we have not sent. Error out.
629 return false; 627 return false;
630 } 628 }
631 629
632 if (incoming_ack.received_info.largest_observed < 630 if (incoming_ack.largest_observed <
633 received_packet_manager_.peer_largest_observed_packet()) { 631 received_packet_manager_.peer_largest_observed_packet()) {
634 DLOG(ERROR) << ENDPOINT << "Peer's largest_observed packet decreased:" 632 DLOG(ERROR) << ENDPOINT << "Peer's largest_observed packet decreased:"
635 << incoming_ack.received_info.largest_observed << " vs " 633 << incoming_ack.largest_observed << " vs "
636 << received_packet_manager_.peer_largest_observed_packet(); 634 << received_packet_manager_.peer_largest_observed_packet();
637 // A new ack has a diminished largest_observed value. Error out. 635 // A new ack has a diminished largest_observed value. Error out.
638 // If this was an old packet, we wouldn't even have checked. 636 // If this was an old packet, we wouldn't even have checked.
639 return false; 637 return false;
640 } 638 }
641 639
642 if (!incoming_ack.received_info.missing_packets.empty() && 640 if (!incoming_ack.missing_packets.empty() &&
643 *incoming_ack.received_info.missing_packets.rbegin() > 641 *incoming_ack.missing_packets.rbegin() > incoming_ack.largest_observed) {
644 incoming_ack.received_info.largest_observed) {
645 DLOG(ERROR) << ENDPOINT << "Peer sent missing packet: " 642 DLOG(ERROR) << ENDPOINT << "Peer sent missing packet: "
646 << *incoming_ack.received_info.missing_packets.rbegin() 643 << *incoming_ack.missing_packets.rbegin()
647 << " which is greater than largest observed: " 644 << " which is greater than largest observed: "
648 << incoming_ack.received_info.largest_observed; 645 << incoming_ack.largest_observed;
649 return false; 646 return false;
650 } 647 }
651 648
652 if (!incoming_ack.received_info.missing_packets.empty() && 649 if (!incoming_ack.missing_packets.empty() &&
653 *incoming_ack.received_info.missing_packets.begin() < 650 *incoming_ack.missing_packets.begin() <
654 received_packet_manager_.least_packet_awaited_by_peer()) { 651 received_packet_manager_.least_packet_awaited_by_peer()) {
655 DLOG(ERROR) << ENDPOINT << "Peer sent missing packet: " 652 DLOG(ERROR) << ENDPOINT << "Peer sent missing packet: "
656 << *incoming_ack.received_info.missing_packets.begin() 653 << *incoming_ack.missing_packets.begin()
657 << " which is smaller than least_packet_awaited_by_peer_: " 654 << " which is smaller than least_packet_awaited_by_peer_: "
658 << received_packet_manager_.least_packet_awaited_by_peer(); 655 << received_packet_manager_.least_packet_awaited_by_peer();
659 return false; 656 return false;
660 } 657 }
661 658
662 if (!sent_entropy_manager_.IsValidEntropy( 659 if (!sent_entropy_manager_.IsValidEntropy(
663 incoming_ack.received_info.largest_observed, 660 incoming_ack.largest_observed,
664 incoming_ack.received_info.missing_packets, 661 incoming_ack.missing_packets,
665 incoming_ack.received_info.entropy_hash)) { 662 incoming_ack.entropy_hash)) {
666 DLOG(ERROR) << ENDPOINT << "Peer sent invalid entropy."; 663 DLOG(ERROR) << ENDPOINT << "Peer sent invalid entropy.";
667 return false; 664 return false;
668 } 665 }
669 666
670 for (SequenceNumberSet::const_iterator iter = 667 for (SequenceNumberSet::const_iterator iter =
671 incoming_ack.received_info.revived_packets.begin(); 668 incoming_ack.revived_packets.begin();
672 iter != incoming_ack.received_info.revived_packets.end(); ++iter) { 669 iter != incoming_ack.revived_packets.end(); ++iter) {
673 if (!ContainsKey(incoming_ack.received_info.missing_packets, *iter)) { 670 if (!ContainsKey(incoming_ack.missing_packets, *iter)) {
674 DLOG(ERROR) << ENDPOINT 671 DLOG(ERROR) << ENDPOINT
675 << "Peer specified revived packet which was not missing."; 672 << "Peer specified revived packet which was not missing.";
676 return false; 673 return false;
677 } 674 }
678 } 675 }
679 return true; 676 return true;
680 } 677 }
681 678
682 bool QuicConnection::ValidateStopWaitingFrame( 679 bool QuicConnection::ValidateStopWaitingFrame(
683 const QuicStopWaitingFrame& stop_waiting) { 680 const QuicStopWaitingFrame& stop_waiting) {
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 last_blocked_frames_.clear(); 885 last_blocked_frames_.clear();
889 last_rst_frames_.clear(); 886 last_rst_frames_.clear();
890 last_ack_frames_.clear(); 887 last_ack_frames_.clear();
891 last_stop_waiting_frames_.clear(); 888 last_stop_waiting_frames_.clear();
892 last_congestion_frames_.clear(); 889 last_congestion_frames_.clear();
893 } 890 }
894 891
895 QuicAckFrame* QuicConnection::CreateAckFrame() { 892 QuicAckFrame* QuicConnection::CreateAckFrame() {
896 QuicAckFrame* outgoing_ack = new QuicAckFrame(); 893 QuicAckFrame* outgoing_ack = new QuicAckFrame();
897 received_packet_manager_.UpdateReceivedPacketInfo( 894 received_packet_manager_.UpdateReceivedPacketInfo(
898 &(outgoing_ack->received_info), clock_->ApproximateNow()); 895 outgoing_ack, clock_->ApproximateNow());
899 DVLOG(1) << ENDPOINT << "Creating ack frame: " << *outgoing_ack; 896 DVLOG(1) << ENDPOINT << "Creating ack frame: " << *outgoing_ack;
900 return outgoing_ack; 897 return outgoing_ack;
901 } 898 }
902 899
903 QuicCongestionFeedbackFrame* QuicConnection::CreateFeedbackFrame() { 900 QuicCongestionFeedbackFrame* QuicConnection::CreateFeedbackFrame() {
904 return new QuicCongestionFeedbackFrame(outgoing_congestion_feedback_); 901 return new QuicCongestionFeedbackFrame(outgoing_congestion_feedback_);
905 } 902 }
906 903
907 QuicStopWaitingFrame* QuicConnection::CreateStopWaitingFrame() { 904 QuicStopWaitingFrame* QuicConnection::CreateStopWaitingFrame() {
908 QuicStopWaitingFrame stop_waiting; 905 QuicStopWaitingFrame stop_waiting;
909 UpdateStopWaiting(&stop_waiting); 906 UpdateStopWaiting(&stop_waiting);
910 return new QuicStopWaitingFrame(stop_waiting); 907 return new QuicStopWaitingFrame(stop_waiting);
911 } 908 }
912 909
913 bool QuicConnection::ShouldLastPacketInstigateAck() const { 910 bool QuicConnection::ShouldLastPacketInstigateAck() const {
914 if (!last_stream_frames_.empty() || 911 if (!last_stream_frames_.empty() ||
915 !last_goaway_frames_.empty() || 912 !last_goaway_frames_.empty() ||
916 !last_rst_frames_.empty() || 913 !last_rst_frames_.empty() ||
917 !last_window_update_frames_.empty() || 914 !last_window_update_frames_.empty() ||
918 !last_blocked_frames_.empty()) { 915 !last_blocked_frames_.empty()) {
919 return true; 916 return true;
920 } 917 }
921 918
922 if (!last_ack_frames_.empty() && 919 if (!last_ack_frames_.empty() && last_ack_frames_.back().is_truncated) {
923 last_ack_frames_.back().received_info.is_truncated) {
924 return true; 920 return true;
925 } 921 }
926 return false; 922 return false;
927 } 923 }
928 924
929 void QuicConnection::UpdateStopWaitingCount() { 925 void QuicConnection::UpdateStopWaitingCount() {
930 if (last_ack_frames_.empty()) { 926 if (last_ack_frames_.empty()) {
931 return; 927 return;
932 } 928 }
933 929
934 // If the peer is still waiting for a packet that we are no longer planning to 930 // If the peer is still waiting for a packet that we are no longer planning to
935 // send, send an ack to raise the high water mark. 931 // send, send an ack to raise the high water mark.
936 if (!last_ack_frames_.back().received_info.missing_packets.empty() && 932 if (!last_ack_frames_.back().missing_packets.empty() &&
937 GetLeastUnacked() > 933 GetLeastUnacked() > *last_ack_frames_.back().missing_packets.begin()) {
938 *last_ack_frames_.back().received_info.missing_packets.begin()) {
939 ++stop_waiting_count_; 934 ++stop_waiting_count_;
940 } else { 935 } else {
941 stop_waiting_count_ = 0; 936 stop_waiting_count_ = 0;
942 } 937 }
943 } 938 }
944 939
945 QuicPacketSequenceNumber QuicConnection::GetLeastUnacked() const { 940 QuicPacketSequenceNumber QuicConnection::GetLeastUnacked() const {
946 return sent_packet_manager_.HasUnackedPackets() ? 941 return sent_packet_manager_.HasUnackedPackets() ?
947 sent_packet_manager_.GetLeastUnackedSentPacket() : 942 sent_packet_manager_.GetLeastUnackedSentPacket() :
948 packet_generator_.sequence_number() + 1; 943 packet_generator_.sequence_number() + 1;
(...skipping 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after
1976 // If we changed the generator's batch state, restore original batch state. 1971 // If we changed the generator's batch state, restore original batch state.
1977 if (!already_in_batch_mode_) { 1972 if (!already_in_batch_mode_) {
1978 DVLOG(1) << "Leaving Batch Mode."; 1973 DVLOG(1) << "Leaving Batch Mode.";
1979 connection_->packet_generator_.FinishBatchOperations(); 1974 connection_->packet_generator_.FinishBatchOperations();
1980 } 1975 }
1981 DCHECK_EQ(already_in_batch_mode_, 1976 DCHECK_EQ(already_in_batch_mode_,
1982 connection_->packet_generator_.InBatchMode()); 1977 connection_->packet_generator_.InBatchMode());
1983 } 1978 }
1984 1979
1985 } // namespace net 1980 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/quic/quic_connection_logger.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698