Advertisement

a few questions

Started by June 16, 2002 04:35 PM
1 comment, last by Tang 22 years, 7 months ago
well, I''m quite new with network prog and here are a few questions : -I know that tcp is a very bad idea for an internet multiplayer game, but is it ok to use tcp on a LAN ? or should I just use udp ? -Also, what average latency should I expect on a LAN ? -then, about packet size : is there an ''optimal'' size when i send a message through yhe network ? in other words, is it better to send only one big message or many smaller msg (with several calls to send() ) ? -- Tang
"-I know that tcp is a very bad idea for an internet multiplayer game, but is it ok to use tcp on a LAN ? or should I just use udp ? "
tcp is a bad idea for a REAL-TIME internet game, it''s fine for turn based games. Using tcp on a lan usually works fine, as long as you''re sure you''ll never want to play over the net

"-Also, what average latency should I expect on a LAN ?"
depends on the size, speed, type of the LAN and the amount of traffic. Soemthing between 0-10ms, but it can get much higher if you are doing things such as playing games such as FPS''s with lots of players on a non-switched network, or if someone is transferring large files on the network.

"-then, about packet size : is there an ''optimal'' size when i send a message through yhe network ? in other words, is it better to send only one big message or many smaller msg (with several calls to send() ) ?"
IF all the computers in the LAN are on the same subnet (ie. none of the traffic needs to be routed to another LAN), it doesn''t matter too much, it especially matters less with tcp, because tcp packets can be fragmented effectively. However, it is generally good practice to send not-to-small packets, as each packet/message you send has the extra overhead of the tcp/ip headers. If you are using UDP you should try not to send anything over about 1000 bytes, because some routers will drop packets that are over 1kb automatically. Also be aware that with very large message sizes (mainly with tcp) they do take a finite amount of time to actually get from one part of the network to the other, and if you have to wait for the entire message to be received before you can process it, it could slow down parts of your game, although once again on a LAN this is much less of a problem than playing over a 33.6 modem
Advertisement
just a quick opinion..

TCP is not "bad" as a rule, for example if the data your sending is critical and Must arrive then use TPC.. if your data can usually arrive but not always, then use UDP. An example of when UDP is better is in like a 3D game where u keep getting updates on where you are etc.. so if you miss one then you get upto date very quickly :-) Personally on my game i use both. TCP for the critical stuff and UDP to send messages such as activating a sound effect that the player hears (who cares if they dont hear it)

best of luck

~ wrathgame
~ Tim

This topic is closed to new replies.

Advertisement