# Packet-Forwarding Algorithm in DTN Based on the Pheromone of Destination Node
## 3 The Model of Pheromone and Community
### Community Model Based on Pheromone
#### 3.3.1 Detailed Description of Community Construction Algorithm  
**Definition 2**. : _(Core node): The community of node \(v_{0}\), which consists of node \(v_{0}\) and nodes that hold the pheromone of \(v_{0}\), is denoted by \(C_{0}\). Then, we define \(v_{0}\) as the core node of \(C_{0}\)._  
**Definition 3**. : _(Neighbor set): The neighbor set of node \(n_{0}\), which is denoted by \(H_{0}\), is the set of nodes that can communicate directly with \(n_{0}\), and \(H_{i}\) represents the neighbor set of node \(n_{i}\)._  
We suppose that the function Compute Pheromone(\(n_{0},n_{\mathrm{i}}\)) is used to compute the pheromone of \(n_{0}\) that is held by \(n_{\mathrm{i}}\). Sleep(\(T\)) is a timer with a time length of \(T\), and the community construction algorithm of \(n_{0}\) is as follows:  
Input: \(n_{0}\) and \(H_{0}\). Output: \(n_{0}\) and sets of nodes that hold the pheromone of \(n_{0}\). ```
1:while \(n_{\mathrm{i}}\) in \(H_{0}\) do
2:\(P_{0,i}=\mathrm{ComputePheromone}(n_{0},n_{\mathrm{i}})\)
3: call SpreadPheromone(\(n_{\mathrm{i}},H_{\mathrm{i}},P_{0,\mathrm{i}}\cdot\omega\))
4:end while
5:Sleep(\(T\))
6:Procedure SpreadPheromone(\(n_{\mathrm{x}},H_{\mathrm{x}},P_{0,\mathrm{x}}\cdot\omega\))
7:if \(P_{0,\mathrm{x}}\cdot\omega\leq P_{\mathrm{min}}\) then
8:return
9:while \(n_{\mathrm{j}}\) in \(H_{\mathrm{x}}\) do
10:\(P_{\mathrm{new}}=P_{0,\mathrm{x}}\cdot\omega\)
11:\(P_{\mathrm{old}}=P_{0,\mathrm{j}}\)
12:if \(P_{\mathrm{old}}\leq 0\) then
13:\(P_{0,\mathrm{j}}=P_{\mathrm{new}}\)
14:elseif \(P_{\mathrm{new}}>P_{\mathrm{old}}\) then
15:\(P_{0,\mathrm{j}}=P_{\mathrm{new}}\)
16: call SpreadPheromone(\(n_{\mathrm{j}},H_{\mathrm{j}},P_{0,\mathrm{j}}\cdot\omega\))
17:else
18:drop(\(P_{\mathrm{new}}\))
19:endif if
20:end while
21:end SpreadPheromone

Figure 4: Community based on the pheromone of \(v_{0}\). #### 3.3.2 Computational Issues

The computational complexity is low and, compared to the improved packet forwarding efficiency, the cost of community construction is acceptable. 1. Complexity: Due to just the node in the communication coverage region of other nodes, it should be able to compute the corresponding node pheromone. Hence, the number of computations required for each node is on the order of \(\text{O}\left(\text{Num}\left(H_{i}\right)\right)\) at each time slot. Num \(\left(H_{i}\right)\) means the number of nodes in \(H_{i}\), and \(H_{i}\) represents the neighbor set of node \(n_{i}\). 2. Construction Cost: In the process of community construction, packets that contain the pheromone of the core node need to be transmitted; the number of these packets can be viewed as the cost of community construction. Given C, denoting the construction cost of \(n_{0}\), it can be calculated as follows:

\[C=Num(H_{0})+\sum_{i=1}^{4}Num\left(S_{i}\right), \tag{14}\]

\[S_{i}=\sum_{j=1}^{Num\left(S_{i-1}\right)}Num\left(H_{j}^{\prime}\right),\ \ S_{0}=\text{H}_{0} \tag{15}\]

\[H_{j}^{\prime}=\left\{v_{k}\ \middle|\ v_{k}\in H_{j},\ \ P_{0,k}>0,\ P_{0,j} \cdot\omega>P_{0,k}\right\}, \tag{16}\]

According to Equations (14)-(16), \(C\) becomes large with the increase in the number of community members. The reduction of \(C\) is left as the next work. ### Core Node Agent

As indicated in the pheromone computing and spreading model, when one node exists in the same position for a certain period, a community around the core node will be constructed, as shown in Figure 5a. However, if the core node moves to a new location, then the member of the community constructed before the core node moves may still preserve the pheromone of the core node at that moment. Therefore, if these nodes forward a packet along the direction where the pheromone is stronger, then the packet may not reach the destination node successfully. To forward a packet to the new location where the core node has moved, we use the agent node to mark the mobile trajectory of the core node, as shown in Figure 5b.