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 1663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1674 if (IsRetransmittable(*packet) == HAS_RETRANSMITTABLE_DATA && | 1674 if (IsRetransmittable(*packet) == HAS_RETRANSMITTABLE_DATA && |
1675 last_send_for_timeout_ <= time_of_last_received_packet_) { | 1675 last_send_for_timeout_ <= time_of_last_received_packet_) { |
1676 last_send_for_timeout_ = packet_send_time; | 1676 last_send_for_timeout_ = packet_send_time; |
1677 } | 1677 } |
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 // TODO(ianswett): Change the packet number length and other packet creator | 1684 if (!FLAGS_quic_simple_packet_number_length) { |
1685 // options by a more explicit API than setting a struct value directly, | 1685 // TODO(ianswett): Change the packet number length and other packet creator |
1686 // perhaps via the NetworkChangeVisitor. | 1686 // options by a more explicit API than setting a struct value directly, |
1687 packet_generator_.UpdateSequenceNumberLength( | 1687 // perhaps via the NetworkChangeVisitor. |
1688 sent_packet_manager_->GetLeastPacketAwaitedByPeer(packet->path_id), | 1688 packet_generator_.UpdateSequenceNumberLength( |
1689 sent_packet_manager_->EstimateMaxPacketsInFlight(max_packet_length())); | 1689 sent_packet_manager_->GetLeastPacketAwaitedByPeer(packet->path_id), |
| 1690 sent_packet_manager_->EstimateMaxPacketsInFlight(max_packet_length())); |
| 1691 } |
1690 | 1692 |
1691 bool reset_retransmission_alarm = sent_packet_manager_->OnPacketSent( | 1693 bool reset_retransmission_alarm = sent_packet_manager_->OnPacketSent( |
1692 packet, packet->original_path_id, packet->original_packet_number, | 1694 packet, packet->original_path_id, packet->original_packet_number, |
1693 packet_send_time, packet->transmission_type, IsRetransmittable(*packet)); | 1695 packet_send_time, packet->transmission_type, IsRetransmittable(*packet)); |
1694 | 1696 |
1695 if (reset_retransmission_alarm || !retransmission_alarm_->IsSet()) { | 1697 if (reset_retransmission_alarm || !retransmission_alarm_->IsSet()) { |
1696 SetRetransmissionAlarm(); | 1698 SetRetransmissionAlarm(); |
1697 } | 1699 } |
1698 | 1700 |
| 1701 if (FLAGS_quic_simple_packet_number_length) { |
| 1702 // The packet number length must be updated after OnPacketSent, because it |
| 1703 // may change the packet number length in packet. |
| 1704 packet_generator_.UpdateSequenceNumberLength( |
| 1705 sent_packet_manager_->GetLeastPacketAwaitedByPeer(packet->path_id), |
| 1706 sent_packet_manager_->EstimateMaxPacketsInFlight(max_packet_length())); |
| 1707 } |
| 1708 |
1699 stats_.bytes_sent += result.bytes_written; | 1709 stats_.bytes_sent += result.bytes_written; |
1700 ++stats_.packets_sent; | 1710 ++stats_.packets_sent; |
1701 if (packet->transmission_type != NOT_RETRANSMISSION) { | 1711 if (packet->transmission_type != NOT_RETRANSMISSION) { |
1702 stats_.bytes_retransmitted += result.bytes_written; | 1712 stats_.bytes_retransmitted += result.bytes_written; |
1703 ++stats_.packets_retransmitted; | 1713 ++stats_.packets_retransmitted; |
1704 } | 1714 } |
1705 | 1715 |
1706 if (result.status == WRITE_STATUS_ERROR) { | 1716 if (result.status == WRITE_STATUS_ERROR) { |
1707 OnWriteError(result.error_code); | 1717 OnWriteError(result.error_code); |
1708 DLOG(ERROR) << ENDPOINT << "failed writing " << encrypted_length | 1718 DLOG(ERROR) << ENDPOINT << "failed writing " << encrypted_length |
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2501 // the sender and a signaling mechanism -- if the sender uses a | 2511 // the sender and a signaling mechanism -- if the sender uses a |
2502 // different MinRTO, we may get spurious retransmissions. May not have | 2512 // different MinRTO, we may get spurious retransmissions. May not have |
2503 // any benefits, but if the delayed ack becomes a significant source | 2513 // any benefits, but if the delayed ack becomes a significant source |
2504 // of (likely, tail) latency, then consider such a mechanism. | 2514 // of (likely, tail) latency, then consider such a mechanism. |
2505 const QuicTime::Delta QuicConnection::DelayedAckTime() { | 2515 const QuicTime::Delta QuicConnection::DelayedAckTime() { |
2506 return QuicTime::Delta::FromMilliseconds( | 2516 return QuicTime::Delta::FromMilliseconds( |
2507 min(kMaxDelayedAckTimeMs, kMinRetransmissionTimeMs / 2)); | 2517 min(kMaxDelayedAckTimeMs, kMinRetransmissionTimeMs / 2)); |
2508 } | 2518 } |
2509 | 2519 |
2510 } // namespace net | 2520 } // namespace net |
OLD | NEW |