Development of an Arti ﬁ cial Fish Swarm Algorithm Based on a Wireless Sensor Networks in a Hydrodynamic Background

: The main objective of the present study is the development of a new algorithm that can adapt to complex and changeable environments. An arti ﬁ cial ﬁ sh swarm algorithm is developed which relies on a wireless sensor network (WSN) in a hydrodynamic background. The nodes of this algorithm are viscous ﬂ uids and arti ﬁ cial ﬁ sh, while related ‘ events ’ are directly connected to the food available in the related virtual environment. The results show that the total processing time of the data by the source node is 6.661 ms, of which the processing time of crosstalk data is 3.789 ms, accounting for 56.89%. The total processing time of the data by the relay node is 15.492 ms, of which the system scheduling and the Carrier Sense Multiple Access (CSMA) rollback time of the forwarding is 8.922 ms, accounting for 57.59%. The total time for the data processing of the receiving node is 11.835 ms, of which the processing time of crosstalk data is 3.791 ms, accounting for 32.02%; the serial data processing time is 4.542 ms, accounting for 38.36%. Crosstalk packets occupy a certain amount of system overhead in the internal communication of nodes, which is one of the causes of node-level congestion. We show that optimizing the crosstalk phenomenon can alleviate the internal congestion of nodes to some extent. Here, a true-world WSN measurement bed is designed and implemented through measurement experiments on independently designed wireless sensor nodes, including sensor nodes based on ATmega128 microprocessor, CC1100 radio frequency chip, and the PC-terminal data acquisition software. The serial ports can be used to collect and store information such as the number of packets, RSSI, and LQI. The throughput, packet reception rate, and packet loss rate are analyzed through MATLAB software. Aiming at the three-dimensional underwater WSNs, a self-deployment algorithm for ﬂ uid model nodes based on improved arti ﬁ cial ﬁ sh swarm is designed. Under the background of hydrodynamics, aiming at the three-dimensional underwater WSNs, a self-deployment algorithm for ﬂ uid model nodes based on improved arti ﬁ cial ﬁ sh swarms is designed. The nodes of this algorithm are viscous ﬂ uids and arti ﬁ cial ﬁ sh, while events are considered as the food for arti ﬁ cial ﬁ sh. Then, the node deployment process of UWSNs becomes a process of ﬂ uid ﬂ ow and arti ﬁ cial ﬁ sh looking for food. This is a distributed deployment algorithm, which prolongs the network life cycle and distributes node power consumption. The algorithm is suitable for node deployment of both two-dimensional UWSNs and three-dimensional UWSNs. This study provides important theoretical support for the deployment of sensor networks, which is bene ﬁ cial to the monitoring of sensors.


Introduction
In the 21st century, with the development of embedded computing, sensors, distributed information processing, and wireless communications, the wireless sensor networks (WSNs) have been widely used in fields such as data acquisition, environmental monitoring, smart home, military, and transportation [1]. Meanwhile, WSNs, bionic human organs, and plastic electronics are regarded as the world's three major high-tech industries in the future [2]. The networking of WSNs does not require fixed equipment as support. It is characterized by rapid deployment, strong resistance to damage, easy networking, and wired network-free [3]. These areas can be efficiently monitored in real-time through WSNs. To avoid invasive damage to the natural ecological environment, WSNs can also be applied to the monitoring of water resources (such as water diversion canals from the south to the north, reservoirs, and rivers) and atmospheric environment [4]. WSNs include two types, i.e., the underwater WSNs and the terrestrial 2 Methodology

