## 3 Simulation of Underwater Electric Field Communication
### CSMA/CA Channel Backoff Algorithm Design and Simulation Analysis  
The design and simulation process of the CSMA/CA channel backoff algorithm for underwater electric field multi-node communication in underwater channels, targeting the backoff problem, is shown in Algorithm 1. ```
while Channel detection is ldle do Distributed inter frame spacing if Channel detection is Busythen Random backoff process Random number(R) selection Time slot t delay if Channel detection is ldlethen \(R=R-1\) if\(R=0\)then  Data transmission else  Time slot t delay endif else  Time slot t delay endif else  Data transmission endif endwhile
```  
**Algorithm 1** An algorithm with CSMA/CA backoff protocol  
The random backoff process in this system is based on the binary exponential backoff algorithm. It involves delaying transmission by randomly selecting a backoff time. During the backoff process, the basic backoff time is defined as a time slot, denoted as t. When an AUV enters the random backoff process, it selects a random backoff number, r, from the discrete integers [0, 1,..., (2k - 1)]. At the end of each time slot, the underwater channel is checked. If the channel is idle, r is decremented by 1; otherwise, r remains unchanged, and the AUV waits for another time slot before continuing to check the underwater channel. After continuously cycling through this process, when r becomes 0, the AUV can send the message. In this system, the DIFS (Distributed Inter-Frame Space) is set to 100 ms, and the time slot t is set to 100 ms. Figure 8 shows that when Node 0 was sending data, Nodes 1, 2, 3, and 4 were receiving underwater electric field communication data. Due to the detection of busy channels by all four nodes, they all needed to perform backoff algorithms and randomly backoff for a period of time before sending the data. From Figure 8, it can be seen that the backoff timer of Node 3 decreased to zero first, and then Node 3 completed the reception of communication data. When Node 3 was receiving data, Nodes 1, 2, and 4 detected that the channel was busy and made data input response requests. The values of their respective backoff timers were set to wait for the channel to become idle again. After Node 3 received the data and the DIFS had passed, the backoff timers of Nodes 1, 2, and 4 started counting down from their respective remaining time. As Node 1, Node 2, and Node 4 were competing for the channel, Node 2's backoff timer was reduced to zero first, so Node 2 received the data. Subsequently, Nodes 1 and 4 completed the reception of communication data in sequence. To verify the feasibility of the protocol in the AUV multi-node communication system, a simulation analysis of the protocol was first conducted using MATLAB. Figure 9 shows the dynamic backoff process of the protocol. The rectangles represent random backoff numbers, and the triangles represent ongoing transmissions. The simulation results for the CSMA/CA dynamic backoff protocol algorithm process are as follows:  
* At t = 1.85 s, Node 3 generated a communication request and detected an idle channel. After waiting for DIFS, the node started transmitting the entire frame (the first triangle in Figure 3);
* At t = 1.91 s, after Node 3 finished transmitting the signal, the channel became idle again and generated a new data transmission request. Nodes 1, 2, and 4 were in a random wait process, and Node 1, with the lowest random backoff number, started occupying the channel for data transmission;
* At t = 2.58 s, Node 2's random B number became 0, and the channel was not occupied. Node 2 started sending data;
* At t = 3.72 s, Node 2 requested to occupy the channel again, but after DIFS and two-channel detections, the channel was still not occupied by other nodes. Therefore, Node 2 was allowed to prioritize channel occupancy;
* At t = 4.73 s and t = 5.62 s, Node 1 and Node 4's random backoff numbers became 0 one after another, and they were allowed to use the channel. Figure 8: CSMA/CA backoff mechanism between five nodes.