## 4 Design of RBMM
### Buffer Replacement Strategy Based on Flow Priority Scoring  
When the available buffer space decreases to the threshold of the reserved partition, the system enters a restrictive state. At this stage, the data scale of the buffer must be controlled by evicting existing packets to accommodate newly arrived ones. Hierarchical packet admission control schemes are widely used in buffer management [43], where the overall data scale that the shared buffer can accommodate is managed at a global level, while flow-level decisions regarding packet acceptance are made using active queue management (AQM) principles [44; 45]. In AQM-related research, eviction strategies based on packet size improve the overall user experience by providing differentiated services for real-time traffic and large-scale data transfers [42; 46]. Inspired by the preceding research, we consider several key factors that influence the reordering process when designing the rules for packet eviction and acceptance: packet size, the size of the Red-Black Tree (representing the number of packets each flow requires to reorder in the buffer), and the presence of discontinuous 'gaps' within the Red-Black Tree. These factors collectively guide the optimization of buffer resource allocation. Figure 3 provides a simple example illustrating how multiple factors collectively influence the probability of successfully reordering and forwarding a flow. When three flows, labeled (a) to (c), coexist in a restrictive state buffer, the decision to evict packets from flow (c) is intuitive, as it occupies a significant amount of buffer space and its packets are arranged discontinuously, making it difficult to forward them all at once. We let \([D_{1},\ldots,D_{n}]\) denote all discontinuous 'gaps' in the Red-Black Tree, where \(D_{1}\) represents the number of packets between its expected sequence number and the minimum sequence number. Similarly, \([N_{1},\ldots,N_{n}]\) represents the number of packets following the \((n-1)\)th gap, with \(N_{1}\) being the total size of the Red-Black Tree. Packet size is normalized to \(L_{\text{norm}}\) using Min-Max scaling to prevent excessive score inflation. Based on this state information, the score calculation method for each flow is defined as follows:  
\[\text{Score}=(D_{1}\cdot N_{1}+D_{2}\cdot N_{2}+D_{3}\cdot N_{3}+\cdots+D_{n} \cdot N_{n})\cdot L_{\text{norm}} \tag{7}\]  
A higher score reflects a reduced likelihood of successfully reordering and fully forwarding the flow, which results in a lower priority for retaining its packets. In the buffer replacement strategy, newly arrived packets are accepted, and those from the flow with the highest score are evicted. To improve computational efficiency, we employ a differential update flow scoring algorithm (as shown in Algorithm 2), which updates the score only when packets are added to or removed from the Red-Black Tree. This approach avoids the performance overhead of traversing the tree to gather information during each score update. Figure 3: An example of out-of-order patterns in the buffer. (**a**) Small packets in a small flow with no data gaps. (**b**) Medium-sized packets in a medium-sized flow with minor data gaps. (**c**) Large packets in a large flow with significant data gaps.