• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
bliztertoto

High latency cause frequent connection loss

5 posts in this topic

Hello,

I am working on a multiplayer action platformer right now.

The game uses only tcp. It is an action game so I am sending about 1 to 3 packets each frame.

The game is stable right now but we are encountering an issue. Players with high latency (typically european players), are getting frequent disconnects while playing the game. Players with a low latency can play without any problems.

Do you guys have any ideas about what might be causing this? Is it an issue with tcp itself that requires software handling?

I'm using SFML for the networking, nagle is disabled.

Thanks!
0

Share this post


Link to post
Share on other sites
[quote]
The game uses only tcp.
[/quote]
I hope I can assume your code correctly handles the fact that TCP is a stream based protocol, rather than a packet based protocol.

[quote]
It is an action game...
[/quote]
Action games generally use semi-reliable UDP rather than TCP. This is because in the event of packet loss TCP forces you to wait for the earliest data to arrive before giving you later data - data that might already be delivered! You might have up-to-date game state sitting in a TCP buffer, but it is waiting for data from the previous frame to arrive before you'll get to see it.

[quote]
... so I am sending about 1 to 3 packets each frame.
[/quote]
How frequent are frames? If you're aiming for 60FPS, then you should probably only be sending data every N frames. Or rather, your networking code should have its own "ticks per second" value - independent of rendering.

Which direction are these packets going?

[quote]
Players with high latency (typically european players), are getting frequent disconnects while playing the game. Players with a low latency can play without any problems.
[/quote]
What is your definition of high latency? It would be interesting if you could estimate the packet loss these players experience. Perhaps their disconnections co-incide with a bout of packet loss.

Do you have a system to automatically "kick" players which fall too far behind? If so, do you log that this is the reason for disconnection?
0

Share this post


Link to post
Share on other sites
Hey, thanks

I was using udp before but the combinaison of tcp and udp seemed to add congestion and more frequent disconnects.

I read somewhere that tcp is not really slower than udp right now in 2012 because of all the hardware acceleration and optimized drivers for it. So I tried it all tcp and I didn't see a difference (except that people seemed to drop less often).

Only tcp allows me to forget about nat punch through and it seemed like a good idea to stick with tcp only.

My code handle tcp as a stream protocol in a non-blocking multithreaded way.

When I mean high latency, I mean about 350 to 500 milliseconds delay.

Client send data to the server then resend it to all other clients.

I am sending important updates every two frames, but there are a lot of one-time events so this might cause congestion. I monitored using perfmon and the game uses about 8ko/s of bandwidth. Is this unusualy high for tcp?

Is there a way to check what the current tcp buffer size is, and what is the maximum? Does a full tcp buffer cause a disconnect?

I don't have any system right now to kick players or disconnect them, so it must be on a lower level.
0

Share this post


Link to post
Share on other sites
TCP is never SLOWER than UDP. What it is, is an in-order stream protocol. This means that the receiving application will never see data out-of-order, which means waiting for a re-transmit if a packet is lost. UDP will let you see data out-of-order, and delivers whatever packet comes into the computer, to the application, as soon as it's available. The main reason to use UDP is to aviod the stall-waiting-for-retransmit before delivering later data in the case of packet drop.

[quote]I am sending about 1 to 3 packets each frame.[/quote]

"Packets" are something you send on the network -- typically by sending a length counter and then that much data. You should never need to send more than one packet per frame. If "frames" means "graphics frames" or "simulation frames," most games will send one packet per N frames, for a packet rate between 10 and 20 packets per second. Within packets you will have "messages" which is your own way of slicing data about different things to different parts of your application.

Finally, what does "disconnect" mean? Does the socket recv() call return -1? Does the send() call return 0? Something else?

Note that SFML does not document whether it packetizes messages or not -- my guess is it's a zero-value wrapper on sockets, and thus a send() for 20 bytes followed by a send() for 35 bytes may receive in a single recv() for 55 bytes. Or one recv() for 12 bytes and one recv() for 18 bytes and one recv() for 25 bytes. Or some other combination.
0

Share this post


Link to post
Share on other sites
This is true, I meant messages instead of packets.

By disconnect, I meant I get sf::[i]Socket[/i]::[i]Disconnected[/i] from TcpSocket::Receive()

This is from SFML:

[CODE]
Socket::Status TcpSocket::Receive(char* data, std::size_t size, std::size_t& received)
{
// First clear the variables to fill
received = 0;
// Check the destination buffer
if (!data)
{
Err() << "Cannot receive data from the network (the destination buffer is invalid)" << std::endl;
return Error;
}
// Receive a chunk of bytes
int sizeReceived = recv(GetHandle(), data, static_cast<int>(size), 0);
// Check the number of bytes received
if (sizeReceived > 0)
{
received = static_cast<std::size_t>(sizeReceived);
return Done;
}
else if (sizeReceived == 0)
{
return Socket::Disconnected;
}
else
{
return priv::SocketImpl::GetErrorStatus();
}
}
[/CODE]
0

Share this post


Link to post
Share on other sites
How much data are you sending? Are you running into your bandwidth limit? Do you get lag spikes?

Use tools like wireshark to analyse your traffic.
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0