OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_sent_packet_manager.h" | 5 #include "net/quic/quic_sent_packet_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 } | 385 } |
386 // TODO(ianswett): Currently the RTO can fire while there are pending NACK | 386 // TODO(ianswett): Currently the RTO can fire while there are pending NACK |
387 // retransmissions for the same data, which is not ideal. | 387 // retransmissions for the same data, which is not ideal. |
388 if (ContainsKey(pending_retransmissions_, packet_number)) { | 388 if (ContainsKey(pending_retransmissions_, packet_number)) { |
389 return; | 389 return; |
390 } | 390 } |
391 | 391 |
392 pending_retransmissions_[packet_number] = transmission_type; | 392 pending_retransmissions_[packet_number] = transmission_type; |
393 } | 393 } |
394 | 394 |
| 395 void QuicSentPacketManager::RecordOneSpuriousRetransmission( |
| 396 const TransmissionInfo& info) { |
| 397 stats_->bytes_spuriously_retransmitted += info.bytes_sent; |
| 398 ++stats_->packets_spuriously_retransmitted; |
| 399 if (debug_delegate_ != nullptr) { |
| 400 debug_delegate_->OnSpuriousPacketRetransmission(info.transmission_type, |
| 401 info.bytes_sent); |
| 402 } |
| 403 } |
| 404 |
395 void QuicSentPacketManager::RecordSpuriousRetransmissions( | 405 void QuicSentPacketManager::RecordSpuriousRetransmissions( |
396 const TransmissionInfo& info, | 406 const TransmissionInfo& info, |
397 QuicPacketNumber acked_packet_number) { | 407 QuicPacketNumber acked_packet_number) { |
398 if (unacked_packets_.track_single_retransmission()) { | 408 if (unacked_packets_.track_single_retransmission()) { |
399 QuicPacketNumber retransmission = info.retransmission; | 409 QuicPacketNumber retransmission = info.retransmission; |
400 while (retransmission != 0) { | 410 while (retransmission != 0) { |
401 const TransmissionInfo& retransmit_info = | 411 const TransmissionInfo& retransmit_info = |
402 unacked_packets_.GetTransmissionInfo(retransmission); | 412 unacked_packets_.GetTransmissionInfo(retransmission); |
403 retransmission = retransmit_info.retransmission; | 413 retransmission = retransmit_info.retransmission; |
404 stats_->bytes_spuriously_retransmitted += retransmit_info.bytes_sent; | 414 RecordOneSpuriousRetransmission(retransmit_info); |
405 ++stats_->packets_spuriously_retransmitted; | |
406 if (debug_delegate_ != nullptr) { | |
407 debug_delegate_->OnSpuriousPacketRetransmission( | |
408 retransmit_info.transmission_type, retransmit_info.bytes_sent); | |
409 } | |
410 } | 415 } |
411 return; | 416 return; |
412 } | 417 } |
413 const PacketNumberList* all_transmissions = info.all_transmissions; | 418 const PacketNumberList* all_transmissions = info.all_transmissions; |
414 for (PacketNumberList::const_reverse_iterator it = | 419 for (PacketNumberList::const_reverse_iterator it = |
415 all_transmissions->rbegin(); | 420 all_transmissions->rbegin(); |
416 it != all_transmissions->rend() && *it > acked_packet_number; ++it) { | 421 it != all_transmissions->rend() && *it > acked_packet_number; ++it) { |
417 // ianswett: Prevents crash in b/20552846. | 422 // ianswett: Prevents crash in b/20552846. |
418 if (*it < unacked_packets_.GetLeastUnacked() || | 423 if (*it < unacked_packets_.GetLeastUnacked() || |
419 *it > unacked_packets_.largest_sent_packet()) { | 424 *it > unacked_packets_.largest_sent_packet()) { |
420 LOG(DFATAL) << "Retransmission out of range:" << *it | 425 LOG(DFATAL) << "Retransmission out of range:" << *it |
421 << " least unacked:" << unacked_packets_.GetLeastUnacked() | 426 << " least unacked:" << unacked_packets_.GetLeastUnacked() |
422 << " largest sent:" << unacked_packets_.largest_sent_packet(); | 427 << " largest sent:" << unacked_packets_.largest_sent_packet(); |
423 return; | 428 return; |
424 } | 429 } |
425 const TransmissionInfo& retransmit_info = | 430 const TransmissionInfo& retransmit_info = |
426 unacked_packets_.GetTransmissionInfo(*it); | 431 unacked_packets_.GetTransmissionInfo(*it); |
427 | 432 |
428 stats_->bytes_spuriously_retransmitted += retransmit_info.bytes_sent; | 433 RecordOneSpuriousRetransmission(retransmit_info); |
429 ++stats_->packets_spuriously_retransmitted; | |
430 if (debug_delegate_ != nullptr) { | |
431 debug_delegate_->OnSpuriousPacketRetransmission( | |
432 retransmit_info.transmission_type, retransmit_info.bytes_sent); | |
433 } | |
434 } | 434 } |
435 } | 435 } |
436 | 436 |
437 bool QuicSentPacketManager::HasPendingRetransmissions() const { | 437 bool QuicSentPacketManager::HasPendingRetransmissions() const { |
438 return !pending_retransmissions_.empty(); | 438 return !pending_retransmissions_.empty(); |
439 } | 439 } |
440 | 440 |
441 QuicSentPacketManager::PendingRetransmission | 441 QuicSentPacketManager::PendingRetransmission |
442 QuicSentPacketManager::NextPendingRetransmission() { | 442 QuicSentPacketManager::NextPendingRetransmission() { |
443 LOG_IF(DFATAL, pending_retransmissions_.empty()) | 443 LOG_IF(DFATAL, pending_retransmissions_.empty()) |
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
995 // Rtt and cwnd do not need to be reset when the peer address change is | 995 // Rtt and cwnd do not need to be reset when the peer address change is |
996 // considered to be caused by NATs. | 996 // considered to be caused by NATs. |
997 return; | 997 return; |
998 } | 998 } |
999 | 999 |
1000 rtt_stats_.OnConnectionMigration(); | 1000 rtt_stats_.OnConnectionMigration(); |
1001 send_algorithm_->OnConnectionMigration(); | 1001 send_algorithm_->OnConnectionMigration(); |
1002 } | 1002 } |
1003 | 1003 |
1004 } // namespace net | 1004 } // namespace net |
OLD | NEW |