Distributed Computation of a Spanning Tree in a Dynamic ... - CiteSeerX

4 downloads 32985 Views 170KB Size Report
tasks on machines that provide agent hosting capability, thus moving the ... motivation is to deal with ad-hoc networks where nodes can join or leave the network ...
IEEE International Conference on Engineering of Intelligent Systems 2006

1

Distributed Computation of a Spanning Tree in a Dynamic Graph by Mobile Agents Shehla Abbas a, Mohamed Mosbah b, Akka Zemmari c

Abstract - We describe a distributed algorithm for computing spanning trees in dynamic networks by using mobile agents. Each agent uses a random walk to move in the network and to construct a spanning subtree for the nodes visited for the first time. Spanning subtrees are merged when agents enter in an already discovered area of the network. In this case, we clone the agent having higher color to capture and to annex the adjacent subtree. We discuss in this paper this operation of agent cloning and show that it is useful to construct an efficient distributed algorithm for computing a spanning tree. The correction and the termination detection are also investigated. We give an implementation and a few experimental results which show the practical efficiency of the method. Keywords - Distributed Algorithms, Mobile agents, Spanning Trees, Random Walks, Self Stabilizing algorithms.

W

1.

INTRODUCTION

ith the emergence of agent technology, mobile agents have become an attractive paradigm for implementing objects that can migrate from one computer to another over the Internet. Complex applications can be deployed on these Mobile Devices because of their increasing computing power and memory resources. Mobile agents are a novel way of building distributed software systems. Traditional distributed systems are built out of stationary programs that pass data back and forth across a network. On the contrary mobile agents are agents that can physically travel across a network, and perform tasks on machines that provide agent hosting capability, thus moving the computation along with the data. Consider a network of processors represented by a graph where nodes represent processors and edges represent bidirectional communication links. Computing a spanning tree of a network is an important problem in distributed computing. Trees are essential structures in various communication protocols (synchronization, deadlock resolution, information broadcasting). This problem is also closely related to the election problem. There are many algorithms for distributed computation of a spanning tree [16, 17] in static networks. In this paper we describe a new algorithm for the distributed computation of spanning tree in dynamic networks. Our main motivation is to deal with ad-hoc networks where nodes can join or leave the network. Our method is based on mobile agents which move in a graph and construct subtrees in a

a [email protected], LaBRI, Université Bordeaux 1, France b [email protected], LaBRI, Université Bordeaux 1, France c [email protected], La BRI, Université Bordeaux 1, France

distributed way which are merged into a final spanning tree. Initially, agents are arbitrary positioned at different nodes. Agents visit different nodes of the network. They mark each node they visit for the first time and the edges by which they arrive. This traversal can be done by different means. There can be different types of these agents or tokens. These agents may or may not have any memory. Agents with memory are studied and compared with agents without memory by Metivier et al. [7]. In one type, token can only be used to mark the nodes without containing any code or instructions. In the other type, tokens may carry the code or the messages to be transferred. Moreover, these tokens do not keep an account of any information for the nodes visited because of absence of memory. Another technique of constructing a spanning tree is by performing Random walks. They have been studied extensively, and have many applications such as generation of random spanning trees [2, 6], token management schemes [18, 21], leader election [4] etc. In our work, the network mobility is random, and mobile agents also take random decisions as to which nodes they are going to visit next. Individual agents start with no knowledge of either the total number of agents or the number and interconnection of active network nodes. It is a simple process of visiting the nodes of a graph G in some sequential random order. The walk starts at some fixed node, and at each step it moves to a neighbor of the current node randomly chosen according to an arbitrary distribution. We propose to use random walks as the main tool for transferring information as the dynamic nature of ad hoc networks does not allow us to collect information concerning the current topology of the system. An attempt to collect such information will often result in out of date information. A Random Walk is a finite Markov Chain [1, 2] and Lovasz defines it as follows in [19]: “given a graph and a starting point, we select a neighbour of it at random, and move to this neighbour; then select a neighbour of this point at random, and move to it etc.” We now describe a random walk of an agent over a dynamic graph as described in [12]. A processor, p, that is about to send an agent, randomly chooses a processor pnext among the processors it can directly communicate with. Then p sends the agent to pnext. The above simple random walk procedure is used for covering the graph. The cover time is defined as the expected number of steps taken by a random walk to visit every node in G by a single agent that is required in order to visit every processor at least once. Cover time of specific graphs vary from the best case of O(nlogn)[14] to worst case of O(n3)[8, 15]. The best cases correspond to dense, highly connected graphs such as the complete graph, d-regular graphs

