Java Reference
In-Depth Information
to the destinations. Internet multicasting is built on top of UDP. Multicasting in Java
uses the DatagramPacket class introduced in Chapter 12 , along with a new Multicast
Socket class.
Multicasting
Multicasting is broader than unicast, point-to-point communication but narrower and
more targeted than broadcast communication. Multicasting sends data from one host
to many different hosts, but not to everyone; the data only goes to clients that have
expressed an interest by joining a particular multicast group. In a way, this is like a public
meeting. People can come and go as they please, leaving when the discussion no longer
interests them. Before they arrive and after they have left, they don't need to process the
information at all: it just doesn't reach them. On the Internet, such “public meetings”
are best implemented using a multicast socket that sends a copy of the data to a location
(or a group of locations) close to the parties that have declared an interest in the data.
In the best case, the data is duplicated only when it reaches the local network serving
the interested clients: the data crosses the Internet only once. More realistically, several
identical copies of the data traverse the Internet; but, by carefully choosing the points
at which the streams are duplicated, the load on the network is minimized. The good
news is that programmers and network administrators aren't responsible for choosing
the points where the data is duplicated or even for sending multiple copies; the Internet's
routers handle all that.
IP also supports broadcasting, but the use of broadcasts is strictly limited. Protocols
require broadcasts only when there is no alternative; and routers limit broadcasts to the
local network or subnet, preventing broadcasts from reaching the Internet at large. Even
a few small global broadcasts could bring the Internet to its knees. Broadcasting high-
bandwidth data such as audio, video, or even text and still images is out of the question.
A single email spam that goes to millions of addresses is bad enough. Imagine what
would happen if a real-time video feed were copied to all billion+ Internet users, whether
they wanted to watch it or not.
However, there's a middle ground between point-to-point communications and broad‐
casts to the whole world. There's no reason to send a video feed to hosts that aren't
interested in it; we need a technology that sends data to the hosts that want it, without
bothering the rest of the world. One way to do this is to use many unicast streams. If
1,000 clients want to watch a BBC live stream, the data is sent a thousand times. This is
inefficient, since it duplicates data needlessly, but it's orders-of-magnitude more efficient
than broadcasting the data to every host on the Internet. Still, if the number of interested
clients is large enough, you will eventually run out of bandwidth or CPU power—prob‐
ably sooner rather than later.
Another approach to the problem is to create static connection trees . This is the solution
employed by Usenet news and some conferencing systems. Data is fed from the origi‐
Search WWH ::




Custom Search