Remix.run Logo
zackmorris 4 days ago

Right, I should have been more clear about that. Window logic was perhaps the wrong term, since I don't care about resends.

The use case I have in mind is for realtime data synchronization. Say we want to share a state larger than 1500 bytes, then we have to come up with a clever scheme to compress the state or do partial state transfer, which could require knowledge of atomic updates or even database concepts like ACID, which feels over-engineered.

I'd prefer it if the protocol batched datagrams for me. For example, if we send a state of 3000 bytes, that's 2 datagrams at an MTU of 1500. Maybe 1 of those 2 fails so the message gets dropped. When we send a state again, for example in a game that sends updates 10 times per second, maybe the next 2 datagrams make it. So we get the most recent state in 3 datagrams instead of 4, and that's fine.

I'm thinking that a large unreliable message protocol should add a monotonically increasing message number and index id to each datagram. So sending 3000 bytes twice might look like [0][0],[0][1] and [1][0],[1][1]. For each complete message, the receiver could inspect the message number metadata and ignore any previous ones, even if they happen to arrive later.

Looks like UDP datagram loss on the internet is generally less than 1%:

https://stackoverflow.com/questions/15060180/what-are-the-ch...

So I think this scheme would generally "just work" and hiccup every 5 seconds or so when sending 10 messages per second at 2 datagrams each and a 99% success rate, and the outage would only last 100 ms.

We might need more checklist items:

  ( ) Doesn't provide a way to get the last known Maximum Transmission Unit (MTU)
And optionally:

  ( ) Doesn't provide a way to get large unreliable message number metadata