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

Real-time multiplayer in a browser with node.js and HTML5 is a myth?

20 posts in this topic

Hi all,

 

I just wanted to post a topic here which I asked recently at other forums also but didn't get yet much feedback.

 

For starters, I wan't to say that I am currently middle of process researching/writing my own first real-time multiplayer roleplaying game to browser environment using technologies such as node.js/socket.io and I have my doubts whether I finish it some day or not - so won't be showing any cool links, at least, not yet smile.png

 

The thing which really concerns me is that I have stumbled upon an issue that TCP/IP (according to many resources and literature) is just not suited for real-time multiplayer games, it works for multiplayer games with slower pace where getting responses from server with varying even bigger milliseconds (or second(s)) doens't matter and don't affect the gameplay much. For instance, Heroes of Might and magic (turn-based) in a browser? possible. Games likes the type of Diablo (real-time), not possible.

 

To be honest, this is sort of a broken dream for me.. articles (from ACM) and through internet worries me that I have jumped too early to a train of technology, which simply to put - is not there yet.

 

I have tried my best to use techniques such as prediction, delta-packets vs full world snapshots and interpolation (which is sort of under dev atm.).. which makes my game use less bandwidth and be more latency tolerant.  

 

However, the real problem is in TCP/IP itself and how it works, because socket.io communicates over it, it is argued not to be not suited for real-time multiplayer games at all.

 

The fact which concerns me most is packet loss and how TCP/IP behaves in front of it compared to UDP:

 

"..whenever a packet is lost, everything has to stop and wait for that packet to be resent. On the client game objects stop receiving updates so they appear to be standing still, and on the server input stops getting through from the client, so the players cannot move or shoot. When the resent packet finally arrives, you receive this stale, out of date information that you don’t even care about! Plus, there are packets backed up in queue waiting for the resend which arrive at same time, so you have to process all of these packets in one frame. Everything is clumped up! Unfortunately, there is nothing you can do to fix this behavior with TCP, nor would you want to, it is just the fundamental nature of it!"

 

As a reference where this text is taken, section: "Why you should never use TCP to network a multiplayer game", see: http://gafferongames.com/networking-for-game-programmers/udp-vs-tcp/

 

So to speak, TCP/IP is not suited because it will try to resend data every time again and again through the line when it detects packet loss (including all buffered data which happened to every client at that time), even more, because it tries to guarantee this delivery it is much more slower than UDP. And the problem within case of a multiplayer game is that every new user joined to a game is a big risk in terms of service quality. We all know that packet loss is way too common.

 

In favor of TCP/IP I must say that I would really like to use it - I though that I could use it, but facts are really getting into me at this point. I have also seen resources like http://onedayitwillmake.com/blog/2011/08/creating-realtime-multiplayer-games-using-node-js/ which demonstrates that "hey this can be done". But lets be real, that is an example with few clients connected to a localhost? (At least, it looks like it) rather than running a remote server under real circumstances.

 

The thing which I also noticed earlier is that in node.js you can send messages using "volatile" flag while emitting, to avoid resending when failure is detected, however as I traveled through google I began to understand that it was only some internal queue issue rather than somehow mystically getting rid of problems of TCP/IP ?

 

Now, the question is - does someone have actual facts and proofs that TCP/IP is a winner in terms of real-time multiplayer games for browser environment or not? sad.png Can it be done? and how? I am sort of a in a dead end right now.

 

If I need to abandon the idea of TCP/IP and just go for the UDP, within browser environment it is sort of "impossible" I found this reference: http://blog.alexmaccaw.com/chrome-tcp-udp but that's basically it, pretty limited.

 

Why this thing is bugging me is that I feel that I have tried to make own multiplayer rpg many times at the past and finally when I am comfortable actually making it (and have the skills to make it), I see a big wall in front of me. As a bright side, I am much better programmer at this point than ever before. tongue.png

 

If UDP is the only way, I might quit my dream of making it to browser environment, that being said I also know java/c# and some c++/c just push me towards to making this all happen.. I would just hate to start it all over again to different environment.

 

Thnx, hopefully posted to a right forum, i need answers from other multiplayer game developers smile.png

0

Share this post


Link to post
Share on other sites

Realm Of The Mad God.
Real-time; Multiplayer; Client is written in Flash and can be played in browser.

So, yes, it can be done.

 

Hmm that's a good point, I actually remember trying it once before.. even though it's with flash I assume that it really goes over TCP/IP (right!?) and works so well, that would be really good news rolleyes.gif

0

Share this post


Link to post
Share on other sites

Another item to keep in mind is that UDP is no longer a guaranteed win in any case.  Many routers are configured to prioritize tcp over any form of UDP and as such have a very high drop rate for games.  Given this, the increased logic of routers to handle tcp packets better, along with the generally higher loss rate of UDP compared to even a few years ago, TCP *can* often provide better gameplay than even the best UDP.  Keep in mind, I'm not saying UDP sucks and you should not use it, just that as far as the win scenario goes, it is no longer easily cut and dry like it was.

2

Share this post


