1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "net/quic/congestion_control/inter_arrival_receiver.h" 6 7 #include "base/basictypes.h" 8 9 namespace net { 10 11 InterArrivalReceiver::InterArrivalReceiver() 12 : accumulated_number_of_recoverd_lost_packets_(0) { 13 } 14 15 InterArrivalReceiver::~InterArrivalReceiver() { 16 } 17 18 bool InterArrivalReceiver::GenerateCongestionFeedback( 19 QuicCongestionFeedbackFrame* feedback) { 20 if (received_packet_times_.size() <= 1) { 21 // Don't waste resources by sending a feedback frame for only one packet. 22 return false; 23 } 24 feedback->type = kInterArrival; 25 feedback->inter_arrival.accumulated_number_of_lost_packets = 26 accumulated_number_of_recoverd_lost_packets_; 27 28 // Copy our current receive set to our feedback message, we will not resend 29 // this data if it is lost. 30 feedback->inter_arrival.received_packet_times = received_packet_times_; 31 32 // Prepare for the next set of arriving packets by clearing our current set. 33 received_packet_times_.clear(); 34 return true; 35 } 36 37 void InterArrivalReceiver::RecordIncomingPacket( 38 QuicByteCount /*bytes*/, 39 QuicPacketSequenceNumber sequence_number, 40 QuicTime timestamp, 41 bool revived) { 42 if (revived) { 43 ++accumulated_number_of_recoverd_lost_packets_; 44 } 45 received_packet_times_.insert(std::make_pair(sequence_number, timestamp)); 46 } 47 48 } // namespace net 49