10
Peer-to-Peer over Ad-hoc Networks: (Re)Configuration Algorithms Fernanda P. Franciscani Marisa A. Vasconcelos Rainer P. Couto Antonio A.F. Loureiro Computer Science Department, Federal University of Minas Gerais Av Antonio Carlos 6627, Belo Horizonte MG, Brazil 31270-010 fepaixao, isa, rainerpc, loureiro @dcc.ufmg.br Abstract A Peer-to-Peer network over an ad-hoc infrastructure is a powerful combination that provides users with means to access different kinds of information anytime and any- where. In this paper we study the (re)configuration is- sue in this highly dynamic scenario. We propose three (re)configuration algorithms especially concerned with the constraints of the environment presented. The algorithms aim to use the scarce resources of the network in an effi- cient way, improving the performance and the network life- time. The algorithms were simulated and used a simple Gnutella-like algorithm as comparison. The results show that the algorithms achieved their goals, presenting a good cost-benefit relation. 1. Introduction Mobile computing has the goal to allow people access the distinct types of information anytime and anywhere. In general, the client-server architecture is not adequate to sat- isfy this demand due to many reasons: the server can be down (little fault-tolerance) or overloaded (scalability prob- lems), or there is no infrastructure to access the server and other entities. Some of the problems above, like scalability and fault- tolerance, can be addressed by Peer-to-Peer (p2p) applica- tions, which build a virtual network over the physical one. The peers can act as servers or as clients, and are called ser- vents. The servents can exchange data among themselves in a completely decentralized manner or with the support of some central entity, which usually helps servents to get in touch with one another. Thus, the success and popularity of the p2p networks reveal how important it is to satisfy the anytime demand. Regarding the anywhere issue, however, we can say that its mainly related to the network itself, that is, it depends This work is partially supported by CNPq-Brazil on the infrastructure provided. Once the lack of infrastruc- ture is a problem, networks that do not need it turn out to be a solution. This is the case of ad-hoc networks, which, once endowed with mobility, are called MANETs (Mobile ad-hoc networks). In these networks, the communication between nodes is based on radio coverage and can be made directly or using other nodes as routers. Thus, the MANETs can be easily formed by a group of people who make use of current devices as cellular phones, PDAs and notebooks. From the arguments above, it is reasonable to think that p2p networks over ad-hoc networks would be a very good solution to both the anytime and the anywhere problems. However, this combination leads to a highly dynamic sce- nario in which references between nodes are constantly changing. The frequent reconfiguration may cause a great impact in the scarce resources of the network, such as en- ergy and bandwidth. Aiming to control and diminish this impact, we designed algorithms to (re)configure a p2p net- work over an ad-hoc network and analyzed their behavior. Although there are some studies on p2p applications over ad-hoc networks, they usually are not concerned about (re)configuration issues. Many times the references be- tween nodes simply show up or are created through the in- discriminate use of broadcasts. The relevance of the current work is therefore to study adequate ways of (re)configuring a p2p network over and ad-hoc network taking into account the serious constraints this scenario presents. The rest of this paper is organized as follows. Section 2 briefly describes p2p networks, whereas Section 3 discusses the p2p over mobile ad-hoc networks. Section 4 describes the main characteristics of a mobile ad-hoc network and the routing protocol used. Section 5 presents the related work. The four (re)configuration algorithms are described in Sec- tion 6 and analyzed through simulations in Section 7. Fi- nally, Section 8 presents our conclusions and future work. 2. Peer-to-Peer Networks The p2p networks are application-level virtual networks. They have their own routing protocols that permit com- 0-7695-1926-1/03/$17.00 (C) 2003 IEEE Proceedings of the International Parallel and Distributed Processing Symposium (IPDPS’03)

[IEEE Comput. Soc International Parallel and Distributed Processing Symposium (IPDPS 2003) - Nice, France (22-26 April 2003)] Proceedings International Parallel and Distributed Processing

  • Upload
    aaf

  • View
    213

  • Download
    1

Embed Size (px)

Citation preview

Page 1: [IEEE Comput. Soc International Parallel and Distributed Processing Symposium (IPDPS 2003) - Nice, France (22-26 April 2003)] Proceedings International Parallel and Distributed Processing

Peer-to-Peer over Ad-hoc Networks: (Re)Configuration Algorithms�

Fernanda P. Franciscani Marisa A. Vasconcelos Rainer P. Couto Antonio A.F. LoureiroComputer Science Department, Federal University of Minas Gerais

Av Antonio Carlos 6627, Belo Horizonte MG, Brazil 31270-010ffepaixao, isa, rainerpc, [email protected]

Abstract

A Peer-to-Peer network over an ad-hoc infrastructureis a powerful combination that provides users with meansto access different kinds of information anytime and any-where. In this paper we study the (re)configuration is-sue in this highly dynamic scenario. We propose three(re)configuration algorithms especially concerned with theconstraints of the environment presented. The algorithmsaim to use the scarce resources of the network in an effi-cient way, improving the performance and the network life-time. The algorithms were simulated and used a simpleGnutella-like algorithm as comparison. The results showthat the algorithms achieved their goals, presenting a goodcost-benefit relation.

1. Introduction

Mobile computing has the goal to allow people accessthe distinct types of information anytime and anywhere. Ingeneral, the client-server architecture is not adequate to sat-isfy this demand due to many reasons: the server can bedown (little fault-tolerance) or overloaded (scalability prob-lems), or there is no infrastructure to access the server andother entities.

Some of the problems above, like scalability and fault-tolerance, can be addressed by Peer-to-Peer (p2p) applica-tions, which build a virtual network over the physical one.The peers can act as servers or as clients, and are called ser-vents. The servents can exchange data among themselvesin a completely decentralized manner or with the support ofsome central entity, which usually helps servents to get intouch with one another. Thus, the success and popularityof the p2p networks reveal how important it is to satisfy theanytime demand.

