Java Enterprise Java P2P Dynamic Networks

P2P Dynamic Networks


This material is from Chapter 6, P2P Dynamic Networks, from the book Java P2P Unleashed with JXTA, Web Services, XML, Jini, JavaSpaces, and J2EE (ISBN: 0-672-32399-0) written by Robert Flenner, Michael Abbott, Toufic Boubez, Frank Cohen, Navaneeth Krishnan, Alan Moffet, Rajam Ramamurti, Bilal Siddiqui, and Frank Sommers, published by Sams Publishing.


P2P Dynamic Networks

by Robert Flenner and Frank Cohen

In This Chapter

  • Discovery

  • Identity and Presence

  • Virtual Spaces

  • Routing

  • Performance

Techniques for peers to discover and use each other's functions are perhaps the greatest distinction between P2P technology and client/server Web technology. P2P technology expects peers to live at the edge of a network, and to require a variety of techniques to interoperate. On the other hand, client/server Web technology requires the network to know where to find resources before the request is made. P2P uses a group of methods known collectively as discovery.

Discovery

Discovery answers the big questions about a network:

  • What peers exist on the network?

  • How are the peers organized around their capabilities?

  • What uniquely identifies a peer?

  • How does a peer exchange data with another peer?

P2P is forced to identify answers to these questions. Unfortunately for the Java developer, not all P2P technologies are successful. Worse yet, some P2P technologies are closed and proprietary, or they hard-code implementations into one solution that would otherwise use open technology.

Although many P2P techniques exist to build peers, three types of peers have emerged as popular designs:

  • Simple peer

  • Rendezvous peers

  • Router peers

A simple peer is designed to be an endpoint that offers functions and data to peers making requests. Simple peers have the least responsibility of all three peer types. They usually reside outside a general network, and possibly behind a firewall or Network Address Translation (NAT) router. Simple peers are not expected to handle communication on behalf of other peers, or to serve information that they don't directly consume themselves.

Rendezvous peers provide a dating service in which peers discover other peers and peer resources like data and functions. All three types of peers issue discovery queries to rendezvous peers, but the rendezvous peer is also usually a cache of previous requests. When a rendezvous peer lives behind a firewall, it must have the ability to communicate through the firewall to other peers.

Router peers provide a mechanism for peers to communicate through firewalls and NAT routers. A router peer tunnels peer requests across a network. The information needed to use a router peer is enough to replace the need for a Dynamic Naming Service (DNS) and supports dynamic IP addressing.

Let's look at a simple example of the three peers in action. Imagine using a P2P client that looks for magazine articles on human genomics. The user initiates a search for the articles with a simple peer. The peer sends a discovery query to all its known simple peers and rendezvous peers. The rendezvous peers that receive the query look to see whether they have data the simple peer is looking for. If so, the rendezvous peer might return a discovery response message containing advertisements from other peers that are stored in its cache. The rendezvous peer will also likely send along the same query to its list of known peers.

Although we have described three different types of peers, in real-world P2P applications each peer might include a combination of the functions described in simple, rendezvous, and router peers. Let's look at how peers discover data, functions, and services using a variety of P2P techniques.

Router Peers and Dynamic Networks

P2P technology expects to find a network filled with firewalls, dynamic addresses, and changing peer locations. P2P provides a loose coupling of peers, so the P2P network remains functional even when parts of the real network break. Three P2P discovery techniques have become popular in this environment:

  • Broadcast—Sends a discovery request to every network node that is reachable

  • Selective broadcast—Sends a discovery request to every network node based on established heuristics

  • Adaptive broadcast—Sends a discovery request to every network node based on heuristics and rules

These techniques will be joined, modified, and abandoned over time as new ways to dynamically form a network are identified. The following are some of the areas of study from which P2P technology innovations might spring:

  • Transport—How do transport services such as broadcast, multicast, and unicast messaging relate to discovery?

  • Radius—How is the discovery horizon established and maintained?

  • Frequency of broadcast—How often should discovery messages be broadcast to populate the network?

  • Discovery protocol—What information should be defined in a discovery protocol?

  • Discovery roles—Do all peers participate equally in the discovery process? Do all peers have the same broadcast role?

Broadcasts

Traditionally, broadcast messages have been sent by devices that deal with
network routing or data packet exchange at a low level, such as routers. Broadcast
messages on IP networks contain a special address reserved for broadcasting.
The network and host part of the address is set to ones (hex:—FFFFFFFF).
This indicates to the network layer that the packet is addressed to every device
on the subnet, as seen in Figure 6.1.


Figure 6.1

Broadcasts try to reach all nodes on the subnet.

In a P2P context, broadcasting might sound like TCP/IP multicasting, but it isn't. P2P technology plays mostly in the application layer of a software application. The actual method for moving a broadcast message across the Internet might use multicasting or a number of other techniques that we will explore next.

Transport—Multicast Versus Unicast Messaging

Multicast messaging is often compared to radio or TV broadcasts, in the sense that only those who have tuned their receivers to a particular frequency receive the information. Only the channels selected are heard. The sender sends the information without knowledge of the number of receivers.

In contrast, when you send a packet and there is only one sender and one recipient, this is referred to as unicast. A unicast transmission is by definition point-to-point. Unicast can be used to send identical information to many different destinations; however, this involves replicating data, and is not the most efficient transport.

Multicast addresses are in the Class D 224–239 range. Multicast messaging uses this range of addresses to define multicast groups, as shown in Table 6.1.

Table 6.1 IPv4 Address Classifications

IP Address Classification

Address Range

Class A

0.0.0.0127.255.255.255

Class B

128.0.0.0191.255.255.255

Class C

192.0.0.0223.255.255.255

Multicast (Class D)

224.0.0.0239.255.255.255

Reserved

240.0.0.0247.255.255.255

Latest Posts

Related Stories