roc-streaming / roc-toolkit

Real-time audio streaming over the network.
https://roc-streaming.org
Mozilla Public License 2.0
1.06k stars 213 forks source link

Add options to simulate packet losses and delays #329

Closed gavv closed 1 year ago

gavv commented 4 years ago

It would be very handy for debugging to be able to simulate packet losses on delays directly in roc-send and in roc-recv tools.

The following solution is suggested:

packet::Interleaver is an example of conditionally-enabled packet writer (in sender pipeline). audio::Watchdog is an example of a component with multiple parameters configured via command-line.

This documentation may be helpful: https://roc-streaming.org/toolkit/docs/internals/data_flow.html

unguest commented 4 years ago

It Would be nice, I'd work on it !

gavv commented 4 years ago

@unguest Great, thanks!

PS. I saw your question in IRC, but was away, sorry. Yes, you figured it out right. And also OFEncoder was renamed to OpenfecEncoder (same for decoder).

gavv commented 4 years ago

@unguest Hi, do you still have plans on it?

gavv commented 4 years ago

Unassigning this so that someone could pick it up. @unguest Feel free to ping me if you'll decide to work on it thought.

jatrindo commented 3 years ago

Hi gavv, is anyone working on this? I'd be interested in giving it a go!

gavv commented 3 years ago

You're welcome!

jm4l1 commented 1 year ago

Hey Gavv, new to the project but I'd like to take on this if there is still the need.

gavv commented 1 year ago

You're welcome, thanks! Yes, the issue is still relevant. Feel free to ask questions here on in chat, if you'll have any.

jm4l1 commented 1 year ago

@gavv Thanks. I have not had the time to dig in as yet but I will work on this. I have done similar features in other projects.

baranovmv commented 1 year ago

It make sense for this component to implement Gilber-Elliott channel model. It would let simulate bursty channel losses with some accountable statistical parameters.

In short, G.-E. channel model means that the component could be in one of two states: State1 and State2. Each state has its own packet loss probability PLoss1 and PLoss2. In addition there are probabilities of changing state from 1 to 2 and from 2 to 1. So, the model characterized by 4 values in range [0, 1].

And, the packet delay could be characterized by some distribution, e.g. gamma

A config could look as follows:

struct JammerConfig {
    float ploss1;
    float ploss2;
    float pswap12;
    float pswap21;

    float mean_delay;
    float jitter;
};
gavv commented 1 year ago

Given this task second thought, it appears that it should be implemented separately from toolkit.

I think the best option would be a UDP proxy with configurable port mapping that will apply delays, reordering, and other modifications, as well as perform some measurements and report metrics.

For now there is no specific plan for developing it and I'm going to close the task. We will reevaluate it later.

gavv commented 1 year ago

@baranovmv Thanks for your input BTW!

@jm4l1 You're welcome to check out other help wanted issues :)