How to ensure my udp sockets receive all packets in order? Assuming the packets are guarantee arrive in order at the receiver machine, and no packet drop.
I am asking this because I ran my program many times in window, and redhat. It always receive in-order packets under windows, on the other hand, out-of-order packet always happen under redhat as well as ubuntu.
I am using boost asio library to create 50 udp sockets, receive rate set to 100 packet/sec. I also have tried without boost asio, and use a boost thread to listen to an epoll, and call recv to fd immediately, but yielded the same result. In addition, If I only open 8 sockets in linux, i receive no out-of-order packets.
guarantee arrive in order at the receiver machine, and no packet drop.
UDP cannot do that. You're describing TCP.
You can add sequence numbers to the data you're sending in each UDP datagram, analyze it after receiving it from the socket and send back requests to resend data with whatever sequence numbers you didn't receive.. Or you can use TCP.