# BGP Neighbor Trust Establishment Mechanism Based on the Bargaining Game
## 3 The BGP Neighbor Trust Mechanism Based on the Bargaining Game
### Implementation of BNTE-BG Mechanism  
This section explains the implementation of the functions in the BNTE-BG. \(AS_{1}\) and \(AS_{2}\) call \(Quote\_req\left(X_{AS_{1}}^{acc},t_{AS_{1}},\delta_{AS_{1}}\right)\), \(Quote\_agr\left(X_{AS_{2}}^{pro},t_{AS_{2}},\delta_{AS_{2}}\right)\), \(U\_req\left(X^{(t_{AS_{2}})},X_{AS_{1}}^{acc}\right)\), \(U\_agr\left(X^{(t_{AS_{1}})},X_{AS_{2}}^{pro}\right)\), and \(Dick(U,u)\). The implementation of the functions is as follows:The quote strategy function \(Quote\_req\left(X_{AS_{1}}^{acc},t_{AS_{1}},\delta_{AS_{1}}\right)\) is implemented as follows: When \(AS_{1}\) wants to send the \(t_{AS_{1}}\)th quotation to \(AS_{2}\), it calls \(Quote\_req\left(X_{AS_{1}}^{acc},t_{AS_{1}},\delta_{AS_{1}}\right)\) to generate the \(t_{AS_{1}}\)th service quality attribute quotation vector \(X^{\left(t_{AS_{1}}\right)}=\left\{x_{1}^{\left(t_{AS_{1}}\right)},x_{2}^{ \left(t_{AS_{1}}\right)},x_{3}^{\left(t_{AS_{1}}\right)},x_{4}^{\left(t_{AS_{1} }\right)},x_{5}^{\left(t_{AS_{1}}\right)}\right\}\). Calculate the benefit attribute quotation \(x_{i}^{\left(t_{AS_{1}}\right)}\) as Formula (1)  
\[x_{i}^{\left(t_{AS_{1}}\right)}=x_{imim_{AS_{1}}}^{acc}-\left[k+\left(1-k\right) \ast\left(\frac{t_{AS_{1}}}{T_{AS_{1}}}\right)^{\delta_{AS_{1}}}\right]\ast \left(x_{imim_{AS_{1}}}^{acc}-x_{imim_{AS_{1}}}^{acc}\right) \tag{1}\]  
Calculate the cost attribute quotation \(x_{j}^{\left(t_{AS_{1}}\right)}\) as Formula (2)  
\[x_{j}^{\left(t_{AS_{1}}\right)}=x_{jmin_{AS_{1}}}^{acc}+\left[k+\left(1-k\right) \ast\left(\frac{t_{AS_{1}}}{T_{AS_{1}}}\right)^{\delta_{AS_{1}}}\right]\ast \left(x_{jmax_{AS_{1}}}^{acc}-x_{jmin_{AS_{1}}}^{acc}\right) \tag{2}\]  
where \(i+j=5\), \(0<\delta_{AS_{1}}<1\), \(0<k<1\), concession factor \(k\), and \(\delta_{AS_{1}}\) are set by \(AS_{1}\). The quote strategy function \(Quote\_agr\left(X_{AS_{2}}^{pro},t_{AS_{2}},\delta_{AS_{2}}\right)\) is implemented as follows: When \(AS_{2}\) wants to send the \(t_{AS_{2}}\)th quotation to \(AS_{1}\), it calls \(Quote\_agr\left(X_{AS_{2}}^{pro},t_{AS_{2}},\delta_{AS_{2}}\right)\) to generate the \(t_{AS_{2}}\)th service quality attribute quotation vector \(X^{\left(t_{AS_{2}}\right)}=\left\{x_{1}^{\left(t_{AS_{2}}\right)},x_{2}^{ \left(t_{AS_{2}}\right)},x_{3}^{\left(t_{AS_{2}}\right)},x_{4}^{\left(t_{AS_{2} }\right)},x_{5}^{\left(t_{AS_{2}}\right)}\right\}\). Calculate the benefit attribute quotation \(x_{i}^{\left(t_{AS_{2}}\right)}\) as Formula (3)  
\[x_{i}^{\left(t_{AS_{2}}\right)}=x_{imim_{AS_{2}}}^{pro}+\left[k+\left(1-k\right) \ast\left(\frac{t_{AS_{2}}}{T_{AS_{2}}}\right)^{\delta_{AS_{2}}}\right]\ast \left(x_{imax_{AS_{2}}}^{pro}-x_{imim_{AS_{2}}}^{pro}\right) \tag{3}\]  
Calculate the cost attribute quotation \(x_{j}^{\left(t_{AS_{2}}\right)}\) as Formula (4)  
\[x_{j}^{\left(t_{AS_{2}}\right)}=x_{jmax_{AS_{2}}}^{pro}-\left[k+\left(1-k\right) \ast\left(\frac{t_{AS_{2}}}{T_{AS_{2}}}\right)^{\delta_{AS_{2}}}\right]\ast \left(x_{jmax_{AS_{2}}}^{pro}-x_{jmin_{AS_{2}}}^{pro}\right) \tag{4}\]  
where \(i+j=5\), \(0<\delta_{AS_{2}}<1\), \(0<k<1\), concession factor \(k\), and \(\delta_{AS_{2}}\) are set by \(AS_{2}\). The payoff function \(U\_agr\left(X^{\left(t_{AS_{1}}\right)},X_{AS_{2}}^{pro}\right)\) and dicker judgment function \(Dick(U,u)\) are implemented as follows: When \(AS_{2}\) receives the service quality attribute quote vector \(X^{\left(t_{AS_{1}}\right)}\), it calls \(Dick(U,u)\) to judge whether to establish a neighbor relationship. Step 1: Call \(U\_agr\left(X^{\left(t_{AS_{1}}\right)},X_{AS_{2}}^{pro}\right)\) function to generate the total payoff \(U_{agr}\).