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

Unified Diff: webrtc/modules/congestion_controller/probe_bitrate_estimator.cc

Issue 2254733005: Only use payload size within the receive/send interval for bitrate probing. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Keep track of the size of the last/first sent/receive packet. Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/congestion_controller/probe_bitrate_estimator.cc
diff --git a/webrtc/modules/congestion_controller/probe_bitrate_estimator.cc b/webrtc/modules/congestion_controller/probe_bitrate_estimator.cc
index 561fde939180b74e0cad8b606952487c984eabbd..98efb623587d23a2fc9ccf4ca7edd88583a34c87 100644
--- a/webrtc/modules/congestion_controller/probe_bitrate_estimator.cc
+++ b/webrtc/modules/congestion_controller/probe_bitrate_estimator.cc
@@ -47,16 +47,23 @@ ProbingResult ProbeBitrateEstimator::PacketFeedback(
return ProbingResult();
}
+ int payload_size = packet_info.payload_size * 8;
danilchap 2016/08/22 13:53:35 may be call it payload_size_bits
philipel 2016/08/22 14:06:40 Done.
AggregatedCluster* cluster = &clusters_[packet_info.probe_cluster_id];
- cluster->first_send_ms =
- std::min(cluster->first_send_ms, packet_info.send_time_ms);
- cluster->last_send_ms =
- std::max(cluster->last_send_ms, packet_info.send_time_ms);
- cluster->first_receive_ms =
- std::min(cluster->first_receive_ms, packet_info.arrival_time_ms);
- cluster->last_receive_ms =
- std::max(cluster->last_receive_ms, packet_info.arrival_time_ms);
- cluster->size += packet_info.payload_size * 8;
+ if (packet_info.send_time_ms < cluster->first_send_ms) {
+ cluster->first_send_ms = packet_info.send_time_ms;
+ }
+ if (packet_info.send_time_ms > cluster->last_send_ms) {
+ cluster->last_send_ms = packet_info.send_time_ms;
+ cluster->size_last_send = payload_size;
+ }
+ if (packet_info.arrival_time_ms < cluster->first_receive_ms) {
+ cluster->first_receive_ms = packet_info.arrival_time_ms;
+ cluster->size_first_receive = payload_size;
+ }
+ if (packet_info.arrival_time_ms > cluster->last_receive_ms) {
+ cluster->last_receive_ms = packet_info.arrival_time_ms;
+ }
+ cluster->size_total += payload_size;
cluster->num_probes += 1;
// Clean up old clusters.
@@ -70,14 +77,6 @@ ProbingResult ProbeBitrateEstimator::PacketFeedback(
float receive_interval_ms =
cluster->last_receive_ms - cluster->first_receive_ms;
- // Since the send/receive interval does not include the send/receive time of
- // the last/first packet we expand the interval by the average inverval
- // between the probing packets.
- float interval_correction =
- static_cast<float>(cluster->num_probes) / (cluster->num_probes - 1);
- send_interval_ms *= interval_correction;
- receive_interval_ms *= interval_correction;
-
if (send_interval_ms == 0 || receive_interval_ms == 0) {
LOG(LS_INFO) << "Probing unsuccessful, invalid send/receive interval"
<< " [cluster id: " << packet_info.probe_cluster_id
@@ -86,16 +85,25 @@ ProbingResult ProbeBitrateEstimator::PacketFeedback(
return ProbingResult();
}
- float send_bps = static_cast<float>(cluster->size) / send_interval_ms * 1000;
- float receive_bps =
- static_cast<float>(cluster->size) / receive_interval_ms * 1000;
+ // Since the |send_interval_ms| does not include the time it takes to actually
+ // send the last packet the size of the last sent packet should not be
+ // included when calculating the send bitrate.
+ float send_size = cluster->size_total - cluster->size_last_send;
danilchap 2016/08/22 13:53:35 probably RTC_DCHECK_GT(cluster->size_total - clust
philipel 2016/08/22 14:06:40 Done.
+ float send_bps = send_size / send_interval_ms * 1000;
+
+ // Since the |receive_interval_ms| does not include the time it takes to
+ // actually receive the first packet the size of the first received packet
+ // should not be included when calculating the receive bitrate.
+ float receive_size = cluster->size_total - cluster->size_first_receive;
+ float receive_bps = receive_size / receive_interval_ms * 1000;
+
float ratio = receive_bps / send_bps;
if (ratio > kValidRatio) {
LOG(LS_INFO) << "Probing unsuccessful, receive/send ratio too high"
<< " [cluster id: " << packet_info.probe_cluster_id
- << "] [send: " << cluster->size << " bytes / "
- << send_interval_ms << " ms = " << send_bps / 1000 << " kb/s]"
- << " [receive: " << cluster->size << " bytes / "
+ << "] [send: " << send_size << " bytes / " << send_interval_ms
+ << " ms = " << send_bps / 1000 << " kb/s]"
+ << " [receive: " << receive_size << " bytes / "
<< receive_interval_ms << " ms = " << receive_bps / 1000
<< " kb/s]"
<< " [ratio: " << receive_bps / 1000 << " / "
@@ -109,9 +117,9 @@ ProbingResult ProbeBitrateEstimator::PacketFeedback(
last_valid_cluster_id_ = packet_info.probe_cluster_id;
LOG(LS_INFO) << "Probing successful"
<< " [cluster id: " << packet_info.probe_cluster_id
- << "] [send: " << cluster->size << " bytes / "
- << send_interval_ms << " ms = " << send_bps / 1000 << " kb/s]"
- << " [receive: " << cluster->size << " bytes / "
+ << "] [send: " << send_size << " bytes / " << send_interval_ms
+ << " ms = " << send_bps / 1000 << " kb/s]"
+ << " [receive: " << receive_size << " bytes / "
<< receive_interval_ms << " ms = " << receive_bps / 1000
<< " kb/s]";

Powered by Google App Engine
This is Rietveld 408576698