Link to post
Share on other sites
TCP works fine for most real-time games if you disable the Nagle algorithm. Which, thankfully, some (maybe even most?) browsers do with their WebSocket implementation.
1

Share this post


Link to post
Share on other sites

Thnx for the replies hpus0603, SeanMiddleditch and jbadams. Very interesting details, I definitely continue my project further and use all the techniques I can find and think of which could benefit making a game over TCP.. even if it means making small gameplay compromises, which I will make if game experience benefits from them. thnx!

1

Share this post


Link to post
Share on other sites

Many routers are configured to prioritize tcp over any form of UDP


Every now and then, I hear this, but I have not seen any actual data or evidence of this being the case.
UDP is used for voice-over-IP, which is a large, important technology for the backbone carriers (that carry telephony and internet data interchangeably.)
UDP is also needed for DNS look-ups, which happen before most TCP connections even start; a slow DNS resolver is a more visible source of "slowness" to a user than almost any other reason!
I would be highly surprised if it was general behavior on the internet to drop UDP and favor TCP.
1

Share this post


Link to post
Share on other sites

In HTML5 you have support for WebRTC which can go through UDP (or is it SCTP?) in Firefox (at the moment). Maybe check that out?

 

https://code.google.com/p/sctp-refimpl/

 

spinningcube

 

PS - It is something I am looking into myself, so quite interested

 

Hmm good point mate, however, that seems sort of a too far future to me when considering all the browsers people uses today (including mobile/tablet) ? we just got over the fact that websites doesn't need to work well at IE 6 anymore biggrin.png I don't even have Firefox installed, wouldn't this be same as using some another plugin in browser which could enable UDP (maybe unity?).. I mean that I am trying to look this thing from user point of view also - for me, browser based games is awesome because you can just navigate to a website and play. If you kill that idea, it is (almost) same to me than making some desktop app which you need to download. hehe.

 

I don't mean to be offending but this thing just crossed my mind smile.png if I continue programming games I might use WebRTC within few years from now.

0

Share this post


Link to post
Share on other sites

OpenGL ES 2.0 compliant -> LLVM -> Emscripten -> Browser


FWIW, at work, we do just this for our newer and upcoming projects!
We actually have a C++ engine that targets native for mobile, and targets Emscripten for browsers.
There is a cost, both in development and runtime, for using Emscripten over using a native JS engine, but that cost is shrinking, and the cost of building two engines (one for native, one for JS) would have been *much* higher.
1

Share this post


Link to post
Share on other sites

I sense the uncomfortable vibe this topic brings to some, and I have recently ran into this little video:

 

http://www.youtube.com/watch?v=NpC1GbPw-fk

Charlie Crane: Game server development in node.js -- JSConf EU 2013

 

These good Chinese fellows are pretty much tackling this topic, in a serious scale. Open source, too. Great stuff. Video has some interesting statistics towards the end. I don't know any details, personally. Their code seems clean.

Edited by Phuein
1

Share this post


Link to post
Share on other sites
Super-dyanamic langauges like JavaScript (or PHP, or Python) can be highly productive while developing, but end up costing not only a bit of performance (a LOT for PHP, a little for JavaScript) but also in maintainability.
Check out this link, about how a single missing "var" statement ruined the launch of a product: http://blog.safeshepherd.com/23/how-one-missing-var-ruined-our-launch/
Sadly, all too common in JavaScript projects (although using jshint helps to some extent: http://jshint.com/ )
1

Share this post


Link to post
Share on other sites

I sense the uncomfortable vibe this topic brings to some, and I have recently ran into this little video:

 

http://www.youtube.com/watch?v=NpC1GbPw-fk

Charlie Crane: Game server development in node.js -- JSConf EU 2013

 

These good Chinese fellows are pretty much tackling this topic, in a serious scale. Open source, too. Great stuff. Video has some interesting statistics towards the end. I don't know any details, personally. Their code seems clean.

 

Well, that's nice.. watched the video and looked up their source.. seems really massive (lots of code comments in Chinese) tongue.png .. too bad that their example demo seems to run at bad server or with even worse bandwidth? downloading simple .js files takes likes 15 sec and executing game never get past 98%.

 

However, I would really like to hear why you describe that vibe to be uncomfortable ? smile.png

 

 

Super-dyanamic langauges like JavaScript (or PHP, or Python) can be highly productive while developing, but end up costing not only a bit of performance (a LOT for PHP, a little for JavaScript) but also in maintainability.
Check out this link, about how a single missing "var" statement ruined the launch of a product: http://blog.safeshepherd.com/23/how-one-missing-var-ruined-our-launch/
Sadly, all too common in JavaScript projects (although using jshint helps to some extent: http://jshint.com/ )

 

Yes, I think the problems of that is somewhat tackled down with automatic jshint (on save) including for example. JsFormat/EditorConfig etc. plugins for sublime, this all requires ofc. that you set those up and full team who is developing is committed to do so. Because jshint actions can be made run on save you really can't push code without var etc. to repository. I really like jshint, just set rules to your js once and start coding. (ok, if you are dumb you can ignore the warnings in console and just go with it).

Edited by maunovaha
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