# Cross-Layer MAC/Routing Protocol for Reliability Improvement of the Internet of Things
## 3 Topological Structure Mesh Routing
### Initial PAN Construction  
In this study, we assumed that the base station was connected to a personal computer via a USB/serial link to connect with the external network and become the first personal area network (PAN) coordinator in the mesh network. The coordinator that joined the mesh network is referred to as the router. In the TSNR, the FFD can operate as a router or leaf node, whereas the RFD can only operate as a leaf node and is connected to the router. Figure 5 shows the timing diagram to configure the mesh network by the base station and router in the TSNR. As shown in Figure 4, the base station collects the network information including PAN ID and channel, and it selects non-overlapped channel and ID as PAN ID and channel. Then, the base station broadcasts the beacon frame which includes the information of the selected channel and PAN ID to the adjacent PAN router. The router that receives the information of the selected channel and PAN ID performs passive scan. The router transmits the association request frame. When the router receives the association response frame from the base station, it configures the mesh network and communicates with neighbor devices. The base station collects the network information\(-\)including the PAN ID and channel\(-\)and selects the non-overlapped channel and ID as the PAN ID and channel, respectively. It then broadcasts the beacon frame\(-\)which includes the information of the  
Figure 5: The timing diagram for constructing the PAN in the TSNR. selected channel and the PAN ID\(-\)to adjacent routers. The router that receives the channel information and PAN ID selected by the base station performs a passive scan. If the channel selected by the base station does not overlap with the channel used by the adjacent PAN or device, the router transmits an association-request frame, the base station receiving the association-request frame during the predefined beacon interval (BI). When the base station receives the association-request frame, it determines the received signal strength indicator (RSSI) field in the association-request frame and compares the values of the RSSI fields received from other routers. The base station then allocates the superframe durations (SD) to the routers that transmit the association-request frame. In this case, it allocates the closer SD of the base station to the router with the higher RSSI value. Subsequently, the base station transmits the association response frame\(-\)which includes the information of the allocated SD\(-\)to the routers. When the router receives an association-response frame from the base station, it completes the initial PAN construction process. Figure 6 shows the proposed association-request frame format. In Figure 6, the _device-type_ field is used to distinguish between the FFD and RFD. If the device is an FFD, it sets the _device-type_ field to 1. If not, the _device-type_ field is set to 0 to indicate an RFD. When the device receives power, it sets the _power-source_ field to 1. If not, the _power-source_ field is set to 0. If the device does not turn off the receiver to save power during the idle period, it sets the receiver to an idle state when the _idle_ field is 1. If not, it sets the receiver to an active state when the _idle_ field is 0. If the device can send and receive encrypted MAC frames, the _security-capability_ field is set to 1. If not, it sets the _security-capability_ field to 0. If the device wants to be assigned a short address after joining the PAN, it sets the _allocate-address_ field to 1. If not, the _allocate-address_ field is set to 0. The RSSI field indicates the RSSI value of the frame received from the base station or router. Figure 7 shows the proposed association response frame format. In Figure 7, the _network ID_ field indicates the MAC address of the router and consists of the row and column ID. The _short-address_ field indicates the MAC address of the leaf device.