# A New Linear Model for the Calculation of Routing Metrics in 802.11s Using ns-3 and RStudio
## 2 Methodology
### Data Collection in ns-3  
To begin, the network simulator ns-3 was employed to write and/or modify four scripts. The first one is a modification of _airtime-metric.cc_, which, in its original version, allows for obtaining the ALM metric, and when modified, results in additional parameters for the protocol performance.  
The script _mesh-ping.cc_ was developed based on the original mesh.cc script. The objective was to create a metric report and the parameters for its calculation every 100 ms to evaluate the network performance frequently. This script works by default with UDP in layer 4.  
Similarly, the script _mesh-tcp.cc_, which shares identical characteristics to _mesh-ping.cc_, was developed with the TCP in layer 4.  
Finally, the script _wifi-phy-header.cc_ was modified to work with network packets with an extension up to 8192 bytes, since the original script only allows 2048 bytes.  
To present the network performance information, particularly unicasts and broadcast in transmission and reception, the following scripts were modified: _peer-management-protocol.cc_, _peer-management-protocol.mac.cc_, _peer-link.cc_, _mesh-point-device.cc_, _mesh-twifi-interface.cc_, _hwnp-protocol.cc_, _mesh-twifi-interface.cc_, _mesh-helper.cc_, and _hwnp-protocol-mac.cc_.  
Once the changes took place, it was possible to set our WMN simulator with the parameters shown below.  
Figure 4 presents the general design for the mesh network used in ns-3 for the simulations.  
Figure 4: WMN 802.11s–HWMP in ns-3.  
The simulation was run for 2.5 s with all the possible interactions among the simulation parameters, as shown in Table 1; these simulations produced the test database that was used to work with RStudio.  
The generated database was:  
See the variable descriptions below:  
* FAILAVG: ef, defined in standard IEEE 802.11s
* TXDURATION: relation between Bt/r. defined in standard IEEE 802.11s
* METRIC: ALM metric, defined in standard IEEE 802.11s  
The previous three variables were taken from the IEEE 802.11s standard draft and it was useful to obtain data from the original model.  
The next six variables were obtained in the mesh network setting, as well as from the IEEE 802.11b y 802.11s standards.  
* L4: protocol in layer 4 (they could be UDP or TCP)
* M_PACKET: packet size
- INTERFACES: number of channels, for IEEE 802.11b 3 channels available: 1, 6 y 11
* COMP: inverse complement to 1 of FAILAVG  
\[COMP=\frac{1}{1-FAILAVG} \tag{3}\]
* PDF: The packet delivery function can be defined as the ratio of the number of data packets delivered to the total number of packets sent. This illustrates the efficiency of the data delivered to the destination.  
\[PDF=\frac{\sum Number\ of\ packets\ received}{\sum Number\ of\ packets\ sent} \tag{4}\]  
A greater value of the packet delivery ratio indicates a better performance of the protocol [3].  
* TXX is YES when PDF > 0.6 TXX is NO when PDF < 0.6  
\begin{table}
\begin{tabular}{c c} \hline \hline
**Parameter** & **Value** \\ \hline Protocol L4 & UDP TCP \\ \hline Step size & 15 \\  & 30 \\  & 50 \\ \hline Mesh size & 3 \(\times\) 3 \\  & 4 \(\times\) 4 \\  & 5 \(\times\) 5 \\ \hline Packet size & 1024 Bytes \\  & 2048 Bytes \\  & 4096 Bytes \\  & 8192 Bytes \\ \hline \hline \end{tabular}
\end{table}
Table 1: Simulation parameters.  
This last variable is qualitative since it shows the network performance based on the criterion about the PDF which should be higher than 60%. This part is critical because at the end of the process, it will be used as a reference to analyze the results.