## 4 IoT-Enabled Traffic-Aware Telemedicine Architecture (ITTA)
### Wearable-Device-based Monitoring Algorithm for Edge Device (WDMA-Edge)
\[V\big{[}A_{ij}I_{ij}C_{j}\big{]}=A_{ij}C_{j} \tag{1}\]
```
Input: data, route, link Output: packet \(data\gets get-data-from-IM^{2}E-node\)  hospital selection function(data): \(packet\gets packetsizdata(data)\) if network is not available then wait else transmit packet(packet) endif check qos parameters() \(route\gets selectroute(r1,r2,\cdots,rm)\) \(link\gets selectlink(l1,l2,\cdots,ln)\) if v2i is not available then if v2v is not available then go back to \(link\gets selectlink(l1,l2,\cdots,ln)\) else \(protocol\gets chooseroutingprotocol(route)\)  transmit packet(packet) endif endif if destination reached then Stop else go back to \(link\gets selectlink(l1,l2,\cdots,ln)\) endif
```

**Algorithm 2** Adaptive QoS-Aware Packet Transmission for fog (AQPT-Fog)

Once the packet is analyzed, the signal-to-noise interference ratio is measured using the formula in Equation (2), where \(N\) denotes the maximum nodes in the topology of the selected path. \(SIR_{i}\) is directly proportional to the signal strength and inversely proportional to the total data loss. \[SIR_{i}=\frac{C_{i}A_{ii}}{\sum_{j\
eq i}^{N}C_{j}A_{ij}+n_{i}} \tag{2}\]

The increase in the probability of the data rate \(P\) is shown in Equation (3). The system throughput \(T\) always relies on the signal strength of each instance and the noise measure in each path. The noise measure is one of the factors deciding the data path that needs to be taken or not. \(S\) denotes the path selection parameter, which assists in finalizing which data path needs to be adopted. Equation (5) denotes the total path metric with respect to the probability of that particular path. The fading of that path is given in Equation (6). The mean signal-to-interference and noise ratio (MSINR) is the accumulated path jitter that is generated in the ad hoc network and needs to be reduced. \[T_{i}=P(SIR_{i}\leq SIR_{th})=P\bigg{(}A_{ij}I_{ij}C_{j}\leq SIR_{th}\sum_{k \
eq i}A_{ik}I_{ik}C_{k}\bigg{)} \tag{3}\]\[T_{i} =1-\prod_{k\
eq i}\frac{1}{1+\frac{SIR_{k}A_{k}A_{k}C_{k}}{A_{i}C_{i}}} \tag{4}\] \[S =1+\frac{-1.5}{ln(5 BERT)}SIR\] (5) \[F_{i} =(1/T)log_{2}\prod_{i}(1+MSIR_{i}) \tag{6}\]

To ensure QoS during data transmission of vital signals, we have proposed an algorithm called Adaptive QoS-aware Packet Transmission for fog (AQPT-Fog), which, as shown in Algorithm 2, has packet formation and packet transmission modules. The packet formation module includes retrieval of aggregated data from the the IM\({}^{2}\)E node followed by packetization of the aggregated data. The hospital selection function runs a resource-aware algorithm and retrieves an appropriate hospital destination. For AQPT-Fog we are assuming that the destination hospital is received as output from this module. After this, the packet formation takes place, following the reception of both data from the IM\({}^{2}\)E node and the hospital selection function. Once a packet is formed, AQPT-Fog checks for network availability to transmit packets. After packet transmission from the IM\({}^{2}\)E node, adaptive QoS-aware packet traversal ensues. First, the QoS parameters based on Table 3 are checked, followed by route selection from 'n' routes and subsequent selection of links based on the road divisions (urban, suburban, or rural). The algorithm first checks for the availability of the vehicle-to-infrastructure (V2I) mode of transmission. If it is not available, then it checks for vehicle-to-vehicle (V2V) mode. After deciding for V2I or V2V, it selects an appropriate routing protocol from an existing pool, thereby transmitting through the selected route until it reaches the destination hospital. QoS based on the network availability and dynamic link selection is thus ensured.