# Smart Hospitals and IoT Sensors: Why Is QoS Essential Here?
## 3 Materials and Methods  
Our strategy focuses on integrating data from many devices in the hospital settings and providing it in a standard format for applications. Therefore, applications do not need to implement different APIs (Application Programming Interfaces) to acquire data from different devices. They can easily connect to the middleware and request data from different sensors in real time. The strategy consists of placing software units, the Data Gateway instances, close to the devices to extract data and provide QoS services individually. The Middleware Core is the main component that collects the data from each Gateway and provides it to the applications. Therefore, it can collect data from many different locations as long as they have Gateway instances deployed. The Core provides data to applications through a publish-subscribe interface [32]. Applications connect to the Core, requesting data from a specific sensor. The Core supports additional parameters in the requests besides the target \begin{table}
\begin{tabular}{l l l l l} \hline \hline
**Paper Year** &
\begin{tabular}{l} **Real** \\ **Time** \\ \end{tabular} & **QoS Strategy** & **Description** \\ \hline
[24] & 2021 & Routing protocol & Routing algorithm for WBAN health monitoring. \\ \hline
[16] & 2021 &
\begin{tabular}{l} Data prioritization, energy control, packet \\ scheduling protocol and data rate adaptation \\ \end{tabular} & Patient monitoring using WBAN. \\ \hline
[17] & 2021 & ✓ & Data prioritization & OpenFlow traffic shaping in the Fog using SDN for e-health services. \\ \hline
[30] & 2022 & ✓ & Dynamic resource allocation & Private cloud with dynamic resource management for health services. \\ \hline
[31] & 2022 & ✓ & Communication protocol & IoT architecture employing edge and fog computing for health services. \\ \hline \hline \end{tabular}
\end{table} 
Table 1: _Cont._sensor. The applications can provide a desirable limit for jitter and delay. If the application does not provide these limits, the Core assumes default values according to the type of the target sensor. For instance, for image sensors, the default maximum accepted delay is 50 milliseconds (ms), and the jitter is 25 ms. In addition to the architecture, the middleware provides a QoS strategy, called QoS Service Elasticity, to improve performance for applications. The QoS Service Elasticity consists of individual elastic service stacks for each Gateway instance. The Core manages them according to the applications' requirements and the current performance of the middleware. The Core periodically monitors whether the applications' limits are respected or not. Once a limit violation occurs, the Core stacks different QoS services for the sensor devices to address the issue. Therefore, the service stacks are elastic, and the Core changes them when needed. The middleware comprises four different QoS services: (_i_) Data Prioritization; (_ii_) Data Compression; (_iii_) Adapting Frame Rate; and (_iv_) Resource Elasticity. Figure 2 illustrates the middleware model showing the Core in more detail. The Middleware Core is responsible for four main tasks: (_i_) Data Provisioning; (_ii_) Performance Tracking; (_iii_) QoS Service Elasticity; and (_iv_) Data Persistence. Figure 3 depicts the flowchart representing the QoS Service Elasticity decision loop. After starting, the Core periodically collects several metrics (1) from each Gateway: CPU consumption (C), memory consumption (M), network consumption (N), delay (D), jitter (J), and the number of applications (A) requesting data. The Core and Gateways implement a control message protocol which the Core uses to request the metrics from each Gateway. Gateways collect CPU, memory and network consumption metrics from the node running them. On the other hand, as applications connect to the Core, it registers the number of applications consuming data each Gateway produces. In addition, each data packet  
Figure 2: Middleware model and its components. The model comprises \(n\) hospital areas equipped with several sensors.