# Optimizing Routing Protocol Design for Long-Range Distributed Multi-Hop Networks
## 4 Load-Balancing Routing Optimization Scheme Design
### Business Routing Model
\right)_{n\times n\times 6} \tag{32}\]  
To ensure that selected relay nodes fall within the transmission range of terminal nodes under the chosen \(SF\), while also preventing overly close distances between the relay and its own nodes, an appropriate distance threshold needs to be set. The constraints are shown in Equation (33), where \(R_{SF}\) represents the single-hop transmission distance for different \(SF\)s, and \(a_{ij}=1\) indicates that node \(j\) can serve as a relay for node \(i\); otherwise, \(a_{ij}=0\). \[a_{ij}=\left\{ \begin{array}{cc}0,a_{ij}<(1-\mu)R_{SF}\\ 1,(1-\mu)R_{SF}\leq a_{ij}\leq R_{SF}\\ 0,a_{ij}>R_{SF}\end{array} \right. \tag{33}\]  
After establishing the adjacency matrix node_Adjoin, all possible bidirectional links for terminal nodes under different \(SF\)s can be determined. Using a distributed network model within a large building as an example, the simulation model consists of 140 terminal nodes and one gateway distributed within a space of 100 m \(\times\) 50 m \(\times\) 18 m, simulating the characteristics of a multi-layer large building. When SF = 7 is selected, the adjacency matrix under constraint conditions provides a feasible link diagram, as shown in Figure 7.  
To construct the link weight matrix D_W, which represents the impact of communication distances between nodes on the selection of relay nodes, the link loss matrix link_Loss is element-wise multiplied by the adjacency matrix node_Adjoin under SF = k. This results in the link weight matrix D_W corresponding to SF = k, as shown in Equation (34). \[\text{D\_W}=\text{link\_Loss}*\text{node\_Adjoin}_{SF=k} \tag{34}\]  
2. Construction of the load matrix  
The load matrix C_W is constructed to represent the impact of node load conditions on the selection of relay nodes, as shown in Equation (35). Here, \(B_{S_{1}}\) represents the maximum amount of business data that node \(S_{i}\) can handle, and \(C_{S_{i}}\) represents the load rate of the node. It is assumed that the load capacity of the aggregation node is infinite, i.e., the cost of business data from terminal nodes to the aggregation node is 0. \[C_{-}W=\left( \begin{array}{ccc}\Delta_{1}&\cdots&\Delta_{n}\end{array} \right)_ {1\times n} \tag{35}\]  
\[\Delta_{k}=\frac{1}{B_{S_{i}}\times\left(1-C_{S_{i}}\right)} \tag{36}\]
3. Construction of the Load Cost Matrix  
For routing optimization of terminal nodes of different business types, it is necessary to comprehensively consider the communication distance between nodes, link loss, and load conditions of each node. The Dijkstra algorithm calculates and generates node routing information, thus finding the minimum load cost transmission path for terminal nodes of different business types. The load cost matrix T_W is established by first repeating the load matrix C_W n times along the row direction to generate a new n \(\times\) n matrix. This matrix is then element-wise multiplied by the link weight matrix \(D_{-}W_{SF=k}\), as shown in Equation (37). \[\text{T\_W}=\text{repeat}(C_{-}W,n,1)*\text{D\_W}_{SF=k} \tag{37}\]