Java Peer-to-peer Computing Practice: Discovery based on IP multicast

Source: Internet
Author: User
Tags port number advantage

To accomplish useful work, peers in peer-to-peer applications must be able to discover each other and interact with each other. This article provides an implementation of a discovery based on IP multicast.

Before a software entity can participate in a direct peer-to-peer interaction with a Peer-to-peer application feature, the entity must discover the appropriate peers to interact with. All available Peer-to-peer architectures provide a solution for discovery problems. In this article I will describe the implementation of one of these mechanisms. Let us begin today's discussion by looking back. Revisit Discovery Peer-to-peer discovery allows peers in peer-to-peer applications to locate each other so that they can interact with each other. There are several ways to implement Peer-to-peer discovery services. The simplest mechanism is an explicit point-to-point configuration. This mechanism works by requiring each peer to know all other peers that it may interact with and to connect to them. The primary advantage of point-to-point configuration is simplicity. Its main disadvantage is the lack of flexibility and the lack of capacity to scale large networks that extend to peers.

Another common model found is the use of a central directory as an intermediary. The model is popular among many traditional, non peer-to-peer distributed types of applications, and its advantages are well understood. Peers register their presence with a central directory and use a central directory to locate other peers. The main advantage of this model is the ability to manage and scale easily. However, its centralized design leads to a single point of failure, so it lacks the ability to withstand the damage caused by natural forces or the increase in the number of Internet surfers.

Many popular peer-to-peer applications use a network model rather than a central directory, in which a single peer knows only the identity of peers on the local domain network. Each peer is a directory of those peers that are connected to it. Peers collaborate by propagating directory queries to neighboring peers and returning related responses. The main advantage of this model is the lack of centralization. Its main disadvantage is that the propagation of queries consumes a lot of network and processing power.

There are numerous variants of the above three mechanisms. Without discussing these variants, let's go ahead and study another discovery mechanism.

IP Multicast Discovery

The multicast model is similar to the network model in terms of maintaining your own directory for each peer. However, peers do not implement large-scale network queries through collaboration. In addition, peers use the features provided by the network itself (IP multicast) to locate and identify other peers.

IP multicast is connectionless and unreliable (unlike TCP/IP is connection-oriented and reliable). Although it uses IP datagrams, unlike unicast IP datagrams, which are sent from one host to another, multicast IP datagrams can be sent to multiple hosts at the same time.

Peers periodically use IP multicasting to announce their presence. Declares that they contain their hostname and a port for normal communication. The peer that is interested in this message detects the message, extracts the host name and port number, and uses the message to establish a communication channel.

The review is enough. Let's get started on the code.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.