## 3 Algorithm Design and Analysis
### TCP-SCTP Method
#### 3.3.3 Algorithm Design  
The TCP-SCTP method was used to predict the network transmission quality, and the MS-SCTP method or the TCP-SCTP switch process was called to improve the network transmission. It was an information record and an algorithm initial process. It is shown in Algorithm 3. ```
0: trace file (computing packet loss rate), DetectSlot
0: Rate
1: Method begin
2: Wait DetectSlot time
3: Record the current packet loss rate in Rate, update LastRate be Rate
4: While true
5: Wait DetectSlot time, then record the current packet loss rate in Rate
6: If Rate > 5%
7: We need to apply MS-SCTP method or TCP-SCTP switch process
8: Let LastRate = Rate
9: Let Count = 0
10: Let DetectSlot = DetectSlot
11: Continue
12: End If
13: Else If Rate >= lastRate
14: Let LastRate = Rate
15: Let Count = Count + 1
16: Let DetectSlot = DetectSlot / 2
17: Else
18: Let LastRate = Rate
19: Let Count = 0
20: Let DetectSlot = DetectSlot * 2
21: End Else
22: End If
23: If Count >= 3
24: We need to apply MS-SCTP method or TCP-SCTP switch process
25: Let Count = 0
26: End If
27: End Else
28: End While
29: Procedure run 600 s, and then end procedure
30: End Method \begin{table}
\begin{tabular}{c c} \hline \hline
**Parameter** & **Description** \\ \hline DetectSlot & Record the detection interval of packet loss rate \\ Count & Record the consecutive increase times of packet loss rate \\ LastRate & Record the previous packet loss rate \\ Rate & Record the current packet loss rate \\ Max[] & Record the maximum packet loss rate for each path \\ Min[] & Record the minimum packet loss rate for each path \\ \hline \hline \end{tabular}
\end{table} 
Table 4: Parameter settings of the TCP-SCTP method. * Line 1 indicates that the algorithm started executing after the initial connection was established. * Line 2 indicates that the method waited for the default detection interval time before starting to detect network conditions. * Line 3 indicates that after the algorithm calculated the packet loss rate, it recorded the packet loss rate into the Rate variable, and at the same time updated the value of LastRate so that it could compare with the next time detection of the packet loss rate so as to predict the state of the network. * The algorithm needed to repeatedly detect packet loss rate of packets, thus Line 4 kept the algorithm running by setting the loop condition to true. * After the algorithm started running, it initially got a packet loss rate value, and Line 5 waited for the DetectSlot time before detecting the network status. * The algorithm got the packet loss rate again after the time interval of the DetectSlot. After the calculation packet loss rate, Line 6 started to judge the packet loss rate. If the packet loss rate was greater than 5%, then the network situation was poor. * Line 7 shows that the algorithm called the previously defined MS-SCTP method or the TCP-SCTP switch process. After calling the MS-SCTP method or the TCP-SCTP switch process, we needed to update some parameter variables. * Line 8 was used to update the LastRate value. It detected the new packet loss rate of the loop every time, thus it needed to update the LastRate every time as well. * Line 9 shows this algorithm set Count value to zero. Because the Count was used to record the times, the PER continued to rise. After switch another protocol, the Count is set to zero. * Line 10 set the interval between the next detection of packet loss rate. The data transmission improved after switching the protocol. Therefore, the DetectSlot kept the current value. * Line 11 indicates that the algorithm should have continued the next loop after switching the protocol instead of continuing to perform the following judgment. * Line 13 represents the algorithm's processing scheme if the detected packet loss rate was less than 5%. Firstly, the packet loss rate obtained at present was compared with the packet loss rate recorded last time to predict network transmission quality.