Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Advanced WinSock UDP help needed!

Author
Message
bobba
16
Years of Service
User Offline
Joined: 10th Apr 2008
Location:
Posted: 28th Apr 2008 15:41
I am trying to make an RTS game. I am using a UDP peer to peer network. I have made the logging in process and all works well. The problem is my game only runs at about 2 frames per second if i am lucky. Now i get 60 fps single player so I know it is the networking that is slowing it down.

I would post the code but it is quite big and hard to understand. So i will explain the process that it uses in the hope that someone could suggest a better way.

Basically the only information that is transmitted is the positions of the clicks and a few other variables. a buffer 105 in length. Now this info has to be swapped between players once per turn/cycle.

The network part works as follows. Each player has one thread to receive on and does the sending from the main game loop. When it is time to swap data each player sits in a loop, whilst in the loop they send requests to each other player, if a player receives a request they send a reply to the person that game them the reply. Both requests and replies contain all the game data to be transferred. Once a player has replies from all the other players they proceed one turn. If a player receives a request from a player 1 turn ahead they will proceed one turn if they have all the data.

I suspect the problem may be to do with players spamming out request too fast but am not sure. All the messages are getting through.

If someone could explain the proper way of doing this I would be very grateful.

Thanks in advance for any help and sorry for the long question.

And if anyone has any simple questions then feel free to ask hear as I will be checking back and can help with the easy stuff.

<-- Great game
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 28th Apr 2008 19:03
The word looping scares me in this context.

Can you make it so there is a "Server" and the other players are clients, and when a player gets a change to staus (more replies?) It just tells server I got another one.. then when all conditions met.. Server then broadcasts the MOVE to everyone... so there isn't repetivie "full game" info getting broadcast.. just server to client "tiny packets" so people can all see the current status of everyone else without major packet tossing?

bobba
16
Years of Service
User Offline
Joined: 10th Apr 2008
Location:
Posted: 29th Apr 2008 00:00
Thanks for the reply.

My game is 'an up to 8 player RTS' so it must be peer to peer so that the game can continue even if the host is killed.

You say "tiny packets", I don’t know much about maximum packet size or what effect packet size has on speed? I am currently sending a char buffer[105]; is that good or bad.

jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 29th Apr 2008 00:45
bobba - makes sense what you say...

Packet size, I wasn't referring to bytes as much as CONSTANT streaming of possibly redundant information....

I mean, after all, your post starts out about a MAJOR FPS drop... so there is SOEMTHING GOING ON that is bad. Could be BLOCKING ports for all I know.

There is a good thread on WinSock going on with Michael P and Benjamin. from what I've seen, Benjamin (Author of MultiSync package for GDK and DBPro) knows alot about UDP and particularly Winsock. To Date, my hardcore Network coding was done in FreePascal on primarily TCP/IP ... so I know stuff, but not as much as Ben - that's for sure.

Although, the next time I need to fight with it I'm sure I'll pick up more...

You shoudl seek that thread.. because Michael and Benjamin have had some very low level discussions that might spark an idea for you.

(Even though your "paradigm" (point to point) is different.

bobba
16
Years of Service
User Offline
Joined: 10th Apr 2008
Location:
Posted: 29th Apr 2008 20:15
Thanks again, but I have already read that thread. It helped me a lot. I could sure use some help from Benjamin, he seems to know what he is talking about.

I have investigated more closely what it happening. The frame rate drops because i am truing to exchange info between cpus once per cycle in my game. Therefore it will not run faster then the cpus can swap info. (it runs lush 1 player).

You mention sending redundant information; I think this is my problem. As I mentioned when the players exchange info they all spam out requests and send echo’s for every request received. They will do this until they have echoes from each player. I think what is happening is that the players are progressing 1 turn but then have to process a load of data that was sent last turn but is only just arriving before getting to the data it needs.

I looked at the number of messages that were being sent and received per turn and it is in the 1000s so my problem is down to the protocol I am trying to use.

So if anyone knows how this is meant to be done or can point me to a good book then please help?

<--- Da Old School
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 1st May 2008 22:00
Hmm....

You know, I wonder if you should but the packet sends on a timer delay so they "broadcast" every second or more.... not repeatitively.

hmm...

bobba
16
Years of Service
User Offline
Joined: 10th Apr 2008
Location:
Posted: 2nd May 2008 04:25
This is the kind of info I needed:

Below is a link to a really good explanation of how the network protocol for Age of Empires was developed and some of the problems they encountered.

http://www.gamasutra.com/view/feature/3094/1500_archers_on_a_288_network_.php?page=1

After reading this it is pretty obvious what I am doing wrong! But I was working along the right lines sending by just the user inputs.

Any more info would still be appreciated, and now I also need to know how to go about synchronizing the Network clocks, and how keep them running in time once they are started.


Login to post a reply

Server time is: 2024-11-20 09:31:07
Your offset time is: 2024-11-20 09:31:07