Receiving UDP packets - only one per game loop, but why?

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

Post Reply
User avatar
adf88
Chief Executive
Chief Executive
Posts: 644
Joined: 14 Jan 2008 15:51
Location: PL

Receiving UDP packets - only one per game loop, but why?

Post by adf88 »

Each game loop OTTD receives only one UDP packet per socket. Is there any reason for that? Why not receive all available packets?

I'm finding it problematic. When we want to fill the multiplayer list of network games, a query is sent to the master server. Master server replies with a list of available servers. Then we send a query to each server and wait for replies. UDP packets may not reach the target so if a certain server is not responding a query is repeated every 60 game loops (maximally 10 times). During 60 game loops we may receive only 60 packets but there are more then 200 servers currently! What is happening after first 60 loops? Our client re-queries servers even though the answers already arrived. This generates more and more queries and answers. There flow about 5 times more packets then required and the list of game servers fills up about 5 times slower then it could.

This becomes more problematic in case of my multiplayer server list patch because I'm marking a certain server as "offline" if it does not reply for 180 (3*60) game loops.

I want to change the way OTTD receives UDP packets. But what should I do? Should I receive all available packets every game loop? Or maybe only a fixed amount of them? Should I change the behaviour for every UDP socket or maybe just for the client socket? What are the risks that can arise?
:] don't worry, be happy and checkout my patches
Rubidium
OpenTTD Developer
OpenTTD Developer
Posts: 3815
Joined: 09 Feb 2006 19:15

Re: Receiving UDP packets - only one per game loop, but why?

Post by Rubidium »

The only risk I can think of is DoS via UDP packets. The rest should/could be answered by r24532.
User avatar
adf88
Chief Executive
Chief Executive
Posts: 644
Joined: 14 Jan 2008 15:51
Location: PL

Re: Receiving UDP packets - only one per game loop, but why?

Post by adf88 »

Rubidium wrote:The rest should/could be answered by r24532.
Very nice!
:] don't worry, be happy and checkout my patches
TrueBrain
OpenTTD Developer
OpenTTD Developer
Posts: 1370
Joined: 31 May 2004 09:21

Re: Receiving UDP packets - only one per game loop, but why?

Post by TrueBrain »

Impressive find, and what a silly bug / brainfart :D Hihi :)
The only thing necessary for the triumph of evil is for good men to do nothing.
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 45 guests