cberner / raptorq

Rust implementation of RaptorQ (RFC6330)
Apache License 2.0
264 stars 47 forks source link

When to call decoding, duplicated outputs #149

Closed the-c0d3r closed 1 year ago

the-c0d3r commented 1 year ago

Hi, I was using the python binding to encode streaming data before sending to the other side through a one directional link with UDP packets.

I was wondering when should I call the decode function. Assuming, I have a block of data (same size as MTU, 4000), then with 1 repair block (same size as MTU, 4000). Then if I transmit these two packets to the other side, when should I call the decode function, as I could have both packets, or in case of loss, I would only have one.

Packets are received one by one on the other side, so I need to know when to call the decode function and when to buffer the packets before calling decode. I found that if I call on every packet, then I will end up with duplicated data block, as the source packet and repair packet will lead to the same output.

Please enlighten me on the possible design for sending data through UDP packets.

cberner commented 1 year ago

You should call it for each packet that arrives, and then stop calling it when you get a non-None output back

the-c0d3r commented 1 year ago

Thanks for the reply. But I am doing an application for streaming data, so I cannot stop it after one successful decoding, as the packets will keep coming in continuously.

I was thinking how to handle such cases, and things get more complicated if the source packet is more than one.

In case of more than one source packet, I have to buffer packets and call decode until it is None, then remove those packets that are able to decode. But this seems very slow for my usecase.

Is there any design that I should follow?

On Wed, 14 Jun 2023, 2:04 am Christopher Berner, @.***> wrote:

You should call it for each packet that arrives, and then stop calling it when you get a non-None output back

— Reply to this email directly, view it on GitHub https://github.com/cberner/raptorq/issues/149#issuecomment-1589794176, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABCRDZIERHUE3TCFWGILCF3XLCTUDANCNFSM6AAAAAAZE75E74 . You are receiving this because you authored the thread.Message ID: @.***>

cberner commented 1 year ago

Take a look at the examples folder. You don't need to buffer all the packets, but you do need to check for None