Jump to content

  • Log In with Google      Sign In   
  • Create Account

Networking layer design decisions


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Sceletor   Members   -  Reputation: 139

Like
0Likes
Like

Posted 30 December 2011 - 06:26 AM

Im working on a game project for quite a while now and now Ive finally come to the point where I need to design its networking layer. As always, the dreaded UDP or TCP question arises, and before I waste too much time due to wrong design decision, Id like to present my thoughts here and gather some feedback from you guys...

Up until now, I had a monolithic application, where the server was only a bundle of gamelogic classes, but for several different reasons, Im planning to make the game online only, with a central server in the web and downloadable clients.

I experimented already with a small network layer using UDP for testing in my LAN, but since package loss became apparent I have to decide now which way Ill go with networking in general.

Right now I think trying to make my own reliability layer with UDP is the way to go, but the reasons against that are equally important as the reasons in favor of it. The following listing is ordered by importance.

Pros UDP:

- The engine I wrote which is used by my game is more flexible and therefore better usable by future game projects

- With UDP, sending and listening is the same on client and server, which makes it easier to develop

- No separate threads for connected clients or accepting connections in the server

- I dont need to worry about message fragmentation

- I dont need to dump my network layer.. Its tiny, but at least its doing its job so far


Cons UDP:

- My current game is a turn based strat game, which is THE standard use case for TCP in gaming

- Reliability and ordering is provided, doing this myself in UDP might be a terrible amount of work


Do you think this is the right decision or did I misjudge some points here?

Using an already existing library (raknet or such) isnt really what I want to do, since I would like to write it myself (yeah, Im mad, I know..).

Sponsor:

#2 Sudi   Members   -  Reputation: 706

Like
0Likes
Like

Posted 30 December 2011 - 06:59 AM

Using an already existing library (raknet or such) isnt really what I want to do, since I would like to write it myself (yeah, Im mad, I know..).

Hmm i would have suggested enet bc its tiny and provides everything needed. It builds the connection and you can choose if you want the packets to be reliable/in order/unordered/unreliable. But since you want to code everything yourself i would say take a look at the quake3 network layer. Its really basic, easy to implement and as well gives you reliable data. I actually implemented a quake3 network system with enet and sending unreliable-ordered packets which works great and gives good performance. I know this hides the really low level network stuff from ya but since you want to write a game and not a network lib i would really recommend that.

Enet: http://enet.bespin.org/
Quake3 network explained: http://trac.bookofho...uake3Networking (currently down??)
maybe this helps as well http://ra.is/unlagged/network.html

#3 hplus0603   Moderators   -  Reputation: 5297

Like
0Likes
Like

Posted 30 December 2011 - 11:53 PM

Most of your "pros" of UDP aren't really pros of UDP. You don't need a thread for managing TCP at all, for example.

In the end, which way you go depends entirely on what ends up working best for you. Personally, I find that TCP is easier to work with, and would use that where possible. If it eworks for World of Warcraft, it can't be all bad. (More FPS style games or simulations, though, and you'd want UDP)

Regarding "the engine is ready for whatever I do next" -- that's generally not a great reason to make a choice for the current game. It's hard enough to ship the current game -- you should make the right choice for that. IF you need another choice for the next game, then you can re-make that choice later, but making a choice for some future possible benefit that you have no way of proving or testing right now is not generally the smartest strategy.
enum Bool { True, False, FileNotFound };




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS