# 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
These nodes will be marked as the agent entering the communication radius of the moving core node and can receive the pheromone of the core node before moving. Similar to other nodes, the pheromone of the agent node will decrease with time. Thus, the agent node will close the forwarding service after the old community disappears. In Figure 5, the core node \(v_{0}\) moves from the old location to the new location, and the agent node is marked while moving. Packets can be successfully forwarded to the destination node \(v_{0}\) by the agent node after they are first forwarded to the shaded area. ## 4 Packet-Forwarding Algorithm Based on Pheromone (FABP)

The FABP proposed in this study is divided into two stages and, with the data forwarding process, the role of the stranger gradually reduced, while the role of community partners gradually increased [8]; therefore, the packet will be forwarded to the furthest node until the pheromone of the destination node is found during the first stage. Figure 5: Packet forwarded by the agent node. As shown in Figure 6, \(v_{0}\) is at the edge of the community of \(v_{3}\), but it is not the edge node of \(v_{1}\) and \(v_{2}\). Hence, \(v_{0}\) will select \(v_{3}\) as the furthest node. On the basis of the pheromone-spreading model, the edge node will receive less pheromone than the node in the community center. Accordingly, the lowest pheromone in the forwarding table indicates that the core node and the current node have the furthest distance. The pheromone of the destination node can be found among all the core nodes of the relay node until the furthest node is reached. If the pheromone is found, then it will enter the second stage of the packet-forwarding algorithm. Otherwise, it should find and forward the packet to the furthest node continually. During the second stage, if the packet is forwarded into the community, then it will select the node that holds a stronger pheromone as the relay node, according to the algorithm FABP. Given that the pheromone is updated regularly, the algorithm can determine the best path for forwarding the packet to the destination node along with the direction where the pheromone is stronger. ### Detailed Description of FABP

We suppose that \(n_{s}\) is the source node or carrier that holds the forwarded packet to the destination node \(n_{d}\), \(n_{m}\) is the met node of \(n_{s}\), and \(P_{d,s}\) is the pheromone of \(P_{d}\) which held by \(n_{s}\). Therefore, \(P_{d,m}\) means indicates the pheromone of \(P_{d}\) which held by \(n_{m}\). \(n_{s,f}\) is the furthest node of \(n_{s}\), and \(n_{s,r}\) is the relay node in the process of forwarding the packet to the furthest node. The FABP is presented as follows. ```
Input: sets of Packets(\(M\)), \(M=\{\;msg_{1},msg_{2},\ldots,msg_{n}\}\), \(msg_{i}\) is a six-tuple packet entity. Output: sets of packets that are successfully delivered(\(S\)), \(S=\{\;msg_{1},msg_{2},\ldots,msg_{m}\}\). ```
```
1:while \(n_{s}\) not hold \(P_{d,s}\) do
2:\(n_{s,r}=\text{getnextrelaynode}(n_{s})\). 3: forward \(msg_{i}\) to \(n_{s,r}\)
4:if \(n_{s,r}\) hold \(P_{d,s}\) then
5:\(n_{s}=n_{s,r}\)
6: go to 13
7:end if
8: If \(n_{s,r}\) equal \(n_{s,f}\) and \(n_{s,r}\) not hold \(P_{d,s}\) then
9:\(n_{s}=n_{s,r}\)
10: go to 1
11:endif if
12:end while
13:if \(n_{s}\) hold \(P_{d,s}\) and \(n_{m}\) hold \(P_{d,m}\) and \(P_{d,s}<P_{d,m}\) then
14: forward \(msg_{i}\) to \(n_{m}\)
15:endif
```

**Algorithm 2** FABP. Figure 6: Schematic diagram for the furthest node. ### Computational Issues

Complexity: In both stages of FABP, every node must check all of the items of the pheromone table to determine the next forwarding node. Hence, the time complexity for each node is order of \(\text{O}\left(\text{Num}\left(T_{pheromone}\right)\right)\), where \(\text{Num}\left(T_{pheromone}\right)\) represents the number of items in the node pheromone table.