# A Network Architecture and Routing Protocol for the MEDIcal WARNING System
## 5 The MultiPath Routing Protocol for MEDIWARN (MP-RPM)
### Init Phase  
The network nodes are initially unaware of the network topology, so they do not know the possible paths to forward the messages to their destination. Each node, with the exception of the end nodes, needs to build a routing table (_rTable_) during the init phase to keep track of the network topology. At the end of the init phase, each node will be able to choose, according to a configurable metrics, the best path to forward the messages to their destination. Each entry of the routing table of the node A contains the following data: the destination node (B) address, the number of hops (\(n\)) between A and B and the address of the node to which forward the message in order to reach B through \(n\) hops (i.e., the next hop).  
Since the network topology can change, the init phase needs to periodically run (with a configurable period, here called \(upd\_period\)). This period is configurable and depends on several aspects, such as the number of mobile nodes and their mobility pattern and the presence of moving obstacles. A lower value of \(upd\_period\) offers higher ability to react to network changes. However, as the \(upd\_period\) impacts on the overhead introduced by the routing protocol, a trade-off between the overhead introduced by MP-RPM and its reaction rate towards network changes must be determined.  
During this phase, the sink and the relay nodes run Algorithm 1.  
Both the sink and the relay nodes transmit an init message containing the address of the source node (i.e., the originating node of the init message), the number of hops field (\(hopCnt\)) that is initially set to 0 by the source node and then increased every time the init message is forwarded and a sequence number (\(seqN\)).  
The nodes that transmit the init message wait for other init messages. Each relay node and the sink will run the init algorithm until a timer, called the receive timer (_rcvTimer_), expires. The receive timer measures the time interval during which no messages are received. If no init messages are received for \(rcvTimerValue\) (i.e., a configurable time interval), the init phase ends.  
During the init phase, upon reception of an init message, both the sink and the relay nodes update their routing table as follows.  
* If the routing table does not contain an entry that specifies a route to the init message source node, then a new entry is added.
* If the routing table contains an entry that specifies a route to the init message source node, but the next hop is a different node than the one that just forwarded the init message from the same source, then a new entry is added.
* If the routing table includes an entry with a route to the init message source node and the same next hop, but with a higher number of hops than the one contained in the received init message (i.e., the \(bestPath()\) function returns \(false\)), then the routing table entry is updated with the new value for the number of hops.  
The relay nodes, i.e., the nodes for which the function \(isRelayNode()\) returns \(true\), forward the init messages received by the other nodes (i.e., both the relay nodes and the sink) according to a controlled flooding mechanism that avoids retransmitting the init messages that have been already forwarded.  
The end nodes discard any init message, as they are totally unaware of the network topology and the routing protocol.