Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: net/quic/quic_connection.cc

Issue 740793002: Record the last packet send time before we start sending the packet (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Remove_QUIC_LOG_80124025
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1431 matching lines...) Expand 10 before | Expand all | Expand 10 after
1442 << ", encryption level: " 1442 << ", encryption level: "
1443 << QuicUtils::EncryptionLevelToString(packet->encryption_level) 1443 << QuicUtils::EncryptionLevelToString(packet->encryption_level)
1444 << ", length:" 1444 << ", length:"
1445 << packet->serialized_packet.packet->length() 1445 << packet->serialized_packet.packet->length()
1446 << ", encrypted length:" 1446 << ", encrypted length:"
1447 << encrypted->length(); 1447 << encrypted->length();
1448 DVLOG(2) << ENDPOINT << "packet(" << sequence_number << "): " << std::endl 1448 DVLOG(2) << ENDPOINT << "packet(" << sequence_number << "): " << std::endl
1449 << QuicUtils::StringToHexASCIIDump( 1449 << QuicUtils::StringToHexASCIIDump(
1450 packet->serialized_packet.packet->AsStringPiece()); 1450 packet->serialized_packet.packet->AsStringPiece());
1451 1451
1452 QuicTime packet_send_time = QuicTime::Zero();
1453 if (FLAGS_quic_record_send_time_before_write) {
1454 // Measure the RTT from before the write begins to avoid underestimating the
1455 // min_rtt_, especially in cases where the thread blocks or gets swapped out
1456 // during the WritePacket below.
1457 packet_send_time = clock_->Now();
1458 }
1452 WriteResult result = writer_->WritePacket(encrypted->data(), 1459 WriteResult result = writer_->WritePacket(encrypted->data(),
1453 encrypted->length(), 1460 encrypted->length(),
1454 self_address().address(), 1461 self_address().address(),
1455 peer_address()); 1462 peer_address());
1456 if (result.error_code == ERR_IO_PENDING) { 1463 if (result.error_code == ERR_IO_PENDING) {
1457 DCHECK_EQ(WRITE_STATUS_BLOCKED, result.status); 1464 DCHECK_EQ(WRITE_STATUS_BLOCKED, result.status);
1458 } 1465 }
1459 1466
1460 if (result.status == WRITE_STATUS_BLOCKED) { 1467 if (result.status == WRITE_STATUS_BLOCKED) {
1461 visitor_->OnWriteBlocked(); 1468 visitor_->OnWriteBlocked();
1462 // If the socket buffers the the data, then the packet should not 1469 // If the socket buffers the the data, then the packet should not
1463 // be queued and sent again, which would result in an unnecessary 1470 // be queued and sent again, which would result in an unnecessary
1464 // duplicate packet being sent. The helper must call OnCanWrite 1471 // duplicate packet being sent. The helper must call OnCanWrite
1465 // when the write completes, and OnWriteError if an error occurs. 1472 // when the write completes, and OnWriteError if an error occurs.
1466 if (!writer_->IsWriteBlockedDataBuffered()) { 1473 if (!writer_->IsWriteBlockedDataBuffered()) {
1467 return false; 1474 return false;
1468 } 1475 }
1469 } 1476 }
1470 QuicTime now = clock_->Now(); 1477 if (!FLAGS_quic_record_send_time_before_write) {
1478 packet_send_time = clock_->Now();
1479 }
1480 if (!packet_send_time.IsInitialized()) {
1481 // TODO(jokulik): This is only needed because of the two code paths for
1482 // initializing packet_send_time. Once "quic_record_send_time_before_write"
1483 // is deprecated, this check can be removed.
1484 LOG(DFATAL) << "The packet send time should never be zero. "
1485 << "This is a programming bug, please report it.";
1486 }
1471 if (result.status != WRITE_STATUS_ERROR && debug_visitor_.get() != nullptr) { 1487 if (result.status != WRITE_STATUS_ERROR && debug_visitor_.get() != nullptr) {
1472 // Pass the write result to the visitor. 1488 // Pass the write result to the visitor.
1473 debug_visitor_->OnPacketSent(packet->serialized_packet, 1489 debug_visitor_->OnPacketSent(packet->serialized_packet,
1474 packet->original_sequence_number, 1490 packet->original_sequence_number,
1475 packet->encryption_level, 1491 packet->encryption_level,
1476 packet->transmission_type, 1492 packet->transmission_type,
1477 *encrypted, 1493 *encrypted,
1478 now); 1494 packet_send_time);
1479 } 1495 }
1480 if (packet->transmission_type == NOT_RETRANSMISSION) { 1496 if (packet->transmission_type == NOT_RETRANSMISSION) {
1481 time_of_last_sent_new_packet_ = now; 1497 time_of_last_sent_new_packet_ = packet_send_time;
1482 } 1498 }
1483 SetPingAlarm(); 1499 SetPingAlarm();
1484 DVLOG(1) << ENDPOINT << "time of last sent packet: " 1500 DVLOG(1) << ENDPOINT << "time "
1485 << now.ToDebuggingValue(); 1501 << (FLAGS_quic_record_send_time_before_write ?
1502 "we began writing " : "we finished writing ")
1503 << "last sent packet: "
1504 << packet_send_time.ToDebuggingValue();
1486 1505
1487 // TODO(ianswett): Change the sequence number length and other packet creator 1506 // TODO(ianswett): Change the sequence number length and other packet creator
1488 // options by a more explicit API than setting a struct value directly, 1507 // options by a more explicit API than setting a struct value directly,
1489 // perhaps via the NetworkChangeVisitor. 1508 // perhaps via the NetworkChangeVisitor.
1490 packet_generator_.UpdateSequenceNumberLength( 1509 packet_generator_.UpdateSequenceNumberLength(
1491 sent_packet_manager_.least_packet_awaited_by_peer(), 1510 sent_packet_manager_.least_packet_awaited_by_peer(),
1492 sent_packet_manager_.EstimateMaxPacketsInFlight(max_packet_length())); 1511 sent_packet_manager_.EstimateMaxPacketsInFlight(max_packet_length()));
1493 1512
1494 bool reset_retransmission_alarm = sent_packet_manager_.OnPacketSent( 1513 bool reset_retransmission_alarm = sent_packet_manager_.OnPacketSent(
1495 &packet->serialized_packet, 1514 &packet->serialized_packet,
1496 packet->original_sequence_number, 1515 packet->original_sequence_number,
1497 now, 1516 packet_send_time,
1498 encrypted->length(), 1517 encrypted->length(),
1499 packet->transmission_type, 1518 packet->transmission_type,
1500 IsRetransmittable(*packet)); 1519 IsRetransmittable(*packet));
1501 1520
1502 if (reset_retransmission_alarm || !retransmission_alarm_->IsSet()) { 1521 if (reset_retransmission_alarm || !retransmission_alarm_->IsSet()) {
1503 retransmission_alarm_->Update(sent_packet_manager_.GetRetransmissionTime(), 1522 retransmission_alarm_->Update(sent_packet_manager_.GetRetransmissionTime(),
1504 QuicTime::Delta::FromMilliseconds(1)); 1523 QuicTime::Delta::FromMilliseconds(1));
1505 } 1524 }
1506 1525
1507 stats_.bytes_sent += result.bytes_written; 1526 stats_.bytes_sent += result.bytes_written;
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
2066 } 2085 }
2067 for (size_t i = 0; i < retransmittable_frames->frames().size(); ++i) { 2086 for (size_t i = 0; i < retransmittable_frames->frames().size(); ++i) {
2068 if (retransmittable_frames->frames()[i].type == CONNECTION_CLOSE_FRAME) { 2087 if (retransmittable_frames->frames()[i].type == CONNECTION_CLOSE_FRAME) {
2069 return true; 2088 return true;
2070 } 2089 }
2071 } 2090 }
2072 return false; 2091 return false;
2073 } 2092 }
2074 2093
2075 } // namespace net 2094 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698