# An Opportunistic Network Routing Algorithm Based on Cosine Similarity of Data Packets between Nodes
## 4 Experiments and Results  
In view of the cosSim routing algorithm proposed in the above section, this paper will use the OppNet simulation platform ONE to compare it with the traditional routing algorithms--the Sprayand Wait (S&W) algorithm and the Epidemic algorithm. This paper will use the three indicators of delivery ratio, delivery delay, and routing overhead to compare the above three algorithms. The simulation scenario settings are shown in Table 2.  
The algorithm parameters as shown in Table 3.  
Through multiple simulation experiments, the upper and lower thresholds are selected based on the delivery ratio and routing overhead as reference values. The overall performance of the cosSim algorithm is relatively good when the lower threshold \(\alpha\) = 0.29 and the upper threshold \(\beta\) = 0.81. As shown in (a) of Figure 6, when the lower threshold \(\alpha\) is equal to 0.29, the delivery ratio remains at a relatively high level, while the routing overhead of the network shows a significant decline when the lower threshold is greater than 0.29. As shown in (b) of Figure 6, when the upper threshold \(\beta\) is greater than 0.81, the growth trend of the delivery ratio has been very slow, while the routing overhead is increasing, so the upper threshold is determined to be 0.81. When the access control number K is 6 or 7, the comparison times between nodes are not significantly increased, and the execution time of the algorithm can be effectively reduced. The following are analysis and comparison of the cosSim algorithm, S&W algorithm, and Epidemic algorithm in different situations. Figure 7 shows the delivery ratio of three routing algorithms with different node caches. According to Figure 7, the size of the node cache has the most significant effect on the delivery \begin{table}
\begin{tabular}{c c} \hline \hline
**Parameter** & **Value** \\ \hline Simulated time & 20 h \\ Simulated area & 5000 m \(\times\) 4000 m \\ Velocity of a node & 2\(\sim\)10 (m/s) \\ Rate of node transmission & 300 kb/s \\ Maximum transmission range & 10 m \\ Communication mode & Bluetooth \\ Node cache & 10 MB \\ Size of data packet & 20 kb\(\sim\)500 kb \\ Lifetime of data packet & 2 h \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Simulation environment. Figure 6: (a) Lower Threshold and (b) Upper Threshold. ratio of the cosSim algorithm. In the case where the node cache is small, the delivery ratio of the three routing algorithms is extremely low. With the increase of node caches, the delivery ratio of the three algorithms show different degrees of growth. The S&W and Epidemic algorithms show a slow growth trend. When the node cache is 50 MB, the delivery ratio of the S&W algorithm and the Epidemic algorithm are maintained at about 60% and 50%, respectively. The growth rate of delivery ratio of the cosSim algorithm is relatively fast. When the node cache is 25 MB, the delivery ratio of the cosSim algorithm has reached the highest level of the S&W algorithm and the Epidemic algorithm. Figure 8 shows the effect of the number of nodes on the delivery ratio of the three algorithms, and the overall trend is similar to the node cache. The difference is that the delivery ratio of the Epidemic algorithm is always higher than the S&W algorithm when the node cache is getting larger. When the number of nodes is increasing, the delivery ratio of the S&W algorithm is always higher than the Epidemic algorithm. This shows that the Epidemic algorithm is more dependent on the node's cache size, while the S&W algorithm is more dependent on the number of nodes in the network. When the number of nodes in the network reaches 600, the delivery ratio of the Epidemic algorithm and the S&W algorithm is 45% and 55% respectively, and the delivery ratio of the cosSim algorithm is as high as 80%. Figure 9 shows the performance of the three algorithms in terms of delivery delay under different number of nodes.