# MTRSRP: Joint Design of Multi-Triangular Ring and Self-Routing Protocol for BLE Networks
## 4 The Proposed MTRSRP
### Self-Routing Protocol of MTRSRP  
With the continuous development of network communication technology and the increasing demand for applications in recent years, the effective design of network architectures to improve packet transmission efficiency and reduce communication latency has become a topic of interest in both academia and industry. In this context, MTRSRP combines multiple triangular ring network structures with coding addressing techniques to achieve optimal self-routing paths and enhance the overall efficiency of network packet transmission. To explain the operation of this self-routing protocol, the encoding mechanism described above was employed because BLE devices depend on transmitting data through their respective piconet masters. This strategy helped streamline the data forwarding process by directing packets from the source master (SM) to the destination master (DM). In addition, an intermediate master (IM) was introduced to represent masters with identical intra-ring IDs that connect different rings, indicating their linkages via B_inter bridges. The self-routing strategy involves transmitting packets from the SM through B_intra to the corresponding IM on the ring of the DM and then forwarding them to the DM via B_inter. This process relies on the aforementioned coding mechanisms to address each piconet. The encoding tasks can be completed during the coordinator's master node calculations, and the results are recorded in a role table sent to each master for the piconet and scatternet. The pseudocode of the self-routing strategy is described in Algorithm 3. ```
Procedure: AssignBinaryLabels(RootNode, MaxRings, K) Input: RootNode: coordinator node, MaxRings: maximum number of rings, K: branching factor per node Output: LabelMap: mapping from each node to its full binary label (InterID + IntraID) Initialize Queue \(\leftarrow\) [RootNode] Set LabelMap[RootNode] \(\leftarrow\) \"000000\" // \(k\) bits InterID + 2 bits IntraID Set RingLevel[RootNode] \(\leftarrow\) 0 While Queue is not empty:  Parent \(\leftarrow\) Queue.dequeue()  ParentLabel \(\leftarrow\) LabelMap[Parent]  CurrentRing \(\leftarrow\) RingLevel[Parent] + 1 If CurrentRing \(\leq\) MaxRings then For i from 1 to K do  Child \(\leftarrow\) GenerateChildNode(Parent, i) If Child \(\
eq\) null then  InterID \(\leftarrow\) Binary(CurrentRing, \(k\)) // fixed \(k\) bits  IntraID \(\leftarrow\) Binary(i, 2) // fixed 2 bits  Label \(\leftarrow\) InterID + IntraID  LabelMap[Child] \(\leftarrow\) Label  RingLevel[Child] \(\leftarrow\) CurrentRing Queue.enqueue(Child) endif endfor endif endwhile Return LabelMap
```  
**Algorithm 3**Pseudocode of the binary label assignment procedure. Figure 5 shows the self-routing method. This study considered the transmission of packets from node 49 (SM) to node 42 (DM) with piconet codes \"01101\" and \"00111,\" respectively. The last two digits of their codes indicate that node 42 is positioned counter-clockwise from node 49. By utilizing the B_intra connection between these nodes, packets from node 49 can be routed to node 11 (code: 01111), which acts as an IM. Subsequently, the process from the IM to the DM was determined by comparing the first three bits of the codes. As \"011\" decreased to \"001,\" the transmission shifted from the outer ring to the inner ring, traversing through layers of B_inter bridges until reaching the preceding master of the destination DM and then reaching DM. Hence, the complete transmission process is as follows: 01101 -> 01111 -> 01011 -> 00111. Another example is the transmission of packets from an inner to an outer ring. This study considered node 38 (SM) with the piconet code \"00010,\" aiming to send data to node 49 (DM) with the piconet code \"01101,\" where the intermediate node (IM) is \"00001.\" The last two digits of their codes indicate that node 49 is positioned counterclockwise from node 38. By utilizing the B_intra connection between these nodes, the packet can be routed to \"00001\" (IM).