Sign in to follow this  
Wooh

LAN: Is it bad practice to use broadcasting to send all data?

Recommended Posts

Wooh    1088

On a LAN game is it considered bad practice to send all information as broadcasts? Sending the same information to all clients would mean more traffic on the wire but using broadcasting would mean more work for the innocent computers that doesn't play the game.

Share this post


Link to post
Share on other sites
hplus0603    11347

is it considered bad practice to send all information as broadcasts?


Not necessarily. However, if there is a server involved (to break ties for "who picked up the healthpack first,") then the information another client would see from other players wouldn't be very useful.

Broadcast also actually uses more bandwidth even for the players that participate, because each individual packet has overhead on the wire from the switch to the computer. With broadcast, N small packets have to go to (N-1) computers. With client/server, (N-1) small packets go to the server one from each player, and (N-1) large (aggregated) packets go from the server, one to each other player.

My advice: If you use a server, don't use broadcast.

Share this post


Link to post
Share on other sites
SeanMiddleditch    17565

I think he's specifically talking about TCP broadcast

 

Short version: heck no, don't use TCP broadcast.  Multicast is another story.

 

A consideration is network topology; sending to individual clients is going to work on far more networks (including the wide, wild Internet) where broadcast is going to limit you to LANs, and then only _simple_ LANs.  Multicast is going to give you a lot of trouble on the Internet though it could be made to work in more complicated LANs.

Share this post


Link to post
Share on other sites
Nypyren    12063

The only thing I ever use broadcast for is for LAN announcement to find active servers.  I stop broadcasting once I get the list of LAN servers.  I then connect directly to the server and run things like a normal client-server setup (since my network code uses the same connection process for internet games).

Edited by Nypyren

Share this post


Link to post
Share on other sites
oliii    2196

Yeah, like Nypren says. I restrict the use of broadcast to LAN host discovery. After that, there is just no need to use a broadcast socket. clients.

 

You could theoretically use broadcast to advertise LAN hosts, and possibly clients too, but I prefer the other way around. Less noise and less traffic. 

Edited by papalazaru

Share this post


Link to post
Share on other sites
wodinoneeye    1689

Generally most games dont sent huge amounts of data changing/sent so that 100Mb network hardware  well exceeds  what is needed.

 

(interesting is how (now more commonly used) WiFi LAN might shift this a little??)

 

BUT ...

 

Maybe some games (future games) which have massive gameworld updates where replicating it all to each client might cause issues.

 

Is Minecraft  an example (or might be as it is growing ever more dynamic) or is the data of that game still too simple/small even if 1/3 of the world goes boom its transmitted in seconds....

Share this post


Link to post
Share on other sites
Wooh    1088
Thank you for all your opinions. I have decided to use UDP broadcasting only to find the other players. I think this will allow me to reuse a lot of code if I choose to implement playing over the Internet in the future. Only the code to find and connect to other players would have to be different.

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