## 6 Network Layer for WVSN
### New Energy-Efficient and Single-Path Routing Protocol for WVSN
#### 6.1.1 Routing protocol for Sender-Mode of VSN  
In order to forward the received data in transport layer to next hop in a reliable way, the proposed single-path routing protocol goes through sender-mode phases as is delineated below:  
_Parent Selection phase_: This phase begins when an RTS is received from the transport layer. An appropriate parent is chosen by drawing on Pr-T and Pa-T in accordance with priority level which was mentioned in RTS. If any value other than zero exists in cell of Pr-T pointed to by priority (_l_) (Pr-T [_l_]), the value shows the relevant parent _ID_. Node selects this parent as a node to communicate with. In a case that Pr-T [_l_] content is zero, algorithm refers to Pa-T. Considering the parents which Pa-T[_l_] has the lowest priority level, the most appropriate parent according to energy and distance is selected by computing the value of _f(e,d)_. Therefore, the parent with maximum value of _f(e,d)_ is chosen and the _ID_ of the chosen parent will be put in all zero cells of Pr-T and _Remote Negotiation phase_ begins. If no acceptable parent exists in Pa-T, NCTS is sent as a notification to the transport layer and the algorithm waits for another RTS from _Parent Selection phase_.  
In order to distributing the energy consumption in the network and having fair energy management, \(e\) is used as the major factor for parent selection, and \(d\) is taken in to account to decrease hop-by-hop delay. Therefore, _f(e,d)_ is defined as _e\({}^{2}\)/d_. Also, some other literatures deployed energy and distance as two parameters for choosing next hop node as well in similar manner [38] and [39].  
_Remote Negotiation phase_: Three inter-node command messages are utilized for negotiating with remote node (selected parent) in transmission. After selecting a proper parent a message called Negotiation Message for Transmission (NMT) is forwarded to the selected parent. Next operation of routing protocol is influenced by Answer to NMT (ANMT) which could be positive (PANMT) or Negative (NANMT). Three conditions could occur at this stage:  
* Receiving PANMT: In this case, a PCTS is forwarded to transport layer to notify it and routing continues from _Preparing Data for Remote Transmission phase_.
* Receiving NANMT: Both Pa-T and Pr-T are updated by receiving NANMT. Priority field of selected parent in Pa-T is updated with value of priority level field of NANMT. Pr-T also changes; all cells with the _ID_ of selected parent are set to zero. Also, NCTS is sent to transport layer and routing proceeds from _Parent Selection phase_.
* Timeout: When selected parent does not respond to NMT in a specified time interval, the timer times out; then Pa-T and Pr-T become updated. Selected parent is eliminated from Pa-T and also all cells of Pr-T which contain the _ID_ of this parent are revalued to zero. Moreover, NCTS is forwarded to transport layer and routing starts from _Parent Selection phase_.  
_Preparing Data for Remote Transmission phase_: In this phase, data is received from transport layer and is put through dropping scheme (see Section 6.2.). Then, all data from current priority level is forwarded to the selected parent bursty. The routing is started from _Parent Selection phase_ after sending entire data to remote parent.  
Figure 10, shows a three-state state-machine which is used to reveal routing protocol in sender-mode. In this state-machine, conditions and operations are laid at the edges.  
Assuming the condition that no parent exists in Pa-T, routing protocol in sender-mode notifies transport layer and goes to sleep-mode. Whenever hierarchical network topology is reconfigured, routing protocol changes its mode and starts from _Remote Negotiation phase_.