# Flow Sensing-Based Congestion Detection for D2D Streaming on a 5G gNB
## 3 System Model
### D2D Flow Congestion Control
#### 3.3.2 D2D Flow Control with the Burst Rate  
If the transmission rates between the buffer cache of \(DUE_{buffer}(x)\) and the requested flow rates are balanced, the D2D streaming due to the transmission rate is optimized. However, the optimization for D2D streaming is not always sustained, since the encoding rate in \(DUE_{buffer}(x)\) is variable.  
* D2D burst rate control: We denote the next flow rate after the streaming of the \((x-1)^{th}\) flow rate as \(FR_{next}(x)\). The size of \(FR_{next}(x)\) may be fixed or variable. Typically, the rate and size of the flow segment are variable.  
Therefore, we consider only variable-size flow segments, which are flows with different burst rates. Here, the encoding rate and bandwidth for a requested rate considers the burst rate. Hence, D2D burst rate control for a requested flow segment (\(BUR_{control}(x)\)) for \(FR_{next}(x)\) in the buffer cache of \(DUE_{buffer}(x)\) is defined as follows:  
\[BUR_{control}(x)=~{}FR_{next}(x)\times T_{synchro}(x)-\frac{E_{r}(k)}{CBW} \times S(x) \tag{13}\]  
where \(T_{synchro}(x)\) is the time synchronization for \(FR_{next}(x)\) and \(S(x)\) is the size of the \(i^{th}\) flow segment. The buffer cache capacity for \(FR_{next}(x)\) should be considered after the determination of \(BUR_{control}(x)\). The buffer cache capacity \(BUR_{cache-capacity}(x)\) for \(FR_{next}(x)\) is defined as follows:  
\[BUR_{cache-capacity}(x)=\frac{\{E_{r}(k)-D_{r}(k)\}}{CBW}\times S(x)\times T_{ synchro}(x)+BUR_{control}(x) \tag{14}\]  
If \(BUR_{control}(x)=0\), buffer caching is stopped, resulting in congestion dueto capacity imbalance. Therefore, streaming is performed for the \(\left\lceil\frac{E_{r}}{BUR}\right\rceil^{th}\) flow, with \(BUR_{control}\
eq 0\) to prevent this type of problem.  
* Buffer cache control: The flow rates in the buffer cache should be detected continuously to maintain streaming without congestion and latency at \(DUE_{buffer}(x)\) to \(DUE_{buffer}(x)\). An imbalance may occur between the rate of a transmitted flow segment and the caching rate. The scenario for \(BUR_{control}(x)=0\) has already been discussed. Therefore, this scenario should be avoided if possible. Let us consider the following operations: \[T_{synchro}(x)\times T>~{}S(x)\text{ and }BUR_{control}(x)~{}>~{}0\] This is the scenario of increasing bandwidth. It must consider the \(T_{synchro}(x)\times T\) operation, since the buffer cache in \(DUE_{buffer}(x)\) depends on bandwidth. The encoding rate at the buffer cache of \(DUE_{buffer}(x)\) provides better responsiveness. Hence, the encoding rate for \(DUE_{buffer}(x)\) is defined as follows: \[BUR_{encoding}(x)=\{S(x)-S(x-1)\}+T_{synchro}(x)\times\mu\times\delta\] (15) where \(\delta\) (\(0<\delta<1\)) is a response coefficient. If \(BUR_{encoding}(x)=0\), then the detecting operation for the encoding rate is stopped and it is performed from the beginning. \(T_{synchro}(x)\times T<S(x)\) and \(BUR_{control}<0\) This is the scenario of decreasing bandwidth. Here, the encoding rate (\(T_{synchro}(x)\times T\)) operation requires the capacity for flow rate, which is operated to \(\delta\). A larger \(\delta\) provides better responsiveness, and subsequently improving QoS for D2D streaming.