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.

DarkBASIC Professional Discussion / Fps capped due to connection

Author
Message
Cescano
9
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 17th Mar 2016 16:45
The communication between the client and the server (using sockets) takes some milliseconds everytime is called, this obviously slow down the fps of the game because there is a fixed amount of time that is used for the connection.
Because of this even if I higher or lower the graphics I have the same fps (around 40), is there a way to avoid this?
How AAA multiplayer games handle the communication when connecting to a server without slowing down the game?
I am only updating data to/from the server once every 200 ms, so 5 times per second, this is already a very slow frequency of update and if I higher it the problem will be even worse.
The server I am using should handle 32 players.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 30th Mar 2016 20:55
Quote: "How AAA multiplayer games handle the communication when connecting to a server without slowing down the game?"


My guess is that they can use several CPUs whereas DBPro can only use one I believe - in other words the server activity can run simultaneously with the game. That's a pure guess because I have no experience of coding more than one CPU.


Powered by Free Banners
hakimfullmetal
9
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 2nd Apr 2016 03:04
So does this means that, lets say, when we want to send a file with the size of 40mb, the gameplay itself will freeze while the file is being networked to the other player?

Or the other game processes can still go on looping while a file is being sent/networked?
Chris Tate
DBPro Master
15
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 2nd Apr 2016 03:30
Following on from Green Gandalf, if your application is using one CPU without any multithread support, any CPU activity has the potential to slow down the performance. If your program has multithread support, then one thread can run the game while the other processes the network; a bit like having two hands instead of just one hand performing a number of physical actions; two hands get the job done more quickly.

In the case of Dark Net which has some multithreading support, much of the network management takes place behind the scenes, in the plugin rather than in your DBP code; but there is still the need to interact and poll its progress.

You will still need to optimize code and predict the potential motion of shared entities because not everyone has a good CPU or great ping. If you timestamp all of your processes that will tell you what needs optimization.
Cescano
9
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 2nd Apr 2016 03:59
I am not using darknet but Matrix1 Utils Sockets, I have been able to let work the UDP packets and I have converted my code to use these ones instead of the TCP ones for passing data to and from the server, while using TCP only for logging in, get servers list, etc.

With UDP packets everything is much smoother and I don't have the choppy movements anymore, probably they still put down the fps but much less, as if I open the game with almost low settings except water with medium settings, I get almost 50 fps, and if I open 2 istances of the game on the same pc I get almost the same fps on both of them, so the network is limiting the fps, but as I use to cap the framerate at 50 fps it's fine.
5 updates per seconds could be few compared with other games that as I have seen use 20-30 updates per second, but for my type of game are fine (I have already implemented the interpolation part and everything is smooth now) and this allow me to use cheap servers and don't overload them, as I still need to manage 32 players per server.
Seditious
10
Years of Service
User Offline
Joined: 2nd Aug 2013
Location: France
Posted: 2nd Apr 2016 05:48
TCP is buffered meaning it will queue data and send (and re-send) as many times as necessary, waiting for receipt of reception in the case of the queue being full. That's most likely what your problem is. If you are repeatedly sending out updated data you should always use UDP.
Chris Tate
DBPro Master
15
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 2nd Apr 2016 17:04
Oh I did not think you were using TCP for object networking, I assumed you would be using UDP. So you found a solution.
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 3rd Apr 2016 04:50
In the case of transferring a large file, matrix1 coroutines may help keep things running without a visible lockup but it will take longer to receive
Cescano
9
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 3rd Apr 2016 15:27
I am not understanding what these coroutines are, can you explain better?
Ortu
DBPro Master
16
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 3rd Apr 2016 19:44
It's not true multithreading, but they essentially let you pause or interrupt one process to switch to another for a while instead of having to wait for it to fully complete.

Take a look at them in the matrix 1 help docs

Login to post a reply

Server time is: 2024-04-20 09:32:32
Your offset time is: 2024-04-20 09:32:32