webrtc_cc_probe (webrtc v0.1.0)

View Source

Bandwidth probing, without I/O: probe clusters sent ahead of the estimate and the bitrate they show, as libwebrtc's probe controller and probe bitrate estimator do.

Without probes the estimate grows from its start value by about 8% a second (draft-ietf-rmcat-gcc §5.5), so a 2 Mbps link takes seconds to fill. Once media flows with transport-wide feedback, clusters of padding packets are sent at 3 and 6 times the start bitrate, each for at least 15 ms and 5 packets. The feedback on a cluster gives a send rate and a receive rate; with 80% of its packets received the result is the smaller of the two, 95% of the receive rate when the link could not carry the cluster. A result above 70% of the probed rate probes again at twice the result, up to max_bitrate.

After start-up, update/3 follows the estimate and the sending rate and probes again, as libwebrtc's ProbeController does:

  • Application limited (ALR): sending under 65% of the estimate for 500 ms, until it is back over 80%. While it lasts a cluster at twice the estimate goes every 5 s, so the estimate keeps up with the link while the application sends little.
  • After a large drop while application limited or within 3 s of it: the estimate fell under 66% of its previous value, the delay detector leaves over-use within 5 s, a probe at 85% of the rate before the drop would still raise it, and no such probe went in the last 5 s. A sender that fills its share does not probe after a drop: the drop came from a competing flow or a smaller link, and probing it back refills the queue.
  • On a raised max_bitrate (max_raised/5): the estimate was at the old maximum, so the new one is probed at once.

At most one cluster is in flight, and these probes are limited to 10 a minute.

While a cluster is sent, media that leaves is part of it (media/3), as libwebrtc's pacer does: padding only makes up the difference with the cluster's rate, and the result counts every packet of the cluster, so media in flight does not make the link look slower.

handle_timeout/2 returns {probe, Cluster, Size} padding packets to send now; the caller tags them with the cluster in the transport-wide send history so feedback/3 sees which results belong to a probe.

Summary

Functions

Transport-wide results of probe packets, {Cluster, SendUs, ArrivalUs | lost, Size}. Returns the bitrates of the clusters that are complete.

Padding packets due now, {probe, ClusterId, Size}: what the cluster's rate allows since it started, less what already left.

max_bitrate went from Old to New: an estimate capped at Old probes New at once.

A media packet of Size bytes leaves now: while a cluster is being sent it is part of it, and the caller tags it with the cluster ({probe, Id}) in the transport-wide send history.

Options: probing (default true) and max_bitrate.

Media started with transport-wide feedback: schedule the initial clusters from the start bitrate. Only the first call counts.

Follow the estimate (estimate), the rate being sent (sending, bps over the last second) and the delay detector state (delay_state), probing when the sender is application limited or after a large drop.

Types

state/0

-opaque state()

Functions

feedback(Results, Now, P)

-spec feedback([{pos_integer(), integer(), integer() | lost, non_neg_integer()}], integer(), state()) ->
                  {[pos_integer()], state()}.

Transport-wide results of probe packets, {Cluster, SendUs, ArrivalUs | lost, Size}. Returns the bitrates of the clusters that are complete.

handle_timeout(Now, P0)

-spec handle_timeout(integer(), state()) -> {[{probe, pos_integer(), pos_integer()}], state()}.

Padding packets due now, {probe, ClusterId, Size}: what the cluster's rate allows since it started, less what already left.

info(Probe)

-spec info(state()) -> map().

max_raised(Now, Old, New, E, Probe)

-spec max_raised(integer(), pos_integer(), pos_integer(), pos_integer(), state()) -> state().

max_bitrate went from Old to New: an estimate capped at Old probes New at once.

media(Now, Size, Probe)

-spec media(integer(), non_neg_integer(), state()) -> {undefined | pos_integer(), state()}.

A media packet of Size bytes leaves now: while a cluster is being sent it is part of it, and the caller tags it with the cluster ({probe, Id}) in the transport-wide send history.

new(Opts)

-spec new(map()) -> state().

Options: probing (default true) and max_bitrate.

next_timeout(Probe)

-spec next_timeout(state()) -> integer() | infinity.

start(Now, StartBps, Probe)

-spec start(integer(), pos_integer(), state()) -> state().

Media started with transport-wide feedback: schedule the initial clusters from the start bitrate. Only the first call counts.

update(Now, _, Probe)

-spec update(integer(),
             #{estimate := pos_integer(), sending := non_neg_integer(), delay_state := atom()},
             state()) ->
                state().

Follow the estimate (estimate), the rate being sent (sending, bps over the last second) and the delay detector state (delay_state), probing when the sender is application limited or after a large drop.