Networked Multiplayer

Some questions we have to answer here is if we want to use TCP/IP or UDP/IP.

TCP

TCP is the typical internet protocol, that does everything for you, from recovering of lost packets, automatic adjustment of packet size and connection handling. However using TCP is often not optimal for games, because packet recovery can heavily increase latency of the connection (=LAG), while often the game logic is robust enough to simply ignore some missed packets (the next packet with positions is on it's way anyway). It's also hard to measure the latency of the connection.

UDP

In general UDP is more suited for games since you have more direct control over retransmissions and the reliability level you need from the connection. Most of the data in tuxkart would be position/velocity values of the other players. However UDP is can be more tricky if you need to reliably transmit some data like collected specials or game end/start messages. This typically involves alot of code and tweaking to get it right. We could eventually solve this work by using existing network libraries.

Discussion

SteveBaker notes that there are two ways to deal with collectibles: Firstly, you can transmit the information as to who has what with every transmission - this avoids the dropped packet problem but creates possible problems of consistency. Secondly, you can send one-shot information via TCP and more volatile information via UDP. The one thing that DOESN'T work is to try to armor up UDP to make it reliable. By the time you finish doing that to the point where it actually works, you have TCP - but less efficient and supported in user-land instead of in the OS where it belongs.

MatzeBraun notes that trying to make UDP reliable is indeed not an easy task, but some of the network libraries noted below already do this (ENet and RakNet?). This is still better than TCP, because it allows you to control which data needs to be sent reliable and which data doesn't. I personally find that alot nicer than opening a UDP and a TCP connection at once. External Network Libraries

There exist some good networking libraries out there:

There are lots of other networking libraries out there. Most of them are just wrappers around the winsock/posix socket calls. I think that in this case you make yourself more trouble when using them instead of using the respective system calls directly. Others seem to be poorly designed (TCP only, UDP is never or always reliable, so that you lack control again). Maybe there are even other good libs out there that I simply missed, add them to this list!

MatzeBraun: Arianne was totally bad here IMO. That's 1 of these dependencies where you don't gain much (compared to other networking libs or coding yourself) but indirectly depend on lots of 3rd party code, which is lots of stuff to learn for people that want to learn tuxkart, makes it very hard to fix bugs if they're in the 3rd party lib (lots of code), and after all arianne isn't designed to be a library, so we might have lacking API and lacking Documentation. Complain and put it back if you still don't agree with me removing this.

donconso: I'd like to see supertuxkart communicate over the jabber-network. Perhaps over multiuser-chatrooms. I think it would raise the acceptance for both stk and jabber. More important should be the high number of jabberservers out there, givin the opportunity to easyly connect to each other without exchanging the ips. As a fact you already have someone with jabberknowledge in your team. Simple jabber-frameworks and libraries in different languages can be found at jabber.org

Coz: I think we should use UDP, because of the lower latency, and because we don't need reliable packets for many things. For example, it is not very important to have the exact position of all karts at all times, only when they do something that affects another player (crossing the finish line, collision between two karts). Also, mixing UDP with TCP seems to cause problems(you will have to google for references), so we would have to go purely through the UDP route.

Retrieved from "http://supertuxkart.sourceforge.net/Networked_Multiplayer"

User Tools