Regarding the anywhere issue, however, we can say thatits mainly related to the network itself, that is, it depends

�This work is partially supported by CNPq-Brazil

on the infrastructure provided. Once the lack of infrastruc-ture is a problem, networks that do not need it turn out tobe a solution. This is the case of ad-hoc networks, which,once endowed with mobility, are called MANETs (Mobilead-hoc networks). In these networks, the communicationbetween nodes is based on radio coverage and can be madedirectly or using other nodes as routers. Thus, the MANETscan be easily formed by a group of people who make use ofcurrent devices as cellular phones, PDAs and notebooks.

From the arguments above, it is reasonable to think thatp2p networks over ad-hoc networks would be a very goodsolution to both the anytime and the anywhere problems.However, this combination leads to a highly dynamic sce-nario in which references between nodes are constantlychanging. The frequent reconfiguration may cause a greatimpact in the scarce resources of the network, such as en-ergy and bandwidth. Aiming to control and diminish thisimpact, we designed algorithms to (re)configure a p2p net-work over an ad-hoc network and analyzed their behavior.

Although there are some studies on p2p applicationsover ad-hoc networks, they usually are not concerned about(re)configuration issues. Many times the references be-tween nodes simply show up or are created through the in-discriminate use of broadcasts. The relevance of the currentwork is therefore to study adequate ways of (re)configuringa p2p network over and ad-hoc network taking into accountthe serious constraints this scenario presents.

The rest of this paper is organized as follows. Section 2briefly describes p2p networks, whereas Section 3 discussesthe p2p over mobile ad-hoc networks. Section 4 describesthe main characteristics of a mobile ad-hoc network and therouting protocol used. Section 5 presents the related work.The four (re)configuration algorithms are described in Sec-tion 6 and analyzed through simulations in Section 7. Fi-nally, Section 8 presents our conclusions and future work.

2. Peer-to-Peer Networks

The p2p networks are application-level virtual networks.They have their own routing protocols that permit com-

0-7695-1926-1/03/$17.00 (C) 2003 IEEEProceedings of the International Parallel and Distributed Processing Symposium (IPDPS’03)

Page 2: [IEEE Comput. Soc International Parallel and Distributed Processing Symposium (IPDPS 2003) - Nice, France (22-26 April 2003)] Proceedings International Parallel and Distributed Processing

puting devices to share information and resources directly,without dedicated servers. P2p members act as a clients andas a servers, thus being called servents [17].

File sharing applications such as Napster, Gnutella, Mor-pheus have become the p2p networks very popular. Thegreat contribution of this kind of system is the scalabilitythat allows millions of users to be online concurrently evenat peak periods [7]. This is obtained thanks the user hybridbehavior (client + server), which yield a greater computingdecentralization.

The p2p systems are classified in three main categories:centralized, decentralized and hybrid [4, 9]. In a central-ized p2p system, coordination between peers is managedby a central server. However, after receiving the informa-tion from the central server, the communication betweenpeers happens directly. Some advantages of this kind ofsystem are: the easiness of management and security. Thedisadvantages are the low fault-tolerance, since some dataare held only by the central server and the scalability limi-tation by the capacity of the server. However, the scalabil-ity can still be achieved through the increasing processingpower of the computers, which make possible one machinebe able to serve a great number of users. Some examplesare the search architecture of Napster [11] and the systemSETI@Home [20], which has a central job dispatcher.

In decentralized topologies, e.g. Freenet [2] andGnutella [3], all the peers have equal roles. The commu-nication is made through multiples multicasts, where peersforward messages on behalf of others peer. Some importantadvantages are extensibility and fault-tolerance. Scalabilityin these systems is difficult to measure: on the one hand, ifyou add more hosts, the system becomes more capable. Onthe other hand, however, the overhead of keeping the con-sistency of the data increases with the size of the system.

In hybrid (centralized + decentralized) topologies, peersforward their queries to ”super-peers” which communicatewith each other in a decentralized manner. The advantagesof this topology resemble the ones of decentralized systemsexcept for data consistency, which was improved. Thishappens since part of the data is kept only by the “super-peers”. Examples of this topology are KazaA [5] and Mor-pheus [10].

Table 1 was derived from [9], in which the advantagesand disadvantages of distributed topologies were listed.

Centralized Decentralized HybridManageable yes no noExtensible no yes yesFault-Tolerant no yes yesSecure yes no noLawsuit-proof no yes yesScalable depend maybe apparently

Table 1. Topologies and their characteristics.

In this work, only hybrid and decentralized configura-tions were adopted for two reasons. First, we consider thesetopologies closer to reality. Second, as it will be shown, theenvironment considered is highly dynamic, making exten-sibility an important issue. The developed algorithms, in-cluding the Hybrid, also were inspired in the decentralizedprotocol Gnutella, especially in query mechanism part.

Gnutella is a public domain p2p protocol used mainlyfor sharing, searches and retrieval of files and content. Tobe part of this network, the servents must connect to theneighbors who already belong to the network. After that,the servent will send messages through broadcasts for itsneighbors and will act as router to the other messages thathad been transmitted. The types of messages exchanged inthis network are: ping to discover other member nodes, thequery messages with information about the searched con-tent and file properly said, which is transferred directly be-tween the peers. When a servent wishes to search for somefile, it sends a query message to its neighbors, which if pos-sible, return the desired files besides forwarding the mes-sage for its own neighbors. In order to prevent the indefi-nite propagation, all the messages are flagged with the TTL(time-to-live) field and with the number of hops passed [17].

3. P2p over Mobile Ad-Hoc Networks

