# A QoS-Guaranteed and Congestion-Controlled SDN Routing Strategy for Smart Grid
## 3 Design of QCORS Algorithm
### Packet-Redirection Strategy Model
The dynamic of \(Q_{n}^{f}(t)\) in slot \(t\) is  
\[Q_{n}^{f}(t+1)=Q_{n}^{f}(t)+\sum\limits_{a\in I(n)}x_{n}^{t}(a,f)-\sum\limits_ {b\in O(n)}x_{n}^{t}(b,f). \tag{8}\]  
(4) Problem model: Our optimization goal is to maximize the average network utility under the constraints of the entire network. The utility function \(U(t)\)\(U_{f}(t)\) uses the logarithm function i.e., \(U(t)=\log(1+\sum\limits_{a\in I(n)}x_{n}^{t}(a))\), which is a limited concave function that has continuous and non-decreasing second derivative. Then the optimization problem can be given by  
\[ \begin{array}{ll}max&\overline{O(t)}=\lim\limits_{T\rightarrow\infty}\frac{ 1}{T}\sum\limits_{t=0}^{T-1}E\{U(t)\}\\ s.t.&0\leqslant\sum\limits_{a\in I(n)}x_{n}^{t}(a)\leqslant x_{max},\forall n \in N,\\ &0\leqslant\sum\limits_{f}x_{n}^{t}(b,f)\leqslant C_{n}^{t}(b),\forall b\in O (n),\\ &0\leqslant\sum\limits_{b\in O(n)}x_{n}^{t}(b)\leqslant Q_{n}(t),\forall n \in N,\\ &\lim\limits_{T\rightarrow\infty}\frac{1}{T}\sum\limits_{t=0}^{T-1} \sum\limits_{n\in N}E[Q_{n}(t)]<\infty.\end{array}  \tag{9}\]  
Because the optimization problem includes a dynamic queue model, it is difficult to be solved by existing convex optimization tools. In this paper, we use the Lyapunov optimization theory, which is generally used to deal with the dynamic problem. (5) Lyapunov optimization algorithm: Although the Lyapunov function has many kinds of expressions, the second method of the Lyapunov function [50] is most widely used, which is defined as follows:  
\[L(Q(t))=\frac{1}{2}\sum\limits_{n}\sum\limits_{f}Q_{n}^{f}(t)^{2}. \tag{10}\]Then, we define the Lyapunov Drift by \(\Delta(t)\). This represents the expected value of change for the Lyapunov function from slot \(t\) to slot \(t+1\). Thus, the Lyapunov drift for a single slot is defined as  
\[\Delta(t)=E\{L(Q(t+1))-L(Q(t))\mid Q(t)\}, \tag{11}\]  
where \(\Delta(t)\) represents the trend of \(L(Q(t))\) over one time slot. Moreover, for a specific slot \(t\), the smaller \(\Delta(t)\) means slower growth rate of \(L\{Q(t)\}\). By minimizing the Lyapunov shift \(\Delta(t)\) in each time slot, the stabilized data queue that satisfied the delay constraint can be achieved. The network utility function can be integrated into the Lyapunov drift \(\Delta(t)\) to further obtain the drift-minus-utility [51] function \(\Delta V(t)\):  
\[\Delta V(t)=\Delta(t)-VE[O(t)|Q(t)\,], \tag{12}\]  
where \(V\) is a nonnegative weight, which represents the network utility \(O(t)\) in the proportion of \(\Delta V(t)\). The higher value of \(V\), the higher proportion of \(O(t)\) in \(\Delta V(t)\)[34]. By minimizing \(\Delta V(t)\), the queue length in SDN network can be stabilized, and the network throughput is also improved. **Lemma 1**. : _If there is a constant \(B\geq 0\), \(V\geq 0\), \(\xi\geq 0\), in all time slots \(t\) = 0, 1, 2,... and the possibility of all queue \(Q(t)\), the upper bound of \(\Delta V(t)\) is_  
\[\Delta(t)-VE[O(t)\,|\,Q(t)]\leqslant B+E\big{[}\bar{\Delta}u(t)|Q(t)\big{]}. \tag{13}\]  
Proof of Lemma 1.: Because \(Q\geq 0\), \(b\geq 0\), \(A\geq 0\), \(\Big{[}(Q-b)^{+}+A^{2}\Big{]}\leqslant Q^{2}+A^{2}+b^{2}+2Q(A-b)\), then  
\[\begin{array}{l}L\{Q(t+1)\}-L\{Q(t)\}\\ =\frac{1}{2}\sum\limits_{n}\sum\limits_{f}\Big{[}Q_{n}^{f}(t+1)^{2}-Q_{n}^{f}( t)^{2}\Big{]}\\ =\frac{1}{2}\sum\limits_{n}\sum\limits_{f}\left\{\begin{array}{l}\left( \left(Q_{n}^{f}(t)-\sum\limits_{b\in O(n)}x_{n}(b,f)\right)^{+}+\sum\limits_ {a\in I(n  
a dynamic programming problem, which makes the optimization problem (9) further simplified as the following optimization problem (17):  
\[ \begin{split} min&\tilde{\Delta}u(t)\\ s.t.& 0\leqslant\sum_{a\in I(n)}x_{n}^{t}(a) \leqslant x_{max},\forall n\in N\\ & 0\leqslant\sum_{f}x_{n}^{t}(b,f)\leqslant C_{n}^{t}(b), \forall b\in O(n)\\ & 0\leqslant\sum_{b\in O(n)}x_{n}^{t}(b)\leqslant Q_{n}(t), \forall n\in N.\end{split}  \tag{17}\]  
In each slot \(t\), all the states in the network can be seen as known quantities.