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] Added SRTO_PACINGMODE pacing mode #1541

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

maxsharabayko
Copy link
Collaborator

@maxsharabayko maxsharabayko commented Sep 11, 2020

These changes are extracted from #1383. Closes #1383. Documentation is in PR #1533.

  • Added option SRTO_PACINGMODE
  • New pacing mode: SRT_PACING_INBW_MINESTIMATE

SRTO_PACINGMODE option can be used to select the desired output pacing only in live mode.

See the description in APISocketOptions.md.

Available modes are:

SRT_PACINGMODE bw bw_overhead Formula for MAXBW Calculation
SRT_PACING_UNSET - - The mode is deduced, see the table below
SRT_PACING_MAXBW_DEFAULT - - MAXBW is set to the default value of 1 Gbps
SRT_PACING_MAXBW_SET MAXBW - MAXBW is set explicitly, in bytes per second, must be positive
SRT_PACING_INBW_SET INPUTBW OHEADBW MAXBW = INPUTBW * (1 + OHEADBW /100)
SRT_PACING_INBW_ESTIMATE - OHEADBW MAXBW = EST_INPUTBW * (1 + OHEADBW /100)
SRT_PACING_INBW_MINESTIMANTE INPUTBW OHEADBW MAXBW = max(INPUTBW, EST_INPUTBW) * (1 + OHEADBW /100)

TODO

  • URI option pacing=mode,bw,ohead.
  • Don't allow to set SRTO_MAXBW, SRTO_INPUTBW, SRTO_OHEADBW if the currently set SRTO_PACINGMODE does not expect it.
  • Consider if SRTO_MININPUTBW option should be added.

Usage Examples

All required options are set at once together with the pacing mode. See test_socket_options.cpp for more examples.

struct SRT_PACEMODECFG
{
    SRT_PACINGMODE mode;
    int64_t bw;
    int32_t bw_ohead;
};
SRT_PACEMODECFG cfg = { SRT_PACING_INBW_SET, 80000000, 25 };
srt_setsockflag(sockid, SRTO_PACINGMODE, &cfg, sizeof cfg); // OK
struct SRT_PACEMODECFG
{
    SRT_PACINGMODE mode;
    int64_t bw;
    int32_t bw_ohead;
};
SRT_PACEMODECFG cfg = { SRT_PACING_INBW_SET, 0, 25 };
// The following function returns error: Invalid Param
// Because input BW value must be positive if INBW_SET mode is used
srt_setsockflag(sockid, SRTO_PACINGMODE, &cfg, sizeof cfg);

@maxsharabayko maxsharabayko added Type: Enhancement Indicates new feature requests [core] Area: Changes in SRT library core labels Sep 11, 2020
@maxsharabayko maxsharabayko added this to the v1.5.0 - Sprint 23 milestone Sep 11, 2020
@maxsharabayko maxsharabayko self-assigned this Sep 11, 2020
@maxsharabayko

This comment has been minimized.

@ethouris

This comment has been minimized.

@maxsharabayko maxsharabayko force-pushed the develop/pacing-mode branch 2 times, most recently from 1ea8908 to e1433bd Compare September 14, 2020 15:22
@@ -228,6 +228,7 @@ CUDT::CUDT(CUDTSocket* parent): m_parent(parent)
m_iIpV6Only = -1;
// Runtime
m_bRcvNakReport = true; // Receiver's Periodic NAK Reports
m_PacingMode = SRT_PACING_UNSET; // API/ABI backward compatible mode
Copy link
Collaborator

@ethouris ethouris Sep 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It make more sense if you simply add kinda m_bHybridPacing boolean field. This is only required to distinguish the INPUTBW and HYBRIDBW modes. Then, you just set:

  • UNLIMITED (default): MAXBW = -1, others ignored
  • MAXBW: MAXBW as provided, others ignored
  • INPUTBW: MAXBW = 0, INPUTBW as provided, OHEADBW as provided, HYBRIDPACING = false
  • ESTINPUTBW: MAXBW = 0, INPUTBW = 0, OHEADBW as provided, HYBRIDPACING = true
  • HYBRIDBW: MAXBW = 0, INPUTBW as provided, OHEADBW as provided, HYBRIDPACING = true

Decoding the mode from fields:

  • If MAXBW == -1, report UNLIMITED
  • If MAXBW > 0, report MAXBW
  • if MAXBW == 0:
    • if INPUTBW == 0, report ESTINPUTBW (ignore HYBRIDPACING)
    • if INPUTBW > 0:
      • if HYBRIDPACING is false, report INPUTBW
      • otherwise report HYBRIDBW

@maxsharabayko
Copy link
Collaborator Author

From the docs, SRTO_MAXBW binding: pre (must be set prior to calling srt_connect() or srt_bind() and never changed thereafter).

TEV_INIT_RESET initialization event comes from two places:

  • a socket is created;
  • SRTO_MAXBW was updated while connected.

From the code of CUDT::updateCC, if init event type is not TEV_INIT_RESET and SRTO_MAXBW is nonzero, nothing is updated. It means that MAXBW can be changed in runtime.

if (event_source != TEV_INIT_RESET && m_llMaxBW)
{
    HLOGC(rslog.Debug, log << CONID() << "updateCC/TEV_INIT: non-RESET stage and m_llMaxBW already set...");
    // Don't change
}

@maxsharabayko maxsharabayko force-pushed the develop/pacing-mode branch 3 times, most recently from 6d3fa9e to 8c7957f Compare September 15, 2020 13:46
@maxsharabayko
Copy link
Collaborator Author

Consider adjusting pacing mode names to be more distinguishable:

  • SRT_PACING_DEFMAXBW -> SRT_PACING_MAXBWDFLT
  • SRT_PACING_MAXBW -> SRT_PACING_MAXBWSET
  • SRT_PACING_INPUTBW -> SRT_PACING_INPUTBWSET
  • SRT_PACING_ESTINPUTBW -> SRT_PACING_INPUTBWEST
  • SRT_PACING_HYBRIDBW -> SRT_PACING_INPUTBWADJ ???

@mbakholdina mbakholdina modified the milestones: v1.5.0 - Sprint 23, v1.5.0 - Sprint 25 Sep 21, 2020
@maxsharabayko maxsharabayko modified the milestones: v1.5.0 - Sprint 25, v1.5.0 - Sprint 24 Sep 22, 2020
@mbakholdina mbakholdina modified the milestones: v1.5.0 - Sprint 24, v1.5.0 Oct 14, 2020
maxsharabayko and others added 3 commits December 8, 2020 12:09
- Added option SRTO_PACINGMODE
- New mode: SRT_PACING_INBW_MINESTIMATE

Co-authored-by: duB <[email protected]>
Co-authored-by: Maria Sharabayko <[email protected]>
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 Priority: Low Type: Enhancement Indicates new feature requests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants