private-octopus / picoquic

Minimal implementation of the QUIC protocol
MIT License
559 stars 165 forks source link

Consider adding application timer support to picoquic interface #1460

Open huitema opened 1 year ago

huitema commented 1 year ago

Some applications need timers, as in "wake me up if there is no message from the peer before time T. It would nice to be able to set these timers in "virtual time", so timers could be tested using the simulation infrastructure.

Any timer API would need three components:

We may consider timer support at the connection or stream level -- acting at the QUIC level would not make much sense, as the application can just do it outside of the QUIC loop. Of the two, implementation at the connection level is easiest, because we already have similar tests for the "idle" timer. Stream level action is plausible, but would require extra code to sort the streams by "next timer".

Plausible design: application creates and maintain "timer objects" tied to a connection. Picoquic organizes a splay of timer objects per connection. Application can insert an object in the splay, or reset it -- the splay stays updated. Application deletes the timers when they expire. Context in case of interaction is the timer object, as defined by the application.