# A MAC Protocol to Support Monitoring of Underwater Spaces +
## 3 Description of the UWSO-TDMA Protocol
### Initialization Phase
#### Clock Synchronization
If no acknowledgment is received, the node assumes its message has been corrupted for some reason and the most probable one is a collision. Then, a back-off algorithm is used for retransmitting the message. The back-off algorithm is similar to the basic ones used in CSMA networks. After the first collision is detected, the nodes involved choose successively and randomly a delay that varies from zero to 16 slots. In the first round, they choose between zero and one, in the second between zero and three slots. In the third round, they choose a delay between zero and seven slots and, finally, between zero and 15. These numbers may change if the nodes' density in a particular area is high. During the synchronization phase, the SB (_synchronization node_) is not aware of the amount of nodes listening and the transmission delay to reach them. It is for this that the SB (_synchronization node_) has to wait for a period of time large enough to allow the transmission of the nodes, as they may be waiting for the channel to be free. Given the maximum transmission range, the SB (_synchronization node_) waits for a time equivalent to \(2(c+2)\) maximum propagation delays, where \(c\) is the expected number of nodes in direct contact with the SB (_synchronization node_). The duration of this period is a parameter that can be enlarged or reduced according to the previous knowledge of the network topology. For example, assuming a maximum transmission range of 500 m and three nodes in direct contact, the waiting time will be 3.33 s according to Table 1. After this period, the SB (_synchronization node_) sends a new _synch_ message. This second message has the ID, time stamp and the IDs of successfully synchronized nodes and the adjusted time for each one. A node that has answered to the first _synch_ message, but is not acknowledge in the second with the adjusted time, is not synchronized and should send again the _asynch_ message. Figure 1 shows the message exchange and time evolution for the process when no collisions are produced. In Figure 1, when Node 2 receives the _synch_ message from the SB, it time stamps its own time as \(T_{21}\). After that, in \(T_{22}\), it is able to send the _asynch_ message to the SB. Node 3 is further away and repeats the actions of Node 2. At \(T_{12}\), the SB receives the _asynch_ message from Node 2 and time stamps its own time. The _asynch_ message contains \(T_{11}\), \(T_{21}\) and \(T_{22}\). With this information, the synchronization can be performed at the SB. \[\Delta t_{1}^{1} =T_{21}\,-\,T_{11}\] \[\Delta t_{1}^{2} =T_{12}\,-\,T_{22}\]  
The required correction is then obtained from:  
\[\Delta=\frac{\Delta t_{1}^{1}\,-\,\Delta t_{1}^{2}}{2} \tag{1}\]  
This protocol is similar to the one proposed for time synchronization in the Internet, Network Time Protocol (NTP, RFC 5905) [24]. The described process follows a top-down approach from the SB towards the end nodes. If a node has two or more parents, it has an equal number of possible synchronization sources. In this case, the node with the lower transmission delay is chosen as the synchronization node. In the case that two or more nodes have equal delay, the node listened first is selected. Figure 2 shows the synchronization process. First, the SB sends a _synch_ message (Figure 2a). Both Nodes A and B listen to it. They are not aware of the presence of each other; therefore, they answer with the _asynch_ message following the protocol described before. Let us suppose there is no collision and that Nodes B and A answer one after the other (Figure 2b,c). The SB recognizes both with a new _synch_ message indicating the time correction and the computed distance to the SB (Figure 2d). With this message, both Nodes A and B learn about the presence of each other. As they both know the delay to the SB and this is the parameter used to order the synchronization process, Node B sends first a _synch_ message (Figure 2e), and Node C recognizes it with an _asynch_ (Figure 2f).