Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Improved input rate calculation. #763

Merged
merged 1 commit into from
Jul 22, 2019

Conversation

maxsharabayko
Copy link
Collaborator

@maxsharabayko maxsharabayko commented Jul 19, 2019

Fixing bandwidth limitation mode with automatic input bitrate Rinput calculation. Configuration SRTO_MAXBW=0, SRTO_INPUTBW=0, live transmission mode.
In this mode the bandwidth limit is Rinput * (1 + OHEAD), with Rinput calculated based on the number of packets added to the sender's buffer (via srt_send*).

The desired behavior of the input rate calculation:

  1. Fast start period of 0.5 sec or 2000 packets to accumulate enough statistics. Meanwhile use default MAXBW + overhead.
  2. If 0.5 seconds have passed or 2000 packets have been sent, calculate input rate Rinput. Update MAXBW = Rinput * (1 + OHEAD). Switch to RUNNING mode with input rate update every 1 sec.
  3. In RUNNING mode update Rinput every second and recalculate MAXBW = Rinput * (1 + OHEAD).

Note. 2000 packets roughly equals to 21 Mbps of 1316 bytes payload. Therefore the condition is true after 0.5 s of 40 Mbps streaming, and the earlier the higher the bitrate is. E.g. for 400 Mbps streaming the input rate will be calculated already after 50 ms.

Changes introduced by this PR

Issue. Initial Input Rate of 10 Mbps for Fast Start Period

The initial input rate for fast start period was only 10 Mbps
static const int SND_INPUTRATE_INITIAL_BPS = 10000000/8;
Now it equals the BW_INFINIT value (30 Mbps, or 1 Gbps after PR #760):
static const int INPUTRATE_INITIAL_BYTESPS = BW_INFINITE;

Issue: Wrong Initial Sampling Period

Wrong condition in CUDT::updateCC. Switching to RUNNING mode on 2000 packets condition does not update the input rate, instead the update is delayed for 1 second instead of 0.5 seconds.

if ((m_stats.sentTotal > SND_INPUTRATE_MAX_PACKETS)
    && (period < SND_INPUTRATE_RUNNING_US))
{
    m_pSndBuffer->setInputRateSmpPeriod(SND_INPUTRATE_RUNNING_US);
}

SND_INPUTRATE_MAX_PACKETS = 2000

Input Rate for Idle Connections (TO DISCUSS)

After this PR the input rate is updated only when new packets are added to the sender's buffer.

Previously the input rate was also updated for idle connections, meaning that if there is a temporal congestion on the link, the input rate estimation might decrease. In this case decreasing the input rate of an idle link is not the desired behavior, because it also decreases the bandwidth limitation, while the expected live stream rate should be at least the same.
Although in some cases it might make sense to decrease the bandwidth limit to decrease the rate of packet retransmission.

CUDT Control Over CSndBuffer's Rnput Rate Calculation Sampling Period

Now CSndBuffer controls input rate calculation sampling period internally, allowing the CUDT to reset the mode back to FAST START.

  • CSndBuffer::setInputRateSmpPeriod(int period); made private
  • Added CSndBuffer::resetInputRateSmpPeriod(bool disable)

TODO

  • Change logging mode around the input rate calculation back to heavy logging
  • Make auto bandwidth limit based on the calculated input bitrate the default mode in SRT. Add a recommendation note to set the input bandwidth though.

@maxsharabayko maxsharabayko added the [core] Area: Changes in SRT library core label Jul 19, 2019
@maxsharabayko maxsharabayko added this to the v.1.3.3 milestone Jul 19, 2019
srtcore/buffer.cpp Outdated Show resolved Hide resolved
srtcore/congctl.cpp Outdated Show resolved Hide resolved
srtcore/core.cpp Outdated Show resolved Hide resolved
srtcore/buffer.cpp Outdated Show resolved Hide resolved
@maxsharabayko
Copy link
Collaborator Author

Streaming 500 Mbps with master banch. Default configuration,maxbw=0

As can be seen on the plots shown below, the initial bandwidth limit of 30 Mbps is active for the first 1 sec. Although after roughly 100 ms the TSBPD mechanism takes over and forces the sender to transmit faster (issue #713 TSBPD suppress max BW limitation).
After 1 sec the input rate is updated, then the bandwidth limitation is updated, and there is a temporal spike in sending rate when sending the buffered packets.

cent2win_master_500Mbps_maxbw0-30Mbpsinf-take1-snd-packets

cent2win_master_500Mbps_maxbw0-30Mbpsinf-take1-snd-pktsendperiod

cent2win_master_500Mbps_maxbw0-30Mbpsinf-take1-snd-rate

@maxsharabayko
Copy link
Collaborator Author

Streaming 500 Mbps with master banch. Default configuration, maxbw=0, tsbpd=0, tlpktdrop=0.

cent2win_master_500Mbps_tsbpd0_tlpktdrop0_maxbw0_30Mbpsinf-take2-snd-packets

cent2win_master_500Mbps_tsbpd0_tlpktdrop0_maxbw0_30Mbpsinf-take2-snd-rate

@maxsharabayko
Copy link
Collaborator Author

Streaming 500 Mbps with this PR banch. Default configuration, maxbw=0, tsbpd=0, tlpktdrop=0.

cent2win_PR_500Mbps_tsbpd0_tlpktdrop0_maxbw0_30Mbpsinf-take1-snd-packets

cent2win_PR_500Mbps_tsbpd0_tlpktdrop0_maxbw0_30Mbpsinf-take1-snd-rate

@maxsharabayko
Copy link
Collaborator Author

2 sec streaming 500 Mbps with this PR banch. Default configuration, maxbw=0.

cent2win_PR_500Mbps_maxbw0-30Mbpsinf-take1-snd-packets

cent2win_PR_500Mbps_maxbw0-30Mbpsinf-take1-snd-rate

cent2win_PR_500Mbps_maxbw0-30Mbpsinf-take1-snd-pktsendperiod

@maxsharabayko
Copy link
Collaborator Author

10 sec streaming 500 Mbps with this PR banch. Default configuration, maxbw=0.

cent2win_PR_500Mbps_maxbw0_30Mbpsinf-take2-snd-packets

cent2win_PR_500Mbps_maxbw0_30Mbpsinf-take2-snd-rate

cent2win_PR_500Mbps_maxbw0_30Mbpsinf-take2-snd-pktsendperiod

@maxsharabayko maxsharabayko force-pushed the develop/inputbw-auto branch from 274d72a to ab46aa0 Compare July 19, 2019 11:25
SRTO_MAXBW=0; SRTO_INPUTBW=0;
@maxsharabayko maxsharabayko force-pushed the develop/inputbw-auto branch from ab46aa0 to 5c758a0 Compare July 19, 2019 11:28
@maxsharabayko maxsharabayko marked this pull request as ready for review July 19, 2019 13:07
@rndi rndi merged commit 10386ce into Haivision:master Jul 22, 2019
@maxsharabayko maxsharabayko deleted the develop/inputbw-auto branch July 24, 2019 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[core] Area: Changes in SRT library core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants