## 4 Energy Aware Software Defined Network (EASDN) Routing Algorithm
The whole procedure continues until all network nodes die. Its scenario is shown in Figure 7. During the operational phase, if any node becomes disconnected due to hardware failure, the neighbor node will intimate to the controller about the disconnected node. If the controller observes that any node runs out of energy or is disconnected due to any reason (e.g., hardware failure) then it removes the detected node related data from the status list and follows the same procedure as in updating phase \(1\) as shown in Figure 8 and described in Algorithm 3. The controller gets the information of residual energy of each node from the sensor node traffic, which  
Figure 7: Updating phase 1.  
is also collected at the controller (the controller controls the network as well as collects the node data packets). The whole algorithm detail is given in Algorithms 1-3. ```
procedureStatus data collection phase (Maximum number of network nodes Nmax) declareSource_Node_address_list = [ ] declareNode_status_list = [ ] declaretime_interval_for_status_data_collection = tsdti declareStatus_data_response number = 0 ifReliable_Broadcasting( ) ==-1 then  Stop_procedure\(\triangleright\) status data request failed endwhile((time < tsdti)and(Status_data_response_number) < Nmax))do OnReceptionHello(Addr)do ifsource_addressnotinSource_Node_address_listthen  Addthe received status data intoSource_Node_address_list  Status_data_response_number = Status_data_response_number + 1  end if endprocedure endprocedure FunctionReliable_Broadcasting\(\triangleright\) Reliable_Broadcasting function provides a high probability of transmission success declareMax_retx = RTx \(\triangleright\) Maximum retransmission declareInit_prob_packet_retx = P0 \(\triangleright\) Initial probability for packet retransmission declareTime_delay = tout \(\triangleright\) Delay before first packet retransmission declareNum_neighb_rebroadcast = Nb \(\triangleright\) Number of neighbor that needs to retransmission declareNum_retx = 0 \(\triangleright\) Number of retransmission declareNxt_hop_forwarder = false declareRequired_neighb_rebroadcast = Neighbors_list * Num_neighb_rebroadcast declareForwarding_neighb = 0 while(Num_retx < Max_retx)and! (Nxt_hop_hop_forwarder)do Ontime_out(t\({}_{\text{m}}\),tout)do Prob = random [0,1) ifProb <Init_prob_packet_retx then  Broadcast the packet  Num_retx = Num_retx + 1  Init_prob_fram_retx = Init_prob_fram_retx / Num_retx  end for OnPacket_receptiondo ifprevious_packet_sender_addr == local_node_addr then  Forwarding_neighb == Forwarding_neighb + 1 ifForwarding_neighb ==Required_neighb_rebroadcastthen  Nxt_hop_forwarding = True  Stop_timer t\({}_{\text{m}}\)  end if ifNxt_hop_forwarder is falsethen  return -1  else  return 0  end if  end if  end for
```
Initialization: j=1,2,3,...,K \(\triangleright\) Number of threshold declare Threshold [j] = [X1,X2,X3,...,Xk] declare topology generation list = [ ] declare fwd_list = [ ] \(\triangleright\) Forwarding rules do topology generation ( ) whileuntil any node alive do On reception of Frame do \(\triangleright\) data packet, status packet (dead/faulty node) if Frame_type is data packet then check residual energy of node if Topology is not generation against energy Threshold[j] then ifnode residual energy < Threshold [j] then topology generation ( ) put the generation list into topology generation list else no action required end if else no action required end if else remove the dead/faulty node data from status list topology generation ( ) end if end Function topology generation clear the fwr_list for each node do Calculate the distance of nodes and its neighboring nodes from controller Select the shortest distance neighboring nodes Select forwarding node from shortest distance neighboring nodes which has highest residual energy put the selected forwarder node in fwd_list end return fwd_list
```

**Algorithm 3** Controller operational phase

Figure 8: Updating phase 2. ## 5 Experimental Setup and Results

### Experimental Setup

In this section, we will explain the experimental results.