The wireless devices have, in general, a restricted trans-mission range due to its limited power supply. Thus, thesearch for data should be made in a small distance range.This search can be made of two distinct ways. The first oneuses a fixed infrastructure, generally it involves a high costand provides continuous access to a information networklike the Internet or a private intranet. The second way ofaccess does not need fixed infrastructure: the own set of themobile devices, acting as routers and information servers,forms the network. This kind of network is called ad-hocnetwork. In this last case, the nearest devices become im-portant sources of data for each other, what resembled thep2p paradigm, in which the network elements act, at thesame time, as clients, servers and routers.

One of the main advantages of a p2p over ad-hoc net-work would be easiness of forming the network, since it isnot necessary to have infrastructure nor it depends on a cen-tral server. Examples of possible uses of p2p over ad-hocnetworks include applications that alert us to the presence offriends at a crowded public space or identify people we wantto meet taking into account our preferences and interests;systems that spread rumors, facilitate the exchange of per-sonal information, or support us in more complex tasks [6].

On the other hand, p2p over ad-hoc networks is a verydynamic combination that demands, among other things,special attention regarding (re)configuration issues.

0-7695-1926-1/03/$17.00 (C) 2003 IEEEProceedings of the International Parallel and Distributed Processing Symposium (IPDPS’03)

Page 3: [IEEE Comput. Soc International Parallel and Distributed Processing Symposium (IPDPS 2003) - Nice, France (22-26 April 2003)] Proceedings International Parallel and Distributed Processing

4. Mobile Ad-Hoc Networks

The ad-hoc mobile networks are composed by wirelessmobile devices, which its communication is based on radiocoverage and can be made directly (point-to-point) or us-ing other nodes as routers. The utilization of this kind ofnetwork is mainly in scenarios without a fixed network in-frastructure. Some examples are conventions or meetings,where people, for comfortableness, wish quickly exchang-ing of information [18], and emergency operations.

Ad-hoc mobile networks show, beyond the common re-strictions to the wireless network, the additional challengeto deal with a very dynamic topology. The limited energyof the devices demands smart routing protocols. In our sim-ulations, the chosen routing protocol was AODV. Compar-ing the performance of some routing protocols, it can beseen that each of them performed well in some scenarios forsome metrics yet had drawbacks in others [13]. We, there-fore, adopted AODV, which exhibited the best performanceon high mobility scenarios.

The AODV protocol is a demand routing algorithm forad-hoc mobile networks, in which each node has the infor-mation about the next hop of a route. It is an on demand al-gorithm since the routes are only maintained if they are be-ing used. When a link is broken, AODV updates the nodesthat have this route saved. Advantages of this protocol are:quick adaptation to dynamic link conditions, self-starting,multi-hop and loop-free [16, 19].

5. Related Work

A comparison is made in [19] between ad-hoc networksand p2p networks routing. Besides presenting taxonomyof both, this work proposed the joint use of these networks,aiming at a synergetic effect. This theory passes to the prac-tical one in [14, 15], where the 7DS (Seven Degrees of Sep-aration) application is presented, a network for data dissem-ination among hosts in an ad-hoc network. Besides the im-plementation, these works present the effect (through sim-ulation) of power conservation, radio control coverage andstrategies to cooperation among host to data dissemination.In [6] it is presented a platform for development of peer-to-peer applications in small range ad-hoc networks, moreprecisely, for PAN’s - Personal Area Network. A study onsensor networks regarding cooperation and network forma-tion is made in [21]. In [13] it is evaluated the perfor-mance of several routing protocols in a p2p over ad-hoc net-work. The works above are related to the world of p2p overad-hoc networks and they all lack the concern about p2p(re)configuration issues. Our work focuses exactly on thisproblem, analyzing its impact on the performance of bothp2p and ad-hoc networks.

In [4] it is described some metrics for performance eval-uation in a p2p network, using Gnutella and Freenet as casestudies, based on four criteria: efficiency, speed, worse caseperformance and scalability. Gnutella was not consideredscalable, since the required bandwidth increases linearly asthe network grows. Conversely, Freenet scales logarithmi-cally, using pathlength as metric.

6. (Re)Configuration Algorithms

For (re)configuration of the network we proposed twotypes of algorithms: decentralized and hybrid. There arethree different decentralized algorithms, which are calledBasic, Regular and Random. The hybrid type has only onerepresentative: the so called Hybrid algorithm.

In the description of all these algorithms, it will be saidthat the nodes are connected, trying to connect, maintaininga connection etc. It is important to notice, however, that weare dealing with wireless networks and thus there are no realconnections, e.g. a TCP connection, between nodes. Then itmust be kept in mind that the so called connections actuallyare references, that is, they represent the knowledge of theaddresses of some reachable nodes. Thus, a symmetricalconnection is the one in which a node A keeps a referenceto node B while B also references A. Asymmetrical connec-tions also exist and are used in the Basic Algorithm.

6.1. Decentralized Algorithms

Our system’s model is based on the use of messages thatare forwarded over many hops from one peer to the next inorder to establish connections and to search for data. De-spite having this same basis, the three decentralized algo-rithms have distinct behaviors, as it will be seen below.

The Basic algorithm will be presented in the next sec-tion. After that, a very important concept will be brieflydescribed: the small-world effect [8], which was the basisfor the changes that turned the Regular algorithm into theRandom algorithm. Finally, there is the description of theselast two algorithms.

6.1.1 The Basic Algorithm

The Basic algorithm was meant to represent a simple(re)configuration algorithm and therefore to serve as a basisfor comparison. Its main characteristic —simplicity— im-plies easy implementation but partially ignores the dynamicnature of the network.

This algorithm, shown in figure 1, makes use of threeconstants named MAXNCONN, NHOPS and TIMER. Thefirst represents the maximum number of connections pernode. The second is the number of hops a message trav-els and the third stands for the time interval between two

