Some question about mutiplayer game design

Started by
4 comments, last by Mr_Network 22 years, 5 months ago
Hi everyone, I am a C/C++ programmer. Have some experience with TCP/IP with Winsock2 on VC. I did some research about how to create Server/Client program for game. And I now knows I need to use UDP for 99% of time. TCP only use for login information. But I don't know how to detect the problem with UDP if the order is wrong, or the packet is not fully transmit. Ex: When I send a text string using UDP... the order may be wrong or missing sometimes right? But can't allow this to happen when player chating with friends. How do I solve these when writing the codes? And is there many other thing I need to taking care of to design the program? And last question, why most game only able to host up to 32 people? And why some other game can break the limit, and able to host few hundred people in single server? It sounds like not just problem with bandwidth for the server..... Thank you for help >__< greatly appreciate ~~~ ! Edited by - Mr_Network on October 30, 2001 3:36:17 AM Edited by - Mr_Network on October 30, 2001 3:40:03 AM
Network
Advertisement
To be able to detect out-of-order or missing packets, you just append a "counter" to each, so the first packet you send is packet 1, the next is 2, 3, 4, etc. Then, at the other end, you can just re-assemble them back in the same order.

There''s other things you can do, like sending ACK packets back for each packet you recieve, that way the client can resend every packet which doesn''t get an ACK.

The reason many servers have a 32 player limit and other can support hundreds (or thousands) is more of a design issue than an implementation one. Quake and UT are much faster-paced than UO or Everquest. Hence, they need to update the clients more often, hence they need more bandwidth per player.

Finally, you don''t need to use TCP for anything really. TCP is only *really* needed when you have two machines behind a firewall. If none or only one is behind a firewall (the one behind the firewall must be the initiator of the communication, though), then you can do everything in UDP.

codeka.com - Just click it.
There is really no difference between UDP and TCP when it comes to firewalls. If you don''t open the right port for incoming traffic on the receiving end the connection won''t be established, no matter whether you''re using TCP or UDP.

The same applies for situation where both parties are behind NAT routers. There is no way the two parties can connect to each other, unless static port forwarding is enabled. This applies to both TCP and UDP.

cu,
Prefect
Widelands - laid back, free software strategy
you (c/sh)ould implement your own protocol over UDP that includes built-in packet ordering ... appending an ordering number is a basic version, but if you include your own headers you can create something that is more robust than UDP but almost as fast.

UDP does guarantee that the data received on the other end is correct, but it could of course be out of order, duplicated, etc

in my game i''ll be implementing chat, login info, and anything that doesn''t involve real-time updates for action sequences (buying/selling, etc) ... the rest will use a custom protocol over UDP.
----------------------------------------Look behind you! A three-headed monkey!
Is there any information on writing own protocol base on UDP?
I only able to find informations on TCP and basic socket stuff.
Network
Another thread references the book Advanced 3D Game Programming with DirectX (Adrian Perez and Dan Royer) Dan Royer has a nice example of implementing reliable UDP.

The code in the above mentioned book is more applicable to a FPS than it is to a MMORPG though, but nevertheless it is a good treatment and a basic introduction to using reliable UDP.

This topic is closed to new replies.

Advertisement