Advanced winsock multiplayer game programming multicasting.pdf




















Multicasting only makes a worthwhile gain in performance when network data is replicated, realistically only worth bothering when there is support for more than four players. Multicasting requires some more coding and programmers are lazy to even look into it.

As you will see, in fact it requires very little additional code. The corporate "Quality Digital TV via Multicasting" idea seems to put game programmers off the subject altogether, I suspect it has something to do with hacker ethics, so long live the. The openness of multicast groups may make your packets easier to sniff. Usually UDP packets can only be intercepted between their source and destination, but now they can be captured anywhere on the network; by joining the right group, anyone can get a carbon-copy!

Broadcasting forwards data to every address on the network. Unlike broadcasting, multicasting only forwards to those addresses who have explicitly registered interest in the data. On an IP network supporting multicasting there are such things as multicast groups. If you want to receive multicast data packets, you must join a multicast group. Although it should be possible to send data packets to a multicast group regardless of membership, it is often better to join a group before sending to it for reasons I won't venture into.

If you are a member of a group to which you are sending multicast data packets, you will receive a copy of the data packets. Also, a client will not receive all data packets from a multicast group, but only those which are sent to the port that the socket is bound to. So a sensible idea would be for all the game clients to join a multicast group and wait for data on the same port. Then the server, by sending a single packet of data to that multicast group, would be sending to all the clients as the packets are replicated somewhere along the way.

We've seen the light, we've seen the darkness, so let us onto the code To request becoming a member of a multicast group is a lot simpler than you may at first imagine.

Game specific info here Cancel Save. Latest Comments. Nick of ZA. So, ten years since this article was written. Broadcasting on the Internet would create an enormous amount of traffic, so it is not allowed. These servers are costly to run and their uptime is often undependable.

This will not connect all the players as some may be in different chatrooms. And the process of finding someone may take a while. So here we are with an age old problem how A finds B on one hand and multicasting on the other. All game clients simply connects to a multicast group, multicast an "I want to play" message and the servers can then advertise their availability directly instead of multicasting, to save bandwidth to the clients who are members of the multicast group.

Sure, there are itsy-bitsy technical problems to sort out, but the idea is cool enough. And the TTL control allows us to query within a certain range of routers see TTL table so we can specifically only ask to send to our LAN, or a university network, or all servers within our country to respond. Don't you think that is COOL? I sure do. But how do we integrate multicasting into our game as an option?

Integrating Multicasting into Games Ok then, where do we start? There are so many different types of multiplayer games that I won't even try to explain how to integrate multicasting into different types of games. Instead I'll just give a few possible ideas of solutions in a client-server relationship. First of all, all the current network code should be kept as it is, when you add multicast support make sure you do not remove any existing code unless you really think it is necessary.

Parallel integration bah, the things I learned in school last year is my favorite as it will use multicasting only if it is supported and should be transparent to the user. How do we determine if multicasting is supported? Just read the error setsockopt gives us when trying to join a group:. The client-server relationship is a game of two halves. So what if the server supports multicasting while the client does not?

How does the server know which clients are covered with a single send to the multicast group and which are not? The client first determines that it does not support multicasting, then connects to the server and tells the server whether it supports multicasting.

The server usually keeps a list or array of clients, to which it is easy to add an extra boolean flag:. Game specific info here The server's function to send data sends a multicast to clients who support multicasting and normal UDP datagrams to those that do not. If, however, the server itself does not support multicasting then we must use the old method.

Here's a useful code snippet for a server with multicasting as an option:. I hope I've shed some light on multicasting and its possible uses in games. If you've found this article the least bit interesting or have a problem, drop an email to denis voxelsoft. I hope to write another article soon, but for now, Happy Multicasting! All rights reserved. Terms of Use Privacy Policy Comments? Send us an e-mail! Open navigation menu.

Close suggestions Search Search. User Settings. Skip carousel. Carousel Previous. Carousel Next. What is Scribd? It is a great and easy to understand book that will guide you through everything you need to know for creating games.

I recommend Linux Game Programming but the programs are written in C. Try to understand pointers and structures and it will be a lot easier to learn it.

You can skip the first few chapters about all those tools. Start at SDL section. All rights reserved.



0コメント

  • 1000 / 1000