IEEE International Conference on Engineering of Intelligent Systems 2006 with d>n/2 and the hypercube [13]. When connectivity decreases, and “bottle necks” exist in the graph, the cover time increases. With the introduction of multiple random walks as proposed in [3], this process can be more efficient and when two agents collide; they merge to form a single tree hence increasing the efficiency of the network and decreasing the time of the spanning tree formed by a single agent. In fact many subtrees can be constructed in parallel at different parts of the network. Once two sub trees are adjacent, they are merged and only one agent will remain as we shall show. Our algorithms are self stabilizing for our dynamic network; that is starting from an arbitrary initial state; the system converges to a desirable state in a finite time. This concept was first introduced by Dijkstra [10]. This paper is organized as follows. In the next section we present the background and our contributions to the work. In Section 3 we give our model for the algorithms. In Section 4 we present our algorithms of wave, termination detection and dynamicity of the network. In section 5 we give an implementation of our algorithms on a tool visidia and we conclude our work by giving future directions in section 6. 2.

BACKGROUND

The traversal in the network for constructing a spanning tree can be done with one or more than one agent at any particular time because any agent can start at any arbitrary time. It is also possible that no agent is present at any moment in the network. At the end, the termination of an algorithm is achieved in spanning tree when there is only one agent left after the agents visit all the nodes of the network. There can be two possible conditions: if the agents do not exist in the network then that problem can be solved by using the concept of timeout which helps any node to create an agent after a certain interval of time if there is not a single agent in the network. The problem of many agents merging into one agent can be solved if one agent enters the region of another agent, then the agent with larger color takes control of the smaller agent and the smaller agent is destroyed. All the nodes marked with this color are replaced or changed with the color of the larger agent. The construction of a spanning tree and the traversal of these nodes are done by using the technique of random walks. Each agent goes to a next node in its neighborhood at random but uniformly. 2.1 Contributions Our main contribution in this work is the introduction of clone agents. This concept is used to improve the algorithm efficiency. The advantage of using clone agents is to delegate certain tasks that can not be executed by the original agents. In our algorithms, we mainly use a clone of an agent when the agent reaches a subtree and decides to annex it. Because the agent moves randomly from a node to another, as it follows a random walk, it avoids doing so when it enters in an already constructed subtree and decides to capture it. This happens if such subtree has lower color, i.e. it has been constructed by an agent with lower color. In such a case, the current agent will create a clone and will continue with its random walk. The clone visits the subtree and captures it. To do so, the clone

2

performs a deterministic traversal of the captured subtree, updates the orientation of the edges and eventually kills the agent of this subtree if it catches it. Once the clone returns back to its initial node, it dies. Thus each agent keeps its behavior by moving randomly in the graph and delegates the task of subtree annexing to clones. This separation allows modular and efficient construction of algorithms as we shall show in Section 4. The second contribution of our work is the termination detection of the algorithm discussed above. We derived our algorithm from [11]. When an agent reaches its root location from where it had started, it tries to detect the termination of the computation of the spanning tree and initiates a wave to check the neighboring nodes at every level of the graph. If all of them have been marked by the same color as that agent, it detects the termination; else it will inform the root node of the non completion of the algorithm. As an application of our algorithm, we investigate the computation of spanning trees for ad hoc wireless networks, since this algorithm can deal with dynamic modifications of the network. We also implemented our algorithms on a tool and we observe that our algorithms give better results than the previous work done on the subject. 3.

MODEL

A network can be modeled by a graph where vertices denote processors and edges denote direct communication links. Every process has a small, non-shareable local memory and communicates only with its neighbors by exchanging messages. Let G = (V, E) be an undirected graph where V is the set of nodes and E is the set of edges. A spanning tree of a graph, G, is a set of |V|-1 edges that connect all vertices of the graph. All the edges of the spanning trees are directed towards the root [22]. If i is any node in the network then Ni is the neighborhood of the node i with which it can communicate. The number of the neighbors of i is the degree of i. In the case of ad hoc networks each node represents a mobile computing device and each link represents a bidirectional logical link, that is, there is no physical connection between the nodes and they communicate with radio frequency. We consider a named network, so every node is associated with a unique identifier. A communication link exists if and only if nodes i and j are neighbors i.e. there is an edge which connects these two nodes. All computations at the nodes are done locally, that is, between this node and its neighbors. There is no global knowledge assumed during the execution of the algorithm. An agent does not have any memory, and moves by following Random Walk. An agent marks the nodes with its color if the nodes are not already colored. The nodes keep track of their parents by the links marked by the agents and eventually the root node; hence forming spanning trees. An agent contains two fields: color and root • Color defines the identity of an agent, two agents can be compared on the basis of their colors i.e. if we take any two mobile agents T1 and T2 then T1 > T2 if [T1.color > T2.color]

