Tuesday, June 4, 2019

Performance Analysis Of Election Algorithm Computer Science Essay

Per physical bodyance Analysis Of Election Algorithm Com bewilderer Science quizDistributed systems are the systems consisting of multiple litigateors that connect finished a ne iirk to communicate. To manage the communication amid different guests and the exchange of entropy between them, a attraction among them is required.In our project we implement the various Election algorithmic rules for choosing the drawing card in Distributed Systems thus solving the coordinator election problem. We are also compa ricochet the performance of separately of these election algorithms. First we implemented the Election algorithms using the communicate passing interface(MPI). Then we measured and compared the performance of to each one of these election algorithms and simulated the results. Fin onlyy we modify the distributed leader election algorithm to suit the mobile ad-hoc entanglements.Key Words Distributed Systems Election algorithms Uni worryal border algorithm Lelan ns algorithm Chang Roberts algorithm Bidirectional ring draw election Mobile Adhoc NetworksIntroductionDistributed systemIt is a assemblage of paradeors where the memory or a clock is not shared. Every central processing unit has its get associated memory and the nurture is exchanged through communication net incomes.Distributed algorithmA distributed algorithm is an algorithm run on such a distributed system presumptuous the non-existence of central coordinator in these systems. So these algorithms require one process to act as a coordinator. There is no way to select one of them to be leader if all the processes are a alike without different characteristics. One of the processes has to take this special responsibility, no matter which process takes it.This problem in which a leader has to be elected is termed as the coordinator election problem that is how to choose a process among the different processors to make it a central coordinator.Election algorithmAn election alg orithm is apply to solve the coordinator election problem in these distributed systems. Any election algorithm must be a distributed algorithm by the genius of the coordinator election problem. The most important feature in election algorithm is it assumes every process has a Unique ID. It votes a process from among the different processors which batch act as the initiator, sequencer and monitor in detecting and solving situations like Deadlock, Mutual Exclusion etc. Thus electing a leader process has become a major issue in wired and ad hoc networks.The goal of election algorithm is to see that when an election begins it ends with all processes by an balance as who has to be the new coordinator.ELECTION ALGORITHM ON RINGS A ring is formed by the processes in ring algorithm. In this each process sends only mental objects to the next process in the ring.It evict be classified into two categoriesUnidirectionalBidirectionalThe pass alongs are sent only in one direction in unidir ectional and in both directions in Bidirectional ring algorithms.To compare the performance of these algorithms, the different criteria taken into recollectation areTotal number of messages passedcomplexness of the messages utilise period elapsed by the algorithm2. Implementation SoftwareWe have used the message passing interface (MPI) for implementing our algorithms which are discussed below. It is a standard specification for communication through messages among different processes. It is independent of any language. It is used in parallel computing to write programs for group and point to point communication between customers.We used the C language to implement the election algorithms. The MPIs routines are directly travel toable in C. The main MPI calls used in our program areMPI_Init Before communicating, all instances of the code should call this so as to prepare the MPI implementation for the communications environment.MPI_Finalize For exiting the communication, this is c alled by all the instances of the code.MPI_Comm_size To memorise about the number of processors which are using MPI environment to communicate, this routine is called.MPI_Comm_rank Each of this process assigns an integer to the communicating process.MPI_Send To send a message to another process, this is called.MPI_Recv This call allows to receive a message from a process.3. Unidirectional Ring AlgorithmsThe ring algorithm consists of processes arranged in the form of a ring consisting of a image. The emblem is passed between processes and the process which has the ring squeeze out send a message.The election problem can be implemented using the ring algorithmsLelanns algorithmChang Roberts algorithm3.1 LeLanns algorithmIn this we assume that all the processes are physically and logically ordered.In LeLanns algorithm whenever the coordinator is lost, the initiator sends a token to the other processes in the ring by adding its id. Nodes cannot initiate any messages once they rece ive the token. aft(prenominal) circulating the token, if the process receives back its id then it is chosen to be the leader since it knows that others cannot become leaders as it knows all the ids of the other processes and it has the least id. The message complexness of LeLanns algorithm is O(N2).ALGORITHM meter stick 1 beginStep 2 send the token to neighbours with id of flow process as iStep 3 add current process id j and forward to neighboursStep 4 if process P receives back its id thenStep 5 leader is PStep 6 else return zero pointStep 7 endMessage ComplexityEvery initiator sends N messages. So the polish off case while complexness is N2. The algorithm is implemented using MPI and the message complexity and era complexity given by the MPI program isNo.of processesMessagesReal dateUser timeSystem time5251.1950.0250.023101001.2920.0270.024152251.4460.0300.027204001.5510.0340.030256251.6540.0360.030 hold oer 1 LeLanns algorithm3.2 Chang Roberts algorithmThis is similar to lelanns algorithm but with a little change. When a process receives a token with an id greater than the current process id, it drops that particular token as that process cannot be a leader . Hence it forwards the token with an id less that itself. In this way it saves time by discarding the unwanted messages. The worst case message complexity of Chang Roberts algorithm is O(N2) and the average case message complexity is O(N logN).ALGORITHMStep 1 send message with identifier = I to other processesStep 2 if identifier J of current process I then send the message to neighbours with identifier IStep 3 else drop message with identifier I and send the message with identifier J to neighboursStep 4 continue this process until a particular process receives back a message with its identifier.Step 5 if a process receives a message with its id then process= leader.Step 6 else return nullStep 7endMessage ComplexityThe best case time complexity is 2N-1. The process with largest id sends N m essages and other N-1 processes send one message each. The algorithm is implemented using MPI and the message complexity and time complexity given by the MPI program is given in the table 2.No.of processesMessagesReal timeUser timeSystem time591.1890.0240.02310191.2990.0270.02415291.4120.0290.02620391.5310.0330.02825491.6500.0360.031Table 2Robert Changs Best Case AlgorithmThe worst case time complexity is N(N+1)/2. The process with largest id sends N messages and other N-1 processes send messages from 1N-1.No.of processesMessagesReal timeUser timeSystem time5151.1860.0240.02310551.3010.0270.025151201.4140.0300.027202102.5110.0340.029253251.6540.0350.030Table 3 Robert Changs defeat Case Algorithm4. Bidirectional Ring Algorithms4.1 Leader election algorithm for Bidirectional RingIn these bidirectional ring algorithm messages can be sent or exchanged in any direction. We have used the algorithm mentioned in 2 An improved upperbound for distributed election in bidirectional rings of pr ocessors. J.Van Leeumen and R.B Tan. Distributed Computing(1987)2149-160 for implementing it with the MPI.The allude (identifier) of a large processor is contained in the register ID which is maintained by the processor and a (Boolean) register DIR that has a direction on the ring in which in that respect are processors that still have a smaller processor up for election.A smaller candidate which is still alive when the messages( the ones having the name of a Large candidate) are created, have them being sent out in its direction. Processors that begin a chase are known as active, and the left hand over processors are observing. To get rid of the smaller candidate and force agreement on the larger candidate is the main idea behind a chase. After the current active processors have begun the chase, the observant processors basically relay messages onwards unless they notice an unusual situation on the ring only. As the algorithm proceeds, there are two unusual situations that can arise at the location of an observant processor. They are(i) The processor receives a message of the current material body, say through its left link, that contains a value which is less than the current value in its ID register. The processor turns active, increments its phase number by 1, and initiates a chase with the value its current ID in the direction of the message that was received, i.e., out over its left link.(ii) Two messages of the alike(p) phase are received by the processor from opposite directions. The processor turns active, increments its phase number by 1, and initiates a chase with the largest value contained in the two messages in the direction of the smallest. As the algorithm proceeds, several active processors that can arise in a phase rapidly decreases, and at the end a single processor bequeath be left precisely. This processor will be familiar that it receives two messages of the same phase from opposite directions that hold same values and is elected b ecause each it receives a message of the current phase with a value exactly alike to the one it sent out (and stored in its ID register) or it receives two messages of the same phase from opposite directions that hold same values. ALGORITHM 2The algorithm describes the actions of an arbitrary processor on a bidirectional ring with half-duplex colligate as required for electing a leader1) Initializationa) allow u be the executing processors identification number. Send message to both neighbors and phase number Pnum=0b) Wait for corresponding messages and to come in from two neighborsc) Compare u1 and u2 and set ID to max(u1,u2)and Dir to the min(u1,u2) and goto Active state else Observant state.2) ElectionA processor performs in either active or observant state.a) ActiveA processor enters the active state with some value v stored in its ID register and a phase number p. The phase number p is either stored in Pnum or it is an update stored in temporary register. The phase number Pnum is incremented by 1 and a message is sent in Dir direction and goes to observant state.b) ObservantIn this state a processor receives messages and passes them on, unless an unusual situation is observed that enables it to initiate a new phase.Receive messages from one or both directions. Discard any message received with p less than Pnum.i) If the number of messages left are zero then go to observant state.ii) If the number of messages left is one then Let the one message received be where necessarily p=PNUM.if p=PNUM thenv = IDgoto inauguratev DIR= direction from which the message was receivedgoto active statev IDbegingoto observantelsePNUM = pID =vDIR=the direction in which the message was going Send message to directionDIRgoto observantiii) If the number of messages left is one thenLet the two messages received be and ,necessarily from opposite directions and with p=PNUMif v1=v2Pnum = pgoto inaugurateelsev1=v2ID-=max(v1,v2)DIR=the direction of min(v1,v2)goto active3) i nauguralA transfer to this final phase occurs when the algorithm terminates and the ID register contains the identity of the unique leader.Message complexityThe message complexity of the bidirectional algorithm is 1.44NlogN + O(N). MPI is used implementing the algorithm. The Time and message complexity given by the MPI program isNo.of processesMessagesReal timeUser timeSystem time5141.1860.0240.02210291.3020.0270.02415441.4170.0300.02620591.5340.0330.02825741.6610.0360.030Table 4 Leader election algorithm for Bidirectional Ring4.2 Leader election algorithm for Mobile Adhoc NetworksA mobile ad hoc network is dynamic in nature. It is composed of a set of peer-to-peer nodes, that exchanges the information within the network through some tuner channels directly or through a series of such links. A node is independent to move close to as there is no fixed final network topology. The nodes move freely in a geographical area and are loosely bounded by the transmission range of these wi reless channels. Within its transmission range, a mobile node communicates with a set of nodes thus implying all of them have to be in a network. These set of nodes are also known as the neighbors of the communicating node. The mobile nodes act as intermediary routers to direct the packets between the source and the finishing nodes (i.e., the set of neighbors). A node is designated as a leader to coordinate the information that needs to be exchanged among nodes and to be in charge of their data requirements. The identification problem of a leader is termed as the leader election problem.Why do we need to select this leader? When the nodes are set out, they form an adhoc network between them within which the self-coloured communication happens. If the topology of the network changes dynamically, a node may suspend its communication with the previous node, just like in distributed networks. So there has risen a need for a leader so that the maintenance of the network and the clock synchronization within it can be done. Also a new leader has to be chosen every time the members of the group are getting updated while communication is taking place.When the communicating nodes move freely and if they are not within the transmission range of each other, then the wireless network fails . Similarly the formation of wireless links happen only when the nodes which are separated and are too far and to communicate, move within the transmission range of one another. The network topology may change rapidly and unpredictably over time since the nodes are mobile. So developing efficient distributed algorithm for adhoc networks is a challenging work to be done. The largest identity node is chosen to be the leader using minimum wireless messages in this approach. A mobile ad hoc network can be considered as a static network with frequent link or node failures, which can be thought of as a mobile node of an adhoc network going out of reach. To cover all the nodes in the networ k we use the diameter concept. While distance is described as the shortest path between the nodes, diameter is defined as the longest distance between any two nodes in the network. The number of hops will be the taken for measuring the distance and the assumption is that the network becomes stable after a change happens during leader election process and there are only a exceptional number of changes in the network.A network having N nodes are considered here. Since the topological changes are considered during the leader election, this algorithm takes more than diameter rounds to terminate. If however, the topological changes are not considered diameter rounds are taken to elect the leader. We have used the algorithm mentioned in 3An Efficient Leader Election Algorithm for Mobile Adhoc Networks Pradeep Parvathipuram1, Vijay Kumar1, and Gi-Chul Yang2 for implementing it with the MPI.Leader ElectionEach node propagates its unique identifier to its neighbors and a maximum identifier is elected as a leader in every round. This maximum identifier is propagated in the ensuant rounds. All the rounds need to be synchronized. idlist (i) identifies identifier list for node i, which consists of all the neighbors for node i. Lid(i) =max(idlist(i))TerminationAt (rounds = diameter), for each node i, If all identifiers in idlist are the same(i) the node i stops displace the maximum identifier further and chooses the maximum identifier in the idlist(i) as the leader. The algorithm gets terminated if for each node i the elements in idlist (for each node) are the same. The termination may not be at the final part of the diameter rounds, If all identifiers in the idlist as the leader.ALGORITHM 3Each node i in the network has two componentsa) idlist identifier listb) Lid(i) leader id of node i.1) Each node say node i transmits its unique identifier in the first round and Lid(i) in the subsequent rounds to their neighbors and all these ids will be stored in idlist. Lid(i) = max (idlist(i))2) A unique leader is elected in diameter rounds, if there are no topological changes in the network. The algorithm is modified to incorporate topological changes in between the rounds and below is the description of howthe algorithm is modified.Case 1If a node has no outgoing links then lid(i) = iCase 2If a node leaves between the rounds, then the neighbors would know this. Suppose node i leaves the network after round r and let its neighbors be j and k. neighbors of i (i.e. j, k).1) Delete (ilist, idlist(j k)) // delete ilist from idlist ilist contains the group of identifiers that node i has sent to its neighbors before round r on with i The ilist information is also deleted from all the neighbors of j and k if the ilist identifiers have been propagated in the previous rounds. This process continues until all the nodes in the network are covered.2) geminate while (round = diameter), //Termination conditionCompare all the identifiers present in idlist(i) for ea ch node i. If all the identifiers in idlist(i) are equal, node i stops propagating its maximum identifier and elects the maximum identifier as the leader.Case 3If a new node i joins the network in between the rounds say round r then the neighbors will update its idlist.1) If neighbors of i say node j is the neighbor for node i. Add (i,idlist(j))The normal algorithm continues (the ids are propagated), nodes keep exchanging the information till diameter rounds.2) Repeat while (round = diameter),For all nodes in the network (node j) receives an identifier i at diameter round. IF i is greater than the maximum identifier node j has propagated in the previous round (diameter-1).a) Propagate node i to all the neighbors of j.b) Also propagate the node i information to all the neighbors of neighbors i until the whole network is covered, if the above condition satisfies.Else do not propagate the information to nodes in the networki) Compare all the identifiers present in idlist(i) If all the identifiers in idlist(i) are equal, node i stops propagating its maximum identifier and elects the maximum identifier as the leader.ii) All nodes in the network follow this process and a unique leader is elected connected component.The time taken for the algorithm to elect a leader will be O (diam + t) where t is the time taken for all the nodes to converge and t depends on the topology changes.Message complexityThe message complexity of this algorithm depends on the number of rounds. In each round it sends 2N messages if we consider a ring topology as every node has 2 neighbors. So message complexity is 2N* No. of rounds. This algorithm is implemented using MPI and the message complexity and time complexity given by the MPI program isNo.of processesMessagesReal timeUser timeSystem time5301.1870.0230.022101201.3010.0260.024152401.4210.0300.027204401.5410.0320.029256501.7520.0370.031Table 5 Leader Election Algorithm for Mobile Adhoc Networks5. SimulationsMessage Complexity with resp ect to number of processesTimeNo.of Messages TransferredSnoAlgorithmN=5N=10N=15N=20N=25N=5N=10N=15N=20N=251LeLanns1.1951.2921.4461.5511.654251002254006252Chang Roberts1.1891.2991.4121.5311.659192939493Bidirectional Ring1.1861.3021.4171.5341.66114294459744MobileAdhoc1.1871.3011.4211.5411.75230120240440650The message and time complexity of each of these 4 algorithms for different number of processes is implemented in our programs and the results are as shown in table 6.All the above simulations are plotted on the graph so as to analyze the way different algorithms message complexity varies with the number of processes on which it executes.6. ConclusionsTable 6 Simulation ResultsComparing the results, we can intermit that the Lelanns algorithm is the most fundamental algorithm and requires large number of message exchanges among the four algorithms. Changs and Robert algorithm madeconsiderable changes to Lelanns algorithm however in the worst case that algorithm also requires O(N2). F or leader election in ring topology these are the two unidirectional algorithms that are to be considered.The bidirectional algorithm requires less messages than the worst case Changs and Roberts algorithm. It requires O(N logN) messages. It takes less time to discover the leader when compared to unidirectional algorithms since the messages are sent in both the directions. The final algorithm is put into effect for mobile adhoc networks and is run in many rounds. The messages complexity depends on number of rounds. It guarantees that there is only one leader at a time but however it handles the partition in the network and requires more number of messages .

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.