# JSSTR: A Joint Server Selection and Traffic Routing Algorithm for the Software-Defined Data Center
## 5 Joint Server Selection and Traffic Routing Algorithm
### Detailed Description of JSSTR  
As shown in Algorithm 1, for solving the above joint server selection and traffic routing problem, an algorithm called JSSTR is proposed based on SFLA. When the controller receives a request sent from the user, it will first parse that request to get its source IP address \(src\_ip\), destination IP address \(dst\_ip\) and protocol type \(pro\_type\). Then, \(ub_{i,j}\), \(tb_{i,j}\) of all links and \(ur_{i}\) and \(tr_{i}\) of all servers are obtained. All servers that can provide service for the user request and all edge switches that connect to those servers are calculated based on the \(dst\_ip\). From Line 5-Line 8, for each switch in all edge switches \(e\_switches\), JSSTR firstly calculates \(m\) initial routing paths between that switch and the user by using the DFS algorithm. The user and a routing path of the initial routing paths form a switch frog. After that, one server is randomly chosen from the servers that connect to that switch. Then, the corresponding server frog will be generated by that chosen server, the link between the chosen server and the switch and the switch frog. Accordingly, all switch frogs and server frogs are generated in that way. The server frogs that have the same edge switch form a group, each for an edge switch. \begin{table}
\begin{tabular}{c c c c} \hline \hline \multirow{2}{*}{**Time Loop**} & \multicolumn{2}{c}{**Group 1**} & \multicolumn{2}{c}{**Group 2**} \\ \cline{2-4}  & **Memeplex 1** & **Memeplex 2** & **Memeplex 3** & **Memeplex 4** \\ \hline begin of time & /1: u5-sw2-sw3-sw4-s1; & /3: u5-sw2-sw3-sw4-s3; & /5: u5-sw2-sw3-s5; & /7: u5-sw2-sw3-s7; \\ loop 1 & /2: u5-sw2-sw1-sw4-s2; & /4: u5-sw2-sw1-sw4-s4; & /6: u5-sw2-sw1-sw4-sw3-s6; & /8: u5-sw2-sw1-sw4-sw3-s8; \\ \hline end of time & /1: u5-sw2-sw1-sw4-s1; & /3: u5-sw2-sw3-sw4-s3; & /5: u5-sw2-sw3-s5; & /7: u5-sw2-sw1-sw4-sw3-s7; \\ loop 1 & /2: u5-sw2-sw3-sw4-s2; & /4: u5-sw2-sw1-sw4-s4; & /6: u5-sw2-sw5-sw3-s6; & /8: u5-sw2-sw3-s8; \\ \hline begin of time & /1: u5-sw2-sw1-sw4-s1; & /3: u5-sw2-sw1-sw4-s3; & /5: u5-sw2-sw3-s5; & /7: u5-sw2-sw3-s7; \\ loop 2 & /2: u5-sw2-sw3-sw4-s2; & /4: u5-sw2-sw3-sw4-s4; & /6: u5-sw2-sw5-sw3-s6; & /8: u5-sw2-sw5-sw4-sw3-s8; \\ \hline end of time & /1: u5-sw2-sw1-sw4-s1; & /3: u5-sw2-sw1-sw4-s3; & /5: u5-sw2-sw3-s5; & /7: u5-sw2-sw3-s7; \\ loop 2 & /2: u5-sw2-sw3-sw4-s2; & /4: u5-sw2-sw5-sw4-s4; & /6: u5-sw2-sw3-s6; & /8: u5-sw2-sw3-s8; \\ \hline \end{tabular}
\end{table} 
Table 2: Example of JSSTR. Figure 3: Design principle of the JSSTR algorithm. From Line 9-Line 16, JSSTR carries out several time loops. In each time loop, all server frogs are firstly divided into a number of memeplexes using the function \(divide\_frogs\). Then, each memeplex executes a certain number of local optimizations. Subsequently, the maximum fitness of all server frogs is calculated in function \(calc\_maximum\_fitness\) by using \(fitness=1/(1+pf+sf)\), where \(pf\) and \(sf\) are defined in Section 4.2. The difference value \(maximum\_fitness\_diff\) of the current maximum fitness \(maximum\_fitness\) and the maximum fitness of the last time loop \(last\_maximum\_fitness\) is calculated. If the number of the time loops reaches the maximum number \(maximum\_time\_loop\_num\) or the difference value \(maximum\_fitness\_diff\) reaches the threshold value \(fitness\_diff\_threshold\), the time loop will stop. Afterwards, the server frog that has maximum fitness is found. The server and path of that server frog are chosen as the destination server \(s_{d}\) and routing path \(p_{r}\). At last, some flow entries are installed on the switches based on \(s_{d}\) and \(p_{r}\) (Line 18). The function \(divide\_frogs\) is used to divide all server frogs into \(n\) memeplexes for each group. In that function, for each \(e\_switch\) in \(e\_switches\), all switch frogs are firstly extracted by subtracting the destination server and the link that connects that server and the corresponding \(e\_switch\) from the server frogs.