{"id":517,"date":"2022-03-08T19:46:25","date_gmt":"2022-03-08T11:46:25","guid":{"rendered":"https:\/\/www.fanyamin.com\/wordpress\/?p=517"},"modified":"2022-03-08T20:12:22","modified_gmt":"2022-03-08T12:12:22","slug":"bandwidth-probe-and-estimation","status":"publish","type":"post","link":"https:\/\/www.fanyamin.com\/wordpress\/?p=517","title":{"rendered":"bandwidth probe and estimation"},"content":{"rendered":"<h1>1. \u4ec0\u4e48\u65f6\u5019\u4f1a\u89e6\u53d1\u63a2\u6d4b<\/h1>\n<p>1\uff09network available at startup \u5728\u542f\u52a8\u65f6\u7f51\u7edc\u8fde\u901a\u65f6<br \/>\n2\uff09enable periodic alr probing \u542f\u7528\u4e86\u5b9a\u65f6 ALR \u63a2\u6d4b<br \/>\n3\uff09large drop in estimated bandwidth \u53d1\u73b0\u8bc4\u4f30\u7684\u5e26\u5bbd\u6709\u5927\u5e45\u8870\u51cf<br \/>\n4) probing results indicate channel has greater capacity \u63a2\u6d4b\u7ed3\u679c\u63ed\u793a\u6709\u66f4\u5927\u7684\u5bb9\u91cf<\/p>\n<h1>2. \u5e26\u5bbd\u63a2\u6d4b\u7684\u914d\u7f6e<\/h1>\n<blockquote>\n<p>These parameters configure the initial probes. First we send one or two probes of sizes p1 <em> start_bitrate<em>bps<\/em> and p2 <\/em> start_bitrate<em>bps<\/em>. Then whenever we get a bitrate estimate of at least further_probe_threshold times the size of the last sent probe we'll send another one of size step_size times the new estimate.<\/p>\n<\/blockquote>\n<ul>\n<li>\u63a2\u6d4b\u65f6\u4f1a\u8bbe\u7f6e\u4e00\u4e2a\u521d\u59cb\u5e26\u5bbd, \u4e58\u4ee5\u4e0d\u540c\u7684\u6bd4\u4f8b\u7cfb\u6570\u6765\u53d1\u9001<\/li>\n<\/ul>\n<p>\u4f8b\u5982\u521d\u59cb\u5e26\u5bbd\u4e3a 300k, p1(first_exponential_probe_scale)=3, p2(second_exponential_probe_scale)=6<\/p>\n<p>\u7136\u540e\uff0c\u6bcf\u5f53\u6211\u4eec\u5f97\u5230\u4e00\u4e2a\u6bd4\u7279\u7387\u4f30\u8ba1\u503c\u81f3\u5c11\u662f\u4e0a\u4e00\u6b21\u53d1\u9001\u63a2\u6d4b\u7684\u5927\u5c0f\u7684  further_probe_threshold \u500d\u65f6\uff0c\u6211\u4eec\u5c06\u53d1\u9001\u53e6\u4e00\u4e2a\u5927\u5c0f\u4e3a step_size \u4e58\u4ee5\u65b0\u4f30\u8ba1\u503c\u7684\u6bd4\u7279\u7387\u3002<\/p>\n<p>\u7b2c\u4e00\u6b21\u4e3a 300 <em> 3 = 900 kbps<br \/>\n\u7b2c\u4e8c\u6b21\u4e3a 300 <\/em> 6 = 1800 kbps<\/p>\n<pre><code class=\"language-cpp\">struct ProbeControllerConfig {\n  explicit ProbeControllerConfig(const WebRtcKeyValueConfig* key_value_config);\n  ProbeControllerConfig(const ProbeControllerConfig&amp;);\n  ProbeControllerConfig&amp; operator=(const ProbeControllerConfig&amp;) = default;\n  ~ProbeControllerConfig();\n\n  \/\/ These parameters configure the initial probes. First we send one or two\n  \/\/ probes of sizes p1 * start_bitrate_bps_ and p2 * start_bitrate_bps_.\n  \/\/ Then whenever we get a bitrate estimate of at least further_probe_threshold\n  \/\/ times the size of the last sent probe we&#039;ll send another one of size\n  \/\/ step_size times the new estimate.\n  FieldTrialParameter&lt;double&gt; first_exponential_probe_scale;\n  FieldTrialOptional&lt;double&gt; second_exponential_probe_scale;\n  FieldTrialParameter&lt;double&gt; further_exponential_probe_scale;\n  FieldTrialParameter&lt;double&gt; further_probe_threshold;\n\n  \/\/ Configures how often we send ALR probes and how big they are.\n  FieldTrialParameter&lt;TimeDelta&gt; alr_probing_interval;\n  FieldTrialParameter&lt;double&gt; alr_probe_scale;\n\n  \/\/ Configures the probes emitted by changed to the allocated bitrate.\n  FieldTrialOptional&lt;double&gt; first_allocation_probe_scale;\n  FieldTrialOptional&lt;double&gt; second_allocation_probe_scale;\n  FieldTrialFlag allocation_allow_further_probing;\n  FieldTrialParameter&lt;DataRate&gt; allocation_probe_max;\n};<\/code><\/pre>\n<p>\u521d\u59cb\u7684\u7f3a\u7701\u503c\u5982\u4e0b<\/p>\n<pre><code class=\"language-cpp\">\/\/ The minimum number probing packets used. \u6700\u5c11\u53d1\u9001\u7684\u63a2\u6d4b\u5305\u4e2a\u6570 5 \u4e2a\u5305\nconstexpr int kMinProbePacketsSent = 5;\n\n\/\/ The minimum probing duration in ms. \u6700\u77ed\u63a2\u6d4b\u7684\u65f6\u95f4 15ms\nconstexpr int kMinProbeDurationMs = 15;\n\n\/\/ Maximum waiting time from the time of initiating probing to getting\n\/\/ the measured results back.\n\/\/ \u5bf9\u53d1\u8d77\u7684\u63a2\u6d4b\u7ed3\u679c\u7684\u6700\u957f\u7b49\u5f85\u65f6\u95f4, \u9ed8\u8ba4\u4e3a 1000ms\nconstexpr int64_t kMaxWaitingTimeForProbingResultMs = 1000;\n\n\/\/ Value of `min_bitrate_to_probe_further_bps_` that indicates\n\/\/ further probing is disabled.\n\/\/ \u662f\u5426\u8fdb\u884c\u8fdb\u4e00\u6b65\u7684\u63a2\u6d4b\nconstexpr int kExponentialProbingDisabled = 0;\n\n\/\/ Default probing bitrate limit. Applied only when the application didn&#039;t\n\/\/ specify max bitrate.\n\/\/ \u9ed8\u8ba4\u7684\u63a2\u6d4b\u5e26\u5bbd\u9650\u5236, \u5982\u679c\u5e94\u7528\u7a0b\u5e8f\u6ca1\u6709\u6307\u5b9a\u6700\u5927\u5e26\u5bbd,\u9ed8\u8ba4\u4e3a 5m bps\nconstexpr int64_t kDefaultMaxProbingBitrateBps = 5000000;\n\n\/\/ If the bitrate drops to a factor `kBitrateDropThreshold` or lower\n\/\/ and we recover within `kBitrateDropTimeoutMs`, then we&#039;ll send\n\/\/ a probe at a fraction `kProbeFractionAfterDrop` of the original bitrate.\n\/\/ \u5982\u679c\u5e26\u5bbd\u5728 kBitrateDropTimeoutMs(\u9ed8\u8ba4\u4e3a 5000ms) \u65f6\u957f\u4e0b\u964d\u5230\u539f\u5148\u7684 kBitrateDropThreshold\uff08\u9ed8\u8ba4\u4e3a 66%)\u3000\u6216\u66f4\u4f4e\uff0c\u6211\u4eec\u4f1a\u53d1\u9001\u4e00\u4e2a\u5927\u5c0f\u4e3a\u539f\u5148\u5e26\u5bbd\u7684 kProbeFractionAfterDrop(\u9ed8\u8ba4\u7cfb\u6570\u4e3a 0.85) \u6bd4\u7387\u7684\u63a2\u6d4b\u5305.\nconstexpr double kBitrateDropThreshold = 0.66;\nconstexpr int kBitrateDropTimeoutMs = 5000;\nconstexpr double kProbeFractionAfterDrop = 0.85;\n\n\/\/ Timeout for probing after leaving ALR. If the bitrate drops significantly,\n\/\/ (as determined by the delay based estimator) and we leave ALR, then we will\n\/\/ send a probe if we recover within `kLeftAlrTimeoutMs` ms.\n\/\/ \u5728\u79bb\u5f00\u5e94\u7528\u53d7\u9650\u533a\u95f4(ALR) \u7684\u8d85\u65f6 kAlrEndedTimeoutMs(\u9ed8\u8ba4\u4e3a 3 \u79d2) \u540e, \u5982\u679c\u5e26\u5bbd\u663e\u8457\u964d\u4f4e,\u800c\u4e14\u6211\u4eec\u79bb\u5f00\u4e86 ALR, \u90a3\u4e48\u5230\u8fbe kLeftAlrTimeoutMs \u7684\u65f6\u957f \u6211\u4eec\u4f1a\u53d1\u9001\u4e00\u4e2a\u63a2\u6d4b\u5305\nconstexpr int kAlrEndedTimeoutMs = 3000;\n\n\/\/ This is a limit on how often probing can be done when there is a BW\n\/\/ drop detected in ALR.\n\/\/  \u5728 ALR \u4e2d\u5f53\u6709\u4e00\u4e2a\u5e26\u5bbd\u4e0b\u964d\u65f6 \u5bf9\u4e8e\u63a2\u6d4b\u5b8c\u6210\u9891\u7387\u7684\u9650\u5236\nconstexpr int64_t kMinTimeBetweenAlrProbesMs = 5000;\n\n\/\/ The expected uncertainty of probe result (as a fraction of the target probe\n\/\/ bitrate). Used to avoid probing if the probe bitrate is close to our current\n\/\/ estimate.\n\/\/ \u4e0d\u786e\u5b9a\u7684\u63a2\u6d4b\u7ed3\u679c, \u5b83\u662f\u5bf9\u4e8e\u76ee\u6807\u63a2\u6d4b\u5e26\u5bbd\u7684\u6bd4\u7387, \u7528\u6765\u5728\u63a2\u6d4b\u5e26\u5bbd\u63a5\u8fd1\u5f53\u524d\u4f30\u8ba1\u65f6\u907f\u514d\u8fd8\u5728\u63a2\u6d4b\nconstexpr double kProbeUncertainty = 0.05;\n\n\/\/ Use probing to recover faster after large bitrate estimate drops.\n\/\/ \u7279\u6027\u5f00\u5173: \u5728\u6709\u5927\u5e45\u5e26\u5bbd\u4e0b\u964d\u65f6\u7528\u63a2\u6d4b\u6765\u5feb\u901f\u6062\u590d\nconstexpr char kBweRapidRecoveryExperiment[] =\n    &quot;WebRTC-BweRapidRecoveryExperiment&quot;;\n\/\/ \u7279\u6027\u5f00\u5173: \u5728\u5230\u8fbe\u914d\u7f6e\u7684\u6700\u5927\u5206\u914d\u5e26\u5bbd\u540e\u4e0d\u518d\u63a2\u6d4b\n\/\/ Never probe higher than configured by OnMaxTotalAllocatedBitrate().\nconstexpr char kCappedProbingFieldTrialName[] = &quot;WebRTC-BweCappedProbing&quot;;\n\nProbeControllerConfig::ProbeControllerConfig(\n    const WebRtcKeyValueConfig* key_value_config)\n    : first_exponential_probe_scale(&quot;p1&quot;, 3.0),\n      second_exponential_probe_scale(&quot;p2&quot;, 6.0),\n      further_exponential_probe_scale(&quot;step_size&quot;, 2),\n      further_probe_threshold(&quot;further_probe_threshold&quot;, 0.7),\n      alr_probing_interval(&quot;alr_interval&quot;, TimeDelta::Seconds(5)),\n      alr_probe_scale(&quot;alr_scale&quot;, 2),\n      first_allocation_probe_scale(&quot;alloc_p1&quot;, 1),\n      second_allocation_probe_scale(&quot;alloc_p2&quot;, 2),\n      allocation_allow_further_probing(&quot;alloc_probe_further&quot;, false),\n      allocation_probe_max(&quot;alloc_probe_max&quot;, DataRate::PlusInfinity()) {\n     \/\/... \n      }<\/code><\/pre>\n<h1>3. \u5e26\u5bbd\u63a2\u6d4b\u7684\u65b9\u6cd5<\/h1>\n<ul>\n<li>ProbeController \u6839\u636e\u5f53\u524d\u7f51\u7edc\u72b6\u51b5\u63a7\u5236\u4f55\u65f6,\u5982\u4f55\u8fdb\u884c\u5e26\u5bbd\u63a2\u6d4b<\/li>\n<li>ProbeBitrateEstimator \u6839\u636e\u63a2\u6d4b\u5305\u7684\u53cd\u9988\u6d88\u606f,\u4f30\u7b97\u5e26\u5bbd<\/li>\n<\/ul>\n<blockquote>\n<p>A probe cluster consists of a set of probes. Each probe in turn can be divided into a number of packets to accommodate the MTU on the network.<\/p>\n<\/blockquote>\n<ul>\n<li>Probe Cluster \u63a2\u6d4b\u96c6\u5408\u5305\u542b\u4e00\u7ec4\u63a2\u6d4b\uff0c\u6bcf\u4e00\u4e2a\u63a2\u6d4b\u4f9d\u6b21\u53ef\u88ab\u5206\u5272\u6210\u4e00\u4e9b\u5305\u6765\u7b26\u5408\u7f51\u7edc\u4e2d\u7684 MTU \u9650\u5236\uff0c<\/li>\n<\/ul>\n<p>\u53d1\u9001\u7684\u63a2\u6d4b\u5305\u4e2d\u4f1a\u6709\u5305\u4fe1\u606f\u5757,\u5305\u542b\u4e86\u63a2\u6d4b\u7684\u4fe1\u606f<\/p>\n<pre><code class=\"language-cpp\">    struct PacedPacketInfo {\n        PacedPacketInfo();\n        PacedPacketInfo(int probe_cluster_id,\n                        int probe_cluster_min_probes,\n                        int probe_cluster_min_bytes);\n\n        bool operator==(const PacedPacketInfo&amp; rhs) const;\n\n        \/\/ TODO(srte): Move probing info to a separate, optional struct.\n        static constexpr int kNotAProbe = -1;\n        int send_bitrate_bps = -1;\n        int probe_cluster_id = kNotAProbe;\n        int probe_cluster_min_probes = -1;\n        int probe_cluster_min_bytes = -1;\n        int probe_cluster_bytes_sent = 0;\n    };<\/code><\/pre>\n<h1>4. \u5e26\u5bbd\u63a2\u6d4b\u7684\u8bc4\u4f30<\/h1>\n","protected":false},"excerpt":{"rendered":"<p>1. \u4ec0\u4e48\u65f6\u5019\u4f1a\u89e6\u53d1\u63a2\u6d4b 1\uff09network available at startup \u5728\u542f\u52a8\u65f6\u7f51\u7edc\u8fde\u901a\u65f6 2\uff09enable periodic alr probing \u542f\u7528\u4e86\u5b9a\u65f6 ALR \u63a2\u6d4b 3\uff09large drop in estimated bandwidth \u53d1\u73b0\u8bc4\u4f30\u7684\u5e26\u5bbd\u6709\u5927\u5e45\u8870\u51cf 4) probing results indicate channel has greater capacity \u63a2\u6d4b\u7ed3\u679c\u63ed\u793a\u6709\u66f4\u5927\u7684\u5bb9\u91cf 2. \u5e26\u5bbd\u63a2\u6d4b\u7684\u914d\u7f6e These parameters configure the initial probes. First we send one or two probes of sizes p1 start_bitratebps and p2 start_bitratebps. Then whenever we get [&hellip;] <a class=\"read-more\" href=\"https:\/\/www.fanyamin.com\/wordpress\/?p=517\" title=\"Permanent Link to: bandwidth probe and estimation\">&rarr;Read&nbsp;more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-517","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/517"}],"collection":[{"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=517"}],"version-history":[{"count":8,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/517\/revisions"}],"predecessor-version":[{"id":525,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/517\/revisions\/525"}],"wp:attachment":[{"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=517"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=517"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=517"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}