0-7695-1926-1/03/$17.00 (C) 2003 IEEEProceedings of the International Parallel and Distributed Processing Symposium (IPDPS’03)

Page 4: [IEEE Comput. Soc International Parallel and Distributed Processing Symposium (IPDPS 2003) - Nice, France (22-26 April 2003)] Proceedings International Parallel and Distributed Processing

Establishing connections

while the node belongs to p2p networkif number of connections < MAXNCONN

try to establish new connections to nodes within NHOPSaway up to the limit of MAXNCONN connections;

wait TIMER before next try;endif

endwhile

Maintaining connections

while this connection existssend a ping to the connected node;wait some time for the pong;if the pong was received then

wait some time before sending next ping;else

close this connection;endif

endwhile

Figure 1. Basic Algorithm.

attempts to establish connections. The algorithm works asdescribed below.

A node, when starting its participation in the p2p net-work, broadcasts a message to discover other nodes withinNHOPS away in the neighborhood. Every node that lis-tens to this message answers it. As soon as a responsearrives, the node establishes a connection to the neighborwho sent it, till the limit of MAXNCONN connections. Incase the number of responses is lesser than MAXNCONN,and whenever else it has less than MAXNCONN connec-tions, the node keeps trying to create the rest of the connec-tions. Between the trials, the node waits for a time interval—TIMER— in order to avoid traffic overload in the net-work. Once a reference1 is created its validity is frequentlychecked by sending pings. Whenever a node receives a pingit answers with a pong. The receiving of a pong thus signalsthe connection still exists while its lack means the neighboris not reachable anymore and then the connection is over.

6.1.2 The Small-World Model

In a regular graph its n vertices are connected to their near-est k neighbors. Differently, in a random graph, the con-nections are randomly established and k stands for the av-erage number of edges per vertex. Thus, two neighbors ofa node have a greater chance of being connected to eachother in regular graphs, that is, the average clustering co-efficient is much greater in regular graphs. This coefficientis obtained as explained: let real conn be the number ofexistent connections between all the neighbors of a node(these neighbors are connected to this given node); and let

1Remember that the so called connections actually are references.

possible conn be the number of all connections that couldexist between these neighbors. The clustering coefficient isgiven by real conn=possible conn. Besides the clusteringcoefficient, the regular and random graphs also have verydistinct characteristic pathlengths. In large regular graphswith n much larger than k —for a k much larger than 1—the pathlength is approximately n=2k. In large randomgraphs this value decreases substantially and is given bylogn= log k [4].

Interestingly, little changes in regular graphs connec-tions are sufficient to achieve short global pathlengths asin random graphs. The rewiring of some connections fromneighbors to randomly chosen vertices represented the cre-ation of bridges between clusters a great distance away.These bridges diminish the pathlength without any con-siderable change in the clustering coefficient. The graphsthat have high clustering coefficients and, at the same time,short global pathlengths are called small-world graphs. OurRandom (re)configuration algorithm —presented next—aimed to construct the peer-to-peer networks as small-worldgraphs.

Before presenting the Regular and Random algorithms,we will list their variables and constants, most of whichare present in both algorithms. There are three vari-ables: nhops, randhops and timer. The first one rep-resents the number of hops a message looking for aregular connection can travel. It is initialized with thevalue NHOPS INITIAL, which is greater than 1, and hasMAXNHOPS as an upper limit. The second one has a simi-lar meaning but it is only applied to random connections; itdoes not need to be initialized. The third variable stands forthe time interval a node waits between two attempts to es-tablish connections. It is initialized with TIMER INITIAL

and can increase up to MAXTIMER. Finally, there aretwo remaining constants not explained yet: MAXNCONN,which is the maximum number of connections per node,and MAXDIST, which is the maximum distance allowedbetween two connected neighbors (measured in number ofhops).

6.1.3 The Regular Algorithm

Initially there is the ad-hoc network over which some (orall) of its nodes want to build the p2p network, followingthe algorithm presented in figure 2. As it can be seen,each of the nodes broadcasts a message communicatingit is looking for establishing connections. The messageshave specific number of hops (nhops) they are expected totravel. When receiving this message, a node willing to con-nect starts a three-way handshake with the sender, aimingto establish a symmetrical connection. If, within that ra-dius, less than MAXNCONN neighbors could be symmet-rically connected to, the node will make another broadcast

0-7695-1926-1/03/$17.00 (C) 2003 IEEEProceedings of the International Parallel and Distributed Processing Symposium (IPDPS’03)

Page 5: [IEEE Comput. Soc International Parallel and Distributed Processing Symposium (IPDPS 2003) - Nice, France (22-26 April 2003)] Proceedings International Parallel and Distributed Processing

with a higher number of hops — nhops + 2. Before thenew broadcast, however, it waits for a timer time inter-val. As in the Basic algorithm, this interval is an attempt toavoid traffic overload. This mechanism is repeated till themaximum of MAXNCONN connections or the maximumof MAXNHOPS hops is achieved, whichever occurs first.When nhops is set to 0 it means that node tried all the pos-sible values for nhops without connecting to MAXNCONNneighbors. In this case, the time interval timer is doubledbefore the next cycle of trials, in which nhops will restartwith the NHOPS INITIAL value. The variable timer hasits upper limit given by MAXTIMER, and its lower limit byTIMER C INITIAL.

A Regular: Establishing connections

while the node belongs to p2p networkif number of connections < MAXNCONN then

if nhops 6= 0 thentry to establish new and symmetrical connections to

nodes within nhops away up to the limit ofMAXNCONN connections;

wait timer before next trial;else

timer = min (timer� 2, MAXTIMER);endifnhops = (nhops+ 2)mod(MAXNHOPS + 2);

endifendwhile

A Regular and A Random: Maintaining connections

while this connection existsif it is the node that asked for the connection

