# DRL-Based Dynamic SFC Orchestration Algorithm for LEO Satellite Networks
## 3 System Model
### Problem Modeling
When readjustment is needed, this cost is influenced by the number of physical link hops traversed during VNF migration between physical nodes, with costs increasing as the number of link hops between target and original physical nodes increases. The operator's total expenditure over the network period equals the sum of costs for individual user requests, as shown in the formula. For individual user service requests, operational costs equal the product of service request traffic volume during the service lifecycle and the sum of physical link hops for all adjusted virtual network function migrations. Additionally, considering the possibility of service readjustment failure during the entire lifecycle, when the network service provider cannot provide service that meets constraints despite best efforts, the user service is considered to have failed readjustment. In this case, because the service cannot continue to be provided,user service experience will be affected during this period; therefore, it is necessary to add the cost of readjustment failure. \[ \begin{split} C&=C_{r}+C_{f}\,,\,\forall vnf_{j}\in V _{i}^{r}(t)\\ C_{r}&=-\sum_{i}\sum_{j}\beta\cdot\delta_{i}\cdot hop _{j}\cdot w_{i}(t)\\ C_{f}&=-\sum_{i}\gamma\cdot\delta_{i}(1-w_{i}(t)) \end{split}  \tag{11}\]  
where \(hop_{i,j}(t)\) represents the migration hops of \(vnf_{j}\) in \(sfc_{i}\) at time \(t\), which requires considering the VNF deployment locations at the previous and current times for calculation. \[hop_{i,j}(t)=\sum_{k_{1},k_{2}\in N_{e}}d_{k_{1},k_{2}}\cdot x_{i,j,k_{1}}(t-1 )\cdot x_{i,j,k_{2}}(t) \tag{12}\]  
where \(d_{k_{1},k_{2}}\) represents the shortest path hop count between physical nodes \(k_{1}\) and \(k_{2}\). When \(vnf_{j}\) migrates from node \(k_{1}\) to node \(k_{2}\), with \(x_{i,j,k_{1}}(t-1)=1\) and \(x_{i,j,k_{2}}(t)=1\), \(hop_{i,j}(t)\) is the hop count between these two nodes. In this research, the main constraints considered when solving the optimization problem are shown as follows:  
1. The source node of SFC can only be mapped to ground nodes: \[ \begin{cases}\sum\limits_{k=1}^{|N_{g}|}x_{i,j,k}(t)=1,j=1,n_{k}\in N_{g}, \forall sfc_{i}\\ \sum\limits_{k=1}^{|N_{g}|}x_{i,j,k}(t)=0,j=1,n_{k}\in N_{s},\forall sfc_{i} \end{cases} \] (13)
2. The destination node of SFC can only be mapped to ground nodes: \[ \begin{cases}\sum\limits_{k=1}^{|N_{g}|}x_{i,j,k}(t)=1,j=|V_{i}|,n_{k}\in N_{g},\forall sfc_{i}\\ \sum\limits_{k=1}^{|N_{g}|}x_{i,j,k}(t)=0,j=|V_{i}|,n_{k}\in N_{s},\forall sfc_{i} \end{cases} \] (14)
3. The \(j\) th virtual network function of the \(i\) th user service request can only be deployed on one satellite node: \[\sum\limits_{k}^{|N_{g}|}x_{i,j,k}(t)=1,j\in\{V_{i}-\{1,|V_{i}|\}\},n_{k}\in N _{s}\] (15)
4. Assuming the nodes in traffic routing path \(p_{j}(t)\) are sequentially arranged to obtain \(N_{j_{tot},t}\) the set of all nodes in the path is \(N_{j_{tot},t}\), and any actual routing path \(p_{j}(t)\) for a user service request cannot contain loops: \[\mid N_{j_{tot}}\mid=\mid N_{j_{tot}}\mid,y_{i,j}(t)=1\] (16)
5. For any satellite node \(n_{k}\in N_{s}\), the total consumption of each resource by virtual network functions deployed on this node cannot exceed its corresponding resource capacity: \[\sum\limits_{i=1}^{|SFC||V_{i}|-1}R_{j}^{r}\cdot x_{i,j,k}(t)\leq C_{n_{k}}^{r },n_{k}\in N_{s}\] (17)For any physical link \(l_{m,n}(t)\), the total link bandwidth must be greater than or equal to the sum of bandwidth occupied by virtual links mapped to this link: \[\sum_{i=1}^{|SFC|}\sum_{\langle j,k\rangle}bw_{i}^{j,k}\cdot z_{i,j,k}^{m,n}(t) \leq B_{m,n}(t)\] (18)
7. For each user request \(sfc_{i}\) and its routing path \(p_{j}(t)\), the path delay \(d_{j}(t)\) must be less than or equal to the maximum allowed delay \(Delay_{i}\) of \(sfc_{i}\), as shown in the formula, where \(delay_{k}\) represents the delay of the \(i\) th physical link in \(p_{j}(t)\): \[Delay_{i}\geq\sum_{k}delay_{k}\] (19)
8.