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

Side by Side Diff: webrtc/modules/remote_bitrate_estimator/test/packet_receiver.cc

Issue 1253473004: BWE Simulation Framework: Standard plot logging (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Comments addressed [2] Created 5 years, 5 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 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
(...skipping 14 matching lines...) Expand all
25 namespace bwe { 25 namespace bwe {
26 26
27 PacketReceiver::PacketReceiver(PacketProcessorListener* listener, 27 PacketReceiver::PacketReceiver(PacketProcessorListener* listener,
28 int flow_id, 28 int flow_id,
29 BandwidthEstimatorType bwe_type, 29 BandwidthEstimatorType bwe_type,
30 bool plot_delay, 30 bool plot_delay,
31 bool plot_bwe, 31 bool plot_bwe,
32 MetricRecorder* metric_recorder) 32 MetricRecorder* metric_recorder)
33 : PacketProcessor(listener, flow_id, kReceiver), 33 : PacketProcessor(listener, flow_id, kReceiver),
34 bwe_receiver_(CreateBweReceiver(bwe_type, flow_id, plot_bwe)), 34 bwe_receiver_(CreateBweReceiver(bwe_type, flow_id, plot_bwe)),
35 metric_recorder_(metric_recorder) { 35 metric_recorder_(metric_recorder),
36 plot_delay_(plot_delay),
37 last_delay_plot_ms_(0),
38 // #2 aligns the plot with the right axis.
39 delay_prefix_("Delay_ms#2"),
40 bwe_type_(bwe_type) {
36 if (metric_recorder_ != nullptr) { 41 if (metric_recorder_ != nullptr) {
37 // Setup the prefix ststd::rings used when logging. 42 // Setup the prefix std::strings used when logging.
38 std::vector<std::string> prefixes; 43 std::vector<std::string> prefixes;
39 44
40 std::stringstream ss1; 45 // Metric recorder plots them in separated figures,
41 ss1 << "Throughput_kbps_" << flow_id << "#2"; 46 // alignment will take place with the #1 left axis.
42 prefixes.push_back(ss1.str()); // Throughput. 47 prefixes.push_back("Throughput_kbps#1"); // Throughput.
43 48 prefixes.push_back("Delay_ms_#1"); // Delay.
44 std::stringstream ss2; 49 prefixes.push_back("Packet_Loss_#1"); // Loss.
45 ss2 << "Delay_ms_" << flow_id << "#2"; 50 prefixes.push_back("Objective_function_#1"); // Objective.
46 prefixes.push_back(ss2.str()); // Delay.
47
48 std::stringstream ss3;
49 ss3 << "Packet_Loss_" << flow_id << "#2";
50 prefixes.push_back(ss3.str()); // Loss.
51
52 std::stringstream ss4;
53 ss4 << "Objective_function_" << flow_id << "#2";
54 prefixes.push_back(ss4.str()); // Objective.
55 51
56 // Plot Total/PerFlow Available capacity together with throughputs. 52 // Plot Total/PerFlow Available capacity together with throughputs.
57 std::stringstream ss5; 53 prefixes.push_back("Throughput_kbps#1"); // Total Available.
58 ss5 << "Throughput_kbps" << flow_id << "#1"; 54 prefixes.push_back("Throughput_kbps#1"); // Available per flow.
59 prefixes.push_back(ss5.str()); // Total Available.
60 prefixes.push_back(ss5.str()); // Available per flow.
61 55
62 metric_recorder_->SetPlotInformation(prefixes); 56 bool plot_loss = plot_delay; // Plot loss if delay is plotted.
57 metric_recorder_->SetPlotInformation(prefixes, plot_delay, plot_loss);
63 } 58 }
64 } 59 }
65 60
66 PacketReceiver::PacketReceiver(PacketProcessorListener* listener, 61 PacketReceiver::PacketReceiver(PacketProcessorListener* listener,
67 int flow_id, 62 int flow_id,
68 BandwidthEstimatorType bwe_type, 63 BandwidthEstimatorType bwe_type,
69 bool plot_delay, 64 bool plot_delay,
70 bool plot_bwe) 65 bool plot_bwe)
71 : PacketReceiver(listener, 66 : PacketReceiver(listener,
72 flow_id, 67 flow_id,
(...skipping 22 matching lines...) Expand all
95 // time once packet reaches the estimator. 90 // time once packet reaches the estimator.
96 int64_t arrival_time_ms = media_packet->send_time_ms(); 91 int64_t arrival_time_ms = media_packet->send_time_ms();
97 int64_t send_time_ms = media_packet->creation_time_ms(); 92 int64_t send_time_ms = media_packet->creation_time_ms();
98 delay_stats_.Push(arrival_time_ms - send_time_ms); 93 delay_stats_.Push(arrival_time_ms - send_time_ms);
99 94
100 if (metric_recorder_ != nullptr) { 95 if (metric_recorder_ != nullptr) {
101 metric_recorder_->UpdateTime(arrival_time_ms); 96 metric_recorder_->UpdateTime(arrival_time_ms);
102 UpdateMetrics(arrival_time_ms, send_time_ms, 97 UpdateMetrics(arrival_time_ms, send_time_ms,
103 media_packet->payload_size()); 98 media_packet->payload_size());
104 metric_recorder_->PlotAllDynamics(); 99 metric_recorder_->PlotAllDynamics();
100 } else if (plot_delay_) {
101 PlotDelay(arrival_time_ms, send_time_ms);
105 } 102 }
106 103
107 bwe_receiver_->ReceivePacket(arrival_time_ms, *media_packet); 104 bwe_receiver_->ReceivePacket(arrival_time_ms, *media_packet);
108 FeedbackPacket* fb = bwe_receiver_->GetFeedback(arrival_time_ms); 105 FeedbackPacket* fb = bwe_receiver_->GetFeedback(arrival_time_ms);
109 if (fb) 106 if (fb)
110 feedback.push_back(fb); 107 feedback.push_back(fb);
111 delete media_packet; 108 delete media_packet;
112 it = in_out->erase(it); 109 it = in_out->erase(it);
113 } else { 110 } else {
114 ++it; 111 ++it;
115 } 112 }
116 } 113 }
117 // Insert feedback packets to be sent back to the sender. 114 // Insert feedback packets to be sent back to the sender.
118 in_out->merge(feedback, DereferencingComparator<Packet>); 115 in_out->merge(feedback, DereferencingComparator<Packet>);
119 } 116 }
120 117
121 void PacketReceiver::UpdateMetrics(int64_t arrival_time_ms, 118 void PacketReceiver::UpdateMetrics(int64_t arrival_time_ms,
122 int64_t send_time_ms, 119 int64_t send_time_ms,
123 size_t payload_size) { 120 size_t payload_size) {
124 metric_recorder_->UpdateThroughput(bwe_receiver_->RecentKbps(), payload_size); 121 metric_recorder_->UpdateThroughput(bwe_receiver_->RecentKbps(), payload_size);
125 metric_recorder_->UpdateDelay(arrival_time_ms - send_time_ms); 122 metric_recorder_->UpdateDelay(arrival_time_ms - send_time_ms);
126 metric_recorder_->UpdateLoss(bwe_receiver_->RecentPacketLossRatio()); 123 metric_recorder_->UpdateLoss(bwe_receiver_->RecentPacketLossRatio());
127 metric_recorder_->UpdateObjective(); 124 metric_recorder_->UpdateObjective();
128 } 125 }
129 126
127 void PacketReceiver::PlotDelay(int64_t arrival_time_ms, int64_t send_time_ms) {
128 const int64_t kDelayPlotIntervalMs = 100;
129 if (arrival_time_ms >= last_delay_plot_ms_ + kDelayPlotIntervalMs) {
130 BWE_TEST_LOGGING_PLOT_WITH_NAME(0, delay_prefix_, arrival_time_ms,
131 arrival_time_ms - send_time_ms,
132 bwe_names[bwe_type_]);
133 last_delay_plot_ms_ = arrival_time_ms;
134 }
135 }
136
130 float PacketReceiver::GlobalPacketLoss() { 137 float PacketReceiver::GlobalPacketLoss() {
131 return bwe_receiver_->GlobalReceiverPacketLossRatio(); 138 return bwe_receiver_->GlobalReceiverPacketLossRatio();
132 } 139 }
133 140
134 Stats<double> PacketReceiver::GetDelayStats() const { 141 Stats<double> PacketReceiver::GetDelayStats() const {
135 return delay_stats_; 142 return delay_stats_;
136 } 143 }
137 } // namespace bwe 144 } // namespace bwe
138 } // namespace testing 145 } // namespace testing
139 } // namespace webrtc 146 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698