# A Preemptive-Resume Priority MAC Protocol for Efficient BSM Transmission in UAV-Assisted VANETs
## 4 Problem Formulation and Performance Metrics
### UAV Queuing Delay  
In this section, we will focus on studying queuing delay, which is an important component of overall latency. It can be defined as the time taken for a packet to reach the transmission buffer and is dependent on the number of users multiplexed on the same wireless resource [46]. Due to vehicle arrivals following a Poisson process and assuming each vehicle sends a data packet of size \(\beta\), arrivals are exponentially distributed in this paper. Even under relatively low loads, queuing delay can occur due to sudden changes in incoming traffic. To measure the performance of the queue, we define the utility ratio \(\rho\) (the probability that all servers are busy). As \(\rho\) is a probability and needs to satisfy the requirement of queue stability, its range should be between 0 and 1. Since the arrival time and service time of packets are independent, and the arrival process in the MAC layer's arrival area and buffer area is also a Poisson process (refer to Section 3.3), based on the standard queuing theory, the packet queuing model for UAV MAC layer can be regarded as a Preemptive-Resume Priority M/G/1 model. In the following calculations, we have different delay expressions for each priority. In this paper, we use the following symbols: \(\mathrm{W_{i}}\) represents the average queuing time for priority \(\mathrm{i}\), \(E(S_{i})\) and \(\mathrm{R_{i}}\) represent the average service time and remaining service time for priority \(\mathrm{i}\). \(E\big{(}S_{i}^{2}\big{)}\) is the second moment of the average service time for priority \(\mathrm{i}\), derived from the formula \(E\big{(}S_{i}^{2}\big{)}=E(S_{i})^{2}+\sigma_{1}^{2}\). \(\sigma_{1}^{2}\) represents the variance of the distribution for that priority, which is exponential distribution in this case. \(\lambda_{\mathrm{i}}\) denotes the average arrival rate for priority \(\mathrm{i}\), and \(\rho_{\mathrm{i}}\) represents the system utilization for priority \(i\). The formula for \(\rho_{\mathrm{i}}=\lambda_{\mathrm{i}}E(S_{\mathrm{i}})\). As mentioned earlier in this paper, the number of priorities in this model is \(\mathrm{r}=3\). The value of \(E(S_{i})\) is obtained from the upstream communication delay and its MAC layer delay. \(E(S_{i})\) is constant. \[E(S_{i})=E(T_{MAC\ i}). \tag{26}\]  
The queuing delay is the time span from when a packet enters the buffer and waits in the channel allocation queue until it starts to be transmitted. According to Little's Law and the Pollaczek-Khintchine (P-K) formula, we can obtain the average waiting time for the highest priority as follows:  
\[WT_{1}=\frac{R_{1}}{1-\rho_{1}}\, \tag{27}\]  
where the remaining service time \(R_{j}\) is obtained from the following formula:  
\[R_{j}=\frac{1}{2}\sum_{j=1}^{i}\lambda_{j}E\Big{(}S_{j}^{2}\Big{)}. \tag{28}\]  
It is evident that the remaining waiting time for different priorities will be different due to the effect of preemptive rules. Customers with higher priority enter the system without having to wait for customers with lower priority to be served. They are immediately interrupted, and the interruption point is set. For the second priority, we need to consider the associated workload of customers with the same and higher priority who are already in the system when this customer enters, as well as the workload generated by higher priority customers who may arrive during the waiting time. Therefore, \(WT_{2}\) can be calculated using the following formula:  
\[WT_{2}=\frac{R_{2}}{(1-\rho_{1})(1-\rho_{1}-\rho_{2})}. \tag{29}\]  
For all priorities, the derivation is similar, and the average waiting time in the buffer can be expressed as follows:  
\[WT_{i}=\frac{R_{i}}{(1-\rho_{1}-\dots\dots-\rho_{i})(1-\rho_{1}-\dots\dots- \rho_{i-1})}\, \tag{30}\]where \(i\) is the priority level, ranging from 1 to \(r\).