OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 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/chromium/quic_connection_logger.h" | 5 #include "net/quic/chromium/quic_connection_logger.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 } | 106 } |
107 | 107 |
108 std::unique_ptr<base::Value> NetLogQuicAckFrameCallback( | 108 std::unique_ptr<base::Value> NetLogQuicAckFrameCallback( |
109 const QuicAckFrame* frame, | 109 const QuicAckFrame* frame, |
110 NetLogCaptureMode /* capture_mode */) { | 110 NetLogCaptureMode /* capture_mode */) { |
111 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 111 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
112 dict->SetString("largest_observed", | 112 dict->SetString("largest_observed", |
113 base::Uint64ToString(frame->largest_observed)); | 113 base::Uint64ToString(frame->largest_observed)); |
114 dict->SetString("delta_time_largest_observed_us", | 114 dict->SetString("delta_time_largest_observed_us", |
115 base::Int64ToString(frame->ack_delay_time.ToMicroseconds())); | 115 base::Int64ToString(frame->ack_delay_time.ToMicroseconds())); |
116 if (frame->missing) { | |
117 // Entropy and Truncated are not present in v34 and above. | |
118 dict->SetInteger("entropy_hash", frame->entropy_hash); | |
119 dict->SetBoolean("truncated", frame->is_truncated); | |
120 } | |
121 | 116 |
122 base::ListValue* missing = new base::ListValue(); | 117 base::ListValue* missing = new base::ListValue(); |
123 dict->Set("missing_packets", missing); | 118 dict->Set("missing_packets", missing); |
124 if (frame->missing) { | 119 if (!frame->packets.Empty()) { |
125 for (const Interval<QuicPacketNumber>& interval : frame->packets) { | |
126 for (QuicPacketNumber packet = interval.min(); packet < interval.max(); | |
127 ++packet) { | |
128 missing->AppendString(base::Uint64ToString(packet)); | |
129 } | |
130 } | |
131 } else if (!frame->packets.Empty()) { | |
132 // V34 and above express acked packets, but only print | 120 // V34 and above express acked packets, but only print |
133 // missing packets, because it's typically a shorter list. | 121 // missing packets, because it's typically a shorter list. |
134 for (QuicPacketNumber packet = frame->packets.Min(); | 122 for (QuicPacketNumber packet = frame->packets.Min(); |
135 packet < frame->largest_observed; ++packet) { | 123 packet < frame->largest_observed; ++packet) { |
136 if (!frame->packets.Contains(packet)) { | 124 if (!frame->packets.Contains(packet)) { |
137 missing->AppendString(base::Uint64ToString(packet)); | 125 missing->AppendString(base::Uint64ToString(packet)); |
138 } | 126 } |
139 } | 127 } |
140 } | 128 } |
141 | 129 |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 const char* const connection_description, | 289 const char* const connection_description, |
302 std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher, | 290 std::unique_ptr<SocketPerformanceWatcher> socket_performance_watcher, |
303 const NetLogWithSource& net_log) | 291 const NetLogWithSource& net_log) |
304 : net_log_(net_log), | 292 : net_log_(net_log), |
305 session_(session), | 293 session_(session), |
306 last_received_packet_number_(0), | 294 last_received_packet_number_(0), |
307 last_received_packet_size_(0), | 295 last_received_packet_size_(0), |
308 no_packet_received_after_ping_(false), | 296 no_packet_received_after_ping_(false), |
309 previous_received_packet_size_(0), | 297 previous_received_packet_size_(0), |
310 largest_received_packet_number_(0), | 298 largest_received_packet_number_(0), |
311 largest_received_missing_packet_number_(0), | |
312 num_out_of_order_received_packets_(0), | 299 num_out_of_order_received_packets_(0), |
313 num_out_of_order_large_received_packets_(0), | 300 num_out_of_order_large_received_packets_(0), |
314 num_packets_received_(0), | 301 num_packets_received_(0), |
315 num_frames_received_(0), | 302 num_frames_received_(0), |
316 num_duplicate_frames_received_(0), | 303 num_duplicate_frames_received_(0), |
317 num_incorrect_connection_ids_(0), | 304 num_incorrect_connection_ids_(0), |
318 num_undecryptable_packets_(0), | 305 num_undecryptable_packets_(0), |
319 num_duplicate_packets_(0), | 306 num_duplicate_packets_(0), |
320 num_blocked_frames_received_(0), | 307 num_blocked_frames_received_(0), |
321 num_blocked_frames_sent_(0), | 308 num_blocked_frames_sent_(0), |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 const size_t kApproximateLargestSoloAckBytes = 100; | 530 const size_t kApproximateLargestSoloAckBytes = 100; |
544 if (last_received_packet_number_ < received_acks_.size() && | 531 if (last_received_packet_number_ < received_acks_.size() && |
545 last_received_packet_size_ < kApproximateLargestSoloAckBytes) { | 532 last_received_packet_size_ < kApproximateLargestSoloAckBytes) { |
546 received_acks_[static_cast<size_t>(last_received_packet_number_)] = true; | 533 received_acks_[static_cast<size_t>(last_received_packet_number_)] = true; |
547 } | 534 } |
548 | 535 |
549 if (frame.packets.Empty()) | 536 if (frame.packets.Empty()) |
550 return; | 537 return; |
551 | 538 |
552 // TODO(rch, rtenneti) sort out histograms for QUIC_VERSION_34 and above. | 539 // TODO(rch, rtenneti) sort out histograms for QUIC_VERSION_34 and above. |
553 if (session_->connection()->version() > QUIC_VERSION_33) { | |
554 return; | |
555 } | |
556 const PacketNumberQueue& missing_packets = frame.packets; | |
557 PacketNumberQueue::const_iterator it = | |
558 missing_packets.lower_bound(largest_received_missing_packet_number_); | |
559 if (it == missing_packets.end() || | |
560 largest_received_missing_packet_number_ == missing_packets.Max()) { | |
561 return; | |
562 } | |
563 | |
564 // Scan through the list and log consecutive ranges of missing packets. | |
565 size_t num_consecutive_missing_packets = 1; | |
566 QuicPacketNumber previous_missing_packet = | |
567 largest_received_missing_packet_number_; | |
568 for (; it != missing_packets.end(); ++it) { | |
569 // Account for case where first interval starts below | |
570 // largest_received_missing_packet_number_. | |
571 QuicPacketNumber interval_min = | |
572 std::max(previous_missing_packet + 1, it->min()); | |
573 DCHECK_LE(interval_min, it->max()); | |
574 | |
575 size_t interval_len = it->max() - interval_min; | |
576 if (interval_len == 0) { | |
577 continue; | |
578 } | |
579 if (interval_min == previous_missing_packet + 1) { | |
580 num_consecutive_missing_packets += interval_len; | |
581 } else { | |
582 UpdatePacketGapSentHistogram(num_consecutive_missing_packets); | |
583 num_consecutive_missing_packets = interval_len; | |
584 } | |
585 previous_missing_packet = it->max() - 1; | |
586 } | |
587 UpdatePacketGapSentHistogram(num_consecutive_missing_packets); | |
588 largest_received_missing_packet_number_ = missing_packets.Max(); | |
589 } | 540 } |
590 | 541 |
591 void QuicConnectionLogger::OnStopWaitingFrame( | 542 void QuicConnectionLogger::OnStopWaitingFrame( |
592 const QuicStopWaitingFrame& frame) { | 543 const QuicStopWaitingFrame& frame) { |
593 net_log_.AddEvent(NetLogEventType::QUIC_SESSION_STOP_WAITING_FRAME_RECEIVED, | 544 net_log_.AddEvent(NetLogEventType::QUIC_SESSION_STOP_WAITING_FRAME_RECEIVED, |
594 base::Bind(&NetLogQuicStopWaitingFrameCallback, &frame)); | 545 base::Bind(&NetLogQuicStopWaitingFrameCallback, &frame)); |
595 } | 546 } |
596 | 547 |
597 void QuicConnectionLogger::OnRstStreamFrame(const QuicRstStreamFrame& frame) { | 548 void QuicConnectionLogger::OnRstStreamFrame(const QuicRstStreamFrame& frame) { |
598 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.QuicSession.RstStreamErrorCodeServer", | 549 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.QuicSession.RstStreamErrorCodeServer", |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
754 | 705 |
755 string prefix("Net.QuicSession.PacketLossRate_"); | 706 string prefix("Net.QuicSession.PacketLossRate_"); |
756 base::HistogramBase* histogram = base::Histogram::FactoryGet( | 707 base::HistogramBase* histogram = base::Histogram::FactoryGet( |
757 prefix + connection_description_, 1, 1000, 75, | 708 prefix + connection_description_, 1, 1000, 75, |
758 base::HistogramBase::kUmaTargetedHistogramFlag); | 709 base::HistogramBase::kUmaTargetedHistogramFlag); |
759 histogram->Add(static_cast<base::HistogramBase::Sample>( | 710 histogram->Add(static_cast<base::HistogramBase::Sample>( |
760 ReceivedPacketLossRate() * 1000)); | 711 ReceivedPacketLossRate() * 1000)); |
761 } | 712 } |
762 | 713 |
763 } // namespace net | 714 } // namespace net |
OLD | NEW |