EricssonResearch / scream

SCReAM - Mobile optimised congestion control algorithm
BSD 2-Clause "Simplified" License
174 stars 53 forks source link

Usage of getTargetBitrate #42

Closed andrisr223 closed 2 years ago

andrisr223 commented 2 years ago

Hello,

I am looking how to use StreamTx::getTargetBitrate to apply the bitrate for x264 encoder. Wanted to know whether that is the intended way?

The app is running in docker and the network interface QoS is set using tc qdisc add dev eth0 root netem delay 200ms rate 4mbit

getTargetBitrate()*rateScale(=0.5) gives values that are large and I end up using getTargetBitrate()*rateScale(=0.5)/100 672010 ends up as 3360kbps for the encoder. If this makes sense...

 summary  45.7  Transmit rate =  1525kbps, PLR =  0.04%( 0.11%), RTT = 0.218s, Queue delay = 0.022s
getTargetBitrate: 676392
 summary  45.7  Transmit rate =  1525kbps, PLR =  0.04%( 0.11%), RTT = 0.218s, Queue delay = 0.022s
 summary  45.7  Transmit rate =  1525kbps, PLR =  0.04%( 0.11%), RTT = 0.218s, Queue delay = 0.022s
 summary  45.7  Transmit rate =  1529kbps, PLR =  0.04%( 0.12%), RTT = 0.218s, Queue delay = 0.024s
 summary  45.7  Transmit rate =  1529kbps, PLR =  0.04%( 0.12%), RTT = 0.218s, Queue delay = 0.024s
 summary  45.8  Transmit rate =  1529kbps, PLR =  0.04%( 0.12%), RTT = 0.218s, Queue delay = 0.024s
 summary  45.8  Transmit rate =  1526kbps, PLR =  0.04%( 0.12%), RTT = 0.218s, Queue delay = 0.025s
 summary  45.8  Transmit rate =  1526kbps, PLR =  0.04%( 0.12%), RTT = 0.218s, Queue delay = 0.025s
 summary  45.8  Transmit rate =  1523kbps, PLR =  0.04%( 0.13%), RTT = 0.218s, Queue delay = 0.026s
 summary  45.8  Transmit rate =  1523kbps, PLR =  0.04%( 0.13%), RTT = 0.218s, Queue delay = 0.026s
 summary  45.8  Transmit rate =  1523kbps, PLR =  0.04%( 0.13%), RTT = 0.218s, Queue delay = 0.026s
 summary  45.9  Transmit rate =  1523kbps, PLR =  0.04%( 0.13%), RTT = 0.218s, Queue delay = 0.026s
 summary  45.9  Transmit rate =  1521kbps, PLR =  0.04%( 0.14%), RTT = 0.218s, Queue delay = 0.026s
 summary  45.9  Transmit rate =  1521kbps, PLR =  0.04%( 0.14%), RTT = 0.218s, Queue delay = 0.026s
 summary  45.9  Transmit rate =  1521kbps, PLR =  0.04%( 0.14%), RTT = 0.218s, Queue delay = 0.026s
 summary  45.9  Transmit rate =  1517kbps, PLR =  0.04%( 0.14%), RTT = 0.219s, Queue delay = 0.026s
 summary  45.9  Transmit rate =  1517kbps, PLR =  0.04%( 0.14%), RTT = 0.219s, Queue delay = 0.026s
 summary  46.0  Transmit rate =  1514kbps, PLR =  0.04%( 0.13%), RTT = 0.219s, Queue delay = 0.025s
 summary  46.0  Transmit rate =  1508kbps, PLR =  0.04%( 0.13%), RTT = 0.219s, Queue delay = 0.025s
 summary  46.0  Transmit rate =  1508kbps, PLR =  0.04%( 0.13%), RTT = 0.219s, Queue delay = 0.025s
 summary  46.0  Transmit rate =  1508kbps, PLR =  0.04%( 0.13%), RTT = 0.219s, Queue delay = 0.025s
 summary  46.1  Transmit rate =  1504kbps, PLR =  0.23%( 0.13%), RTT = 0.219s, Queue delay = 0.025s
getTargetBitrate: 672010

