# Energy-Efficient LoRa Routing for Smart Grids
## 3 Proposed IoT-Based Communication in Smart Grid Environment
### Test Packet Transmission
As the current location where they are present is unsafe and lacks adequate grazing fields, the buffaloes were warned to explore the other grazing areas by utilising the \"waaa\" calls. Hence, the two sounds are modelled as  
\[z_{m}(d+1)=\phi(x,z_{m}(d))+y_{1}(g_{b}(d)-e_{m}(d))+y_{2}(p_{b}(d)-e_{m}(d)) \tag{6}\]  
Figure 5: Flowchart of QKE-ABO. \[\phi(z_{m}(d))=\left(x^{\mathrm{T}}z_{m}(d)\right)^{2} \tag{7}\]  
where \(Z_{m}\) and \(e_{m}\) represent the migration moves of each individual during the exploitation and exploration of the search space, the learning parameters \(y_{i1}\) and \(y_{i2}\) are between 0 and 1, the global best solution is specified as \(g_{b}\), \(d\) is the current iteration, the quadratic kernel function is denoted as \(\phi(\bullet)\), the number of kernels is \(x\), and the individual's best solution is \(p_{b}\). Step 3: In comparison to its current position, the previously visited areas were tracked by the African buffalo along with the solution acquired from all to alert about the most-effective position. Informed decisions were made by this search for solutions. Step 4: The buffalo's position is updated as  
\[e_{m}(d+1)=\frac{e_{m}(d)+z_{m}(d+1)}{\gamma} \tag{8}\]  
where \(\gamma\) takes a value at random between (0,1), the shift towards the current position is denoted as \(e_{m}(d+1)\), and \(e_{m}(d)\) is the current exploration value of the buffalo. Then, the fitness is evaluated, and the best solutions are saved. Finally, the algorithm checks for the improvement of the best buffalo. After updating, the stopping criteria are evaluated. The algorithm continues until the best fitness meets the stopping criteria. Algorithm 1 shows the pseudo-code of the QKE-ABO algorithm. Based on the adjustments made to the buffalo's mobility during the iterations, the last optimum result is obtained. In this way, the QKE-ABO algorithm is utilised to select the optimal LOADng parameters that maximise the PDR with the minimum routing delay. Then, with the optimal parameters, efficient routing is performed using the qAB_LOADng protocol. The vital elements for route discovery and route maintenance are as follows:  
* RREQ: This has the destination's address as the source node (SN) and is forwarded to the destination. * RREP: This is responsible for sending a reply to the RREQ after the destination node (DN) receives the RREQ from the SN. * RREP ACK: To confirm the reception of the RREP message, this packet is used by the LOADng router. * RERR: The route error message is used to alert about the failure in forwarding the data. For the data transmission, a smart grid communication network was utilised. From that network structure, multiple paths are discovered by the qAB_LOADng protocol. With the assistance of the above-mentioned control messages, all the possible solutions are discovered, and the source nodes send the data packets to the destination node via these routing paths. The discovered multiple routing paths are mathematically expressed as  
\[\psi_{i}=\{\psi_{1},\psi_{2},\psi_{3}\ldots\ldots\ldots,\psi_{n}\} \tag{9}\]  
where the routing paths are defined as \(\psi_{i}\) and the \(n\)th routing path is specified as \(\psi_{n}\). As for the SN to the DN, the routing paths should be consistent, highly energy-efficient, and the shortest to obtain the minimal transmission delay and energy consumption. Therefore, choosing the appropriate routing path is an essential aspect to be covered in a smart grid communication network. Therefore, the optimal routing path was discovered by using the scrambled-mutation-based Mexican axolotls optimisation (SMAx) algorithm.