WSN
The wireless sensor nodes in the monitoring area can form a network cooperatively, which senses and records the environmental information (including temperature, humidity, air pressure, and sound) in the nearby area. Then, the network converts the encoded data into digital signals, which are processed and forwarded by multiple sensors in the form of the data packet. The data packet is transmitted hop-by-hop to the convergence node then the computer and other equipment for processing and storage, which are transmitted to the users further via the Internet and satellite [11]. According to different routing methods of data transmission, WSNs are divided into two architectures, i.e., the planar structure and the hierarchical structure [12]. Fig. 1 illustrates a planar structure network. All nodes in the monitoring area transmit the collected data to the sink node in a wireless multi-hop manner, and the sink node transmits these data to the observer or user. The transmission method of the planar structure is simple. However, each node needs to build a path to the sink node, forming a large dynamic routing area. Therefore, it consumes enormous control information to maintain the route, resulting in additional energy overhead. As a result, it has poor scalability. Fig. 2 illustrates a hierarchical structure network. Unlike the planar structure, the sensor nodes in the monitoring area no longer transmit information to the sink nodes. Instead, they cluster the network under certain algorithms and mechanisms. Various nodes in the network are divided into multiple small ad hoc networks that are centered on the cluster head nodes and contain some cluster member nodes. The cluster member nodes only transmit the collected data to the cluster heads, and the cluster heads in each area form an ad hoc network. The information aggregated to the cluster head is transmitted to the aggregation node via wireless multi-hop between the cluster heads, forming multiple layers such as clustering networks and cluster-head networks. All the nodes in the hierarchical structure do not have to learn the path to the convergence node. Instead, the nodes only need to build a route to the cluster head node in the area, which reduces the cost of cluster member nodes and has good scalability [13]. The disadvantage is that the cluster head node needs to transmit various information and thereby bears a higher load. Therefore, the planar structure is more suitable for smaller networks, while the hierarchical structure performs better in larger networks.
The traditional WSNs protocol stack mainly includes five layers of protocols, i.e., physical layer, network layer, data link layer, transport layer, and application layer [14]. These protocols correspond to the Internet protocol stack. Usually, WSNs protocol stack also includes three platforms, i.e., energy management, mobile management, and task management. The protocol stack of WSNs is shown in Fig. 3. The two functional sub-layers of time synchronization and positioning are represented by inverted L-shapes. The major reason is that their functions are special; therefore, they not only need to provide information support for each layer of the network protocol but also coordinate with positioning and time

Satellite or network
The sensor nodes.

Network terminals and users
The base station node synchronization. Because of the application value of WSNs, the industrial and academic industries worldwide have valued this issue. The WSNs were started in the 1980s. Some international research results on WSNs gradually appeared. The United States and Europe have successively launched research programs for WSNs. In particular, the US Department of Defense and the National Natural Science Foundation of China have invested heavily in scientific research projects to support WSNs.

