# A Preemptive-Resume Priority MAC Protocol for Efficient BSM Transmission in UAV-Assisted VANETs
## 4 Problem Formulation and Performance Metrics
### UAV Communication Latency
#### 4.1.2 UAV MAC Layer Service Delay  
In this paper, we only consider the access mechanism. Furthermore, we have the following assumptions: (1) The network consists of r competing stations, where r is the number of priority levels. (2) Since vehicles follow a Poisson arrival model and each vehicle sends a message containing only one data packet of the same size \(\beta\) bits, the arrival of data packets at the MAC layer also follows a Poisson process with the same arrival rate as the vehicle arrival rate \(\lambda_{i}\). (3) It is assumed that the probability P of collision occurring in transmission from a station is constant and independent of the transmission history. In this paper, the probability of a station sending in a random time slot is defined as \(\tau\). The relationship formula between \(\tau\) and P is derived from a generalized Markov chain model [19]. In this paper, a Monte Carlo algorithm is used to calculate the probability of collision for each priority level. The value of P depends on the arrival rate, and the value of P for lower priority levels should be added to the value of P for higher priority levels (because priority level 1 will only have effective collisions with priority level 1, while priority level 3 will have effective collisions with priority levels 1, 2, and 3). The specific process is as shown in Algorithm 1:  
```
Input: arrival rate array, num packet array, window size array, number of priorities, number of iterations Initialize: num collisions = array of size num priorities initialized with zeros Output: collision probability array for each priority Begin: for iter = 1 to num iterations do  arrival times = generate arrival times (arrival rates, num packets)  for i = 1 to num priorities do  for j = 1 to num packets[i] do  if check collision (arrival times, i, j, window sizes) then  num collisions[i] = num collisions[i] + 1  end if  end for  end for  collision probabilities = calculate collision probabilities (num collisions, num packets, num iterations) End
```  
**Algorithm 1**Proposed algorithm for Packet Channel Collision Probability. This algorithm is used to calculate the collision probability (P) for different priority levels and scenarios, and then this information can be utilized for subsequent calculations. Let \(\mathbf{j}\in[0,\mathbf{m}]\) denote the backoff stage and \(W_{j}\) denote the corresponding contention window size, \(W_{j}=2^{j}W\). W represents the initial window size, typically defined as 15 or 31 according to the 802.11P protocol. m denotes the maximum backoff stage defined by the 802.11P protocol. \(b(t)\) represents the value of the backoff counter at time \(t\), and \(s(t)\) represents the backoff stage of the node at time t.  
In this paper, we assume a constant collision probability P that is independent of the transmission history, allowing us to discretize the two-dimensional stochastic process \((s(i,t),b(i,t))\) for Markov chain modeling. Due to the impact of factors such as vehicle speed and road conditions, the packet arrival rate in this paper is limited, resulting in an unsaturated condition. When the buffer is empty, the backoff counter is not activated. Therefore, to represent this condition, we introduce states \((-1,0)\) to indicate an empty buffer. It should be noted that we assume that if no collision occurs, a packet will either be successfully transmitted or reach the maximum retry limit and be discarded, without considering other reasons for transmission failure. Let \((1-q)\) denote the probability of no packet arrival within a time slot, which depends on the slot size and the packet arrivalrate. The mentioned virtual slot size refers to the average interval between two consecutive decrements of the backoff timer. Therefore, we build a discrete-time Markov chain model based on the two-dimensional stochastic process \((s(i,t),b(i,t))\), where the combination of backoff stage \(s(t)\) and backoff counter value \(b(t)\) represents the state of a node.