## 4 The Proposed QoS-Aware Routing
### Delay Control  
This unit concerns the routing strategy for on-time delivery of time critical emergency packets. The delay-guaranteed service defines the maximum allowable latency, bounded by the lifetime of a packet (\(t_{life}\)), required by the application. The total latency is experienced by a packet to traverse the network nodes from the source to the destination. At the network layer, the end-to-end packet latency is the sum of the processing delay, the transmission delay, the queuing delay, and the propagation delay. The queuing delay contributes most significantly to the total latency followed by the transmission delay; the other delays are negligible. The CP and DP packets should travel through the next-hop nodes that provide with higher speeds so that the delay-guaranteed service is maintained. Our delay control algorithm is presented in Algorithm 2 that works as follows. Each node \(i\) first computes the required velocity of a packet, \(v_{req}(s)=\frac{dist(i,s)}{t_{life}[packet.type]}\), toward any sink \(s\in\mathcal{S}\) based on its distance from the sink, \(dist(i,s)\), and the remaining lifetime of the packet, \(t_{life}[packet.type]\). As a packet travels, intermediate nodes update the packet's remaining lifetime as follows, \(t_{life}=t_{life}-t_{elapsed}\), where \(t_{elapsed}\) is the elapsed time of the packet at an intermediate node. We measure the _elapsed time_ at each node \(i\) and piggyback it to the packet so that the following node \(j\) can determine the remaining time to deadline without using a globally synchronized clock. For this, when a node \(i\) receives the last bit of a packet, its MAC layer tags \(t_{arrival}\) to the packet. This packet is processed by the network layer and forwarded to the chosen next-hop node \(j\) via the MAC layer. Note that the MAC layer of \(i\) requires some time to capture the channel using an RTS/CTS handshake and may transmit the packet several times until receiving ACK from \(j\). For \(i\) to piggyback the accurate elapsed time, the MAC layer updates the field of elapsed time \(t_{elapsed}\) just before it actually transmits the packet to the physical link as follows, \(t_{elapsed}=t_{departure}+t_{transDelay}-t_{arrival}\), where \(t_{departure}\) is the time at which node \(i\) transmits the first bit of the packet to the physical link and \(t_{transDelay}\) is the transmission delay of the packet which can be computed using the transmission rate and packet length. Thus, once node \(j\) successfully receives the packet, the packet contains the correct measurement of the elapsed time at node \(i\) and computes the remaining lifetime of the packet. After that the node \(i\) calculates the velocities offered by candidate next-hop nodes \(j\) toward a sink \(s\in\mathcal{S}\), \(v_{j}(s)\), by taking into account the packet's waiting time at the queue of node \(i\), \(\hat{d}^{i}_{q}[packet.type]\), the estimated packet transmission delay of node \(i\), \(\hat{d}^{i}_{tr}\), and the packet's waiting time at the candidate next-hop node \(j\), \(\hat{d}^{j}_{q}[packet.type]\) (see instruction 4). The consideration of queuing delay at a candidate next-hop node is very important for localized and delay-constrained routing because it indicates the traffic forwarding efficiency of the node. Nodes in the congested (or high traffic) area may have higher queuing and transmission delays, and thus their offered velocities will be lower. Hence, they will not be able to meet the required velocity level of the CP or DP data packets. For all sinks, after computing the velocities of all candidate nodes, the algorithm then identifies the set of next-hop nodes \(NH_{d}\) that are supposed to meet the required delay deadline (see instruction 6). Note here that there could be several non-overlapping paths from a source to the destination(s) even though they may not be the shortest paths. A non-shortest path is acceptable as long as it can deliver a packet within its end-to-end delay deadline.