StreamTx initialization (basically from scream_sender.cpp):

    _screamTx = new ScreamTx(scaleFactor, scaleFactor,
        delayTarget,
        false,
        1.0f, dscale,
        (initRate * 100) / 8,
        packetPacingHeadroom,
        20,
        ect == 1,
        false,
        enableClockDriftCompensation);

    _screamTx->setCwndMinLow(5000);

    _screamTx->registerNewStream(this,
        SSRC,
        1.0f,
        minRate * 1000,
        initRate * 1000,
        maxRate * 1000,
        rateIncrease * 1000, rateScale,
        0.2f, txQueueSizeFactor, queueDelayGuard, scaleFactor, scaleFactor);

where

int initRate = 1000;
int minRate = 800;
int maxRate = 200000;
int rateIncrease = 10000;
float rateScale = 0.5f;
float dscale = 10.0f;
bool enableClockDriftCompensation = false;
float burstTime = -1.0;
float burstSleep = -1.0;
bool isBurst = false;
float burstStartTime = -1.0;
float burstSleepTime = -1.0;
bool pushTraffic = false;
float packetPacingHeadroom = 1.25f;
float txQueueSizeFactor = 0.1f;
float queueDelayGuard = 0.05f;

float scaleFactor = 0.9f;
float delayTarget = 0.06f;

Thanks for making an interesting algorithm available.

IngJohEricsson commented 2 years ago

Hi Thanks for trying out.

The rate scaling looks suspicious. I see that x264enc use the unit [kbit/s] therefore the rate scaling should be 0.001. Please let me know the gstreamer pipelines for sender and receiver, and I’ll give it a try

One word of caution when you use netem to set the bitrate. I have experienced that it appears to use rate policing, i.e the network queue delay does not increase, rather it just drops packet in a burst and this makes SCReAM work less optimal.

/Ingemar

