## 4 SD-EAR in Detail  
### Network Model  
Network is modeled as a graph \(G=(V,E)\) where \(V\) represents the set of vertices or sensor nodes, and \(E\) represents the set of edges between those nodes. The SDN controller of a zone \(Z_{P}\) (\(1\leq p\leq P\); \(P\) is the number of all of the zones in the network) consists of the two following tables:  
1. NET-TOPL\({}_{P}\)
2. NODE-STAT\({}_{P}\)  
The network topology of zone \(Z_{P}\) is stored in the form of the adjacency list in NET-TOPL\({}_{P}\). The attributes of this table are:  
1. node-id
2. neighbor-list  
node-id specifies the unique identification number of a node, whereas neighbor-list is the set of neighbors of the node. NODE-STAT\({}_{P}\) is a table that contains information about all of the nodes within the zone \(Z_{P}\). The components of this information are:  
1. node-id
2. (latitude, longitude) pair
3. radio range
4. maximum energy
5. most recent residual energy
6. most recent rate of energy depletion
7. minimum receive power
8. sleep status
9. last sleep timestamp
10. peripheral status  
For a node \(n_{i}\), the present geographical position in terms of the (latitude, longitude) pair is specified as \((x_{i},y_{i})\), with its radio range being \(rad_{i}\). Maximum energy, the last known residual energy, and the rate of battery depletion are denoted as \(m\)-en\({}_{i}\), \(r\)-en\({}_{i}\), and \(dep_{i}\). Sleep status \(slp_{i}\) is 1 if currently \(n_{i}\) is sleeping; it is 0 otherwise. \(\tau\)-sl\({}_{i}\) is the most recent timestamp when \(n_{i}\) went to sleep. The peripheral status of \(n_{i}\) is given by \(pphr_{i}\). It is set to 1 if the radio circle of current node \(n_{i}\) is not completely embedded within the area of the zone, i.e., it may have some neighbor belonging to any neighboring zone of \(Z_{P}\). Otherwise, it is set to 0. Whenever a node \(n_{i}\) starts its operation in the network, it has to first register itself by sending a registration request message to the SDN controller. The components of the registration request are:  
1. message-type-id (0 for registration)
2. node-id
3. (latitude, longitude) pair 4. radio range
5. maximum energy  
Receiving the registration request of n\({}_{\rm i}\), the corresponding SDN controller checks the NODE-STAT\({}_{\rm P}\) table to determine whether any entry with same node identifier n\({}_{\rm i}\) exists within that table. If yes, then an id-clash message will be sent back to n\({}_{\rm i}\). The components of an id-clash message are:  
1. message-type-id (1)
2. node-id  
On the other hand, if no such event of a node identifier clash is detected, then a registration-success message is sent to n\({}_{\rm i}\). The attributes of registration-success are the same as id-clash; only the message-type-id is set to 2. After that, the peripheral status of n\({}_{\rm i}\) is determined. It finds out whether the radio circle of n\({}_{\rm i}\) is completely embedded within a zone. Three types of zone structures are considered: polygonal, circular, and elliptic. The polygonal structure is the closest to the real life scenario, while the circular structure is the ideal one, where the neighborhood of a node spreads around the node equally in all directions. Please note that the circle is a special kind of ellipse, where both foci are at the same point (the center). Therefore, both circular and elliptic structures have been considered in our simulation. Below, we derive the conditions under which a polygonal, circular, or elliptic zone embeds a radio circle of n\({}_{\rm i}\). If the radio circle of n\({}_{\rm i}\) is completely embedded in the zone, then pphr\({}_{\rm i}\) is set to 0; otherwise, it is 1. Situation 1: The zone under inspection is polygonal, defined by consecutive vertices (x\({}_{\rm v+q}\), y\({}_{\rm v+q}\)) s.t. 0 \(\leq\) q \(\leq\) Q; the node to be embedded has center (x\({}_{\rm i}\), y\({}_{\rm i}\)) and a radiorange ofrad\({}_{\rm i}\).