-
Notifications
You must be signed in to change notification settings - Fork 866
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
Backup groups: Take source rate estimate from an active link on idle member activation #2260
Merged
maxsharabayko
merged 3 commits into
Haivision:master
from
maxsharabayko:hotfix/bwlimit-backup-switch
Mar 14, 2022
Merged
Backup groups: Take source rate estimate from an active link on idle member activation #2260
maxsharabayko
merged 3 commits into
Haivision:master
from
maxsharabayko:hotfix/bwlimit-backup-switch
Mar 14, 2022
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from CSndBuffer
from an active link on idle member activation
This comment was marked as off-topic.
This comment was marked as off-topic.
The increased BW limit is because the rate estimation calculates how many bytes are submitted within a certain period, even though relying on the source time of packets. void CRateEstimator::updateInputRate(const time_point& time, int pkts, int bytes)
{
// no input rate calculation
if (m_InRatePeriod == 0)
return;
if (is_zero(m_tsInRateStartTime))
{
m_tsInRateStartTime = time;
return;
}
m_iInRatePktsCount += pkts;
m_iInRateBytesCount += bytes;
// Trigger early update in fast start mode
const bool early_update = (m_InRatePeriod < INPUTRATE_RUNNING_US) && (m_iInRatePktsCount > INPUTRATE_MAX_PACKETS);
const uint64_t period_us = count_microseconds(time - m_tsInRateStartTime);
if (early_update || period_us > m_InRatePeriod)
{
// Required Byte/sec rate (payload + headers)
m_iInRateBytesCount += (m_iInRatePktsCount * CPacket::SRT_DATA_HDR_SIZE);
m_iInRateBps = (int)(((int64_t)m_iInRateBytesCount * 1000000) / period_us);
LOGC(bslog.Warn,
log << "updateInputRate: pkts:" << m_iInRateBytesCount << " bytes:" << m_iInRatePktsCount
<< " rate=" << (m_iInRateBps * 8) / 1000 << "kbps interval=" << period_us);
m_iInRatePktsCount = 0;
m_iInRateBytesCount = 0;
m_tsInRateStartTime = time;
setInputRateSmpPeriod(INPUTRATE_RUNNING_US);
}
} |
A simple solution would be to ignore samples with timestamps from the past. The estimate then looks better, but there is some overhead anyway, just happens a bit later. --- a/srtcore/buffer.cpp
+++ b/srtcore/buffer.cpp
@@ -133,6 +133,11 @@ void CRateEstimator::updateInputRate(const time_point& time, int pkts, int bytes
m_tsInRateStartTime = time;
return;
}
+ else if (time < m_tsInRateStartTime)
+ {
+ // Old packets are being submitted for estimation, e.g. during the backup link activation.
+ return;
+ }
m_iInRatePktsCount += pkts;
m_iInRateBytesCount += bytes; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In the source (input) rate estimation configuration (
SRTO_MAXBW=0
,SRTO_INPUTBW=0
) SRT estimates input rate based on the data coming from the app viasrt_sendmsg2(..)
. The estimate is used to set the maximum BW limit and pacing rate of sending.In the main/backup mode an inactive member does not get any data for sending and does not perform any rate estimation.
Once it is activated, the rate estimator state is taken from an active member and assigned to this newly activated member.
Fixes #2122, fixes #2200.