## 3 Adaptive Real-Time Routing Protocol
### Adaptive Traffic Handling  
An adaptive routing algorithm ensures the selection of a path with shorter end-to-end delay than the previous path according to both \(DBP_{i}\) in \(S_{i}\) and \(DBP_{ObjID}\) in \(T_{ObjID}\). However, if no other path is available, that is, \(P_{i}^{1}\) is set to the current path, the adaptive traffic handling algorithm executes. The algorithm aims to reduce end-to-end delay by either redefining the \((m_{i},k_{i})\)-firm model dynamically or by reducing the packet size adaptively. Without regard to adaptive handling, the application requirement remains the same. Adaptive traffic handing consists of two major functions, multiple sets for \((m\),\(k)\)-firm stream and dynamic payload adjustment. First, \(S_{i}\) is redefined as \(\{node_{i},m_{i},k_{i},D_{i},DBP_{i}\}\) where \((m_{i},k_{i})\in\{m_{i}^{1},k_{i}^{1}\},\ldots(m_{i}^{s},k_{i}^{s})\) as shown in Algorithm 2. By redefining the \((m\),\(k)\)-firm stream as sets, a \((m\),\(k)\)-firm stream is composed with loose \((m\),\(k)\)-firm which conforming the initial requirement. Because this procedure is performed whenever no more path is available in adaptive routing algorithm, it aims to take loose \((m\),\(k)\)-firm requirement. In \(S_{i}\), the lower index has, the looser \((m\),\(k)\)-firm requirement set. In order to maintain consistency for requirement, each element in \(S_{i}\) should keep the condition of Equations (1) and (2). One of the elements in the set \((m_{i},k_{i})\) is selected by comparing the DBP value at consecutive moments in time, i.e., at \(t\) and \(t+1\). The selection procedure is dependent on the DBP value. ```
1:\(DBPT_{i}^{t}\leftarrow\) DBP value of node \(i\) at time \(t\)
2:\(e\leftarrow\) Current index in \(\{m_{i}^{1},k_{i}^{1}\},\ldots(m_{i}^{s},k_{i}^{s})\)\(\triangleright\) The larger index means the looser \((m\),\(k)\)-firm requirement
3:\(k\leftarrow\) Parameter to reduce packet size
4:if\(DBPT_{i}^{t}\) < 0 then
5:if\(DBPT_{i}^{t+1}\) < 0 then\(\triangleright\) if two consecutive DBP values are negative
6:if\(e\)! = 5 then\(\triangleright\) If any available traffic set for \((m\),\(k)\) is available
7:\((m_{i},k_{i})=(m_{i+1},k_{i+1})\)\(\triangleright\) Change traffic set for next loose \((m\),\(k)\)
8:else\(\triangleright\) If any available traffic set for \((m\),\(k)\) is not available
9:\((m_{i},k_{i})=(m_{s},k_{s})\)\(\triangleright\) Set the traffic as the least \((m\),\(k)\) requirement
10:\(payload\_size\gets payload\_size\times\frac{1}{k}\)\(\triangleright\) Traffic shaping by reducing packet size
11:\(\text{Payload\_Size\_Changed ==\text{TURE}}\)\(\triangleright\) Set the flag
12:endif
13:else\(\triangleright\) if only one DBP values are negative
14:\((m_{i},k_{i})=(m_{i-1},k_{i-1})\)\(\triangleright\) Set the traffic as the next strict \((m\),\(k)\) requirement
15:endif
16:else\(\triangleright\) If the second DBP value become postive
17:if\(DBPT_{i}^{t+1}\) > 0 then
18:if\(e\)== \(s\) && Packet_Size_Changed == TURE then\(\triangleright\) If the current set index is the largest value
19:\(payload\_size\gets payload\_size\times k\)\(\triangleright\) Restore the packet size
20:endif
21:else
22:\((m_{i},k_{i})=(m_{i-1},k_{i-1})\)\(\triangleright\) Set the traffic as the next strict \((m\),\(k)\) requirement
23:endif
24:endif
```  
**Algorithm 2** Adaptive Traffic Handling at node \(i\). If the two values are negative as shown in lines 3 and 4, the current requirements of \((m_{i},k_{i})\) are relaxed to \((m_{i+1},k_{i+1})\), where the current index does not reach the maximum value. This is to allow more missed packets in \(S_{i}\) by loosing \((m\),\(k)\)-firm requirement. This kind of adjustmentis available when any subset is available. Otherwise, if the current index is the maximum, another approach to reduce the payload size is applied. * If the second DBP value becomes positive, the index for \((m_{i},k_{i})\) increases to make current \((m,k)\)-firm requirement strict because packet delay is not passed beyond deadline.