Artificial Fish Swarm Algorithm
The artificial fish swarm algorithm is an intelligent optimization algorithm based on fish swarm behavior. It mainly simulates fish swarming behaviors, following behaviors, foraging behaviors, and other behaviors. Through individual local optimization, it finally reaches the global maximum of the search group [15]. Animal autonomy refers to autonomous robots or entities that simulate animals. It is a way to show that animals can produce adaptive intelligent behaviors in complex and changeable environments. The concept of animal autonomy is introduced into the fish swarm optimization algorithm. A bottom-up design idea is adopted, and a behavior-based artificial intelligence method is used to form a new model for solving optimization problems. Since it is based on the analysis of fish behaviors, it is called the fish swarm model. The artificial fish swarm algorithm is formed by using this model in optimization. Generally, in a water area where the fish is the majority, the water area is also rich in nutrients. Based on   Figure 3: Protocol stack of WSN this feature, the foraging, swarming, and following behaviors of fish are simulated for global optimization, which is the basic idea of artificial fish swarm algorithm [16].
The artificial fish swarm algorithm is a swarm intelligence algorithm. The main mathematical model can be described as follows: In the n-dimensional target search space, a group is composed of N artificial fish, and the vector Eq. (1) can be used to represent the state of each artificial fish: where Xi (i = 1, 2, …, n) is the variable to be optimized. Xi represents an object in the fish swarm. The food concentration at the current location of the artificial fish is expressed as Eq. (2): where Y is the objective function. The distance between the individual artificial fish can be expressed as Eq. (3): where "visual" represents the perception range of artificial fish; d represents the congestion factor; "step" represents the step length of artificial fish movement; "trynumber" represents the maximum number of trials per artificial fish foraging.
(1) Foraging behavior is one of the basic behaviors of artificial fish, which is also an act of individual artificial fish toward food. Artificial fish use vision to sense the concentration of food in water and decide what kind of behavior to take.
Behavior description: The current state of artificial fish i is assumed as X i , and a state X j within its visual perception range is randomly selected.
where "Rand ()" is a random number between 0 and 1. For the problem of finding the maximum value Y i < Y j (Y i > Y j in the case of finding the minimum value; the problems of maximum value and minimum value can be converted mutually; the following discussions only involves the maximum value problem), it moves one step forward (Eq. (5)).
(2) Swarming behavior. Fish will naturally swarm into a herd while looking for food. This kind of life characteristic is to ensure the safety of the entire herd and avoid predators. Birds and fishes have such a swarming method. Generally, they do not need to have a leader. If everyone follows some rules of local interaction, the swarming phenomenon as a global pattern will be shown in the local and individual interactions.
Behavior description: In nature, to ensure the survival of the group and avoid the danger, the fish will naturally swarm into a group while swimming. The artificial fish swarm algorithm makes the following two rules for each artificial fish: (1) try to swim to the center of the neighboring partner; (2) try to avoid overcrowding.
The current state of the artificial fish is assumed as Xi, the number of partners n f and the center position X c within the current field of view (di, j < Visual) are explored. Y C =n f > dY i indicates that the concentration of food in the center of the partner is high and not too crowded; therefore, it moves one step towards the center of the partner (Eq. (6)).
Otherwise, foraging behavior is performed.
(3) Following behavior. While fish are looking for food, if one or several fish found food, the neighboring partners will follow and quickly track to the position of the food (Fig. 4). Fig. 4 illustrates that artificial fish 1 is the artificial fish with the highest food concentration in the respective fields of vision of artificial fish 2-6. Its food concentration is Y j , and C 1 is a circle with artificial fish 1 as the center and its field of view as the radius. The closer the other artificial fish is to artificial fish 1, the better the state of the artificial fish is.
Behavior description: The following behavior is the behavior of chasing artificial fish near a high food concentration. In the artificial fish swarm algorithm, it is a process of advancing to the nearest partner with the best fitness value. The current state of the artificial fish i is assumed as X i , the partner X j within the current field of view (di, j < Visual) is explored. Y C =n f > dY i indicates that the concentration of food in the center of the partner X j is high and its surrounding area is not too crowded; therefore, it moves one step towards the center of the partner X j .
Otherwise, foraging behavior is performed.
The flowchart of the artificial fish swarm algorithm is shown in Fig. 5:

Node Deployment Algorithm of the Fluid Model
Although the artificial fish swarm algorithm has low requirements for parameter setting, objective function, and initial value, it also has the advantages of global optimization and parallel processing. However, disadvantages also exist. For example, some individuals do not participate in the foraging of the fish swarm, causing a waste of resources such as calculation and space. Also, the efficiency of the algorithm operation is affected. Also, if the parameters are not set properly, the algorithm only finds the approximate interval range of the optimal solution. Since it is difficult to find the optimal solution, the solutions oscillate near the optimal solution. Besides, if the problem to be solved is a large system, the overall performance of the algorithm will be greatly reduced, which ultimately makes it difficult to obtain optimal results. In the underwater environment, the node first uses the viscous fluid model to self-deploy to complete the coverage of the monitoring area. Then, based on the monitoring area, the fish swarm algorithm is used to monitor the occurrence of the event to efficiently complete the monitoring task. The basic fish swarm algorithm has good performance in places with evenly distributed events. However, in deployment scenarios with uneven distribution, the performance will decrease. In areas with a high incidence of events, nodes need to consume much more energy than in areas with a low incidence of events. In this way, the energy consumption of nodes in the entire network will be uneven, and it will easily cause premature failure of nodes in areas with a high incidence of events.

