| 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 1667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1678 } | 1678 } |
| 1679 SetPingAlarm(); | 1679 SetPingAlarm(); |
| 1680 MaybeSetMtuAlarm(); | 1680 MaybeSetMtuAlarm(); |
| 1681 DVLOG(1) << ENDPOINT << "time we began writing last sent packet: " | 1681 DVLOG(1) << ENDPOINT << "time we began writing last sent packet: " |
| 1682 << packet_send_time.ToDebuggingValue(); | 1682 << packet_send_time.ToDebuggingValue(); |
| 1683 | 1683 |
| 1684 if (!FLAGS_quic_simple_packet_number_length) { | 1684 if (!FLAGS_quic_simple_packet_number_length) { |
| 1685 // TODO(ianswett): Change the packet number length and other packet creator | 1685 // TODO(ianswett): Change the packet number length and other packet creator |
| 1686 // options by a more explicit API than setting a struct value directly, | 1686 // options by a more explicit API than setting a struct value directly, |
| 1687 // perhaps via the NetworkChangeVisitor. | 1687 // perhaps via the NetworkChangeVisitor. |
| 1688 packet_generator_.UpdateSequenceNumberLength( | 1688 if (FLAGS_quic_least_unacked_packet_number_length) { |
| 1689 sent_packet_manager_->GetLeastPacketAwaitedByPeer(packet->path_id), | 1689 packet_generator_.UpdateSequenceNumberLength( |
| 1690 sent_packet_manager_->EstimateMaxPacketsInFlight(max_packet_length())); | 1690 sent_packet_manager_->GetLeastUnacked(packet->path_id), |
| 1691 sent_packet_manager_->EstimateMaxPacketsInFlight( |
| 1692 max_packet_length())); |
| 1693 } else { |
| 1694 packet_generator_.UpdateSequenceNumberLength( |
| 1695 sent_packet_manager_->GetLeastPacketAwaitedByPeer(packet->path_id), |
| 1696 sent_packet_manager_->EstimateMaxPacketsInFlight( |
| 1697 max_packet_length())); |
| 1698 } |
| 1691 } | 1699 } |
| 1692 | 1700 |
| 1693 bool reset_retransmission_alarm = sent_packet_manager_->OnPacketSent( | 1701 bool reset_retransmission_alarm = sent_packet_manager_->OnPacketSent( |
| 1694 packet, packet->original_path_id, packet->original_packet_number, | 1702 packet, packet->original_path_id, packet->original_packet_number, |
| 1695 packet_send_time, packet->transmission_type, IsRetransmittable(*packet)); | 1703 packet_send_time, packet->transmission_type, IsRetransmittable(*packet)); |
| 1696 | 1704 |
| 1697 if (reset_retransmission_alarm || !retransmission_alarm_->IsSet()) { | 1705 if (reset_retransmission_alarm || !retransmission_alarm_->IsSet()) { |
| 1698 SetRetransmissionAlarm(); | 1706 SetRetransmissionAlarm(); |
| 1699 } | 1707 } |
| 1700 | 1708 |
| 1701 if (FLAGS_quic_simple_packet_number_length) { | 1709 if (FLAGS_quic_simple_packet_number_length) { |
| 1702 // The packet number length must be updated after OnPacketSent, because it | 1710 // The packet number length must be updated after OnPacketSent, because it |
| 1703 // may change the packet number length in packet. | 1711 // may change the packet number length in packet. |
| 1704 packet_generator_.UpdateSequenceNumberLength( | 1712 if (FLAGS_quic_least_unacked_packet_number_length) { |
| 1705 sent_packet_manager_->GetLeastPacketAwaitedByPeer(packet->path_id), | 1713 packet_generator_.UpdateSequenceNumberLength( |
| 1706 sent_packet_manager_->EstimateMaxPacketsInFlight(max_packet_length())); | 1714 sent_packet_manager_->GetLeastUnacked(packet->path_id), |
| 1715 sent_packet_manager_->EstimateMaxPacketsInFlight( |
| 1716 max_packet_length())); |
| 1717 } else { |
| 1718 packet_generator_.UpdateSequenceNumberLength( |
| 1719 sent_packet_manager_->GetLeastPacketAwaitedByPeer(packet->path_id), |
| 1720 sent_packet_manager_->EstimateMaxPacketsInFlight( |
| 1721 max_packet_length())); |
| 1722 } |
| 1707 } | 1723 } |
| 1708 | 1724 |
| 1709 stats_.bytes_sent += result.bytes_written; | 1725 stats_.bytes_sent += result.bytes_written; |
| 1710 ++stats_.packets_sent; | 1726 ++stats_.packets_sent; |
| 1711 if (packet->transmission_type != NOT_RETRANSMISSION) { | 1727 if (packet->transmission_type != NOT_RETRANSMISSION) { |
| 1712 stats_.bytes_retransmitted += result.bytes_written; | 1728 stats_.bytes_retransmitted += result.bytes_written; |
| 1713 ++stats_.packets_retransmitted; | 1729 ++stats_.packets_retransmitted; |
| 1714 } | 1730 } |
| 1715 | 1731 |
| 1716 if (result.status == WRITE_STATUS_ERROR) { | 1732 if (result.status == WRITE_STATUS_ERROR) { |
| (...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2511 // the sender and a signaling mechanism -- if the sender uses a | 2527 // the sender and a signaling mechanism -- if the sender uses a |
| 2512 // different MinRTO, we may get spurious retransmissions. May not have | 2528 // different MinRTO, we may get spurious retransmissions. May not have |
| 2513 // any benefits, but if the delayed ack becomes a significant source | 2529 // any benefits, but if the delayed ack becomes a significant source |
| 2514 // of (likely, tail) latency, then consider such a mechanism. | 2530 // of (likely, tail) latency, then consider such a mechanism. |
| 2515 const QuicTime::Delta QuicConnection::DelayedAckTime() { | 2531 const QuicTime::Delta QuicConnection::DelayedAckTime() { |
| 2516 return QuicTime::Delta::FromMilliseconds( | 2532 return QuicTime::Delta::FromMilliseconds( |
| 2517 min(kMaxDelayedAckTimeMs, kMinRetransmissionTimeMs / 2)); | 2533 min(kMaxDelayedAckTimeMs, kMinRetransmissionTimeMs / 2)); |
| 2518 } | 2534 } |
| 2519 | 2535 |
| 2520 } // namespace net | 2536 } // namespace net |
| OLD | NEW |