send a ping to the connected node;wait some time for the pong;if the pong was received then

if this is a random connection thenif the node is nearear than 2�MAXDIST then

wait some time before sending next ping;else close this connection;endif

elseif the node is nearear than MAXDIST then

wait some time before sending next ping;else close this connection;endif

endifelse close this connection;endif

else wait some time for the ping;if the ping was received then

send a pong;else close this connection;endif

endifendwhile

Figure 2. Regular and Random Algorithms.

Once a connection is successfully built, the node starts

its maintenance as presented in the algorithm of figure 2.The connection is frequently checked using pings. As weare dealing with symmetrical connections, only the vertexthat started the process of establishing the connection willsend pings. The reception of pings is controlled by the othernode with the use of a timer; whenever it receives a ping, itanswers with a pong and reschedules the timer. In case atimeout occurs, it closes the connection. When receiving apong, the other node knows its neighbor is still reachable,but this is not enough to maintain the connection. To remainconnected, the distance between the nodes must be less thanMAXNHOPS hops. In case the distance is bigger than that,the connection is closed. The same occurs in the absence ofa pong.

This algorithm has four improvements compared to theBasic algorithm. First, the number of hops a message look-ing for connections may travel is increased gradually. Oncethis kind of message is sent by broadcast, controlling thenumber of hops means less traffic in the network. The traf-fic is also potentially diminished by the control of the dis-tance between connected nodes as the pings and pongs theyexchange will span a narrower area. This was the secondimprovement, which is complemented by the third one: thenumber of pings and pongs was cut half because only onevertex checks the connection actively, that is, sending pings.As we are dealing with wireless networks, which have band-width constraints, these three actions added together mayhave a reasonable positive impact.

Last, but not least, there is the fourth improvement, re-lated to timer and which was inspired by the dynamic na-ture of our network, together with the traffic concern. As itcan be seen, the time interval between two broadcasts hasnot a fixed value. Instead, it doubles every time a cycle ofattempts to establish connections is over, diminishing theoverall traffic. Besides, if it has been difficult to connect toother nodes, while waiting for a longer interval the networkcan change to a more favorable configuration. Then, it maybe easier to finally establish the desired connections. Onedetail not presented in the pseudo-code is that, whenever aconnection is done, the timer is reset to its initial value.This is done because this new connection may be a signalof a better network configuration.

6.1.4 The Random Algorithm

Adopting the Regular algorithm, each node would prefer-entially connect to its nearest neighbors. In a dense peer-to-peer network, the connections thus would be establishedwithin a low number of hops. This would probably lead toa network whose characteristics would resemble the onesof regular graphs, mainly in the sense of long global path-lengths. Aiming to avoid this and to gain small-world char-acteristics, our Regular algorithm suffered a little change,

0-7695-1926-1/03/$17.00 (C) 2003 IEEEProceedings of the International Parallel and Distributed Processing Symposium (IPDPS’03)

Page 6: [IEEE Comput. Soc International Parallel and Distributed Processing Symposium (IPDPS 2003) - Nice, France (22-26 April 2003)] Proceedings International Parallel and Distributed Processing

leading to the Random algorithm.The establishment of the first MAXNCONN� 1 connec-

tions follows exactly the same steps mentioned in the Reg-ular algorithm. For this reason, they will be called regularconnections. The difference of the two algorithms lies inthe last connection, as it can be seen in the algorithm in fig-ure 3. As we have already seen, few rewiring can turn a

Establishing connections

while the node belongs to p2p networkif number of connections < MAXNCONN then

if nhops 6= 0 thentry to establish new and symmetrical connections

to nodes within nhops away up to the limit ofMAXNCONN � 1 regular connections;

wait timer before next trial;else

timer = min (timer� 2,MAXTIMER);endifif a random connection is needed then

set randhops to a randomly chosen value betweennhops and 2�MAXNHOPS;

try to establish one new and symmetrical randomconnection to the farest node possible withinrandhops away;

endifnhops = (nhops+ 2)mod(MAXNHOPS + 2);

endifendwhile

Figure 3. Random Algorithm.

regular graph into a small-world graph. To promote thisrewiring, the node does not try to establish its last connec-tion within nhops away. Instead, it chooses a random num-ber —randhops— between nhops and 2�MAXNHOPS.Then it broadcasts a message looking for connections to allnodes within randhops hops away. It waits some time forresponses to arrive, analyzes them, and only continues thethree-way handshake with the most distant neighbor. Oncea connection is established this way, it is called a randomconnection and, whenever it goes down, it must be replacedby another random connection. The maintenance of the ex-isting connections follow the scheme shown in figure 2.

The final effect expected is that some of the overall con-nections will link distant peers and therefore would actas bridges, turning the pathlength shorter while maintain-ing the clustering coefficient high. Then we would haveachieved the small-world effect.

6.2. Hybrid Algorithm

Decentralized algorithms were designed to work on a ho-mogeneous network, that is, network that makes no distinc-tion of their nodes. In this case, all effort should be dis-

tributed evenly among the nodes in order to increase life-time. However, ad-hoc networks often will be formed bydifferent types of devices and, in this case, the most part ofall effort should be made by the most powerful devices. Hy-brid algorithm was developed for heterogeneous networks,that is, networks in which all nodes are differentiated by aqualifier. This qualifier can be related to any characteristicof the node, e.g. energy level or processor power.

The principle is to form subnets with one master anda limited number of slaves. The slaves can only commu-nicate to their master, but masters can communicate witheach other, resulting in the hybrid network. To achieve thisconfiguration, A Hybrid defines several states that peers canpresent at any given time: master, slave, reserved and ini-tial. Each peer starts at initial state and later, becomes amaster or a slave. Reserved state is only used on transi-tions. The algorithm is described on figure 4.

