# A Terminal-Oriented Distributed Traffic Flow Splitting Strategy for Multi-Service of V2X Networks
## 4 TFSS Algorithm
### Optimization Problem  
According to the optimization goal of the service offload, the utility function is established as follows:  
\[F(\lambda)=\eta_{1}D(\lambda)+\eta_{2}C(\lambda)=\eta_{1}\sum\limits_{i=1}^{n} \frac{1}{\mu_{i}-\lambda_{i}}+\eta_{2}\sum\limits_{i=1}^{n}\frac{\lambda_{i} \cdot\theta_{i}}{\mu_{i}-\lambda_{i}} \tag{12}\]  
In the above equation, \(\eta_{1}\) and \(\eta_{2}\) are weighting factors, and \(\eta_{1}+\eta_{2}=1\). If the gateway service requires a short delay, that is, a delay-sensitive service, then \(\eta_{1}>\eta_{2}\). If the gateway service can tolerate a higher delay and requires a low cost, that is, a cost-based service, then \(\eta_{2}>\eta_{1}\). When \(\eta_{1}=1,\eta_{2}=0\), only the system delay is considered. Conversely, when \(\eta_{1}=0,\eta_{2}=1\), only the cost is considered at the time. Therefore, the specific values of \(\eta_{1}\) and \(\eta_{2}\) depend on the characteristics of the gateway service. The traffic flow splitting algorithm will be affected by the stability of the network transmission, the characteristics of the service itself, and other factors in the network. Therefore, the following should be set: (1) the transmission to greater system stability requirements are \(0\leq\lambda_{i}<\mu_{i}\), that is, the service rate of the data packet is better guaranteed than the arrival rate and (2) the delay limit is \(D_{i}=\frac{1}{\mu_{i}-\lambda_{i}}<D_{0}\), where \(D_{0}\) is the maximum delay of the system. Thus, the problem is equivalent to the following optimization problem with practical constraints:  
\[\left\{ \begin{array}{l}\min(F(\lambda))\\ \lambda=\sum\limits_{i=1}^{n}\lambda_{i}\\ 0\leq\lambda_{i}<\mu_{i}(i=1,2,\cdots,n)\\ \frac{1}{\mu_{i}-\lambda_{i}}<D_{0}\end{array} \right. \tag{13}\]  
The Lagrange multiplier method is combined with KKT (Karush-Kuhn-Tucher) to solve the optimization problem, and the global optimal solution is obtained as follows:  
The Lagrange multipliers, \(\omega_{0}\) and \(\omega_{1}\), are introduced to construct a Lagrangian function:  
\[L(\lambda,\omega)=\eta_{1}\sum\limits_{i=1}^{n}\frac{1}{\mu_{i}-\lambda_{i}}+ \eta_{2}\sum\limits_{i=1}^{n}\frac{\lambda_{i}\cdot\theta_{i}}{\mu_{i}-\lambda_ {i}}-\omega_{0}\left(\sum\limits_{i=1}^{n}\lambda_{i}-\lambda\right)  
Therefore, Equation (14) can be simplified to  
\[L(\lambda,\omega)=\eta_{1}\underset{i=1}{\overset{n}{\sum}}\frac{1}{\mu_{i}- \lambda_{i}}+\eta_{2}\underset{i=1}{\overset{n}{\sum}}\frac{\lambda_{i}\cdot \theta_{i}}{\mu_{i}-\lambda_{i}}-\omega_{0}\left(\underset{i=1}{\overset{n}{ \sum}}\lambda_{i}-\lambda\right) \tag{16}\]  
Because the KKT condition satisfies the function \(L\), the derivation for each \(\lambda\) is 0,  
\[\left\{ \begin{array}{l}\frac{\partial L}{\partial\lambda_{i}}=0\\ \frac{\partial L}{\partial\omega_{0}}=0\end{array} \right. \tag{17}\]  
Then,  
\[\left\{ \begin{array}{l}\frac{\eta_{1}}{\left(\mu_{1}-\lambda_{1} \right)^{2}}+\frac{\eta_{2}\mu_{1}\theta_{1}}{\left(\mu_{1}-\lambda_{1}\right) ^{2}}-\omega_{0}=0\\ \frac{\eta_{1}}{\left(\mu_{2}-\lambda_{2}\right)^{2}}+\frac{\eta_{2}\mu_{2} \theta_{2}}{\left(\mu_{2}-\lambda_{2}\right)^{2}}-\omega_{0}=0\\ \cdots\\ \frac{\eta_{1}}{\left(\mu_{n}-\lambda_{n}\right)^{2}}+\frac{\eta_{2}\mu_{n} \theta_{n}}{\left(\mu_{n}-\lambda_{n}\right)^{2}}-\omega_{0}=0\\ \lambda_{1}+\lambda_{2}+\cdots+\lambda_{n}=\lambda\end{array} \right. \tag{18}\]  
Assuming that there are two heterogeneous subnets in the network, i.e., \(n=2\), then Equation (18) can be reduced to the following:  
\[\left\{ \begin{array}{l}\frac{\eta_{1}}{\left(\mu_{1}-\lambda_{1} \right)^{2}}+\frac{\eta_{2}\mu_{1}\theta_{1}}{\left(\mu_{1}-\lambda_{1}\right) ^{2}}-\omega_{0}=0\\ \frac{\eta_{1}}{\left(\mu_{2}-\lambda_{2}\right)^{2}}+\frac{\eta_{2}\mu_{2} \theta_{2}}{\left(\mu_{2}-\lambda_{2}\right)^{2}}-\omega_{0}=0\\ \lambda_{1}+\lambda_{2}=\lambda\end{array} \right. \tag{19}\]  
Next,  
\[\left\{