From: Andris Rudzitis @.> Sent: Wednesday, 9 February 2022 19:35 To: EricssonResearch/scream @.> Cc: Subscribed @.***> Subject: [EricssonResearch/scream] Usage of getTargetBitrate (Issue #42)

Hello, I am looking how to use StreamTx::getTargetBitrate to apply the bitrate for x264 encoder. Wanted to know whether that is the intended way? The app is running in docker and the network interface QoS is set using tc qdisc add dev eth0 root netem delay 200ms rate 4mbit getTargetBitrate()rateScale(=0.5) gives values that are large and I end up using getTargetBitrate()rateScale(=0.5)/100 672010 ends up as 3360kbps for the encoder. If this makes sense... summary 45.7 Transmit rate = 1525kbps, PLR = 0.04%( 0.11%), RTT = 0.218s, Queue delay = 0.022s getTargetBitrate: 676392 summary 45.7 Transmit rate = 1525kbps, PLR = 0.04%( 0.11%), RTT = 0.218s, Queue delay = 0.022s summary 45.7 Transmit rate = 1525kbps, PLR = 0.04%( 0.11%), RTT = 0.218s, Queue delay = 0.022s summary 45.7 Transmit rate = 1529kbps, PLR = 0.04%( 0.12%), RTT = 0.218s, Queue delay = 0.024s summary 45.7 Transmit rate = 1529kbps, PLR = 0.04%( 0.12%), RTT = 0.218s, Queue delay = 0.024s summary 45.8 Transmit rate = 1529kbps, PLR = 0.04%( 0.12%), RTT = 0.218s, Queue delay = 0.024s summary 45.8 Transmit rate = 1526kbps, PLR = 0.04%( 0.12%), RTT = 0.218s, Queue delay = 0.025s summary 45.8 Transmit rate = 1526kbps, PLR = 0.04%( 0.12%), RTT = 0.218s, Queue delay = 0.025s summary 45.8 Transmit rate = 1523kbps, PLR = 0.04%( 0.13%), RTT = 0.218s, Queue delay = 0.026s summary 45.8 Transmit rate = 1523kbps, PLR = 0.04%( 0.13%), RTT = 0.218s, Queue delay = 0.026s summary 45.8 Transmit rate = 1523kbps, PLR = 0.04%( 0.13%), RTT = 0.218s, Queue delay = 0.026s summary 45.9 Transmit rate = 1523kbps, PLR = 0.04%( 0.13%), RTT = 0.218s, Queue delay = 0.026s summary 45.9 Transmit rate = 1521kbps, PLR = 0.04%( 0.14%), RTT = 0.218s, Queue delay = 0.026s summary 45.9 Transmit rate = 1521kbps, PLR = 0.04%( 0.14%), RTT = 0.218s, Queue delay = 0.026s summary 45.9 Transmit rate = 1521kbps, PLR = 0.04%( 0.14%), RTT = 0.218s, Queue delay = 0.026s summary 45.9 Transmit rate = 1517kbps, PLR = 0.04%( 0.14%), RTT = 0.219s, Queue delay = 0.026s summary 45.9 Transmit rate = 1517kbps, PLR = 0.04%( 0.14%), RTT = 0.219s, Queue delay = 0.026s summary 46.0 Transmit rate = 1514kbps, PLR = 0.04%( 0.13%), RTT = 0.219s, Queue delay = 0.025s summary 46.0 Transmit rate = 1508kbps, PLR = 0.04%( 0.13%), RTT = 0.219s, Queue delay = 0.025s summary 46.0 Transmit rate = 1508kbps, PLR = 0.04%( 0.13%), RTT = 0.219s, Queue delay = 0.025s summary 46.0 Transmit rate = 1508kbps, PLR = 0.04%( 0.13%), RTT = 0.219s, Queue delay = 0.025s summary 46.1 Transmit rate = 1504kbps, PLR = 0.23%( 0.13%), RTT = 0.219s, Queue delay = 0.025s getTargetBitrate: 672010 StreamTx initialization (basically from scream_sender.cpp): _screamTx = new ScreamTx(scaleFactor, scaleFactor, delayTarget, false, 1.0f, dscale, (initRate * 100) / 8, packetPacingHeadroom, 20, ect == 1, false, enableClockDriftCompensation);

_screamTx->setCwndMinLow(5000);

_screamTx->registerNewStream(this,
    SSRC,
    1.0f,
    minRate * 1000,
    initRate * 1000,
    maxRate * 1000,
    rateIncrease * 1000, rateScale,
    0.2f, txQueueSizeFactor, queueDelayGuard, scaleFactor, scaleFactor);

where int initRate = 1000; int minRate = 800; int maxRate = 200000; int rateIncrease = 10000; float rateScale = 0.5f; float dscale = 10.0f; bool enableClockDriftCompensation = false; float burstTime = -1.0; float burstSleep = -1.0; bool isBurst = false; float burstStartTime = -1.0; float burstSleepTime = -1.0; bool pushTraffic = false; float packetPacingHeadroom = 1.25f; float txQueueSizeFactor = 0.1f; float queueDelayGuard = 0.05f;

float scaleFactor = 0.9f; float delayTarget = 0.06f; Thanks for making an interesting algorithm available. — Reply to this email directly, https://protect2.fireeye.com/v1/url?k=31323334-501d5122-313273af-454445555731-29a12626f51018c7&q=1&e=3b72eff5-a2bc-4020-86e3-b5a5b9bd187d&u=https%3A%2F%2Fgithub.com%2FEricssonResearch%2Fscream%2Fissues%2F42, or https://protect2.fireeye.com/v1/url?k=31323334-501d5122-313273af-454445555731-67344d1b8c7fcfd3&q=1&e=3b72eff5-a2bc-4020-86e3-b5a5b9bd187d&u=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FACRZ2GBE4B7JFNILLJNSTDLU2KXVXANCNFSM5N6J52ZA. Triage notifications on the go with GitHub Mobile for https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or https://protect2.fireeye.com/v1/url?k=31323334-501d5122-313273af-454445555731-aa66f83e1a88601a&q=1&e=3b72eff5-a2bc-4020-86e3-b5a5b9bd187d&u=https%3A%2F%2Fplay.google.com%2Fstore%2Fapps%2Fdetails%3Fid%3Dcom.github.android%26referrer%3Dutm_campaign%253Dnotification-email%2526utm_medium%253Demail%2526utm_source%253Dgithub. You are receiving this because you are subscribed to this thread.Message ID: @.***>

andrisr223 commented 2 years ago

Thanks,

Yes, using target bitrate in kbit/s (getTargetBitrate()*0.001) worked really well!

I am not using gstreamer (for now); the packets (payload) come from x264 encoder (profile: baseline, preset: superfast, tune: zerolatency).

Thanks for the warning about netem. (I'm using it to see what happens when there are sudden changes what gets through; the algorithm works nice in this scenario)