Got questions about networking or multiplayer?
Miscellaneous Forums/General Discussion/Got questions about networking or multiplayer?
I have written a short article on Networking.
It explains the basics of how packets travel the internet and how TCP and UDP works. Read it
Here .
Topic: Multiplayer and NetworkingI'm still interested to hear what you would like to know on the subject.
- Anything you want to know or have been woundering about?
- Do you know of any myth or common missconception?
- Do you got any "must have" questions you can suggest?
- Which topics would you like to be brought up?
- Any discussion questions that you see interesting?
If you have any interesting links you are welcome to post them and I'll add them at the end for those who want to learn more.
That's a good idea.
I've always wondered about how I should send data to/from the server (like player coords etc) and how they should be handled by the server.
how bout everything. Networking scares the monkeys out of me. It would be great to understand
[edit] double post sorry.
How do I make a MMPORPG?
With some cardboard loo rolls, egg cartons and sticky-back plastic.
something explaining how to maintain synchronised data regardless of connection speed would probably be useful.
One Eyed Jack: ya forgot the washing up liquid bottles otherwise how else will you mane the millions of things they disassemble into ROFL :)
Keep it coming :)
I've got several :)
Knowing/Wondering about:
- advantages/disadvantages of TCP vs UDP in regards to stability and reliability. Is there a particular protocol used for particular genres (ie turn-based uses TCP vs FPS uses udp)?
- Why isn't a Peer-to-Peer networking model used more often as it boast a better ping average and less bandwidth usage overall on the server. (I've created a game that actually uses a hybrid p2p/server-client and it worked out rather well).
--------
Myths/Misconceptions:
- I've seen several accounts of people believing as the graphical complexity of games go up that there must be an equal amount of increase in network data to be transferred.
---------
Must Have:
- how to go about testing varying network situations (i.e. out-of-order packets, packet-loss, high ping) in a closed devlopement environment.
-------
Topics:
- Simplistic overview of the different solutions for client-side interpolation. (kind of on par with Perturbatio's question)
- useful article on dealing with latency issues in real-time games:
http://www.gamedev.net/reference/articles/article914.asp--------
Discussion:
- How far off you think before we consistantly see real-time MMO's that'll require time-critical player input that's on par with fast-paced small-group online games like Quake, BF2, Unreal Tournament? Going back on a previous question, wouldn't you think a P2P solution would be much more advantageous than a centralized server-farm (especially with the widespread use of broadband nowadays)?
Thanks, I'm holding back from starting to answer all questions right here ;)
haha, can't wait to see the article :D
It would be nice to have some examples/articles about protocols and how to keep the "chat" secure and short.
Maybe something about what is an acceptable amount of transfer (Kb/s, etc) for a game with some examples to go by.
I'm looking forward to reading your article.
Off Topic: Rimmsy, I tried replying to your mail, but it's blacklisted somewhere between my provider and your mail server. Any other address where I can reach you?
Sorry dude, matt AT birdinsky.com . I think my email might have been the plaything of a script kiddie. I'll have to get that sorted. Thanks!
Some of the topics brought up is enough for several articles, however I still like to hear more comments.
Common questions that I have been thinking about bringing up:
o Protocols - TCP v UDP and what happens when you send data.
o Architecture - Some examples (Basically how the data transfer between the players works).
o Latency,Lag and Prediction.
o How MMORPGs work.
Most indi developers automatically send packets using a timed interval. For many games this isn't sensible because it could mean you've got 200ms latency before you even send a packet.
Most of my multiplayer coding uses a timed interval, but when a new control key is pressed the interval is set to 0 so that when a player changes direction or presses a control which will directly impact their position or orientation on other clients the packet is sent strait away.
In a game sending 5 packets a second this means that anything up to 200ms is instantly cut from network latency.
I dont send verification packets or anything like that at all, if a packet is dropped I simply replace it with the next packet to arrive on the timed interval, so the packet timing is the fall-back security and therefore a lost packet will, at worst, result in discrepancy for just .2 of a second.
In my experiance another comman mistake is to send too much information. For instance when a player fires the only information that need be sent is that the player has fired, the receipient machine can then work out the position of the projectile. The co-ord of the projectile dont need to be transfered as the receipient machine can work these out. Also if a player is not visible then no data is required to be sent regarding position etc.
I looked in network coding myself a while ago and there is a lot more to it then many people think, it is a very complex subject, and will take many hours to implement 'well' into even the simplest of games.
I would be interested in a tutorial covering schemes to make UDP packets reliable, as well as ensuring that they are processed in the order they are sent.
I am pretty experienced with BNet, and could do a simple server/client game tutorial showing the reliable and duplicate packet schemes that I use, if you need me to.
I'll read it :-)
Eikon, I'll be happy to take a look at it.
Keep the questions and suggestions coming.
An indepth tutorial on how to create a networking framework and how to set-it-up/implement into existing game codewould be nice, last time I tried doing networking in b3d, my code was a horrid mess for something just as simple as sending player coordinates.
(still was cool see'ing my red & green boxs send their movements to each other)
Alright, thanks for the encouragement guys.
Tutorial code is complete. It's a Mario Bros. demo where two players can jump around the screen at the same time. Features include:
- Ping routine
- Reliable packet scheme
- Old and duplicate packet detection scheme
- Join and quit routines
- Player animation state system, shows how to achieve smooth movement and animation at relatively any ping.
Keep an eye on the BlitzMax tutorial section. Since the code is done, I could have the tutorial up as soon as later tonight.
* edit *
it's posted now
Where do I post an Article?
I posted mine in the
BlitzMax Tutorial Section. I would advise linking from there to the article in HTML or other format. Writing up articles using forum code can be a pain.
Is a tutorial considered the same as an article?
Here is a link to part 1 of my networking tutorial, it is in html format, I will upload a pdf after I have gotten some feedback and I feel it is more complete.
Very nice and detailed though there are some misspellings.
Thanks, can you point them out? Then I'll fix them :)
- You computer receives a lot of messages of different types.
+ Your computer receives a lot of messages of different types.
- If a message arrive out-of-order then TCP will “hold” the message until the missing messages is received and the then reordered in the same way they where sent.
+ If a message arrive out-of-order then TCP will “hold” the message until the missing messages are received and then reordered in the same way as they where sent.
- TCP is a stream based.
+ TCP is stream based.
+ TCP is a stream based protocol.
- A UDP message can also be duplicated are received more than once.
+ An UDP message can also be duplicated and/or received more than once.
There's probably more, but I'm not sure.
I understand how it works... I just want some easy to read code!!!
There isn't any difference if you have code, with more lines of comments than there's code itself, than having a tutorial where main attention is on the comments rather than code. Atleast I think there will be some code examples too because it would be the best way for creating a tutorial/article.
Better create a tutorial for everyone, but not just for those who already know how to code net and just need to know something specific.
Thanks Andres, I will fix those in the next update :)
Here is a simple chat program for Blitzmax:
It uses the TNet Multiplayer Library and shows how you can quickly set up a client-server game and send messages.
Import Truplo.TNet_Advanced
Graphics 300,300,0
Const HostPort = 44444
Const CHAT = 1 ' Message Type for Normal Chat Messages
Local WantToHost = True ' True to Host
Select WantToHost
Case True
If TNet_HostUDP( HostPort ) = False RuntimeError "Port "+HostPort+" already in use!"
Case False
Local IPofHost$ = "127.0.0.1" ' Use 127.0.0.1 to connect to yourself
If TNet_JoinUDP( IPofHost$, HostPort ) = False RuntimeError "Cannot find host!"
EndSelect
Repeat ' -------------- -L -O -O -P -------------------
Local Message$
TNet_Update()
If KeyHit( KEY_1 ) Message = "Hello"
If KeyHit( KEY_2 ) Message = "Hi"
If KeyHit( KEY_3 ) Message = "Greetings"
If KeyHit( KEY_4 ) Message = "Yo"
' If any Key was hit then send a message to everyone who is connected:
If Message Then TNet_Send( CHAT, Message )
'Chat
TNet_Receive( CHAT ) 'Updates the Global TNetData Variable
DrawText "Last Received: "+TNetData,20,200
DrawText "Use keys 1-4 to send messages. ",10,20
'Draws each Client and their Latency
TNet_DrawClientList(10,50)
Flip;Cls
Until KeyDown(Key_Escape) ' -------------- -L -O -O -P -------------------
I'm sorry for the lack of comments but I consider it pretty selfexplainatory. Feel free to ask any questions about the example and I will improve it.
Yes I agree with the point of not including any code in the article when discussion theory. The theory is the same whatever network library or method you use and by not including code it can prove informational to anyone - even non-programmers.
But when it comes to something specific like creating your own protocol then it would be nice to see some code examples too because not everyone's english is very good (including me), but maybe they'll understand the code example.