IEEE International Conference on Engineering of Intelligent Systems 2006 •

The root variable indicates the node that has created the agent hence becoming the original or root node. The agent starts its Random Walk from the root node.

Remark 1: Note that the identity of a node is fixed before the beginning of the algorithm and therefore is related to the network. However, we use colors during the execution of the algorithm to describe agent passages. 4.

ALGORITHMS

4.1 Wave Algorithm[20] For the nodes; each nodep maintains a data structure • node’s unique identifier • color, the identity of an agent • master, the (sub)tree root to which the node belongs • parent, the node parent within the (sub)tree • sons, (optional) set of node sons, if no sons are present then it is a leaf node When a node creates an agent, a color is being assigned to it. The nodes are marked with the color of an agent when the agent visits these nodes. All agents have their own color. If the agents visit the nodes which are already marked they can do the comparisons and local computations. For example if an agent with bigger color visits a node which is already marked with another but smaller color, it will change the previous color by the color of the new agent. Termination state of an algorithm can be achieved when an agent arrives at its root node and checks for termination. Termination is explained in the section termination detection. Faults may occur in the system which means that these faults can cause changes arbitrarily in the state of any node i.e. the local states of the node, the value of program counter and its internal variables. The algorithms used are self stabilizing that is these arbitrary faults can be recovered and the sates of the variables and counters can be reset and they will come back in a legal state in finite time without external intervention if there are no more faults that happen at that time. We calculate the progression of algorithm by using the concept of wave algorithm. It calculates how an already traversed graph will be added to the current graph that is the merger of any two subgraphs. The wave is executed by a clone agent. If two agents collide or enter in each other’s region then there are some possible scenarios described below. We illustrate the first case by Fig. 1, all other cases are similar. Algorithm 1: i) We suppose that the agent with bigger color enters at any node p, which is already colored by another agent with smaller color and the smaller color agent is still present at that node. (See Fig. 1) if colori >colorj ∧ agentj is present at node p then ∃ spanning tree of agentj nodep will be marked with the color of bigger color agent colorp := colori //color of bigger agent is assigned to the node p q := parent //q is the node from where the bigger identity agent is coming

rooti := master //master is the (sub)tree root to which the node belongs

3

now the agentj with smaller color will change its color with the bigger agenti and also change its root, i.e. it acts as a slave of the bigger agenti. It will traverse the subgraph of agentj which had the smaller color as the edges have been marked previously by agentj. Agent with changed color acts as a clone to the agenti, it goes to previous parent node to traverse the subtree. The clone agent has variables and behavior which are similar to the original agent but with the difference of doing a wave traversal instead of Random Walks, that is deterministic traversal. It also

agenti agenti Subtree constructed by agenti Subtree constructed by agentj Fig. 1 Meeting of two agents at nodep of the network (case i)

marks the node from where it starts its traversal. All the nodes with colorj of that subgraph will be colored again with colori . colorj := colori q:=parent rooti :=master until all the graph of old agentj is traversed. ii) We suppose that the agent with bigger color enters at any node p, which is already colored by another agent with smaller color and the smaller color agent is not present at that node. (See Fig. 1) if colori >colorj ∧ agentj is not present at node p then ∃ spanning tree of agentj nodep will be marked with the color of bigger identity agent colorp := colori q := parent rooti := master //generate a new agent with the same values of the variables

nodep = clone(agenti ) clone(agenti) traverse to previous parent node of agentj The node will create a clone agent; agent′. In this case an already marked node can create a clone agent as in general there is a limitation of generating an agent by marked node. Moreover the clone agent will mark the node from where it has started the traversal and when after traversing the subtree it reaches back to the node from where it had started, it will be killed there. colorj := colori q:=parent rooti :=master until all the graph of old agentj is traversed. when clone(agenti ) meets agentj agentj = kill iii) We suppose that the agent with smaller color enters at any node p, which is already colored by another agent with bigger color and the bigger color agent is still present at that

IEEE International Conference on Engineering of Intelligent Systems 2006 node. This case is nearly similar to case i) except that smaller agent takes a Random Walk. (See Fig. 1) if colori