# Flow Sensing-Based Congestion Detection for D2D Streaming on a 5G gNB
## 3 System Model
### FS-CDA Strategy  
We denote the D2D streaming procedure on the cellular link under a 5G gNB as FS-CDA; it schedules the procedure according to the proposed algorithm and guarantees giga-bit based communication streaming for DUEs. In the FS-CDA procedure, DUEs are devices that directly perform D2D communication. In the initial stage of scheduling cellular networking under gNB, CUEs and DUEs sustain weak streaming services with each other, and then gradually sustain a strong service stage. In the D2D streaming procedure, if the FS-CDA scheduler does not know information such as channel status, SINR, and flow error, the link channel of the gNB suffers from traffic congestion; the proposed FS-CDA is a strategy to mitigate such a problem. Therefore, the proposed FS-CDA is an important strategy that improves the QoS of both the cellular and D2D links while overcoming congestion. Pseudo codes arrange the FS-CDA operation and then schedule streaming in the order of the lowest traffic flow error rate and SINR. Thereafter, the scheduler creates the buffer queue \(B_{Queue}\) and performs an optimal streaming scheduling operation. At each level, \(D2D_{streaming}(x)\) for traffic flows, is defined as follows:  
\[D2D_{streaming}(x)=\max_{i,j}\left\{\frac{1}{1+\left|\mu\times TF_{j}-\mu\times TF _{i}\right|}+TF_{i}^{j}\right\} \tag{16}\]  
where \(TF_{i}\) is an FV of the \(i^{th}\) traffic flow. The max operation is calculated for \(i^{th}\) and \(j^{th}\) streaming flow in the same pair.  
As shown in the Algorithms 1 FS-CDA procedure, DUEs are stably allocated traffic flows to operate an optimal streaming procedure. In this procedure, traffic congestion and delay owing to flow rate errors are mitigated. Therefore, the aim of the proposed FS-CDA is to guarantee streaming QoS by minimizing the latency due to traffic flow error, and procedure codes shows such a scheduling operation. Therefore, FS-CDA effectively operates D2D stream scheduling to ensure a 5G cellular-based streaming service.  
```
Input: Traffic flows Output: Traffic flows that satisfy threshold D2D Streaming: \(B_{Queue}=\{TF_{1},TF_{2},\ldots,TF_{n}\}\) //Traffic flows assigned to the buffer queue of DUE \(\sum\limits_{i=1}^{n}\left|B_{Queue}(x_{i})\right|\geq\mu\) \(\text{TrafficFlowListIndex}=0\) //Initialization for every traffic flows if (TrafficFlowListIndex > \(\sum\limits_{i=1}^{n}\left|B_{Queue}(x_{i})\right|\geq\mu\)) \(\{D2D_{streaming}(x)=\max_{i,j}\left\{\frac{1}{1+\left|\mu\times TF_{j}-\mu \times TF_{i}\right|}+TF_{i}^{j}\right\}\) GetTrafficFlowDataSet(TrafficFlowStreamList[FlowStreamListIndex]); //Generation of traffic flow lists satisfying the optimal D2D streaming operation (GetTrafficFlowDataSet(TrafficFlowStreamList[FlowStreamListIndex]), FlowStreamListIndex + 1); //Get the next flow to operate D2D stream scheduling \(\}\) else if (FlowStreamListIndex < \(\sum\limits_{i=1}^{n}\left|B_{Queue}(x_{i})\right|\geq\mu\)) \(\{\) \(\text{Threshold}=\sum\limits_{i=1}^{n}\left|B_{Queue}(x_{i})\right|\geq\mu\) //Streaming operation with threshold \(\}\) else (\(D2D_{streaming}(x)\cap\sum\limits_{i=1}^{n}B_{Ci}\
eq 0\)) //Operation whether continue or stop \(D2D_{streaming}(x)\) \(\{\) \(\sum\limits_{i=1}^{n}\left|B_{Queue}(x_{i})\right|\leq 0.5\) //Stop \(D2D_{streaming}(x)\) operation \(\}\)
```  
**Algorithm 1**FS-CDAprocedure