## 3 Methodology
### Split Hop Penalty for Unidirectional Links  
All wireless links are unidirectional as opposed to Ethernet connections; although it is highly dependent on the hardware of the wireless interface, it causes the algorithm of the hop penalty to be doubled or implemented twice. This duplication of the hop penalty on the incoming and outgoing packets increases the hop penalty's pre-configured value to twice the size and causes the \(TQ\) metric to decrease to low values, resulting in severely affected multi-hop transmission. The problem is also present for multi-channel and multi-antenna multiple input/multiple output (MIMO) systems as the data link layer for all the antennas is the same and a packet is processed twice when entering layer 2 from the physical layer and when it is being forwarded to the physical layer of the OSI model. The default implementation of BATMAN IV suffers from performance issues caused by the high hop penalty values, which have twice the effect and cause the metric to function  
Figure 5: Impact of hop penalty on transmission quality metric. as a simple hop-count metric. To solve the above problem, several different formations of a split hop penalty were tested to differentiate the links that cause this problem from those interfaces in which this problem does not exist. The tests were conducted on a hit-and-trial basis rather than analytically derived for multi-hop communication. The scenario was chosen to be diverse enough so that the topology supports more than one path towards the destination in an indoor scenario. The basic idea was to use a different hop-penalty value to compute the overall \(TQ\) such that the effect caused by the duplication of the hop penalty can be dismissed. This is achieved by dividing the hop penalty configured value by 2, as it will be implemented on a unidirectional interface exactly two times; therefore, the actual value set by the user will be accommodated on the \(TQ\) metric only once. The new penalty is similar or symmetrical to the original one but only uses half of the HP value. If the interface chosen is a wired interface, the hop penalty value is implemented as defined by the user with no change. Therefore, \(TQ_{path}\) can be incorporated with the newly developed hop penalty through the below equation:  
\[TQ_{HP}= \begin{cases}TQ_{local}\times\frac{TQ_{\max}-\frac{HP}{2}}{TQ_{\max}} &\text{for uni-directional links}\\ TQ_{local}\times\frac{TQ_{\max}-HP}{TQ_{\max}}&\text{for bi-directional links}\end{cases}  \tag{6}\]  
The path metric presented in (6) will be used after the \(TQ_{path}\) is calculated with its own metric according to (3) and before the transmission of \(TQ_{path}\) into the forwarding OGM. This would prevent any deduction that may happen twice for the hop penalty and cause the link cost to be of better quality as compared to the original. It is important to notice that if a node has multiple interfaces, then each node will calculate individual hop penalties for each physical interface as presented in Figure 6.  
The algorithm of the code that was inserted to modify the behavior exhibited by the BATMAN nodes is presented in Algorithm 1. ```
1. Input: HP, \(TQ_{path}\)
2. Output: \(TQ_{path}\)
3. Function split_hop_penalty (HP, \(TQ_{path}\))
4. For all but interfaces
5. For all bind interfaces
6. If the interface is uni-directional then
7. \(TQ_{HP}=TQ_{local}\times\frac{TQ_{\max}-\frac{HP}{2}}{TQ_{\max}}\)
8. Else
9. \(TQ_{HP}=TQ_{local}\times\frac{TQ_{\max}-HP}{TQ_{\max}}\)
10. End If
11. End for
12. End for
13. Return \(TQ_{path}\)
```  
**Algorithm 1** Split hop penalty for batman-adv version iv  
The algorithm takes the HP value and \(TQ_{path}\) value as input to the function. The \(TQ_{path}\) value is taken after it is calculated using (3) and before the inclusion of \(TQ_{path}\) in OGM that is to be sent out to the wireless interface through its own interface \(bat0\). The algorithm checks the type of interface and applies the appropriate hop penalty to the \(TQ_{path}\) metric.