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

Side by Side Diff: webrtc/tools/event_log_visualizer/analyzer.cc

Issue 2656333002: Compute packet loss for event log visualization similar to how it is defined in RFC 3550. (Closed)
Patch Set: Fix incorrect loss rate for first sample. Created 3 years, 10 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/tools/event_log_visualizer/analyzer.h" 11 #include "webrtc/tools/event_log_visualizer/analyzer.h"
12 12
13 #include <algorithm> 13 #include <algorithm>
14 #include <limits> 14 #include <limits>
15 #include <map> 15 #include <map>
16 #include <sstream> 16 #include <sstream>
17 #include <string> 17 #include <string>
18 #include <utility> 18 #include <utility>
19 19
20 #include "webrtc/base/checks.h" 20 #include "webrtc/base/checks.h"
21 #include "webrtc/base/logging.h" 21 #include "webrtc/base/logging.h"
22 #include "webrtc/base/rate_statistics.h" 22 #include "webrtc/base/rate_statistics.h"
23 #include "webrtc/call/audio_receive_stream.h" 23 #include "webrtc/call/audio_receive_stream.h"
24 #include "webrtc/call/audio_send_stream.h" 24 #include "webrtc/call/audio_send_stream.h"
25 #include "webrtc/call/call.h" 25 #include "webrtc/call/call.h"
26 #include "webrtc/common_types.h" 26 #include "webrtc/common_types.h"
27 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" 27 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h"
28 #include "webrtc/modules/congestion_controller/include/congestion_controller.h" 28 #include "webrtc/modules/congestion_controller/include/congestion_controller.h"
29 #include "webrtc/modules/include/module_common_types.h"
29 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" 30 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h"
30 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" 31 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
31 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/common_header.h" 32 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/common_header.h"
32 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h" 33 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h"
33 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extensions.h" 34 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extensions.h"
34 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" 35 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h"
35 #include "webrtc/video_receive_stream.h" 36 #include "webrtc/video_receive_stream.h"
36 #include "webrtc/video_send_stream.h" 37 #include "webrtc/video_send_stream.h"
37 38
38 namespace webrtc { 39 namespace webrtc {
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 kTopMargin); 679 kTopMargin);
679 plot->SetTitle("Sequence number"); 680 plot->SetTitle("Sequence number");
680 } 681 }
681 682
682 void EventLogAnalyzer::CreateIncomingPacketLossGraph(Plot* plot) { 683 void EventLogAnalyzer::CreateIncomingPacketLossGraph(Plot* plot) {
683 for (auto& kv : rtp_packets_) { 684 for (auto& kv : rtp_packets_) {
684 StreamId stream_id = kv.first; 685 StreamId stream_id = kv.first;
685 const std::vector<LoggedRtpPacket>& packet_stream = kv.second; 686 const std::vector<LoggedRtpPacket>& packet_stream = kv.second;
686 // Filter on direction and SSRC. 687 // Filter on direction and SSRC.
687 if (stream_id.GetDirection() != kIncomingPacket || 688 if (stream_id.GetDirection() != kIncomingPacket ||
688 !MatchingSsrc(stream_id.GetSsrc(), desired_ssrc_)) { 689 !MatchingSsrc(stream_id.GetSsrc(), desired_ssrc_) ||
690 packet_stream.size() == 0) {
689 continue; 691 continue;
690 } 692 }
691 693
692 TimeSeries time_series; 694 TimeSeries time_series;
693 time_series.label = GetStreamName(stream_id); 695 time_series.label = GetStreamName(stream_id);
694 time_series.style = LINE_DOT_GRAPH; 696 time_series.style = LINE_DOT_GRAPH;
695 const uint64_t kWindowUs = 1000000; 697 const uint64_t kWindowUs = 1000000;
696 const LoggedRtpPacket* first_in_window = &packet_stream.front(); 698 const uint64_t kStep = 1000000;
697 const LoggedRtpPacket* last_in_window = &packet_stream.front(); 699 SequenceNumberUnwrapper unwrapper_;
698 int packets_in_window = 0; 700 SequenceNumberUnwrapper prior_unwrapper_;
699 for (const LoggedRtpPacket& packet : packet_stream) { 701 size_t window_index_begin = 0;
700 if (packet.timestamp > first_in_window->timestamp + kWindowUs) { 702 size_t window_index_end = 0;
701 uint16_t expected_num_packets = last_in_window->header.sequenceNumber - 703 int64_t highest_seq_number =
minyue-webrtc 2017/01/30 12:05:44 should it be more correct to placed after 708, and
terelius 2017/01/30 14:49:34 Without these lines, highest_prior_seq_number won'
702 first_in_window->header.sequenceNumber + 1; 704 unwrapper_.Unwrap(packet_stream[0].header.sequenceNumber) - 1;
703 float fraction_lost = (expected_num_packets - packets_in_window) / 705 int64_t highest_prior_seq_number =
minyue-webrtc 2017/01/30 12:05:44 and this maybe after 715
terelius 2017/01/30 14:49:34 We could track the highest sequence number reporte
704 static_cast<float>(expected_num_packets); 706 prior_unwrapper_.Unwrap(packet_stream[0].header.sequenceNumber) - 1;
705 float y = fraction_lost * 100; 707
706 float x = 708 for (uint64_t t = begin_time_; t < end_time_ + kStep; t += kStep) {
707 static_cast<float>(last_in_window->timestamp - begin_time_) / 709 while (window_index_end < packet_stream.size() &&
708 1000000; 710 packet_stream[window_index_end].timestamp < t) {
711 int64_t sequence_number = unwrapper_.Unwrap(
712 packet_stream[window_index_end].header.sequenceNumber);
713 highest_seq_number = std::max(highest_seq_number, sequence_number);
714 ++window_index_end;
715 }
716 while (window_index_begin < packet_stream.size() &&
717 packet_stream[window_index_begin].timestamp < t - kWindowUs) {
718 int64_t sequence_number = prior_unwrapper_.Unwrap(
719 packet_stream[window_index_begin].header.sequenceNumber);
720 highest_prior_seq_number =
721 std::max(highest_prior_seq_number, sequence_number);
722 ++window_index_begin;
723 }
724 float x = static_cast<float>(t - begin_time_) / 1000000;
725 int64_t expected_packets = highest_seq_number - highest_prior_seq_number;
726 if (expected_packets > 0) {
727 int64_t received_packets = window_index_end - window_index_begin;
728 int64_t lost_packets = expected_packets - received_packets;
729 float y = static_cast<float>(lost_packets) / expected_packets * 100;
709 time_series.points.emplace_back(x, y); 730 time_series.points.emplace_back(x, y);
710 first_in_window = &packet;
711 last_in_window = &packet;
712 packets_in_window = 1;
713 continue;
714 } 731 }
715 ++packets_in_window;
716 last_in_window = &packet;
717 } 732 }
718 plot->series_list_.push_back(std::move(time_series)); 733 plot->series_list_.push_back(std::move(time_series));
719 } 734 }
720 735
721 plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); 736 plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin);
722 plot->SetSuggestedYAxis(0, 1, "Estimated loss rate (%)", kBottomMargin, 737 plot->SetSuggestedYAxis(0, 1, "Estimated loss rate (%)", kBottomMargin,
723 kTopMargin); 738 kTopMargin);
724 plot->SetTitle("Estimated incoming loss rate"); 739 plot->SetTitle("Estimated incoming loss rate");
725 } 740 }
726 741
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
1190 int64_t capture_ms = packet.header.timestamp / 90.0; 1205 int64_t capture_ms = packet.header.timestamp / 90.0;
1191 int64_t arrival_ms = packet.timestamp / 1000.0; 1206 int64_t arrival_ms = packet.timestamp / 1000.0;
1192 timestamps.push_back(std::make_pair(capture_ms, arrival_ms)); 1207 timestamps.push_back(std::make_pair(capture_ms, arrival_ms));
1193 } 1208 }
1194 } 1209 }
1195 } 1210 }
1196 return timestamps; 1211 return timestamps;
1197 } 1212 }
1198 } // namespace plotting 1213 } // namespace plotting
1199 } // namespace webrtc 1214 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698