As reviewed in Section 2, a relay as a kind of HFWTRP tokens is required to address temporary link outages. DM is an important factor in relay strategy. Behind DM, an Adjacency Matrix (AM) needs to be formed at first [9]. AM is an N × N matrix for N nodes in network. Each element of AM defines the connectivity between pair of nodes in the algorithm:
AM= [\({a}_{i,j}\)=1 if a link exists between node i and node j, \({a}_{i,j}\)= 0 otherwise]
Moreover, DM elements are:
DM= [\({dist}_{i,j}\)= the minimum distance in hops from node i to node j]
An AM should be established and updated based on the received frames. STANAG emphasizes that node j may put \({a}_{i,j}\) and \({a}_{j,i}\)=1 if an ACK Data link Protocol Data Unit (DPDU) is received from node i. This proves that an ACK connotes that the link is bidirectional. Moreover, node j should be set \({a}_{i,j}\)=1 whenever a DPDU is received from node i. As a result each node can set each element on its row whenever it hears ACK after sending a DPDU to them and can set the related elements in other rows when it hears a DPDU from them. For other elements, we need to sniff the receiving frames on the modem to detect link availability between other nodes. Based on the topology of Fig. 7, the AM can be formed as (1):
\(AM=\left[ {\begin{array}{*{20}{c}} {{a_{AA}}}&{{a_{AB}}}&{{a_{AC}}}&{{a_{AD}}} \\ {{a_{BA}}}&{{a_{BB}}}&{{a_{BC}}}&{{a_{BD}}} \\ {{a_{CA}}}&{{a_{CB}}}&{{a_{CC}}}&{{a_{CD}}} \\ {{a_{DA}}}&{{a_{DB}}}&{{a_{DC}}}&{{a_{DD}}} \end{array}} \right]\) (1)
The main diagonal is set to 1 because each node is connected to itself. Assume that we want to create AM for node A. In this case,\({\text{a}}_{\text{A}\text{A}}\),\({\text{a}}_{\text{B}\text{B}}\) ,\({\text{a}}_{\text{C}\text{C}}\), and \({\text{a}}_{\text{D}\text{D}}\)will be 1. If node A sends a DPDU to node B and it responds to node A with an ACK frame, then \({a}_{AB}\)and \({a}_{BA}\)are set to 1. This concept is identical for \({a}_{AC}\) and\({a}_{AD}\). If node A hears a DPDU from node B, then \({a}_{BA}\) is set to 1. This concept is the same for \({a}_{CA}\) and\({a}_{DA}\). We can sniff our channel to find any DPDUs from other nodes to set other elements as\({a}_{BC}\), \({a}_{CB}\), \({a}_{BD}\),\({a}_{DB}\) ,\({a}_{CD}\) and\({a}_{DC}\). Since there might be no data frame for a while elements of AM will not be updated completely. Thus, both data and MAC token frames are used to update AM elements. This point is so important in updating the AM whenever a node is not responsible for the RTT frame and its connectivity must set to 0. As a result, some time is required to sniff and configure AM in each node. Based on Fig. 6 with a complete link between the nodes A, B, and C and link outage between the nodes C and D, we have AM as (2):
\(A{M_C}=\left[ {\begin{array}{*{20}{c}} 1&1&1&1 \\ 1&1&1&1 \\ 1&1&1&0 \\ 1&1&0&1 \end{array}} \right]\) (2)
If node B can hear from node D but node D cannot send anything to it, the AM in node C can be as (3).
\(A{M_C}=\left[ {\begin{array}{*{20}{c}} 1&1&1&1 \\ 1&1&1&0 \\ 1&1&1&0 \\ 1&1&0&1 \end{array}} \right]\)
(3)
STANAG does not recommend an algorithm to compute DM from AM. However, there are some algorithms including DIJKSTRA, Bellman ford, A search, FloydWarshall. This paper incorporates DIJKSTRA as an algorithm to find the shortest path between the nodes in a graph as a ring. DIJKSTRA is dedicated to positive costs on each connection between the nodes and we replace them by 1 or 0 based on their connectivity, respectively. Therefore, a function is established based on (4) to compute that its input argument is AM and selected node to compute shortest path to others and its output is DM related row.
\(dist[N]=DIJKSTRA(\operatorname{int} \mathop {}\limits^{{}} AM[N \times N])\) (4)
Algorithm 1 demonstrates the DIJKSTRA function. The AM and a number related to each node are first applied and by setting all connections infinity, the shortest path is calculated as the desired output based on graph theory. Each node takes its DM and puts its row in DM payload as Fig. 5 (b). We use onehop relay as Fig. 7to cope with link outage. Node C chooses node A as the Relayer as shown in Fig. 8 (a).
Algorithm 1: DIJKSTRA algorithm to find the shortest path.

