## 4 Algorithm Design
### Queue Scheduling  
Most airtime fairness scheduling implementations are based on the Deficit Round-Robin (DRR) algorithm [21]. In this approach, each flow is assigned a queue and a service quantum. If a queue is not selected in the current round, its remaining quantum is carried over to the next round. This process tracks deficits, ensuring that any unfairness from one round is compensated in subsequent rounds. While [21] effectively addresses unfairness caused by varying packet sizes among flows, our approach incorporates packet size into the quantum calculation from the outset, preemptively resolving this issue.  
Paper [22] improved the airtime Deficit Round Robin algorithm to prevent nodes with high packet loss rates from monopolizing the wireless channel, thereby optimizing system performance. However, this method requires real-time estimation of airtime during decision-making, leading to higher overhead. In contrast, our method calculates airtime only when a flow changes its Modulation and Coding Scheme (MCS). During decision-making, it relies solely on this pre-calculated airtime, thereby reducing overhead.  
Figure 6 illustrates the logic of our proposed queue scheduling algorithm. This algorithm is a QoS scheduling method deployed on top of an active queue management algorithm, responsible only for selecting frames from the queue. Unlike the approach in [21], our algorithm requires just a single queue, reducing both complexity and deployment overhead.  
Figure 5: Workflow of our algorithm.  
Figure 6: Our queue scheduling algorithm.  
The queue scheduling algorithm proposed in this section relies on the quotas determined by the resource allocation algorithm (discussed in Section 4.3). Adhering to the logic of the DRR algorithm, it selects the most appropriate flow at any given time and then transmits the earliest frame from that flow. The detailed steps of this queue scheduling algorithm are presented in Algorithm 1.  
```
0:\(deficit\_counter,quantum\)
0:selected\(flow\)
1:Init:deficit_counter[] = quantum[];
2:functionpeek_flow()[
3:min_dc = deflict_counter[0];
4:selected = 0;
5:for(i = 0; i < N; i++)do
6:if(deflict_counter[i] > min_dc)then
7:min_dc = deflict_counter[i];
8:selected = i;
9:endif
10:endfor
11:for(i = 0; i < N; i++)do
12:deflict_counter[i] = min_dc;
13:endfor
14:deflict_counter[selected] = quantum[selected];
15:return selected;
16:endfunction
```  
**Algorithm 1** Queue scheduling algorithm based on QoS.  
To achieve airtime fairness, we assign different transmission opportunities (quantum) to each STA node. This quantum is determined by the node's rate, transport layer type, transmission direction, and other characteristics, as calculated by the resource allocation module. When selecting a flow for transmission, we identify the minimum value of the 'deficit_counter' array ('min_dc') and its corresponding index. The flow associated with that index is then selected, and its 'deficit_counter' is reset based on its airtime quantum. For the flows not selected, we subtract'min_dc' from their 'deficit_counter' values, increasing their chances of being selected in future transmissions, thereby achieving airtime fairness, as illustrated in Figure 2.  
In this queue scheduling algorithm, flows with larger quanta have fewer opportunities to transmit wireless data frames, resulting in a smaller number of sent frames (n). In other words, the number of packets sent (n) is inversely proportional to the assigned quantum.  
\[\frac{n_{i}}{n_{j}}=\frac{quantum_{j}}{quantum_{i}} \tag{8}\]