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

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: 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 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_)) {
689 continue; 690 continue;
690 } 691 }
691 692
692 TimeSeries time_series; 693 TimeSeries time_series;
693 time_series.label = GetStreamName(stream_id); 694 time_series.label = GetStreamName(stream_id);
694 time_series.style = LINE_DOT_GRAPH; 695 time_series.style = LINE_DOT_GRAPH;
695 const uint64_t kWindowUs = 1000000; 696 const uint64_t kWindowUs = 1000000;
696 const LoggedRtpPacket* first_in_window = &packet_stream.front(); 697 const uint64_t kStep = 1000000;
697 const LoggedRtpPacket* last_in_window = &packet_stream.front(); 698 SequenceNumberUnwrapper unwrapper_;
698 int packets_in_window = 0; 699 SequenceNumberUnwrapper prior_unwrapper_;
699 for (const LoggedRtpPacket& packet : packet_stream) { 700 size_t window_index_begin = 0;
700 if (packet.timestamp > first_in_window->timestamp + kWindowUs) { 701 size_t window_index_end = 0;
701 uint16_t expected_num_packets = last_in_window->header.sequenceNumber - 702 int64_t highest_seq_number = 0;
702 first_in_window->header.sequenceNumber + 1; 703 int64_t highest_prior_seq_number = 0;
703 float fraction_lost = (expected_num_packets - packets_in_window) / 704 if (packet_stream.size() > 0) {
704 static_cast<float>(expected_num_packets); 705 unwrapper_.Unwrap(packet_stream[0].header.sequenceNumber);
705 float y = fraction_lost * 100; 706 prior_unwrapper_.Unwrap(packet_stream[0].header.sequenceNumber);
706 float x = 707 }
707 static_cast<float>(last_in_window->timestamp - begin_time_) / 708
708 1000000; 709 for (uint64_t t = begin_time_; t < end_time_ + kStep; t += kStep) {
710 while (window_index_end < packet_stream.size() &&
711 packet_stream[window_index_end].timestamp < t) {
712 int64_t sequence_number = unwrapper_.Unwrap(
713 packet_stream[window_index_end].header.sequenceNumber);
714 highest_seq_number = std::max(highest_seq_number, sequence_number);
715 ++window_index_end;
716 }
717 while (window_index_begin < packet_stream.size() &&
718 packet_stream[window_index_begin].timestamp < t - kWindowUs) {
719 int64_t sequence_number = prior_unwrapper_.Unwrap(
720 packet_stream[window_index_begin].header.sequenceNumber);
721 highest_prior_seq_number =
722 std::max(highest_prior_seq_number, sequence_number);
723 ++window_index_begin;
724 }
725 float x = static_cast<float>(t - begin_time_) / 1000000;
726 int64_t expected_packets = highest_seq_number - highest_prior_seq_number;
727 if (expected_packets > 0) {
728 int64_t received_packets = window_index_end - window_index_begin;
stefan-webrtc 2017/01/27 13:02:11 Is there any chance that this diff becomes zero ev
terelius 2017/01/27 14:03:11 The loop on line 700 advances the window_index_end
729 int64_t lost_packets = expected_packets - received_packets;
terelius 2017/01/27 14:03:11 Note, reordering or duplication can cause expected
minyue-webrtc 2017/01/30 08:22:34 Is this a flaw in RFC 3550?
terelius 2017/01/30 10:03:05 They are aware that the computation can give negat
730 float y = static_cast<float>(lost_packets) / expected_packets * 100;
709 time_series.points.emplace_back(x, y); 731 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 } 732 }
715 ++packets_in_window;
716 last_in_window = &packet;
717 } 733 }
718 plot->series_list_.push_back(std::move(time_series)); 734 plot->series_list_.push_back(std::move(time_series));
719 } 735 }
720 736
721 plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); 737 plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin);
722 plot->SetSuggestedYAxis(0, 1, "Estimated loss rate (%)", kBottomMargin, 738 plot->SetSuggestedYAxis(0, 1, "Estimated loss rate (%)", kBottomMargin,
723 kTopMargin); 739 kTopMargin);
724 plot->SetTitle("Estimated incoming loss rate"); 740 plot->SetTitle("Estimated incoming loss rate");
725 } 741 }
726 742
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
1190 int64_t capture_ms = packet.header.timestamp / 90.0; 1206 int64_t capture_ms = packet.header.timestamp / 90.0;
1191 int64_t arrival_ms = packet.timestamp / 1000.0; 1207 int64_t arrival_ms = packet.timestamp / 1000.0;
1192 timestamps.push_back(std::make_pair(capture_ms, arrival_ms)); 1208 timestamps.push_back(std::make_pair(capture_ms, arrival_ms));
1193 } 1209 }
1194 } 1210 }
1195 } 1211 }
1196 return timestamps; 1212 return timestamps;
1197 } 1213 }
1198 } // namespace plotting 1214 } // namespace plotting
1199 } // namespace webrtc 1215 } // 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