Structure of the Measurement System
Measurement is an essential means for network performance research. A network is built in a simulated or real environment. Through the operations of nodes in the network, specific performance parameters are observed, including the data processing speed inside the microprocessor of the node, the duty cycle the system, the working frequency, the data transmission rate, and the signal strength. Also, the in-depth analysis and evaluation of WSN are performed on node working efficiency, network transmission performance, link quality, system configuration rationality, and protocol mechanism performance. Such analyses provide a critical basis for optimizing the node hardware and software systems, the reasonable allocation of network resources, the improvement of protocols and mechanisms, and the setting of parameters. In summary, measurement is an indispensable foundation for network research [17].
The structure of the WSN measurement system in this study is shown in Fig. 6. The Tiny OS system program can compile a file with a suffix of .hex, and download the .hex file to the node through the progress node programming software. The data are transmitted to PC through serial ports for observation and storage.

Carrier Sense Multiple Access (CSMA) Measurement Experiments
In the Carrier Sense Multiple Access (CSMA) measurement experiment, the packet rate of the source node of the experiment is 50 PPS, i.e., the set packet interval is 20 ms. By calculating the sending interval of each data packet, the real duty cycle of the node, and the change range of the total back-off window is obtained. The size of the back-off window is causally related to the probability of the node accessing the channel. When a large back-off window is randomly selected, the probability of a node accessing the channel decreases, the SPI bus duty cycle decreases, and the utilization rate decreases, resulting in the transmission of the next data packet being suppressed because it cannot preempt the channel. The competition-based media access control (MAC) protocol can adjust the back-off window of each node based on the measurement results, the actual network scale, and traffic needs. In WSNs where traffic is aggregated, the data traffic borne by relay nodes increases hop-by-hop. The fallback window should be reduced for a larger channel access probability. The relative traffic of its child nodes is relatively small, which can increase the back-off window, so that the probability of accessing the channel is reduced, thereby avoiding data congestion at the relay node caused by the excessive back-off window. Also, it can prevent excessive channel conflicts, which will result in the waste of energy and unnecessary resources, due to the excessively small back-off window. Thus, network performance is improved in terms of throughput, latency, and energy consumption [18].

Node Deployment Results
For the influence of water flow, an ad hoc mobile node deployment strategy with dynamic adjustment of node positions is adopted. After the deployment is completed by using the algorithm, in the deployment area, the coverage and uniformity indicators of the nodes in the sensor network are measured with a time interval of T. If the relevant performance indicators are not met, it indicates that the node position has changed with the flow, and the network needs to be redeployed to meet the network monitoring quality requirements. The node deployment process of the UWSNs is also a dynamic node deployment process.
Two scenarios, i.e., normal deployment and obstacle deployment, are selected to test the performance of the algorithm. Three performance evaluation indicators of coverage, uniformity, and coverage effectiveness are selected in simulation experiments. Also, a comparison experiment with the self-organization map (SOM) deployment algorithm on the coverage efficiency is performed. For the problem of network connectivity, the non-conservative viscous fluid model considers the viscosity coefficient of the actual fluid. Therefore, sensor nodes in the network are not excessively dispersed during deployment, and the connectivity between network nodes can be better solved in actual deployment. Also, in the setting of the simulation parameters, the communication radius of the node is set to be twice the sensing radius, which also theoretically solves the problem of network connectivity [19].  Figure 6: Structure of the WSN measurement system In a normal deployment scenario, nodes detect and collect information within the sensing radius Rs. Similarly, it will be subject to external forces from neighboring nodes or obstacles within Rs. The communication radius Rc of the nodes must be larger than the sensing radius Rs. Thus, the nodes can freely exchange information with the nodes within their communication radius. The initial position of the node is in the center of area G. At the initial moment of deployment, the density of nodes in the deployment area is exceptionally large. When the deployment begins, all nodes are subject to unbalanced behavior and move to other parts of the area mouth. Eventually, they reach an equilibrium state. The changes in the two indicators of node coverage and uniformity during deployment are shown in Fig. 7. Fig. 8 illustrates the changes in the two factors of node coverage and uniformity during deployment with obstacles. Due to the presence of obstacles, nodes cannot achieve full coverage, and the maximum coverage is less than 0.9. Meanwhile, compared with Fig. 7, after reaching the equilibrium state, the uniformity value is also slightly higher, which is due to the reduction of uniformity by the existence of obstacles.