Initially, each peer tries to contact other peers that arewithin NHOPS INITIAL (ad-hoc) hops away. If there isno response, then the peer doubles the limit and tries newcontacts. Eventually, if this limit exceeds MAXNHOPS,then the peer entitles itself a master and uses the regularalgorithm to contact other masters. The type of messageused in this first step is the capture one, with only one ar-gument - the qualifier of the sender. If one peer in initialstate and with a smaller qualifier receives this message, itwill try (through a three-way handshake) to become a slaveof the sender. If the qualifier of the receiver is bigger andits state is either initial or master, then it responds with acapture message. This step guarantees that new peers willalways get some feedback from their neighborhood, eitherby discovering the masters already there or other peers ininitial state. The peers in slave or reserved state don’t com-municate with any one else, except their masters or mastercandidates, respectively.

The reconfiguration is done in two kinds of situation.The first one is when a master owns no slave after a period.This master could, potentially, be another peer slave. Thesecond one is when a slave is too far away from its master.This peer should look for another master on its neighbor-hood. This self-reorganization ensures that the hierarchyremains balanced and that the elements of the clusters arenot being scattered over a wide area.

The maintenance phase is similar to decentralized algo-rithm’s one. A ping message is sent to all neighbors and,if a response message is not received after a while or theneighbor is too far, then the peer closes that connection and,if it is a slave, the peer resets its state to initial. It, then,tries to contact other peers.

0-7695-1926-1/03/$17.00 (C) 2003 IEEEProceedings of the International Parallel and Distributed Processing Symposium (IPDPS’03)

Page 7: [IEEE Comput. Soc International Parallel and Distributed Processing Symposium (IPDPS 2003) - Nice, France (22-26 April 2003)] Proceedings International Parallel and Distributed Processing

Establishing connections

while this node belongs to p2p networkswitch statecase INITIAL:

if nhops 6= 0 thentry to find a master and become its slave or tryto find slaves and become their master;

elsechange its state to MASTER;

endifnhops = (nhops+ 2)mod(MAXNHOPS+ 2);

break;case MASTER:

use the regular algorithm to contact other masters;if nslaves < MAXNSLAVES then

accept any incomming slave connection;endifif the node hasn’t got any slaves during

MAXTIMERMASTER thenchange its state to INITIAL;

endifbreak;case SLAVE:

just maintain the connection to the master;break;

endswitchendwhile

Figure 4. Hybrid Algorithm.

7. Simulation

We used the ns-2 simulator [12], a well known simula-tor for networking, which supports ad-hoc network models.We chose AODV as our routing protocol, which is alreadyavailable in ns-2 v.9 distribution. Its implementation, how-ever, lacks the support to broadcast messages. We addedthis feature to the existing code by including a controlledbroadcast function such that each node has a cache to keeptrack of the broadcast messages received. This mechanismavoids forwarding the same message several times. Such animprovement is relevant since each message transmitted orreceived consumes energy, which is a restrict resource in amobile ad-hoc network. The simulations were repeated 33times.

7.1. Model

In this section, the p2p network model used in the simu-lations is discussed. First of all, it must be highlighted thatour model was not developed based in any specific applica-tion and it intends to work with generic algorithms for datasearch and exchange.

In the decentralized algorithms, all nodes are consideredidentical since they play the same role: they are servents.

The hybrid algorithm, however, is slightly different since anode can be either a master or a slave.

It is important to restate that what we are calling connec-tions are actually references. In other words, a node keepsa list of references to other nodes it believes to be its neigh-bors. Connections can be either symmetrical or asymmet-rical. The connections are created and maintained in orderto provide the p2p application with means to perform datasearch and exchange.

7.2. Scenarios

We have simulated an ad-hoc network with 50 and 150nodes, distributed over an area of 100 m � 100 m and witha wireless range of 10 m. The p2p is formed by 75% of allnodes, thus some nodes belongs to the ad-hoc network only.For mobility, based on human walking, we used RandomWay model [1] with maximum speed value of 1,0 m/s andmaximum pause time of 100s. The node interleaves mov-ing and pause periods. Initially, all nodes were randomlypositioned over the area, following a uniform distribution.Unless mentioned, the default values for the parameters aretaken from Table 2. All scenarios were simulated for 3,600seconds.

Parameter for simulation Valuetransmission range 10 m

number of distinct searchable files 20frequency of the most popular file 40%

NHOPS INITIAL 2 ad-hoc hopsMAXNHOPS 6 ad-hoc hops

NHOPS (Basic Algorithm) 6 ad-hoc hopsMAXDIST 6 ad-hoc hops

MAXNCONN 3MAXNSLAVES 3TTL for queries 6 p2p hops

Table 2. Parameters used and their typical val-ues.

The query system used in the simulation is based onGnutella. A node sends a query to all nodes in its list ofneighbors. The query contains the identification of the re-quested file and of the requirer—the original source of thequery. When a node receives a query, it processes and for-wards the message even if it has the file. In order to con-trol the message traffic, we stated the following three rules.First, each node only forwards a query or responds to aquery once. Second, a node does not forward a query tothe neighbor from which it was received. Third, a query isnot forwarded to its original source. In case a node has therequested file, it sends a response directly to the requirer.After sending a query, the node waits for a response for 30

0-7695-1926-1/03/$17.00 (C) 2003 IEEEProceedings of the International Parallel and Distributed Processing Symposium (IPDPS’03)

Page 8: [IEEE Comput. Soc International Parallel and Distributed Processing Symposium (IPDPS 2003) - Nice, France (22-26 April 2003)] Proceedings International Parallel and Distributed Processing

seconds. Then, the node waits for a random period between15 to 45 seconds to send the next query.

Different files are distributed in the network following aZipf law [22] with maximum frequency —MAXFREQ— of40%. This means that the most popular file will be presentin 40% of all nodes, the second most popular one in 40%

