# Adaptive Method for Packet Loss Types in IoT: An Naive Bayes Distinguisher
## 5 Numerical Analysis  
To comprehensively analyze and verify the effectiveness of the NB-TCP algorithm, we use simulations with NS2 to build the system model. Figure 1 shows the model used. There have four TCP connection from servers to wireless sensors. The four connections share the bottleneck link between router and IoT gateway which have a bandwidth of 2 Mbps. Wireless links between the gateway and sensors have wireless error rate(WER) which take the values from 0.01 to 0.05. The simulation parameters show as Table 1 and each experiment lasts 160 seconds. TCP senders are fed with FTP traffic. The training sample obtained by data acquisition and the sample format specified in Section 3. We conduct the experiment with NB-TCP, TCP-Casablanca [16] and NewReno [17]. The result showed here for the throughput and accuracy are the average over the 20 runs same experiment. Figure 3 shows the average throughput versus WER for the three methods. We can see that NB-TCP improves the throughput performance and is superior to comparison methods. With the increase of WER, more packets are lost due to bad wireless link conditions, the advantage of NB-TCP is more obvious. When the WER is 0.01, the performance of NB-TCP is nearly 35% higher than TCP-Casablanca. Compared to NewReno, the average throughput of NB-TCP is double. When the WER is 0.05, the performance is approximately 180% higher than the comparison algorithm. This is because the packet loss type is correctly classified, so the unnecessary congestion control is avoid. Figure 4 shows the accuracy versus WER for the three methods. It can be seen that NB-TCP has a high accuracy, and is almost higher than the comparison methods with the increase of WER. When the WER is 0.02, the rate of correct classification packet loss types can reach up to 95%, and the overall probability remains above 85%. The accuracy of TCP-Casablanca and NewReno methods is less than 50% at a WER of 0.05. This shows that NB-TCP improves the classification accuracy. Comparing Figures 3 and 4, the performance of NB-TCP is better with the higher WER. When multiple TCP flows compete for bottleneck links, allocate bandwidth fairly is very important for each TCP flow. Fairness of network resource allocation is an important index to evaluate TCP performance. Here we measure fairness using the fairness index, which can be given by [32]  
\[F_{index}=\frac{\left(\sum_{i=1}^{s}f_{i}\right)^{2}}{s(\sum_{i=1}^{s}f_{i}^{2} )}, \tag{10}\]  
where \(s\) is the number of flows and \(f_{i}\) is the average throughput. When \(F_{index}\) is closer to 1, the fairness is the best and represents the absolute fair distribution of network resources. When the value is \(1/s\), it indicates that the network resource allocation is seriously unfair, it is monopolized by one flow. This experiment uses 10 flows to calculate the fairness index of three methods, respectively, and simultaneously send data to count the average throughput of each flow. Figure 5 shows the \begin{table}
\begin{tabular}{l c} \hline \hline
**Parameters** & **Values** \\ \hline Link bandwidth & 10 Mbps \\ Link delay & 1 ms \\ Bottleneck link bandwidth & 2 Mbps \\ Bottleneck link delay & 10 ms \\ Packet size & 1000 Bytes \\ Wireless error rate & 0.01–0.05 \\ Router cache & 62 \\ Number of samples & 1000 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Simulation Parameters. fairness index of NB-TCP and its comparison methods under different WER. It can be seen that the fairness index of all three algorithms exceeded 0.96, among which NB-TCP fairness index is higher, close to 1, indicating good fairness. Figure 4: Accuracy versus WER. Figure 3: Average throughput versus WER. The friendliness is reflected in the degree to which different TCP protocols, which share the bottleneck link, interact with each other. To prove that NB-TCP is friendly to other methods and will not preempt shared resources unduly, the experiment uses two groups of senders and receivers to establish two flows.