Input: Adjacency Matrix (int AM[N][N]),
Source node (int s)
Output: Related Row of Distance Matrix (int DM[N])

1. For each vertex V in Adjacency Matrix:

2. dist[V]:=infinity

3. previous[V]:=undefined

4. dist[S]:=0

5. While Q is not empty:

6. u:=node in Q with smallest path[]

7. remove u from Q

8. For each neighbor V as u:

9. alt:=dist[u] + dist_between(u,V)

10. if alt<dist[V]

11. dist[v]:=alt

12. previous[V]:=u

13. Return previous[]

Based on Algorithm 1, the DM payload based on Fig. 7 can be as (5)
\({DM}_{C}=\left[\begin{array}{cccc}0& 1& 1& 1\\ 1& 0& 1& 2\\ 1& 1& 0& 2\\ 1& 1& 2& 0\end{array}\right]\) (5)
Because each node has “0” step distance to itself, so the main diagonal of DM is set to "0" [9]. Based on this algorithm node C must choose a node which has minimum distance to node D from the last column of matrix (4) [9]. So node A is selected to be Relayer. The onehop relay flowchart as used in this paper is shown in Fig. 8 (b). Node A employs this algorithm to send RTT to node D that is temporarily unreachable. Now consider this situation, where the link between the Relayer and the target node is corrupted as well. In this situation, we must drop out that target from the ring. However, besides the onehop relay, the effect of twohop relay on QoS of the network is also evaluated in this paper. In the twohop relay, the Relayer node has an action as given in Fig. 8 (c) and computes another Relayer that has onehop distance from that target node.
In Fig. 9 (a) node A sends RTT token to node B and as can be seen in Fig. 9 (b), node B is not responsible. Therefore, node A in Fig.10 (a) selects node D as the Relayer. Node D sends RTT token to node B but it is not responsible yet. Fig. 10 (a)(c) show these concepts, respectively.
In this situation, based on Fig. 10 (c), node D decides to try another hop to reach node B. Therefore, it selects node C as the secondary Relayer and sends RTT token to node B. Fig. 11 (a) and (b) show these two operations, respectively. This action can increase the delay in the network, but the data frame can be delivered to an unreachable node as much as possible. Hence, throughput can be preserved in HF unreliable channel. This is evaluated by simulations in this study.
3.1 Prevention of Loop Creation
STANAG 5066 in its 3rd edition proposed onehop relay to assist a node to reach its unreachable node. Accordingly, that unreachable node should be deleted from the ring after the operation of the onehop relay [9]. This algorithm can be employed for more than onehop [9]. However, it is assumed that, based on longrange transmission, the nodes in an HF network can reach to each other in onehop. Nonetheless, channel interruptions must be considered in the HF link which can be a temporary event for some time. Consequently, to preserve the throughput and reach an unreachable node, twohop or multihop relay should be used with a bound as a limitation to control relay operation in an attempt to avoid selecting the Relayer as much as possible. Hence, we should see a loop to select a Relayer one after another when an unreachable node is irresponsible. This event can be a challenge for delay in network and also is a pretext for bringing out the nodes from ring. Especially, this point is a challenge for a realtime message transmission request. When a realtime message is not delivered in its suitable time, it will be worthless. This problem is an operational challenge experienced in STANAG. This critical point was observed in our primary simulations and this problem must be solved in the realworld implementation of HF networks. In general header of DPDU of HFWTRP, three unused bits can be found based on the 3rd edition of STANAG 5066 (Annex L) [9]. To control relay performance and avoid creation of a loop in the network for selecting Relayer node after second hop which is our selection and it can be investigated to more hops too, these unused bits are adopted in this study as an algorithm like Time to Live (TTL) in IP header structure. As a result, at first, we set two first bits in terms of maximum hops like\({b}_{1}{b}_{0}=10\) in binary representation (2 in decimal). Based on the proposed method, the relay requester decreases one bit from this field before sending REL token to the first Relayer. When the first Relayer takes the REL token and finds \({b}_{1}{b}_{0}=01\) in its header, it knows that it can use the second hop in relay strategy if it is required. Therefore, it must try to deliver RTT to unreachable node firstly. If it is unsuccessful, it can try another hop after setting\({b}_{1}{b}_{0}=00\). So, the second Relayer knows that its action is the last hop and if the unreachable node is irresponsible, it drops it from TOL and continues normal operation of the ring. This scheme can control the multihop relay strategy and avoid loop creation in Relayer selection by the nodes. By default, the limitation on maximum hops can be 3 in decimal based on two bits of \({b}_{1}{b}_{0}\) or 7 in decimal based on \({{b}_{2}b}_{1}{b}_{0}\). However, more hops are supported by more number of nodes and this selection in an HF network is not suitable. Because by increasing the number of nodes in a network, performance will be decreased [9]. Hence twohop is a reasonable choice in a tactical and real implementation of an HF network.