2=

20%, the third in 40%

3, and so on.

7.3. Metrics

We have chosen a few metrics considered relevant to theperformance of p2p networks [4] and ad-hoc networks.� Number of hops: the minimum number of hops (p2p and

ad-hoc) from the source to the peer holding the requestedinformation. We evaluated the medium value for all sim-ulated requests.

� Number of exchanged messages: the number of mes-sages of each type, queries and pings, received by thenodes. We evaluated the medium number of messagesreceived by each node.

7.4 Results

This section contains the results considering the metricsdescribed above. These results show the expected behaviorof the four proposed algorithms.

The graphics in Figures 5 and 6 show the average mini-mum distance to reach a node that has requested file and theaverage number of answers per file request. Those graphicswere, respectively, for the scenario with 50 and 150 nodes,75% of them belonging to the p2p network. Clearly, thenumber of answers decreases as the requested file becomesunpopular, reflecting the Zipf distribution of files. Despitesome oscillations, the distance tends to increase.

1.1

1.15

1.2

1.25

1.3

1.35

1.4

1.45

1 2 3 4 5 6 7 8 9 10

Ave

rage

min

imum

dis

tanc

e

Ave

rage

num

ber

of a

nsw

ers

Files

BasicRegular

RandomHybridBasic

RegularRandom

Hybrid

Figure 5. Distance to find the file and # ofanswers per file request (50 nodes, 75% p2p).

1.3

1.35

1.4

1.45

1.5

1.55

1.6

1.65

1.7

1.75

1 2 3 4 5 6 7 8 9 10

Ave

rage

min

imum

dis

tanc

e

Ave

rage

num

ber

of a

nsw

ers

Files

BasicRegular

RandomHybridBasic

RegularRandom

Hybrid

Figure 6. Distance to find the file and # of an-swers per file request (150 nodes, 75% p2p).

Figures 7 and 8 show the medium number of connectmessages received by each node. The nodes were orderedby the amount of messages received. The graphics showthat the Basic algorithm, which uses broadcasts indiscrim-inately, presents greater values for all nodes. The progres-sive connection method, used by the other three algorithmsproposed, makes a controlled use of broadcasts and this re-sulted in less connect messages per node. It is also depictedthat the curve of the Random algorithm is above the ones ofthe Regular and the Hybrid algorithms due to the randomconnection establishment phase, in which broadcast mes-sages are sent with higher TTL values.

20

40

60

80

100

120

140

160

180

0 5 10 15 20 25 30 35 40

Num

ber

of c

onne

ct m

essa

ges

Nodes − decreasingly ordered by # of received connects

BasicRegular

RandomHybrid

Figure 7. Connect messages (50 nodes, 75%p2p).

Figures 9 and 10 show how the p2p configuration im-pacts the traffic volume each node receives. It is knownthat the traffic of ping messages in p2p networks is the

0-7695-1926-1/03/$17.00 (C) 2003 IEEEProceedings of the International Parallel and Distributed Processing Symposium (IPDPS’03)

Page 9: [IEEE Comput. Soc International Parallel and Distributed Processing Symposium (IPDPS 2003) - Nice, France (22-26 April 2003)] Proceedings International Parallel and Distributed Processing

0

100

200

300

400

500

600

700

800

0 20 40 60 80 100 120

Num

ber

of c

onne

ct m

essa

ges

Nodes − decreasingly ordered by # of received connects

BasicRegular

RandomHybrid

Figure 8. Connect messages (150 nodes, 75%p2p).

0

5

10

15

20

25

30

35

40

45

50

0 5 10 15 20 25 30 35 40

Num

ber

of p

ing

mes

sage

s

Nodes − decreasingly ordered by # of received pings

BasicRegular

RandomHybrid

Figure 9. Pings (50 nodes, 75% p2p).

0

20

40

60

80

100

120

0 20 40 60 80 100 120

Num

ber

of p

ing

mes

sage

s

Nodes − decreasingly ordered by # of received pings

BasicRegular

RandomHybrid

Figure 10. Pings (150 nodes, 75% p2p).

higher one [17]. The best way to cope with lack of re-sources in ad-hoc networks is to distribute the work amongall nodes. If the network in question is supposed to be ho-mogeneous, the more uniform the distribution is, the bestperformance we will achieve and the longer the networkwill last. This is exactly what random and regular algo-rithms do compared to the basic algorithm. On the otherhand, if the network is heterogeneous, we should assign ahigher load to nodes with higher capacity. The hybrid algo-rithm accomplishes this task by putting a bigger burden onnodes with a high qualifier, which means that masters getmore ping and query messages (Figures 11 and 12). Thethree improved algorithms (Regular, Random and Hybrid)profited from the symmetrical connections: only one nodesends pings to check the connection; the other vertex an-swers with pongs and uses a timer to control the receiv-ing of pings. This feature diminishes the overall number ofmessages in the network. From these results we can in-

0

20

40

60

80

100

120

140

160

0 5 10 15 20 25 30 35 40

Num

ber

of q

uery

mes

sage

s

Nodes − decreasingly ordered by # of received queries

BasicRegular

RandomHybrid

Figure 11. Queries (50 nodes, 75% p2p).

0

100

200

300

400

500

600

700

0 20 40 60 80 100 120

Num

ber

of q

uery

mes

sage

s

Nodes − decreasingly ordered by # of received queries

BasicRegular

RandomHybrid

Figure 12. Queries (150 nodes, 75% p2p).

fer that nodes communicating through the Basic algorithm

0-7695-1926-1/03/$17.00 (C) 2003 IEEEProceedings of the International Parallel and Distributed Processing Symposium (IPDPS’03)

