Skip to main content
GameDev.net gamedev.net
🔒 Locked

Multiplayer ENET Runs Extremely Slow

Started by brwarner Jul 4, 2010 at 12:55 AM 2 replies 2k views
Original Post
brwarner
brwarner
Here is my architecture design which runs very smoothly when connecting by localhost, but up to 1.5 seconds of lag when going through the internet, I am trying to find out why.

Server Loop:
Process all packets in queue
-Read the packet into a string, each character is a key that is down on the client
If it has been 1/30 seconds since last update
-Update objects (player changes position based on keys down)
-Send XY position of objects to client (in unreliable packet)

Client Loop:
Process all packets in queue
-Read raw XY coordinates into local variables
If it has been 1/30 seconds since last update
-Send a string of all keys down to server (in unreliable packet)
Render Scene

I know its not the most efficient setup, as its just a mock-up version at the moment, but it seems extraordinarily slow considering there is only one object and only one client. Any ideas?

EDIT: I'm using enet by the way
Beyond_Repair
Beyond_Repair
You really need to tell us more:

- The characteristics of the Internet connections of the computers involved. Alone saying "connected by Internet" doesn't mean much because there are really crappy Internet connections.

- How large is the data you're sending every frame? (I.e. how many bytes?)

In spite of this, I'd spontaneously say: Yes it sounds weird with 1500 ms ping with ENet, but without the above information one cannot be more precise.

Btw, ensure the ENet bandwidth limiter isn't active.
brwarner
brwarner
Every frame (30 fps) the server sends about 13 bytes to the client while the client sends between 0 and 5 bytes to the server.

By internet (sorry I wasn't specific) I meant that instead of using "localhost" I used by external IP address, so only one computer is involved.

The ping ends up being more like 0.7 seconds, but still really noticeable and unplayable. I deactivated the bandwidth limitations on the client but it still has this delay.
brwarner
brwarner
Wait nevermind, I'm an idiot....
I wrote microseconds instead of milliseconds so it was actually running at 30 000 frames per second. Fixed and now it runs fine (still needs tuning though).

Thanks anyway

[Edited by - brwarner on July 4, 2010 10:36:57 AM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.