## 3 System Design
### Path State-Aware Multicast Tree Node Selection Mechanism  
As mentioned above, when an edge router receives the join message sent by a receiver, it obtains the MTNs of the multicast service through the NRS. To make full use of low-load links and to avoid traffic aggregation, the edge router executes the path state-aware MTN selection algorithm to detect the path state information of each MTN and select the optimal MTN to join. The path state-aware MTN selection algorithm takes the returned MTNs as input and takes the optimal MTN as output. The symbols used in the algorithm are shown in Table 2, and the execution steps of the Algorithm 1 are as follows: \begin{tabular}{l c c c} \hline \hline
**Symbol** & **Meaning** & **Symbol** & **Meaning** \\ \hline \(\{MTN\}\) & the list of multicast tree nodes & \(L_{a\text{\emph{err}}}^{\text{\emph{opti}}}\) & the average link load of \(MTN_{\text{\emph{opti}}}\) \\ \(MTN_{\text{\emph{opti}}}\) & the optimal multicast tree node & \(L_{\text{\emph{max}}}\) & the maximum link load of the \(MTN\) \\ \(L_{\text{\emph{max}}}^{\text{\emph{opti}}}\) & the maximum link load of \(MTN_{\text{\emph{opti}}}\) & \(L_{\text{\emph{aver}}}\) & the average link load of the \(MTN\) \\ \hline \hline \end{tabular}   
Step 1: Initialization: \(MTN_{\text{\emph{opti}}}=\varnothing\), \(L_{\text{\emph{max}}}^{\text{\emph{opti}}}=\infty\), \(L_{\text{\emph{avg}}}^{\text{\emph{opti}}}=\infty\). Step 2: For each \(MTN\) in \(\{MTN\}\), the edge router sends a path state detection message to the \(MTN\) to obtain the maximum link load \(L_{\text{\emph{max}}}\) and the average link load \(L_{\text{\emph{avr}}}\) of the path between the edge router and the \(MTN\), and then go to step 3. Step 3: If \(L_{\text{\emph{max}}}<\ L_{\text{\emph{max}}}^{\text{\emph{opti}}}\), then set \(MTN_{\text{\emph{opti}}}\) to the \(MTN\), set \(L_{\text{\emph{max}}}^{\text{\emph{opti}}}\) to \(L_{\text{\emph{max}}}\), set \(L_{\text{\emph{avr}}}^{\text{\emph{opti}}}\) to \(L_{\text{\emph{avr}}}\), and go to step 5. Otherwise, go to step 4. Step 4: If \(L_{\text{\emph{max}}}=\ L_{\text{\emph{max}}}^{\text{\emph{opti}}}\) and \(L_{\text{\emph{avr}}}<\ L_{\text{\emph{avr}}}^{\text{\emph{opti}}}\), then set \(MTN_{\text{\emph{opti}}}\) to the \(MTN\) and set \(L_{\text{\emph{avr}}}^{\text{\emph{opti}}}\) to \(L_{\text{\emph{avr}}}\). Then, go to step 5. Step 5: Check if all \(MTN\)s in \(\{MTN\}\) have been visited. If satisfied, then go to step 6. Otherwise, return to step 2. Step 6: Output the optimal multicast tree node \(MTN_{\text{\emph{opti}}}\), which has the best path state. \begin{tabular}{l} \hline \hline Input: \(\{MTN\}\) \\ Output: \(MTN_{\text{\emph{opti}}}\) \\
1: Initialization: \(MTN_{\text{\emph{opti}}}=\varnothing\), \(L_{\text{\emph{max}}}^{\text{\emph{sel}}}=\infty\), \(L_{\text{\emph{avr}}}^{\text{\emph{sel}}}=\infty\) \\
2: for each \(MTN\) in \(\{MTN\}\) do: \\
3: Send _Link Detection Message_ to the \(MTN\) and get the \(L_{\text{\emph{max}}}\) and \(L_{\text{\emph{avr}}}\); \\
4: if \(L_{\text{\emph{max}}}<\ L_{\text{\emph{max}}}^{\text{\emph{sel}}}\) then: \\
5: \(MTN_{\text{\emph{opti}}}=MTN\); \\
6: \(L_{\text{\emph{max}}}^{\text{\emph{sel}}}=L_{\text{\emph{max}}}\); \\
7: \(L_{\text{\emph{avg}}}^{\text{\emph{sel}}}=L_{\text{\emph{avr}}}\); \\
8: else if \(L_{\text{\emph{max}}}=\ L_{\text{\emph{max}}}^{\text{\emph{sel}}}\) and \(L_{\text{\emph{avr}}}<\ L_{\text{\emph{avr}}}^{\text{\emph{sel}}}\) then: \\
10: \(MTN_{\text{\emph{opti}}}=MTN\); \\
11: \(L_{\text{\emph{avr}}}^{\text{\emph{sel}}}=L_{\text{\emph{avr}}}\); \\
12: return \(MTN_{\text{\emph{opti}}}\) \\ \hline \hline \end{tabular}   
The edge router sends the path state detection message to the MTN to detect the state of the path between the MTN and the edge router. As shown in Figure 2(a), the path state detection message contains three fields, which are Hop Count, Max Load, and Total Load. The Hop Count field represents the number of hops that the message passes through.