Page 10: [IEEE Comput. Soc International Parallel and Distributed Processing Symposium (IPDPS 2003) - Nice, France (22-26 April 2003)] Proceedings International Parallel and Distributed Processing

will have to spend more battery to sustain the network. Thisis an undesirable situation, since energy is a scarce resourcein mobile ad-hoc devices. The excessive consume of batterymay cause many nodes to go down, making it necessary toreorganize the network, which in turn causes the remainingnodes to spend even more energy.

The Random algorithm was designed based on the small-world concept. However, in the results presented it wasnot possible to detect any manifestation of the small-worldcharacteristic. One possible reason for this is that the num-ber of nodes should be much larger than the number of con-nections, as mentioned in Section 6.1.2, which was not thecase. We intend to explore such a scenario in the future.Another explanation would be that, due to the dynamics ofthe network, the random connections go down before thenodes could benefit from them.

8. Conclusions and Future Work

In this paper we studied the (re)configuration of p2p net-works over ad-hoc networks. This combination is a naturalsolution in making data available to users anytime and any-where.

In the p2p paradigm, peers can act both as client andserver, which increases fault-tolerance and data availability.In ad-hoc wireless networks, each node is able to establisha point-to-point communication to other nodes within its ra-dio signal range, without the need of a fixed infrastructure.

To promote an efficient sharing of information, we de-signed four algorithms that provide configuration, mainte-nance and reorganization of the p2p network over ad-hocnetwork. To analyze the performance of the algorithms weperformed some simulations using the ns-2. The results ob-tained show that the Regular and the Random algorithmshad almost identical behavior despite the introduction ofnew features in the latter. They proved to be adequate tohomogeneous networks.

Focusing the heterogeneous scenarios, the Hybrid algo-rithm had a performance similar to the Regular and the Ran-dom algorithms in this different type of network. Finally,we showed that the Basic algorithm, based on a traditionalfixed-network solution, presented the worse overall perfor-mance regarding the effort made by each node to sustain itsparticipation in the network.

We will further investigate the performance and behav-ior of these algorithms under different scenarios. We aremost interested in analyzing the effects of wireless cover-age, density of nodes, energy, mobility and death/birth rateof nodes in ad-hoc and p2p layers. We are also developinga theoretical study on how the connectivity of nodes influ-ences our metrics and how small-world properties could bebetter used in these systems.

References

[1] T. Camp, J. Boleng, and V. Davies. A Survey of MobilityModels for Ad Hoc Network Research. Wireless Communi-cations and Mobile Computing, 2(5):483–502, 2002.

[2] Freenet. http://freenetproject.org/.[3] Gnutella. http://www.gnutella.wego.com/.[4] T. Hong. Peer-to-Peer: Harnessing the Power of Disrup-

tive Technologies, chapter 14 - Performance. O’Reilly andAssociates, 2001.

[5] KazaA. http://www.kazaa.com/.[6] G. Kortuem, J. Schneider, and D. Preuitt. When Peer-to-Peer

comes Face-to-Face: Collaborative Peer-to-Peer Computingin Mobile Ad hoc Networks. In Proceedings 2001 Interna-tional Conference on Peer-to-Peer Computing, August 2001.

[7] R. Lienhart, M. Holliman, Y. Chen, I. Kozintsev, and M. Ye-ung. Improving Media Services on P2P Networks. IEEEInternet Computing, pages 73–77, Jan./Feb. 2002.

[8] S. Milgram. The Small-World Problem. Psychology Today,1(1):60–67, 1967.

[9] N. Minar. Distributed Systems Topologies. In The O’ReillyP2P and Web Services Conf, 2001.

[10] Morpheus. http://www.morpheus.com/.[11] Napster. http://www.napster.com/.[12] NS-2. http://www.isi.edu/nsnam/ns.[13] L. B. Oliveira, I. G. Siqueira, and A. A. Loureiro. Evalua-

tion of Ad-hoc Routing Protocols under a Peer-to-Peer Ap-plication. In IEEE Wireless Communication and NetworkingConference (to appear), 2003.

[14] M. Papadopouli and S. H. A Performance Analysis of 7DS:A Peer-to-Peer Data Dissemination and Prefetching Tool forMobile Users. In Advances in Wired and Wireless Commu-nications. March 2001.

[15] M. Papadopouli and H. Schulzrinne. Effects of Power Con-servation, Wireless Coverage and Cooperation on Data Dis-semination among Mobile Devices. In ACM SIGMOBILESymposium on Mobile Ad Hoc Networking & Computing(MobiHoc) 2001, October 2001.

[16] C. Perkins, E. Royer, and S. Das. ”Ad-Hoc On-Demand Dis-tance Vector (AODV) Routing”. IETF Internet draft, draft-ietf-manet-aodv-11.txt, June 2002.

[17] M. Ripeanu, I. Foster, and A. Iamnitchi. Mapping theGnutella Network. IEEE Internet Computing Journal, 6(1),2002.

[18] E. M. Royer and C. K. Toh. A Review of Current Rout-ing Protocols for Ad Hoc Mobile Wireless Networks. IEEEPersonal Communications, 2:46–55, April 1999.

[19] R. Schollmeier and I. Gruber. Routing in Peer-to-peer andMobile Ad Hoc Networks. A Comparison. In InternationalWorkshop on Peer-to-Peer Computing, May 2002.

[20] SETI@Home. http://setiathome.ssl.berkeley.edu/.[21] R. Subramanian, L. e Katz. An Architecture for Building

Self-Configurable Systems. In IEEE/ACM Workshop on Mo-bile Ad Hoc Networking and Computing, August 2000.

[22] G. K. Zipf. Human Behavior and the Principle of Least-Effort. Addison-Wesley, 1949.

0-7695-1926-1/03/$17.00 (C) 2003 IEEEProceedings of the International Parallel and Distributed Processing Symposium (IPDPS’03)