1. Introduction
Consider a large-scale networked system in which the participating nodes are counting external triggers. The distributed trigger counting (DTC) problem is defined as raising an alarm and notifying a user when the total number of received triggers reaches a predefined value
w in a distributed system of
n nodes [
1,
2,
3,
4]. We assume that no statistical data on the triggers (e.g., the sequence of nodes receiving the triggers and the number of triggers received by each node) are given to the system ahead of time. Only the case where the number of triggers is significantly greater than the number of nodes, i.e.,
, is taken into account. Otherwise, the DTC problem can be solved with
messages [
2,
5].
DTC algorithms can be utilized for distributed monitoring [
6,
7,
8] and global snapshots [
9,
10,
11,
12]. Monitoring is essential to manage distributed networks such as sensor networks [
13]. Sensor networks monitor environmental or physical status such as traffic volume, wild animal behavior, troop movement, and atmospheric conditions. For example, in traffic management, an alarm can be raised when the number of vehicles on the road surpasses a certain threshold. When observing wild animal behavior, an alarm can be raised when the number of a specific species in a specific area surpasses a certain threshold. For a data network, you can also monitor the amount of traffic or the number of remote logins to detect DDoS (distributed denial-of-service) attacks. To declare that a global snapshot of a distributed system is valid, all messages in transit must be recorded. Garg et al. [
14] proved that the DTC problem can be used to solve the problem of deciding whether all messages in transit have been received.
Message complexity and MaxRcv are major performance metrics for DTC algorithms [
2]. Message complexity indicates the total number of messages sent and received by all nodes, and MaxRcv means the maximum number of received messages per node. While message complexity evaluates the performance of the overall algorithm, MaxRcv represents the overload of a specific node due to the algorithm.
In this paper, we propose a simple and efficient algorithm for the DTC problem. The proposed algorithm is based on a tree structure of degree
and height 2. The proposed algorithm operates in three phases depending on the remaining number of triggers. We prove the correctness of the proposed algorithm; namely, we prove that the probability of not notifying a user when the total number of triggers received from a distributed system reaches a predefined value
w is 0. Experimental results show that the proposed algorithm has lower message complexity than
CoinRand [
2] and
TreeFill [
3]. MaxRcv of the proposed algorithm is also smaller than
CoinRand and
TreeFill when the number of nodes is not very large.
The rest of the paper is organized as follows. In
Section 2, we summarize the related works on DTC algorithms. The proposed algorithm is described in
Section 3 and the failure probability of the proposed algorithm is analyzed in
Section 4. In
Section 5, the experimental results are discussed. Finally, we conclude this paper in
Section 6.
2. Related Works
For global snapshots, DTC algorithms can be utilized as a primitive operation [
14]. By employing an efficient DTC algorithm, the message complexity for storing global snapshots can be significantly lowered when compared to existing global snapshot algorithms [
7,
13,
15,
16,
17]. The message complexity of recording channel states in existing global snapshot algorithms is typically
[
12]. By using an efficient DTC algorithm, the cost of recording channel states can be reduced to
[
14].
Garg et al. proposed three DTC algorithms: one grid-based, one tree-based, and one centralized algorithm. They also proved that the lower bound of message complexity for generic DTC algorithms is
[
14]. The centralized algorithm shows an optimal message complexity, but the MaxRcv of it is not bounded.
Chakaravarthy et al. proposed an almost optimal DTC algorithm called
LayeredRand [
1]. The message complexity of
LayeredRand is
with high probability, and its MaxRcv is
. Chakaravarthy et al. also proposed two DTC algorithms,
CoinRand and
RingRand, which can be regarded as improvements of
LayeredRand [
2]. The message complexity of
CoinRand is
with high probability, and its MaxRcv is
. It is based on a network topology similar to a binary tree. By using a randomized approach in the message aggregation process,
CoinRand outperforms
LayeredRand. The message complexity of
RingRand is
, and its MaxRcv is
with high probability.
Kim et al. proposed
TreeFill, an optimal DTC algorithm [
3]. The message complexity and MaxRcv of
TreeFill are
and
, respectively.
TreeFill is also based on a tree-like network topology.
Emek and Korman proposed two DTC algorithms called
CompTreeRand and
CompTreeDet with more general assumptions about node-to-node communication [
18]. The algorithms are built on a tree network with nodes which are only able to communicate with their immediate neighbors. The message complexity of
CompTreeRand is
; however, MaxRcv of
CompTreeRand is not investigated. The message complexity and MaxRcv of
CompTreeDet are, respectively,
and
.
For global snapshots, Kshemkalyani suggested a
hypercube-based algorithm [
12]. The message complexity of the
hypercube-based algorithm is
, which is lower than the optimal message complexity for DTC problems of
. The
hypercube-based algorithm, on the other hand, has a message size of
, whereas DTC algorithms have a message size of
.
Tsai used the general grid interconnection network, which is an extension of the
hypercube-based network to prove the lower bound of message complexity for global snapshot algorithms [
19].
Chang et al. proposed a DTC algorithm without any assumption about the network topology [
5]. The algorithm they propose primarily focuses on sensor networks whose network topology is unknown ahead of time. In the worst case scenario, their algorithm solves the DTC problem using
messages, where
x is double the number of edges in the network.
Recently, Kim et al. proposed
DDR-coin, an efficient probabilistic DTC algorithm [
4]. It is a Monte Carlo algorithm in the sense that the system may fail to raise the alarm when it receives
w triggers. Compared with the previous work (
CoinRand,
RingRand and
TreeFill), it shows a smaller message complexity and MaxRcv. However, for a small
n,
DDR-coin shows larger a message complexity and MaxRcv. Furthermore, it has a limitation in that a mathematical analysis of message complexity and MacRcv is incomplete.
Table 1 compares major performance metrics for DTC algorithms.
3. Proposed Algorithm
In this section, we present a simple and efficient tree-based algorithm for the distributed trigger counting problem. It is an exact algorithm in that it has no false positives and no false negatives. To make the problem easier to understand, we assume all nodes are fully linked and that there are no message losses, no node failures, and no external attackers. Events are triggered by arbitrary distribution on the nodes in the system. We want to detect when w or more triggers occur in the system and raise an alarm.
The proposed algorithm works as follows. For ease of explanation, we assume the number of nodes for some positive integer k. The n nodes are arranged in three layers: layer 0, 1, and 2. Layer 0 consists of a single node, and layer 1 consists of k nodes. As in CoinRand, all the n nodes are arranged in layer 2. Among the n nodes, one node is arranged in layer 0 and other k nodes are arranged in layer 1. The nodes which play dual roles in the proposed algorithm are selected in a round-robin fashion. We assume that all nodes in the system know the layering information.
Figure 1 shows the hierarchical structure of the proposed algorithm when
. In the first round, node 0 is assigned to layer 0 and nodes 1, 2, 3, and 4 are assigned to layer 1 as in
Figure 1. In the second round, node 5 is assigned to layer 0 and nodes 6, 7, 8, and 9 are assigned to layer 1.
The algorithm works in three phases depending on the number of triggers that has not yet been detected, (). The first phase is when , the second phase is when , and the third phase is when .
3.1. The First Phase ()
In the first phase, the proposed algorithm works on a round basis. At the start of each round, the system must know how many triggers have not yet been detected. The system counts it by keeping a counter for each node that stores the number of triggers the node has received in each round. A variable is used to store the initial value for each round. We set in the first round because all the w triggers have not yet been detected.
Hereafter, we describe the behavior of specific rounds. Each node calculates a leaf node threshold value . Each node also keeps a counter variable to indicate the number of triggers received by the node x in each round. Each time the node x receives a trigger from external sources, it increments by 1. When the counter variable reaches the leaf node threshold , the node x decreases by and chooses a node y uniformly assigned to layer 1 at random and sends a coin message to y. Each node assigned to layer 1 maintains another counter variable to indicate the number of coin messages received by the node y in each round. Upon receiving a coin message, the node y increments by 1. When the counter variable reaches the internal node threshold , the node y decreases by and sends a coin message to the root node assigned to layer 0. Finally, when the number of coin messages that the root node receives reaches k, the root node computes the total number of triggers received by all the nodes in this round and updates . It is possible via a simple broadcast and upcast procedure in a pre-determined binary tree as in CoinRand. The aggregation notification is broadcast to all the nodes in a recursive top–down fashion. Similarly, aggregation values are computed from the leaf nodes to the root node in a recursive bottom–up fashion. After that, the root node updates and broadcasts it to all the nodes, again recursively. Upon receiving the updated , all the nodes update values for the next round. If the newly computed is less than , the algorithm enters the second phase. Algorithm 1 shows the first phase of the proposed algorithm.
3.2. The Second Phase ()
The proposed algorithm also works on a round basis in the second phase. A variable
is also used to store the initial value for each round. Whenever every node receives a trigger from external sources, it chooses a node
y uniformly assigned to layer 1 at random and sends a coin message to
y (i.e.,
). Recall that each node assigned to layer 1 maintains a counter variable
to indicate the number of coin messages received by the node
y in the current round. Upon receiving a coin message, the node
y increments
by 1. When the counter variable
reaches another internal node threshold
, the node
y decreases
by
and sends a coin message to the root node assigned to layer 0. Finally, when the number of coin messages that the root node receives reaches
k, the root node computes the total number of triggers received by all the nodes in this round and updates
. If the newly computed
is less than
, the algorithm enters the third phase. Algorithm 2 shows the second phase of the proposed algorithm.
Algorithm 1: The first phase of the proposed algorithm |
- 1:
When ith round begins: - 2:
if then - 3:
- 4:
end if - 5:
if then - 6:
Go to the second phase - 7:
end if - 8:
- 9:
- 10:
for all node x - 11:
for all node y - 12:
- 13:
When the node x receives a trigger: - 14:
- 15:
if then - 16:
- 17:
Choose a node y assigned to layer 1 uniformly at random - 18:
Send a coin message to y - 19:
end if - 20:
- 21:
When the node y assigned to layer 1 receives a coin message: - 22:
- 23:
if then - 24:
- 25:
Send a coin message to the root node assigned to layer 0 - 26:
end if - 27:
- 28:
When the root node z receives a coin message: - 29:
- 30:
if then - 31:
Compute the total number of triggers received by all the nodes in this round and updates (via a simple broadcast and upcast procedure) - 32:
Go to the next round () - 33:
end if
|
Algorithm 2: The second phase of the proposed algorithm |
- 1:
When ith round begins: - 2:
if then - 3:
Go to the third phase - 4:
end if - 5:
- 6:
for all node y - 7:
- 8:
When the node x receives a trigger: - 9:
Choose a node y assigned to layer 1 uniformly at random - 10:
Send a coin message to y - 11:
- 12:
When the node y assigned to layer 1 receives a coin message: - 13:
- 14:
if then - 15:
- 16:
Send a coin message to the root node assigned to layer 0 - 17:
end if - 18:
- 19:
When the root node z receives a coin message: - 20:
- 21:
if then - 22:
Compute the total number of triggers received by all the nodes in this round and updates (via a simple broadcast and upcast procedure) - 23:
Go to the next round () - 24:
end if
|
3.3. The Third Phase ()
In the third phase, all the nodes in the system send the received trigger information directly to the root node, and the root node updates
accordingly. When the newly updated
becomes zero, the root node raises an alarm and finishes the algorithm. Algorithm 3 shows the third phase of the proposed algorithm.
Algorithm 3: The third phase of the proposed algorithm |
- 1:
When the node x receives a trigger: - 2:
Send a coin message to the root node assigned to layer 0 - 3:
- 4:
When the root node z receives a coin message: - 5:
- 6:
if then - 7:
Raise an alarm and finish the algorithm - 8:
end if
|
4. Analysis
Theorems 1 and 2 show that in the first phase of the proposed algorithm, the probability of not notifying a user even though the total number of received triggers is greater than or equal to w is 0.
Theorem 1. In the first phase of the proposed algorithm (where ), each node sends a coin message to a node uniformly chosen at random among the k nodes assigned to layer 1 whenever it receives triggers from external sources. In this case, regardless of the trigger distribution in each round, at least n coin messages are always sent to the nodes assigned to layer 1 before a total of triggers occur.
Proof. Let us calculate the maximum number of triggers that can occur when
n coin messages are sent to the nodes assigned to layer 1. The maximum number of triggers that each node can receive without generating a coin message is
. Therefore, the maximum number of triggers that can occur when
n coin messages are sent is less than
according to Equation (
1):
□
Theorem 2. In the first phase of the proposed algorithm (where ), each k node assigned to layer 1 sends a coin message to the root node assigned to layer 0 whenever it receives coin messages. In this case, regardless of the trigger distribution in each round, at least k coin messages are always sent to the root node assigned to layer 0 before a total of triggers occur.
Proof. According to the Theorem 1,
k nodes assigned to layer 1 always receive at least
n coin messages before a total of
triggers occur. Let us calculate the maximum number of coin messages received by the nodes assigned to layer 1 when
k coin messages are sent to the root node. The maximum number of coin messages that each node assigned to layer 1 can receive without generating a coin message is
. Therefore, when
k coin messages are sent to the root node, the maximum number of coin messages sent to the nodes assigned to layer 1 is less than
n according to Equation (
2):
□
Theorem 3 shows that in the second phase of the proposed algorithm, the probability of not notifying a user even though the total number of received triggers is greater than or equal to w is 0.
Theorem 3. In the second phase of the proposed algorithm (where ), each node sends a coin message to a node uniformly chosen at random among the k nodes assigned to layer 1 whenever it receives a trigger from external sources. In addition, each k node assigned to layer 1 sends a coin message to the root node assigned to layer 0 whenever it receives coin messages. In this case, regardless of the trigger distribution in each round, at least k coin messages are always sent to the root node assigned to layer 0 before a total of triggers occur.
Proof. Since each node sends a coin message to a node assigned to layer 1 whenever it receives a trigger, when a total of
triggers occur, the
k nodes assigned to layer 1 also receive
coin messages. Let us calculate the maximum number of coin messages received by the nodes assigned to layer 1 when
k coin messages are sent to the root node. The maximum number of coin messages that each node assigned to layer 1 can receive without generating a coin message is
. Therefore, when
k coin messages are sent to the root node, the maximum number of coin messages sent to the nodes assigned to layer 1 is less than
according to Equation (
3):
□
From Theorems 1–3, we can obtain the following result.
Theorem 4. In the proposed algorithm, the probability of not notifying a user even though the total number of received triggers is greater than or equal to w is 0.
5. Experimental Results
In this section, we compare the simulation results of the proposed algorithm with those of previous works. Among the previous exact DTC algorithms,
CoinRand [
2] and
TreeFill [
3], which show the best performance in terms of message complexity and MaxRcv are chosen for comparison. The source code for the simulation is available online [
20]. The simulation code is written in Python. It is assumed that triggers are received uniformly at random among all the nodes in the system.
Table 2 shows the parameters for the simulation. For each number of triggers and nodes, the simulation is repeated 10 times and the average is used for comparison.
Figure 2 shows the message complexity of
CoinRand,
TreeFill, and the proposed algorithm. As shown in the figure, the proposed algorithm has more efficient message complexity than
CoinRand and
TreeFill, except when
w = 10,000 and
. Since the DTC problem can be easily solved when the number of triggers is not significantly larger than the number of nodes, the parameters
w = 10,000 and
need not be taken seriously. When the number of triggers is 1,000,000
and the number of nodes is
,
,
,
, and
, the message complexity of
CoinRand is 2.04 times, 2.16 times, 1.98 times, 1.85 times, and 1.60 times larger than that of the proposed algorithm. Furthermore, the message complexity of
TreeFill is 1.43 times, 1.67 times, 1.56 times, 1.54 times, and 1.48 times larger than that of the proposed algorithm.
Figure 3 shows MaxRcv of
CoinRand,
TreeFill, and the proposed algorithm. As shown in the figure, the proposed algorithm has more efficient MaxRcv than
CoinRand and
TreeFill when the number of nodes is 16, 64, and 256. When the number of nodes is 4096,
CoinRand is more efficient than the proposed algorithm. This is because, as the number of nodes increases, the degree of the root node and the nodes assigned to layer 1 increases as well (by
), which increases the MaxRcv of the proposed algorithm. When the number of triggers is 1,000,000
and the number of nodes is
,
,
,
, and
, MaxRcv of
CoinRand is 1.97 times, 1.88 times, 1.68 times, 1.21 times, and 0.71 times larger than that of the proposed algorithm. Furthermore, MaxRcv of
TreeFill is 1.44 times, 1.77 times, 2.17 times, 2.62 times, and 2.69 times larger than that of the proposed algorithm.
Figure 4 shows the number of rounds of
CoinRand,
TreeFill, and the proposed algorithm. The number of rounds of the proposed algorithm is significantly smaller than that of
CoinRand, regardless of the number of nodes and triggers. When the number of triggers is 1,000,000
and the number of nodes is
,
,
,
, and
, the number of rounds of
CoinRand is 1.83 times, 1.93 times, 1.83 times, 1.77 times, and 1.74 times larger than that of the proposed algorithm. However, the number of rounds of the proposed algorithm is significantly larger than that of
TreeFill, regardless of the number of nodes and triggers. When the number of triggers is 1,000,000
and the number of nodes is
,
,
,
, and
, the number of rounds of
TreeFill is 0.73 times, 0.74 times, 0.63 times, 0.59 times, and 0.54 times larger than that of the proposed algorithm.