WSN Measurement Results
In this experiment, the length of the data packet is 25 Bytes, the length of the ACK packet is 8 Bytes, and the transmission rate is 100 kb/s. The transmission delay of a data packet sent or received by a node over a wireless link is 2 ms, and the transmission delay of an ACK packet sent or received is 0.64 ms. According to the experimentally measured timing, for the SPI bus, the transmission time to process a data packet is 0.871 ms, and the transmission time to process an ACK packet is 0.279 ms. The same transmission time is also required for crosstalk data packets or ACK packets. The measurement results Tab. 1 showed that the total processing time of the data by the source node is 6.661 ms, of which the processing time of crosstalk data is 3.789 ms, accounting for 56.89%. The total processing time of the data by the relay node is 15.492 ms, of which the system scheduling and the CSMA rollback time of the forwarding is 8.922 ms, accounting for 57.59%. The total time for the data processing of the receiving node is 11.835 ms, of which the processing time of crosstalk data is 3.791 ms, accounting for 32.02%; the serial data processing time is 4.542 ms, accounting for 38.36%.
According to the analysis of the measurement and calculation results, in the actual communication process of the multi-hop network using the Tiny OS system, the extra overhead of the crosstalk data packet from the source node is large, and the crosstalk data packet may inhibit the data packet rate of source nodes under high-load traffic. The total cost of data processing by the relay node is the largest, and most of it is occupied by the system scheduling and internal mechanisms. In a network where the traffic is aggregated, the traffic load of the relay node relative to the source node is large, and both transmission and reception require time overhead, which limits the effective throughput of data packets [20].

Discussion
The deployment strategy of nodes in WSNs directly affects the network topology, network quality, coverage degree, and the monitoring quality of the network. Especially, in complex and harsh environments such as mountains, oceans, and bad weather, sensor nodes are prone to failure or movement, which is unfavorable for the monitoring of WSNs. Despite the terrestrial WSN or UWSN environment, the top priority is designing an algorithm for deploying superior nodes that can adapt to complex and changing environments, thereby completing the specific monitoring tasks. The precise measurement analysis can be used to derive the timing details of system scheduling and data communication, providing a basis for system and network protocol improvement. The measurement and analysis results show that crosstalk packets occupy a certain amount of system overhead in the internal communication of the node, which is one of the causes of node-level congestion. The optimization of the crosstalk phenomenon can alleviate the internal congestion of the node to a certain extent. The results are consistent with those of the above-mentioned studies.

Conclusion
The application of artificial fish swarm algorithm in WSN measurement under the background of hydrodynamics is explored. Based on the previous research, the node deployment algorithm of an ideal fluid model is discussed according to location information. The fluid model node deployment algorithm of an artificial fish swarm algorithm is adopted, and the effects of water flow in the actual deployment The differences between an idealized model and an actual application in simulation environments are optimized, and measurement results closer to the actual application are provided. Based on the platform, a multi-hop network is constructed, and the timing of SPI and serial port timing is measured for the internal communication flow of the node. The proposed WSN node deployment algorithm is based on large network node deployment experiments in complex environments. Due to the experimental conditions, currently, the network virtual deployment is performed only through simulation software and digital satellite maps. Absolutely, there are differences between the simulation experiment and the actual deployment tests. In the subsequent study, actual tests will be performed to verify the algorithm performance.