Token Based Algorithm For Supporting Mutual Exclusion in
Token Based Algorithm For Supporting Mutual Exclusion in
Opportunistic Networks
Sagar A. Tamhane and Mohan Kumar
Computer Science and Engineering Department
University of Texas at Arlington, TX, U.S.A.
[email protected], [email protected]
ABSTRACT in an opportunistic network is a challenging problem. Due
Opportunistic networks are essentially distributed networks to mobility and failures, a node might never get access to
with transient connectivity among nodes. Nodes in its critical section. Incorrect fault detection might lead to
opportunistic networks are resource constrained, mobile multiple nodes
and infrequently come in executing their CS simultaneously. Recently, much of the
contact with each other. In such a distributed network, research work in opportunistic networks
nodes may require exclusive access to a shared object or has been focused on such challenges as routing ], security,
resource. Ensuring freedom from starvation is a challenging privacy and modeling of user mobility . Very limited
problem in opportunistic amount of work has been done to provide mutual exclusion
networks due to the infrequent contacts and node failures. in generic mobile ad hoc networks (MANETs). Existing
In this paper, we review mutual exclusion algorithms algorithms for mutual exclusion can be classified as
proposed for generic mobile ad hoc networks (MANETs) permission based and token based. In permission based
and discuss their applicability algorithms such as [9] and , a node that wishes to enter CS
to opportunistic networks. Further, we propose a novel sends messages to a set of nodes. If all of the nodes in that
token based algorithm and prove it is free from starvation set grant permission, the requesting node enters CS.
and deadlock, and satisfies the safety property. Unlike In token based algorithms, a token is circulated in the
existing algorithms for MANETs, network. A node can enter its CS only if it holds the token.
the proposed algorithm does not require continuous Token based algorithms can be further classified into token
monitoring ofthe network topology. Simulation results passing and token
show that our algorithm is communication efficient as requesting algorithms. In token passing algorithms such
compared to other algorithms proposed for generic mobile as], the nodes are arranged into a static or dynamic ring and
ad hoc networks. We also propose a timeout the token is passed to all the nodes on that ring. In token
based fault detection algorithm that exploits the inter requesting algorithms
contact time distributions. To the best knowledge of the a directed acyclic graph (DAG) is constructed
authors, the proposed algorithm is the first to support such that each node points towards its neighbor through
mutual exclusion in opportunistic which the token holder can be reached. When the token is
networks. transferred from one node to another, the pointers are
updated accordingly. For a
Keywords static network, the DAG can be updated easily without
Opportunistic Networks, Critical Section, Mutual much over- head. When a node wishes to enter CS, it sends
Exclusion, Token Passing, Distributed Resources a request message to its neighbor in the direction of the
1. INTRODUCTION token holding node. The message
Mutual exclusion is one of the fundamental challenges in is thus propagated to the token holder via multiple hops.
distributed systems. Need for mutual exclusion arises when Once the token holder exits its CS, the token is sent to the
two or more nodes wish to perform (or enter) their critical requestor using the reverse path of the request message. In
section (CS) this paper, we discuss the applicability of the distributed
such as gaining exclusive access to a shared resource. mutual
Examples of problems that require mutual exclusion are: exclusion algorithms available for MANETs and propose a
assigning unique values such as IDs and IP addresses to new token based algorithm, called as Mutual Exclusion for
mobile nodes in dynamic OPportunistic
networks , ensuring total ordering of message delivery in networks (MEOP). MEOP avoids continuous monitoring of
mobile networks and updating a shared file in a peer to the network and is communication efficient as compared to
peer environment. Opportunistic networks are typified by other algorithms. The proposed algorithm is independent of
nodes that come in contact infrequently. Nodes in the the underlying routing protocols used to transfer the token
network are resource constrained from one
and have limited residual energy. A series of opportunistic node to another. We propose a timeout based fault
contacts in time and space leads to opportunistic paths. An detection mechanism in which the distribution of
opportunistic network comprises a set of opportunistic intercontact times is exploited to decide the timeout values.
contacts andpaths, distributed in space and time. The We prove that, under certain realistic
topology of such an opportunistic network changes assumptions, MEOP satisfies following correctness
frequently due to mobility, link and node failures. In the properties:
near future, several applications are expected to exploit 1. Safety: At most one node must be executing its critical
opportunistic networks. Hence ensuring mutual exclusion section at any given time.
2. Liveness: Liveness implies freedom from starvation and In the Local-Recency (LR) and Local-Frequency (LF)
deadlock. Starvation is defined as: any node that wishes to algorithms, the token holder forwards token only to its
execute its CS, will eventually do so. Deadlock is defined neighbors. If there are multiple neighbors, the LR algorithm
as: if there is any node that wishes to execute its CS, then chooses the node that was least recently visited by the
some node will eventually enter its own CS. token, whereas the LF algorithm chooses the node that was
Ordering is a desirable but not mandatory mutual exclusion least frequently visited. In Global-Recency (GR) algorithm,
property. Ordering requires that if one node requested token is forwarded
access to CS before another node, the access is granted in to any node in the network that was least recently visited.
that order. This node may not necessarily be the neighbor of the token
2. EVALUATION OF EXISTING holder. If the token is passed using multihop
communication, the intermediate
ALGORITHMS nodes do not enter their CS. The Global-Recency with Next
2.1 Token Ring Based Algorithms (GRN) algorithm is similar to the GR algorithm except that
In Baldoni-Virgilito (BV) algorithm, the token is passed when the token is transferred using multihop
over a dynamically created logical ring. Each round over communication, intermediate nodes can enter their CS. In
the ring has a coordinator. Initially, the coordinator of the Global-Frequency (GF) algorithm,
first round holds the token. When a node wishes to enter its the token is passed to any node in the network that was
CS, it sends a request to least frequently visited by the token. If multihop
the coordinator, thus initiating token circulation. The token communication is used, intermediate nodes do not enter
is circulated over the entire ring even if only a single node their CS. The Global-Frequency with Next (GFN)
wishes to enter the CS. Hence the BV algorithm has large algorithm is similar to GF except that the intermediate
overhead if the request nodes can enter their CS. Simulation show that the LR
generation rate is low or only a few nodes generate algorithm performs better than other five algorithms.
requests. At the beginning of every round, the role of Starvation and deadlock are avoided only in the absense of
coordinator is transferred to the next node in the ring. failures.
Hence in each round, ID of the next coordinator is passed 2.2 DAG Based Algorithm
along with the token. Thus token In Derhad-Badache (DB) algorithm , a DAG is created
requests need not be passed along the ring and can be fortoken requesting and forwarding. Edges in the DAG
passed using any routing protocol. When a node exits its represent the route to be used by the token request and the
CS, the node passes the token to a node that has not been token. When the token
visited by the token and is at a minimum number of hops holder wishes to release the token, it chooses its successor
from the token holder. The algorithm such that (i) there is a path from token holder to successor,
tries to avoid starvation by passing the token to all the (ii) the successor
nodes by creating a ring structure. The authors make the has been waiting for longest period of time and (iii) routing
following assumptions: cost between token holder and its successor is minimum.
(i) Nodes do not fail and the network is not subject To obtain the routing cost, the algorithm requires a network
to permanent partitions. Hence the algorithm can correctly topology monitor
avoid starvation and deadlock only in the absence of node that can continuously update the information about current
failures. (ii) A protocol that can provide such metrics as network topology. The algorithm assumes that the network
number of hops between does not get partitioned permanently. To avoid starvation,
two nodes is available. (iii) Topology does not change algorithm requires each requestor node to connect to token
during the multi hop transmission of token. These holder’s partition for a time duration of atleast TCS +
assumptions are not valid for opportunistic networks. Tdiscovery + TToken, where TCS, Tdiscovery and TToken are
Hence the BV algorithm is not suitable for opportunistic execution time of CS, route discovery delay and time
networks. required to deliver token from holder to requestor
The Mobile Dual-Token MUTEX (MDTM) algorithm for respectively. In an opportunistic network, due to node
detection of token loss is proposed. The algorithm detects mobility, the above assumption is not valid. Since the
token loss due to communication failure only. The authors topology changes frequently, the DAG needs to be updated
assume that the nodes do not fail. Two tokens are circulated continuously, even if the token is not transferred between
in the network. Each token has its own dynamic ring and a nodes. This updation has a huge overhead. Hence the
coordinator. Only one DBalgorithm is not suitable for opportunistic networks.
token, called as primary token, gives permission to enter
CS. The two tokens monitor presence of each other. When 2.3 Permission Based Algorithms
a token visits a node, the token records its ID onto the node. In permission based algorithms , a node that wishes
If a token completes a cycle
over the ring and does not find the ID of other token on any to enter CS sends messages to a set of nodes. If all of the
of the nodes, loss of the latter is declared and the lost token nodes in that set grant permission, the requesting node
is regenerated. Since MDTM is a token ring algorithm, it enters CS. The algorithms assume that the nodes do not fail
deadlocks if the ring is broken due to node failures. Hence and the network topology is assumed to be static. These
MDTM algorithm is not suitable for opportunistic algorithms do not tolerate loss of messages. In an
networks. opportunistic network, since any two nodes rarely come in
contact, seeking permission from a set of nodes incurs
heavy communication overhead and a large delay. Table 1 contact with other nodes, the token holder informs other
summarizes the above described algorithms. Simulation nodes about the location of the token. If there are any
show that the LR algorithm performs better than other five pending requests in the request list, the token holder selects
algorithms. Hence the following table includes only LR. the request that was generated earliest
3. PROPOSED ALGORITHM
The MEOP algorithm is light weight and can be deployed
in conjunction with any underlying routing protocol. The
algorithm is comprised of three main components: (i)
request generation, (ii)
request propagation and (iii) token propagation. In this
section, we provide a detailed discussion of these and tries to route the token to the corresponding node. After
components. Let N be the total number of nodes in the exiting the CS, the node generates another request after an
network. Nodes are represented as n1, average of _time units. A node, ni, that receives the token
n2, :::, nN . Let E[Ti; j] be the average intercontact time might have multiple requests (including its own) pending in
between two nodes ni and nj, where i; j 2 P. Let E[Ti] be the its request list. If its own request was not generated earlier
average inter-any-contact time between node ni and all than all of the other requests, the node may again enter its
other nodes that it connects to. We first list the CS only if E[Ti] is less than the expected time required to
assumptions: finish the CS. Else, ni waits and transfers the token to other
1. Inter contact time between two nodes has either a heavy nodes.
tailed or an exponential distribution with average E[Ti; j].
2. The distributions of inter contact times and inter-any-
contact times have reached a steady state before the
algorithm for mutual exclusion is executed.
3. A node ni might come in communication range of only a
subset of nodes in the network.
4. When two nodes are in communication range of each
other, messages are transferred in FIFO order. The nodes
communicate synchronously and hence any message loss
can be detected by both the nodes.
5. Multihop communication between two nodes need not
preserve FIFO order of the messages.
6. Communication channel between neighboring nodes is
bidirectional.
7. Though the network is partitioned most of the time, there When two nodes opportunistically come within range, they
eventually will be a path between any two nodes. exchange
8. Clock drift is negligible. such information as requests for CS, token location and
Figure 1 shows the state transition diagram of applications routing tables recorded by each till that time. Figure 2
that need mutual exclusion. Each node maintains a list of shows communication exchange between two nodes of the
pending requests. When a node wishes to enter its CS, it network. In Figure 2(a), nodes ni and nj have partial
generates a request information about the network.
and adds the request to the list. The request is propagated to Let nodes nc, nd, ne, nf and ng, where c; d; e; f; g 2 P, be
other nodes. The requestor then waits to receive the token. some of the other nodes in the network. Node ni is aware
A node does not generate another request if its current that node nd is the token holder. Node nj does not have
request has not been satisfied. As soon as the token is information about the location of the token. Figure 2(b)
received, the requestor enters CS. For the period of CS shows the combined graph of intercontact
execution, a node may turn off its radio and stop times. Since information is spread only upon opportunistic
communicating with other nodes. After completing the CS, contacts, some nodes in the network will have older
whenever the token holder opportunistically comes in information than others. When such nodes come in contact,
it is necessary to decide which node has the recent Algorithm 1 shows the proposed algorithm, Mutual
information. Hence such information as Exclusion
generated request and ID of the last known token holder for OPportunistic network (MEOP). The algorithm is
carries a timestamp. Using the timestamp, the older explained in
information is updated with the recent. For example, if detail in the following subsections.
node ni knows nd as the last known 3.1 Request Generation
token holder and node nj has ne as the token holder, a During the initialization of the system, ID of token holder
timestamp associated with the information helps identify node
recent most information. Depending on the node mobility is not known to other nodes. Hence the token holder floods
patterns, a node might meet only a subset of nodes in the the network
network. For example, in Figure 2, nc might never meet ne. informing its ID to all other nodes. Once the location of the
For such cases average intercontact time is token becomes known, nodes can start generating requests.
computed as the minimum sum of intercontact times over When
all paths between the two nodes. Thus E[Tc;e] = E[Tc;i] + node ni wishes to enter its CS and does not have the token,
E[Ti; j] + E[Tj;e]. it creates
Algorithm 1 Mutual Exclusion in OPportunistic Networks a request. Each request consists of a timestamp
{id: variable that stores ID of the node} representing
Procedure generateRequest() {Generate Request and Start the time at which the request was generated and the ID of
Request the corresponding
Propagation} node. The node executes its CS only after receiving the
1: if tokenHolder is known then token. The node can generate another request for token
2: Requestid = (Tid, id) only after
3: routeRequestTo(tokenHolder) exiting its CS, that is, the node does not generate a request
4: end if if its
Procedure routeRequestTo(destination) {Forward Request previously generated request is not satisfied.
to
Token Holder} 3.2 Request Propagation
1: if tokenHolder == id then In traditional DAG based algorithms, the edges of the DAG
2: Add request to list of pending requests represent
3: else the path along which token request is routed. The DAG
4: Store local copy of the request needs to be updated if the network topology changes due to
5: exchangeInfo() node
6: Use routing protocol to find next hop towards mobility. This continuous monitoring of the network
tokenHolder introduces a
7: Transfer request to next hop large overhead. The DAG is also updated when the token is
8: end if transferred
Procedure consumeToken() {Execute CS and forward from one node to another. The proposed MEOP algorithm
token to is a DAG based algorithm. Nodes of the DAG in MEOP
successor} point to
1: Execute critical section the last known token holder. The DAG need not be updated
2: if request list is not empty then when
3: successor = get next high priority node from request list the topology changes. Thus the DAG in MEOP is a logical
4: forwardToken(successor, request list) DAG,
5: else as compared to the routing based DAG used in traditional
6: exchangeInfo() algorithms.
7: end if The logical DAG is independent of the underlying node
Procedure forwardToken(destination, request list) mobilities. The token request messages and the token might
{Forward token be
and list of pending requests to destination} propagated over a multihop route. The actual multihop
1: if destination == id then routing of
2: consumeToken() the token requests and the token is performed by
3: generateRequest() underlying routing
4: else protocols. Since routing protocol is not the focus of this
5: exchangeInfo() paper,
6: Use routing protocol and transfer token to next hop we adopt such existing routing algorithms as [6]. MEOP
towards abstracts
destination the routing algorithms as follows: using some routing
7: end if criteria, each
Procedure exchangeInfo() {Update information with node is assigned a rating. When node ni wishes to send a
neighbors} message
1: Transmit network topology, ID of token holder to all to nj, and they are not in the communication range, ni
neighbors transfers
the message to some other node nk only if nk has a higher n
rating
than ni, for the given criteria. The process is repeated till na
message c
reaches nj. For example: in BubbleRap [6], node popularity d
and community membership are used as the routing
criteria. In our ef
simulations, we use intercontact time as the routing criteria. (a) nc holds token
When nd
ni wishes to transfer a message to nj, and they are not in the nb
communication
range, ni transfers the message to another node nk only ne nf
if E[Tk; j] < E[Ti; j]. na
When a node, that is not the token holder, receives a token nc
request, (b) nc updates na and nd
the node inserts the new request in its local list of pending
requests. Upon next opportunistic contact, the list is nf
forwarded by ne
the underlying routing protocol. If the node is the token nd
holder, the nb
request is inserted into the request list. Figure 3 shows an
example na
of creation and updates to the logical DAG. For simplicity, nc
only six (c) na receives token from
nodes are shown in Figure 3(a). Let nc be the initial token nc
holder nb
and na, nb, nd, ne and nf be the requestors, where a; b; c; d; e;
f 2 P.
ne
Figure 3(b) shows that na and nd consider nc as the last na
known token nc
holder. The token request message from the requestors nf nd
might (d) nb receives token from
reach nc at different times. If nc is not executing its CS and na
it receives
the first request, say from na, it will route the token to na. nb ne
As nc
mentioned above, the actual routing is performed by an nd
underlying
routing protocol. nf
3.3 Token Propagation na
Unlike traditional DAG based algorithms, in opportunistic (e) nb updates nc and nd
networks Figure 3: Example of updates to the logical DAG.
the reverse path of request may not be the path taken by the earliest and tries to route the token to the corresponding
token to reach the requestor, na. In Figure 3(c), na receives node. Token
the request made by nb is routed to nc. nc stores a copy of
token from nc and hence nc now points to na. After receiving request
the made by nb and then forwards the request to na. Figure 3(d)
token, na executes its CS. After completing its CS, the shows
token holder that, after leaving the CS, na routes the token to nb. It might
checks if its list of pending requests is empty. If the list is happen
empty, nc does not receive the token while it is being routed from
the token is kept idle till the arrival of next request. If the na
list is nb. Hence nc still considers na to be the last known token
not empty, the token holder selects the request that was holder.
generated Similarly, nd still points to nc.
129 Intermediate nodes retain a copy of the token request. In
nb the
worst case, the token request reaches each and every node
n in the
n network. Hence in the worst case, N number of messages
n are required
for reaching the token holder. In order to reduce the consider nb as the last known token holder.
number If there are more than one pending requests in the request
of hops taken by the token request, other nodes in the queue,
network the token holder chooses the requestor that had generated
need to be informed about the change in location of the the request
token. On at the earliest. Hence requests that were made earlier in
extreme, the network can be flooded each time the token is time,
transferred. On the other extreme, no update messages are receive higher priority. An opportunistic network may not
passed have
the token request follows the path along which the token a global clock or global time. Hence comparing two
was timestamps
passed. Thus there is a tradeoff between the amount of directly may not guarantee happened-before relation. Since
flooding clock
performed and the number of hops the token request is synchronization is not the focus of this paper, we adopt the
transmitted. algorithm
MEOP uses the following limited flooding mechanism: proposed in [3] to find the difference in clocks, and the
when clock
node ni transfers the token to another node nj, only those drift. When a token request is received, the receiver adjusts
two the
nodes have the accurate information about the location of timestamp of the request with the difference in clocks. Thus
the token. timestamps
When ni comes in contact with another node nk, nk is of requests received from multiple nodes are adjusted to the
informed local clock.
about the change in token location. nk does not propagate Since token requests may be sent over multiple hops, the
update to other nodes in the network. After receiving the next
token, highest priority node chosen by the token holder need not
token holder enters its CS and may stop communicating be a
with neighbor. The token may be transmitted over multiple hops
other nodes till the end of CS. After exiting the CS, the to the
token holder next highest priority node. Since contacts between nodes
also informs its neighbors about the location of the token. are infrequent,
Only the the intermediate nodes are allowed to enter their CS only
sender and receiver of the token are allowed to update other if the average inter-any-contact time of the intermediate
nodes. node is
It may happen that ni and nj never come in communication more than the average time required to execute the CS on
range that node.
of some nodes. These nodes will not receive the update Hence even though the token requests made by
message. intermediate nodes
Requests sent by these nodes, will either reach ni (and then do not have the highest priority, the time spent in waiting
will be for an opportunistic
redirected to nj) or some intermediate node, that has been connection is exploited to execute CS on intermediate
updated, nodes.
might redirect the request to nj. Since only the sender and 4. FAULT DETECTION
receiver We consider two types of failures: (i) node ni is waiting to
of the token are allowed to update other nodes, a large transfer
amount of the token to a specific node nj. ni and nj do not come in
time is required to flood the entire network. Before the communication
entire network range due to their mobility patterns or due to crash at
gets flooded, nj might transfer the token to some other node. nj. (ii) nj receives the token from ni and moves away from
Nodes that receive the recent update messages do not other
receive the nodes for a very long time or it has crashed. In both the
older update messages. Hence entire network is flooded cases, ni
only in the performs the fault detection of nj. We assume that ni and nj
worst case. do not
Figure 3(d) shows that nb and ne come in communication fail simultaneously. This assumption is similar to the one
range made in
and hence ne points to nb. Figure 3(e) shows that nb still [15]. According to assumption 4, communication channel
holds the between
token, but the topology has changed such that the token two neighboring nodes is FIFO. If the devices move away
holder nb from
comes in communication range of nc and nd. Hence nc and each others’ communication range while the token request
nd now or token
was being transferred, the error in transmission can be cancels the timeout for nj.
detected by We set _i; j to be the maximum of observed intercontact
both the nodes. Hence any incomplete transmission is time between
cancelled by the two nodes. According to assumptions 1, 2 and 7, the
both the nodes. Thus token loss does not occur due to link inter contact time between two nodes follows a distribution
failures. and the
Consider that node ni is waiting to transfer the token to nj. distribution has reached steady state. Hence the probability
This that
case occurs when the routing protocol computes ni to be the nj is alive and does not meet ni during multiple timeouts
best becomes
router to nj. ni sets a timeout, _i; j, for meeting with nj. If ni almost negligible. If a token loss is detected, ni generates a
comes new
within communication range of nj or a node that is a better token.
router to It could happen that a node ni generates a token request,
nj, nj transfers the token and cancels the timeout. Else, if the propagates
time- the request to another node nj and nj crashes. After
130 transfering
out expires, ni chooses the next highest priority request and the request to nj, ni sets a timeout of some fixed value. If
sends ni does not receive the token before the timeout expires, ni
the token to the corresponding node. A SENDBACK() retransmits
message the same request to other nodes. Hence the token request
is piggybacked along with the token. After the next high will
priority eventually reach the token holder even in presence of node
node completes its CS, the SENDBACK() message makes failures.
the token 5. MUTUAL EXCLUSION
come back to ni. When the token comes back to ni the
process CORRECTNESS
of waiting for nj is repeated. PROPERTIES
Consider that ni transfers the token to nj at time t. ni sets a 5.1 Safety
timeout, _i; j, for meeting with nj. If ni and nj come within
MEOP is a token based algorithm. Hence safety property is
communication
guaranteed
range, and nj still has the token, the timeout is reset to _i; j.
if there is at most one token in the network. Failures can
If nj does not have the token, the timeout is cancelled and ni
occur
stops
in two situations: node ni transfers the token to nj and nj
performing fault detection of nj. If ni and nj do not come
faces
within
software or hardware failure and crashes, or nj moves away
communication range before the timeout expires, ni floods
from
the network
all other devices for a very long time. In both the cases, ni
with PING(nj; t) messages. After receiving the PING(nj; t)
experiences
message, a node nx that has met nj or any other node that
timeout and generates a new token. We set the timeout _i; j
was carrying
to be the maximum of observed intercontact times between
the token (after time t) sends an ISALIVE(nj) message to
the two
ni, else nx sets a timeout _x; j for nj. If node nx meets nj (or
nodes. Since the distribution has stabilized, the probability
any
that nj
other node that is carrying the token) before the timeout
meets ni after time greater than _i; j is very small. Moreover,
expires, nx
after
sends ISALIVE(nj) message to ni, else nx sends a
the timeout expires, ni floods network looking for nj and the
NOTALIVE(nj)
token.
to ni. If ni receives at least one ISALIVE(nj) message, it
If other nodes also have not met nj or the token, they set
resets
timeouts
the timeout to _i; j and again starts waiting for nj. If ni
with corresponding maximum intercontact time values. ni
receives
declares
NOTALIVE(nj) messages from all other nodes, it considers
nj to have failed only when all nodes have not met nj and the
nj to
token
have failed and generates a new token. Due to the
for the maximum observed intercontact time. The
opportunistic
probability
nature of the network, it may happen that ni has started a
that nj is alive and does not meet any node during
timeout
corresponding
for nj and ni meets another node nk that currently has the
timeouts is extremely small and so nj is considered to have
token or
failed.
ni might receive the token from some other node. In such
Consider that ni starts waiting for nj at time t. Let Ti; j be the
cases, ni
random
variable that denotes the intercontact times between nodes not met any node during the corresponding maximum
ni intercontact
and nj and max(Ti; j) be the maximum observed value. The times, and hence can infer that ni has regenerated a token.
distribution Hence
of Ti; j might be non zero till infinity. Since the intercontact nj deletes its token. Thus there is only one token in the
time distribution is either heavy tailed or exponential, the system.
probability Thus our algorithm satisfies the safety property.
that ni and nj meet after time max(Ti; j) is very small. Let 5.2 Starvation
_i; j = P(Ti; j > max(Ti; j)) be the probability that ni and nj do Each token request is propagated in the network till it
not meet before time max(Ti; j). If the two nodes do not reaches the
meet in token holder. In the worst case every node will have a copy
max(Ti; j), ni broadcasts PING(nj; t) message. Let _i;x be the of the
time request. Hence the token request is guaranteed to reach the
taken for the PING() message to reach from node ni to node token.
nx. nx Each token request has a timestamp. The request that was
sends an ISALIVE(nj) message if nx has met either nj or any made
token earlier than other request, receives a higher priority. As
holding node after time [t; t+max(Ti; j)+_i;x]. Otherwise, nx explained
starts above, there is always atmost one token in the network.
a timeout with value max(Tx; j). If nx does not meet either nj Thus the
or any algorithm is free from starvation.
other node with the token in max(Tx; j), nx sends
NOTALIVE(nj) 5.3 Deadlock
message to ni. The NOTALIVE(nj) message transmitted by When a node ni is waiting to transfer token to nj, no other
nx node
can be a false negative only if nj has not crashed, has the in the network can enter its CS. To show that our algorithm
token and is free
does not meet nx in time interval [t; t+max(Ti; j)+_i;x from deadlock, it is sufficient to show that ni does not
+max(Tx; j)]. indefinitely
Let P(FAILx;i; j) be the probability of a NOTALIVE(nj) wait for nj. Infinite waiting time is avoided by using time _i;
j as
message
from nx to ni. This probability is given by: explained in previous section. After the timeout, ni sends
P(FAILx;i; j) = _i; jP(Tx; j > max(Ti; j) + _i;x + max(Tx; j)) (1) the token
If node ni receives atleast one ISALIVE(nj) message, it to the next high priority node and receives the token back.
repeats the ni
131
process of waiting for nj. ni decides that nj has failed only
then repeats the process of waiting. Hence at least one node
after
in the
receiving NOTALIVE() from all other nodes. Let _x;i be the
network can enter its CS. Thus our algorithm is free from
time
deadlock.
taken by the reply, sent by nx to reach ni. Hence at time (t +
td), ni 5.4 Ordering
will decide that nj has failed, where td is given by: In an opportunistic network, messages are transmitted over
td = max(Ti; j) + max multiple
8x,i;x,j hops. Due to location and mobility of nodes, even if two
(_i;x + max(Tx; j) + _x;i) (2) token
Consider that ni has received NOTALIVE(nj) message from requests are generated at the same time, the requests might
all reach token holder at different times. Hence total ordering
other nodes in the network. If nj has not crashed, has the cannot
token be guaranteed. When token holder has multiple pending
and meets any of the nodes after the corresponding requests,
maximum intercontact it chooses the node that generated the request earlier. Hence
time, all the received NOTALIVE(nj) messages would there
become false negatives. Hence the probability that ni is ordering between received requests. However, requests
incorrectly that have
declares nj to have failed is given by: not been received by the token holder cannot be ordered
P(FAILi; j) = P(Ti; j > td) (3) according
Y 8x,i;x,j to their timestamps. In MEOP, when the token holder
P(Tx; j > max(Ti; j) + _i;x + max(Tx; j)) selects
In order to recover from the crash, ni generates a token. If nj the next high priority node, say ni, it transfers the token to
has not crashed and has the token, nj itself can observe that that
it has node, possibly using multi hop communication.
Intermediate nodes
might have generated token request after ni had generated m/s (low speed) to 60 m/s (high speed). All of the nodes
the request. generate
To maintain strict ordering, intermediate nodes should not requests. We see that the number of messages transferred
be first
allowed to enter their CS. In order to decrease the average increases and then decreases with _, whereas the average
waiting waiting
time, MEOP allows intermediate node, say nj, to enter its time per CS continuously increases. This behavior is
CS only explained as
if E[Tj] > average time required to execute the CS at follows. When _ = 100, after completing a CS, the token
intermediate holder
node. Thus MEOP satisfies the safety and liveness generates the next request much faster than that when _ =
properties. 10000.
6. SIMULATION STUDIES Nodes in an opportunistic network infrequently come in
To simulate an opportunistic network, we use contact
RandomWaypoint with each other. Hence when _ = 100, the token holder can
mobility model for results shown in Figures 4, 5 and 6. For satisfy
results many of its own CS requests before meeting another node.
shown in Figure 7, the "cambridge/haggle" dataset [14] was Thus,
used. while waiting for an opportunistic contact, the token holder
For the random waypoint mobility model, we use the can
mobigen-ss satisfy requests (generated by itself) that do not have the
tool [11] to generate the steady state of node location and highest
speed. priority in the pending queue. It may happen that a node
Hence our simulations start in a steady state. The comes
simulations use (a) Average number of messages transmitted
10 nodes moving in an area of 300m x 300m. The average (b) Average waiting time per CS request
communication Figure 4: Effect of varying _: the average delay between
range is 10m. We compare our algorithm with the BV end
algorithm. The simulations use intercontact time as routing of CS and generation of new request on each node
criteria. in contact with the token holder when the token holder is
When ni wishes to transfer a message to nj, and they are not executing
in its non-highest priority CS, and thus the opportunity to
the communication range, ni transfers the message to forward
another node the token to the actual highest priority node is lost. Thus the
nx only if E[Tx; j] < E[Ti; j]. The routing protocol can be number
changed to of messages sent and the average waiting time per CS is
any existing protocol without affecting MEOP algorithm. less.
For request When the delay between end of CS and generation of next
generation, we use variations similar to that used in [5]: request
after is _ = 1000, there is a lesser probability of losing an
a node has executed its CS, it generates a new request after opportunity
an average to forward the token. Hence number of messages
delay of _ seconds. We vary _ from 100 seconds (heavy transmitted
load) increases. As the token is transferred to another node, next
to 10000 seconds (light load). BV algorithm does not token request generated on previous token holder has to
handle node wait a
failures and hence does not avoid starvation and deadlock larger amount of time. Hence average waiting time also
in case increases.
of failures. Hence, to perform fair comparisons, node When _ = 10000, requests are generated at large time
failures are intervals. In
not simulated. In following simulations, each reading is an MEOP, the token is less frequently transferred to other
average nodes due
of 50 executions. Confidence intervals are computed with to possibly empty pending queue at the token holder. BV
95% uses a
confidence level. token ring. Hence, even if a node does not need to execute
Figures 4(a) and 4(b) show the average number of CS, it
messages still gets the token. In traditional token rings over a static
transmitted in the network and the average waiting time per network,
CS the token would have been immediately passed onto the
per node with varying _. Average time required to execute next node.
the critical In an opportunistic network, the token holder has to wait
section is 30 seconds. The average speed is varied from 20 for an
opportunistic contact. Hence the average waiting time Figure 6: Effect of varying percentage of nodes that
increases. generate
The difference between trends in Figures 5(a) and 5(c) also token request.
show In the above simulations, all of the nodes in the network
the same behavior: average waiting time increases with made
increasing token requests. Figure 6 shows the effect of varying
_ and the number of messages transmitted first increases percentage of
and then participation. We see that MEOP has lower communication
decreases with increasing _. overhead
MEOP is based on a logical DAG. Token is transferred to a irrespective of the number of nodes making token requests.
node, The average waiting time per CS request is lower in MEOP
say ni, only when its request has reached the token holder when
(and few of the nodes generate token requests.
when the node is an intermediate node on the route to ni). For simulation results shown in Figure 7, the
BV is a "cambridge/haggle"
token ring. Token circulation is started as soon as the token dataset [14] was used. This dataset includes bluetooth
holder sightings
(or coordinator) receives the first token request. Hence a made by 12 students carrying iMotes for six days. We see
node ni that
might receive token even though its request has not reached MEOP has much less communication overhead as
the compared to the
coordinator. Hence the average waiting time of BV is less BV algorithm.
than 7. CONCLUSION AND FUTUREWORK
that of MEOP. In BV, the token is circulated over all nodes, Mutual Exclusion is a fundamental problem in distributed
even if systems.
some of the nodes do not wish to execute CS. Hence the Nodes in an opportunistic network meet infrequently and
number of are resource constrained. In such a dynamic and distributed
messages transmitted in BV is more than that in MEOP. environment,
(a) Average number of messages transmitted nodes requesting starvation might face starvation and
(b) Average waiting time per CS per node deadlock due to node mobilities and failures. In this paper,
(c) Average number of CS executed we first
Figure 5: Effect of varying average time required to discussed the applicability of some of the existing
execute CS algorithms available
Figures 5(a), 5(b) and 5(c) show the effect of varying the for MANETs. We presented a novel algorithm, Mutual
average Exclusion
time required to execute CS on number of transmissions, for OPportunistic networks (MEOP) that
average (a) Average number of messages transmitted
waiting time and number of executed CS respectively. The (b) Average waiting time per CS request
effect Figure 7: Effect of varying _, on the [14] dataset.
of varying _ is as explained above in Figure 4. When the liveness properties. The algorithm uses a logical DAG for
time passing
required to execute CS is increased, the token holder the token requests. MEOP is independent of the underlying
spends more routing
time executing CS and lesser time waiting for an protocols and hence does not need continuous monitoring
opportunistic contact. of the
Hence the number of messages transmitted decreases, entire network. We proposed a timeout based fault
average detection mechanism
waiting time increases and the number of executed CS in which the distribution of intercontact times is exploited
decreases to
with increase in CS. decide the timeout values. Simulation results show that
The routing protocol used for above simulations can be MEOP is
changed communication efficient.
without affecting the MEOP algorithm. We performed Social networking concepts have been used to route
simulations messages
to study the effect of varying _ when the PRoPHET [8] between nodes in an opportunistic network [6]. We
routing envisage using
protocol is used and observed that the trends remained such concepts in order to reduce the average waiting time
same as per
obtained in previous simulations. critical section request. Similar to the assumption made in
(a) Average number of messages transmitted [15],
(b) Average waiting time per CS request MEOP assumes that when a node is tracking the presence
of a particular
token holder, at most one of those two nodes fails. We are 24(1):9–17, Jan. 1981.
extending MEOP to handle multiple simultaneous failures. [14] J. Scott, R. Gass, J. Crowcroft, P. Hui, C. Diot, and
8. REFERENCES A. Chaintreau. CRAWDAD trace
[1] M. Abdulla and R. Simon. A simulation study of cambridge/haggle/imote/cambridge (v. 2006-01-31).
common Downloaded from http://crawdad.cs.dartmouth.edu/
mobility models for opportunistic networks. In 41st Annual cambridge/haggle/imote/cambridge, January 2006.
Simulation Symposium (anss-41 2008), pages 43–50, 2008. [15] W. Wu, J. Cao, and M. Raynal. A dual-token-based
[2] R. Baldoni, A. Virgillito, and R. Petrassi. A distributed fault
mutual exclusion algorithm for mobile ad-hoc networks. tolerant mutual exclusion algorithm for manets. Mobile
International Symposium on Computers and Ad-Hoc and Sensor Networks, 4864/2007:572–583, 2007.
134
Communications, pages 539– 544, 2002.
[3] Q. M. Chaudhari and E. Serpedin. Clock offset and
skew
estimation in wireless sensor networks with known
deterministic delays and exponential nondeterministic
delays. In International conference on Digital
Telecommunications (ICDT ’08), pages 37–40, June 2008.
[4] G. Coulouris, J. Dollimore, and T. Kindberg.
Distributed
Systems Concepts and Design, chapter 11. 2001.
[5] A. Derhab and N. Badache. A distributed mutual
exclusion
algorithm over multi-routing protocol for mobile ad hoc
networks. International Journal of Parallel, Emergent and
Distributed Systems, 23(3):197–218, June 2008.
[6] P. Hui, J. Crowcroft, and E. Yoneki. Bubble rap: social-
based
forwarding in delay tolerant networks. In International
Symposium on Mobile Ad Hoc Networking and
Computing,
pages 241–250, 2008.
[7] L. Lilien, Z. H. Kamal, V. Bhuse, and A. Gupta. The
concept
of opportunistic networks and their research challenges in
privacy and security. In Mobile and Wireless Network
Security and Privacy, pages 85–117, 2007.
[8] A. Lindgren, A. Doria, and O. Schelén. Probabilistic
routing
in intermittently connected networks. MobiHoc 2003
posters, 7(3):19–20, July 2003.
[9] M. Maekawa. A pN algorithm for mutual exclusion
decentralized systems. ACM Transactions on Computer
Systems, 3(2):145–159, 1985.
[10] N. Malpani, Y. Chen, N. H. Vaidya, and J. L. Welch.
Distributed token circulation in mobile ad hoc networks.
IEEE Transactions on Mobile Computing (TMC),
4(2):154–165, March/April 2005.
[11] W. Navidi, T. Camp, and N. Bauer. Improving the
accuracy
of random waypoint simulations through steady-state
initialization. In 15th International Conference on
Modeling
and Simulation, pages 319–326, March 2004.
[12] S. Nesargi and R. Prakash. Manetconf: Configuration
of
hosts in a mobile ad hoc network. INFOCOM 2002,
2:1059–
1068, 2002.
[13] G. Ricart and A. Agrawala. An optimal algorithm for
mutual
exclusion in computer network. Communication of the
ACM,