• 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
MARS_999

UDP or TCP?

9 posts in this topic

I am working on a RTS or maybe a turn based strategy game, IIRC UDP is better for RTS, FPS games, so should I use UDP or stick with TCP?

has this changed at all in the last few years? or is UDP the way to go?

Thanks!
0

Share this post


Link to post
Share on other sites
This depends entirely on your network model.

If you intend to do lockstep simulation, stick with TCP as guaranteed delivery is important and you don't want to have to reimplement that on top of UDP. If you're going for only-show-latest-data, UDP is fine since you can always update once new data comes in.
1

Share this post


Link to post
Share on other sites
Given that Starcraft, Age of Empires, and Warcraft all use TCP, I don't understand why you think UDP is better for a RTS.

The main thing UDP has going for it is that NAT punch-through is easier to build. However, there are many other things you need to have before NAT punch-through is even important (much less possible,) so I wouldn't worry about that right now.
0

Share this post


Link to post
Share on other sites
If you require confirmation of data retrieved, i.e. you are making a synchronous system, TCP is a must
if you just need the latest data, as fast as posible, UDP is a better option.

for a RTS/turn based, skill shots is usually less of a requirement than having all the data you need. Also, TCP always seems to be efficient enough for a reliable connection speed.
-1

Share this post


Link to post
Share on other sites
Is it reasonable to have a combination of both? I'm confused exactly what the broadcasting life of a fired bullet might look like.

Would you TCP message a server that a bullet was fired to make sure the hit happened? Would that be responsive enough? Or would you UDP update the bullet's position/velocity along like the player position/velocity over the bullet's lifetime and hope that one of the packets makes it? Is general latency such that a bullet's lifetime lasts less than a UDP trip to a server so the game might only get one packet off, which might be lost? In which case would you have to UDP along the bullet's position several times, possibly even after the bullet's lifetime, to make sure that one of the packets makes it? If so, how long should you send these packets after the original shot?

What's the general way to handle traffic for bullets or other short-lived events? and via UDP or TCP?

I might be network paranoid/mistrusting. o_O

Edit: Up there I was assuming the creation of the bullets happened on the client side. You might also UDP along that the player is holding down the fire button, by which the server will react whenever it catches on. It would then create the bullets and manage them server side, and UDP the position/velocity of the bullet back to the player. The client physics engine would take it over as if a regular particle, and its visual look would then have no implications on what happened. Is it still possible for some freak packet loss circumstance that makes it so the player's bullets aren't displayed, but still acted on? >_>
0

Share this post


Link to post
Share on other sites
UDP is the wrong thing to use if you need to know what's going on, period.

Either you use TCP and get the job done, or optionally use a reliability layer on top of UDP (which is, IMHO, almost always a waste of time, except for really niche applications, since you could have just used TCP with appropriate configuration). Otherwise, something like this happens:

- Player hits Fire button for 1/5th of a second, which is, say, 6 frames.
- UDP packets are lost for 8 frames around this time, due to network hiccup.
- All the UDP packets saying "fire" are gone
- Other player, being on a different network, hits Fire at this time and his packets make it to the server
- The server then "reliably" tells the first player he is dead
- Player ragequits because he shot first and still died, and then tells everyone on reddit that your game is shitty

This kind of thing happens all the time in network models that are not designed for reliability. If you need to know when something happens, don't use UDP.

That's not to say TCP is a panacea or magic sauce, though. Look at early releases of Halo 2 for examples: they had a terrible latency compensation model, and players were [i]constantly[/i] complaining that they pulled the trigger and then died 2-3 seconds later of mysterious circumstances.



TL;DR: networking is hard. Don't make it harder than it has to be by trying to overcomplicate things with unreliable network protocols.
2

Share this post


Link to post
Share on other sites
Lastly for me, is it uncommon to see both TCP and UDP built into a server? TCP to get critical stuff done, and UDP to pump out ever-moving "acceptably lost" data?
0

Share this post


Link to post
Share on other sites
Using TCP + UDP is sometimes done, but it kind-of has the worst performance of both. TCP simetimes likes to jam really big segments down the uplink, causing jitter in packet delivery of the UDP half. Also, TCP doesn't play as nice through NAT punch-through as UDP.
Thus, you either stick with TCP, and accept that sometimes data is delayed, or you go with UDP, and once you have UDP working, you might as well put a thin reliable/re-send layer on top of that UDP code.
0

Share this post


Link to post
Share on other sites
TCP will throttle UDP badly if you get into traffic contention issues.

I would not mix and match. use one or the other.

If latency is not an issue and you can use a deterministic model a-la Starcraft 2, TCP is good to go.
0

Share this post


Link to post
Share on other sites
A lot of theory was crafted studying TCP vs. UDP, deterministic vs. non-deterministic...

And then [url="http://www.realmofthemadgod.com/"]there's this[/url].

Flash, TCP, in browser, 85 players always updated, per-pixel hit tracking, works across continents, twitch that makes Diablo look like turn-based Chess match.

Networks are fine, so are computers. The rest will be on how things are handled on client and server.
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