ddlox said:
Let's say if u were getting 25 udp packets per second in a 25FPS scenario:
(P1, P2, P3,….. P10, P11, P13, P15, P12, P14 …. P20, P21, P23, P24, P25) per second:
- if your app processes 25packets after each second, then all u need to do is sort this list every second and process them
- if your app processes each packet as they arrive then depending on what your app's use-case is trying to achieve:
- UC1: when u receive P13 after P11, u can process P13, but when P12 arrives just discard it
- UC2: when u receive P13 after P11, u can hold P13, and wait for N packets in hope of receiving P12, if it arrives within N packets then process P12, P13 etc… if it doesn't arrive then process P13 (discard P12 whenever it arrives in the future). Same deal for P15 (waiting for P14)
- UC3: when u receive P13 after P11, you can time the arrival of each packet, so if for ex P12 within the next 40ms then process P13 and discard P12 when it arrives in the future
- etc…
- etc…
point being, it is your responsibility to establish some rules for your incoming data packets; and if your packets have no inter-related dependency then the easier the decision;
For example:
- Case A: a player increasing her car speed: these packets would contain current incremental velocity/accelaration values of speed
- Case B: a player teleporting to various places: these packets would contain the current positional values (as opposed to incremental) of location
Case A could be treated with UC1, UC2 or UC3, whereas case B would be treated with UC1 only (ideally)
so it's all in your hands ;-)
@ddlox Thanks alot for those use-cases ! in your experience is it true that the packet reordering isnt all over the place but that its within X packets and not ex between 100 packets ( so you expect ex packet no 2 but get packet 100 ) ? i would probably be looking at UC3 but will start from UC1 and see how it goes but probably end down in a compliacted rabbithole with UC2 or UC3 ?