## 3 How to Calculate Accurate Airtime at the AP Side
### Analysis of UDP Flows  
UDP is suitable for applications requiring high real-time performance with low data integrity demands. It does not guarantee reliable transmission and lacks an acknowledgment mechanism. UDP streams involve only unidirectional transmission, with wireless latency comprising both the direct transmission delay of data packets and the indirect delay occupying the wireless link. Figure 4 illustrates the process of an AP sending UDP data to a STA. The \"Data\" section in Figure 4 represents the direct time required for transmitting actual data over the wireless channel, while the other sections represent the indirect time caused by the wireless DCF design. This indirect time overhead does not involve the transmission of useful data but ensures the orderly transmission of wireless data and reduces collisions. \begin{table}
\begin{tabular}{l l} \hline \hline
**Notation** & **Description** \\ \hline \(F\) & The set of flows \\ \(T_{udp}\) & One segment airtime of a UDP flow \\ \(T_{ICP}\) & One segment airtime of a TCP flow \\ \(t_{dir}\) & The direction airtime of one frame \\ \(t_{ind}\) & The indirection airtime of one frame \\ \(s\) & Size of frame \\ \(r\) & Wireless rate of frame \\ \(W_{i}\) & Contention window of the i-th retransmission \\ \(R\) & Maximum number of wireless retransmissions \\ \(p\) & Packet loss probability obtained from AP statistics \\ \(d\) & Efficiency of TCP Reply ACK \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Notations in airtime fairness calculation. Figure 4: Airtime of a single transmission in Wi-Fi. Figure 3: Overview of our airtime definition. As shown in Figure 4, the airtime \(T_{udp}\) for transmitting a UDP stream from an AP to an STA is equal to the airtime \(T_{data}\) of the data frame, which can be expressed as the sum of the direct transmission time \(t_{dir}\) and the indirect transmission time \(t_{ind}\):  
\[T_{udp}=T_{data}=t_{dir}+t_{ind} \tag{1}\]  
The direct transmission time of a wireless data frame is calculated as follows, in seconds:  
\[T_{dir}=\frac{s}{r} \tag{2}\]  
where \(s\) represents the frame size in bits and \(r\) represents the wireless rate in bps. The indirect transmission time \(t_{ind}\) is the delay required by the DCF to avoid collisions. If the RTS and CTS mechanisms are not used, \(t_{ind}\) can be calculated as follows:  
\[t_{ind}=DIFS+Backoff+SIFS+MAC\_ACK \tag{3}\]  
The formula includes both fixed and variable time components. Let us first introduce the fixed-length components, which include \(DIFS\), \(SIFS\), and \(MAC\_ACK\). Different IEEE 802.11 standards define different SIFS times and Slot times. The AP can obtain parameters such as modulation type, coding scheme, and data rate during operation. Thus, it can retrieve the corresponding SIFS and Slot values from the configuration file. In the formula, the length of DIFS is equal to SIFS plus twice the Slot time. Additionally, the ACK in the wireless MAC layer is usually transmitted at the lowest rate. By using the length of the wireless ACK frame and the following formula, the fixed airtime required for wireless ACK transmission can also be calculated. To prevent data packet collisions when multiple devices send data simultaneously, wireless communication protocols introduce the backoff mechanism and backoff algorithm, with the most common being the Binary Exponential Backoff (BEB) algorithm. When sending data, the device will select a random backoff time, commonly referred to as the contention window. The random range of this window dynamically adjusts based on the number of collisions, doubling the range with each collision. There has been modeling research on the backoff delay of wireless nodes [18, 19, 20]. The research indicates that the expected backoff time is related to the number of streams \(N\), the minimum contention window size \(CW_{\text{min}}\), the maximum contention window size \(CW_{\text{max}}\), and the maximum number of wireless retransmissions (\(R\)). Specifically, the expected backoff time in this scenario is calculated as follows.