| 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 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 if (!ValidateAckFrame(incoming_ack)) { | 741 if (!ValidateAckFrame(incoming_ack)) { |
| 742 SendConnectionClose(QUIC_INVALID_ACK_DATA); | 742 SendConnectionClose(QUIC_INVALID_ACK_DATA); |
| 743 return false; | 743 return false; |
| 744 } | 744 } |
| 745 | 745 |
| 746 if (FLAGS_quic_process_frames_inline) { | 746 if (FLAGS_quic_process_frames_inline) { |
| 747 ProcessAckFrame(incoming_ack); | 747 ProcessAckFrame(incoming_ack); |
| 748 if (incoming_ack.is_truncated) { | 748 if (incoming_ack.is_truncated) { |
| 749 should_last_packet_instigate_acks_ = true; | 749 should_last_packet_instigate_acks_ = true; |
| 750 } | 750 } |
| 751 if (!incoming_ack.missing_packets.empty() && | 751 if (!incoming_ack.missing_packets.Empty() && |
| 752 GetLeastUnacked() > *incoming_ack.missing_packets.begin()) { | 752 GetLeastUnacked() > incoming_ack.missing_packets.Min()) { |
| 753 ++stop_waiting_count_; | 753 ++stop_waiting_count_; |
| 754 } else { | 754 } else { |
| 755 stop_waiting_count_ = 0; | 755 stop_waiting_count_ = 0; |
| 756 } | 756 } |
| 757 } else { | 757 } else { |
| 758 last_ack_frames_.push_back(incoming_ack); | 758 last_ack_frames_.push_back(incoming_ack); |
| 759 } | 759 } |
| 760 return connected_; | 760 return connected_; |
| 761 } | 761 } |
| 762 | 762 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 826 | 826 |
| 827 if (incoming_ack.largest_observed < sent_packet_manager_.largest_observed()) { | 827 if (incoming_ack.largest_observed < sent_packet_manager_.largest_observed()) { |
| 828 DLOG(ERROR) << ENDPOINT << "Peer's largest_observed packet decreased:" | 828 DLOG(ERROR) << ENDPOINT << "Peer's largest_observed packet decreased:" |
| 829 << incoming_ack.largest_observed << " vs " | 829 << incoming_ack.largest_observed << " vs " |
| 830 << sent_packet_manager_.largest_observed(); | 830 << sent_packet_manager_.largest_observed(); |
| 831 // A new ack has a diminished largest_observed value. Error out. | 831 // A new ack has a diminished largest_observed value. Error out. |
| 832 // If this was an old packet, we wouldn't even have checked. | 832 // If this was an old packet, we wouldn't even have checked. |
| 833 return false; | 833 return false; |
| 834 } | 834 } |
| 835 | 835 |
| 836 if (!incoming_ack.missing_packets.empty() && | 836 if (!incoming_ack.missing_packets.Empty() && |
| 837 *incoming_ack.missing_packets.rbegin() > incoming_ack.largest_observed) { | 837 incoming_ack.missing_packets.Max() > incoming_ack.largest_observed) { |
| 838 DLOG(ERROR) << ENDPOINT << "Peer sent missing packet: " | 838 DLOG(ERROR) << ENDPOINT << "Peer sent missing packet: " |
| 839 << *incoming_ack.missing_packets.rbegin() | 839 << incoming_ack.missing_packets.Max() |
| 840 << " which is greater than largest observed: " | 840 << " which is greater than largest observed: " |
| 841 << incoming_ack.largest_observed; | 841 << incoming_ack.largest_observed; |
| 842 return false; | 842 return false; |
| 843 } | 843 } |
| 844 | 844 |
| 845 if (!incoming_ack.missing_packets.empty() && | 845 if (!incoming_ack.missing_packets.Empty() && |
| 846 *incoming_ack.missing_packets.begin() < | 846 incoming_ack.missing_packets.Min() < |
| 847 sent_packet_manager_.least_packet_awaited_by_peer()) { | 847 sent_packet_manager_.least_packet_awaited_by_peer()) { |
| 848 DLOG(ERROR) << ENDPOINT << "Peer sent missing packet: " | 848 DLOG(ERROR) << ENDPOINT << "Peer sent missing packet: " |
| 849 << *incoming_ack.missing_packets.begin() | 849 << incoming_ack.missing_packets.Min() |
| 850 << " which is smaller than least_packet_awaited_by_peer_: " | 850 << " which is smaller than least_packet_awaited_by_peer_: " |
| 851 << sent_packet_manager_.least_packet_awaited_by_peer(); | 851 << sent_packet_manager_.least_packet_awaited_by_peer(); |
| 852 return false; | 852 return false; |
| 853 } | 853 } |
| 854 | 854 |
| 855 if (!sent_entropy_manager_.IsValidEntropy( | 855 if (!sent_entropy_manager_.IsValidEntropy( |
| 856 incoming_ack.largest_observed, | 856 incoming_ack.largest_observed, |
| 857 incoming_ack.missing_packets, | 857 incoming_ack.missing_packets, |
| 858 incoming_ack.entropy_hash)) { | 858 incoming_ack.entropy_hash)) { |
| 859 DLOG(ERROR) << ENDPOINT << "Peer sent invalid entropy."; | 859 DLOG(ERROR) << ENDPOINT << "Peer sent invalid entropy."; |
| 860 return false; | 860 return false; |
| 861 } | 861 } |
| 862 | 862 |
| 863 for (QuicPacketNumber revived_packet : incoming_ack.revived_packets) { | 863 for (QuicPacketNumber revived_packet : incoming_ack.revived_packets) { |
| 864 if (!ContainsKey(incoming_ack.missing_packets, revived_packet)) { | 864 if (!incoming_ack.missing_packets.Contains(revived_packet)) { |
| 865 DLOG(ERROR) << ENDPOINT | 865 DLOG(ERROR) << ENDPOINT |
| 866 << "Peer specified revived packet which was not missing."; | 866 << "Peer specified revived packet which was not missing."; |
| 867 return false; | 867 return false; |
| 868 } | 868 } |
| 869 } | 869 } |
| 870 return true; | 870 return true; |
| 871 } | 871 } |
| 872 | 872 |
| 873 bool QuicConnection::ValidateStopWaitingFrame( | 873 bool QuicConnection::ValidateStopWaitingFrame( |
| 874 const QuicStopWaitingFrame& stop_waiting) { | 874 const QuicStopWaitingFrame& stop_waiting) { |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1190 return false; | 1190 return false; |
| 1191 } | 1191 } |
| 1192 | 1192 |
| 1193 void QuicConnection::UpdateStopWaitingCount() { | 1193 void QuicConnection::UpdateStopWaitingCount() { |
| 1194 if (last_ack_frames_.empty()) { | 1194 if (last_ack_frames_.empty()) { |
| 1195 return; | 1195 return; |
| 1196 } | 1196 } |
| 1197 | 1197 |
| 1198 // If the peer is still waiting for a packet that we are no longer planning to | 1198 // If the peer is still waiting for a packet that we are no longer planning to |
| 1199 // send, send an ack to raise the high water mark. | 1199 // send, send an ack to raise the high water mark. |
| 1200 if (!last_ack_frames_.back().missing_packets.empty() && | 1200 if (!last_ack_frames_.back().missing_packets.Empty() && |
| 1201 GetLeastUnacked() > *last_ack_frames_.back().missing_packets.begin()) { | 1201 GetLeastUnacked() > last_ack_frames_.back().missing_packets.Min()) { |
| 1202 ++stop_waiting_count_; | 1202 ++stop_waiting_count_; |
| 1203 } else { | 1203 } else { |
| 1204 stop_waiting_count_ = 0; | 1204 stop_waiting_count_ = 0; |
| 1205 } | 1205 } |
| 1206 } | 1206 } |
| 1207 | 1207 |
| 1208 QuicPacketNumber QuicConnection::GetLeastUnacked() const { | 1208 QuicPacketNumber QuicConnection::GetLeastUnacked() const { |
| 1209 return sent_packet_manager_.GetLeastUnacked(); | 1209 return sent_packet_manager_.GetLeastUnacked(); |
| 1210 } | 1210 } |
| 1211 | 1211 |
| (...skipping 1241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2453 packet_number_of_last_sent_packet_ + packets_between_mtu_probes_ + 1; | 2453 packet_number_of_last_sent_packet_ + packets_between_mtu_probes_ + 1; |
| 2454 ++mtu_probe_count_; | 2454 ++mtu_probe_count_; |
| 2455 | 2455 |
| 2456 DVLOG(2) << "Sending a path MTU discovery packet #" << mtu_probe_count_; | 2456 DVLOG(2) << "Sending a path MTU discovery packet #" << mtu_probe_count_; |
| 2457 SendMtuDiscoveryPacket(mtu_discovery_target_); | 2457 SendMtuDiscoveryPacket(mtu_discovery_target_); |
| 2458 | 2458 |
| 2459 DCHECK(!mtu_discovery_alarm_->IsSet()); | 2459 DCHECK(!mtu_discovery_alarm_->IsSet()); |
| 2460 } | 2460 } |
| 2461 | 2461 |
| 2462 } // namespace net | 2462 } // namespace net |
| OLD | NEW |