Research and Implementation of a Wireless Sensor Network Ad hoc Network Protocol
2026-04-06 06:01:29··#1
1. Introduction Wireless sensor networks are composed of a number of low-power, small-sized sensor nodes that communicate wirelessly to form a network. These dispersed nodes can cooperate to monitor, sense and collect information about various environmental objects, and have a very broad application prospect [1]. In recent years, the research progress of wireless sensor networks has been very rapid and has achieved relatively rich research results. Self-organizing algorithms are one of the core technologies of wireless sensor networks. The good network topology structure automatically generated by self-organizing algorithms can improve the efficiency of routing protocols and MAC protocols, and can lay the foundation for many aspects such as data fusion, time synchronization and target positioning. It is also conducive to saving the energy of nodes to extend the life of the network. Researchers at home and abroad have drawn on valuable experience from ad hoc networks and proposed self-organizing algorithms with different forms and focuses. Reference [2] gives a traditional flooding algorithm, which is also the earliest and simplest routing protocol. Nodes send messages in the form of broadcast, and the nodes that receive the messages forward the data packets to all neighboring nodes in the form of broadcast. This process is repeated until the data packets reach the destination or reach the preset maximum number of hops. Reference [3] proposed the most representative hierarchical self-organizing algorithm (LEACH, low energy adaptive clustering hierarchy). LEACH is a low-power adaptive clustering routing algorithm designed by Heinzelman et al. of MIT for wireless sensor networks. It is mainly implemented by randomly selecting cluster leaders and distributing relay communication services evenly. Reference [4] gives the data-centric self-organizing algorithm SPIN (Sensor Protocols for Information Via Negotiation). Its main idea is to name the sensor data through a high-level description method - metadata. Before sending the real data, the sensor node broadcasts the metadata of the collected data description information. Only when there is a corresponding request will the data information be sent in a targeted manner. These studies have made progress in the self-organizing algorithm of wireless sensor networks. However, Flooding has the defects of message "implosion" and "overlap". The dynamic clustering of LEACH brings additional overhead such as topology transformation and a large number of broadcasts. The metadata in SPIN does not have a unified form. The topology change of SPIN is local, so it is not suitable for applications that require high reliability. There are many other related algorithms that remain in the theoretical research stage. These studies have made progress in self-organizing algorithms for wireless sensor networks, but they haven't considered many factors in practical applications, such as implementation difficulties, algorithm convergence, how to reduce external interference to communication, and how to add nodes after failure. Addressing the current state of research on self-organizing algorithms in wireless sensor networks, this paper first proposes a simple and easy-to-implement self-organizing protocol. Using the MSP430F149 microcontroller as the processor, a miniature sensor node was designed, and a low-power wireless network was implemented. The node, using the proposed protocol, can automatically generate a multi-level mesh network, determining the data transmission path according to the energy priority principle and including multiple backup paths. The developed host computer processing software can automatically display the network topology, reflect sudden changes in the state of sensor nodes, and display the network data transmission path in real time. It can also remotely control sensor nodes within the network. When the network topology changes, the host computer software will also reflect this promptly. The intelligent control strategy significantly reduces system power consumption. 2. Self-Organizing Protocol In the protocol, node self-organization is achieved by defining the format and keywords of data packets. The data packet contains a keyword and multiple bytes of data. By filling in the corresponding information according to the data packet format, self-organization can be achieved. The multiple bytes include node information, packet hop count, data routing, etc.; the keyword indicates different types of packets, distinguishing data in various situations and improving network communication capabilities. Information can be encrypted simply by changing the flag bits in the data packet. 2.1 Protocol Format The self-organizing protocol format is shown below. Pre represents the preamble; these characters are less prone to noise generation. Testing and experiments have shown that highly regular signals like 0x55 and 0xAA are not easily generated in noise. Key represents the keyword, distinguishing data in various situations. The receiving node will enter different data processing units based on these keywords. From represents the source address, which is the sending node's own information. Final represents the destination address of the data. Data represents valid data; these data use different formats depending on the Key character and can carry different information. Check represents the check bit, preventing the reception of erroneous data packets. Flag represents the end-of-packet flag. Based on the Key in the protocol format, the data packets piggybacked during node communication can be categorized into self-organizing network information, environmental change information, host computer control commands, broadcast information, etc. The following is an example of the data packet format when a node sends a state change signal. 0x55 and 0xAA are the data preamble, 0xFF is the keyword used by the sensor node to send data when it senses a state change, 0x11 represents the address of the sending node, 0x00 is the destination address of the data packet, 0x01 represents the hop count of the data packet in network transmission, the following 0x01 indicates the node's level in the current network, 0x15 represents the temperature collected by the node at that time, 0x20 represents the power supply voltage value collected by the node at that time, 0x03 represents the node's status, 0x00…0x00 are 11 bytes of valid data, which can record the addresses of the nodes the data packet passed through, 0x3A is the lower 8 bits of the sum of the preceding core data, serving as the data packet checksum, and 0xBB is the end-of-data packet marker. The receiving node needs to respond to the sending node; the following table shows the data packet format for responding to a state change. 0xFE represents the key character for responding to the state change, followed by the addresses of the sending and receiving nodes. 2.2 Self-Organizing Network Process The network consists of a base station node connected to a host computer and several sensor nodes. After power-on initialization, the base station node enters a low-power mode. Sensor nodes are randomly deployed. After power-on initialization, each sensor node first sends a command to the base station node requesting a level allocation, then enters a low-power state and starts a timer. If it receives a level allocation from the base station node within a set time, the sensor node sends a data packet containing self-organizing information to the base station node. If it does not receive a level allocation from the base station node within the set time, the node wakes up from the low-power state and sends the request command again, repeating this cycle. When a sensor node has sent a set number of requests for level allocation from the base station but still has not determined its level in the network, it broadcasts a command to the entire network, then enters a low-power state and starts a timer. When the timer expires, the node returns to the state of broadcasting commands. When the number of broadcasts by a sensor node reaches a set value, the node organizes the received response information, determines its level in the network, and identifies relevant information about its superior, peer, and subordinate nodes. The node then sends data packets containing this information to the upper-level node until the data packets are transmitted to the base station node, thus determining the topology of the entire network. The self-organizing process of the node is shown in Figure 1. Figure 1 Self-organizing process of the node 2 Hardware development In order to verify the proposed self-organizing protocol, this paper selects the MSP430F149 microcontroller with abundant on-chip resources as the processor and develops a miniature sensor node [5]. 2.1 Overall scheme The system consists of base station nodes and sensor nodes. The node hardware selected the MSP430F149 microcontroller and nRF905 radio frequency module that support low power operation mode, uses a 32 768 Hz low frequency crystal oscillator, and is powered by two AA batteries. In the process of designing the node, the design of the DIP switch, buzzer, and LCD indicator light greatly facilitated the debugging of the experiment. 2.2 Node design Figure 2 is a block diagram of the sensor node. The node is powered by batteries and is small in size, only the size of a lighter. [align=center] Figure 2 Sensor node block diagram[/align] The MSP430 series microcontroller is a mixed-signal controller produced by TI. Its outstanding advantages are low power supply voltage, ultra-low power consumption, battery operation, and long service life[6]. The nRF905 is a single-chip radio frequency transceiver launched by Nordic VLSI of Norway. It operates at low voltage and has very low power consumption. It operates on three ISM (Industrial, Scientific and Medical) channels of 433/868/915 MHz, and the switching time between channels is less than 650 μs[7]. The ShockBurst™ working mode can automatically process the header and CRC (Cyclic Redundancy Check). It communicates with the microcontroller through the SPI serial port, which is very convenient to use; it has built-in idle mode and power-off mode, which makes it easy to achieve energy saving. The nRF905 is suitable for many fields such as wireless data communication and wireless unlocking. The antenna design is a very important part of the entire system design. The system power consumption and network performance are closely related to the antenna design. The antenna design adopts an overall PCB loop differential antenna. Compared with traditional whip antennas, it not only saves space and reduces production costs, but also has a more stable and reliable structure. Since this paper mainly studies the self-organizing network and low power technology of wireless sensor networks, only the internal integrated thermistor of the MSP430 series microcontroller was selected to measure the working temperature of the node, but a large number of external sensor interfaces were reserved. The signal of the external sensor can wake up the node in the interrupt mode. 2.3 System power consumption The sensor node is powered by battery, and the power consumption directly affects the life of the entire network. The power consumption of the system is not only related to the selected components, but also to the control strategy of the entire network. Different control strategies will result in different working times of the system. If the node is expected to work for a year (365×24=8760 hours), the theoretical average working current is required to be about 263 μA (2300÷8760). The working time from transmitting data to receiving the response is about 50 ms, so the average sleep time before each operation can be calculated to be 2.3 s[8]. In practical applications, the working and sleep times of the system can be selected according to the network's response speed and the information sampling rate. 3. Software Development Low-power system design is a technology that integrates hardware and software. It requires the use of low-power chips while employing intelligent control strategies. For example, the system can run at full speed when needed, and then enter a low-power mode after processing events, waiting for external events to wake it up. The system software includes base station node software, sensor node software, and host computer processing software. 3.1 Base Station Node Software The main program of the base station node is relatively simple. After initialization, it enters low-power mode, waiting for external events to wake it up. External events include serial port interrupt events, received data events, and timer interrupt events. Figure 3 shows the serial port interrupt flow of the base station node. [align=center] Figure 3 Base Station Node Serial Port Interrupt Flow[/align] To prevent data loss during serial communication, a handshake protocol is added to the software design. When the base station node sends a data packet to the host computer, the host computer sends an acknowledgment signal to the base station node until the data packet is sent to the host computer. After receiving the data packet, the node wakes up from low-power mode and enters different processing units according to the different characters in the flag bits of the received data. When multiple sensor nodes communicate with a single sensor node simultaneously, channel contention occurs. To prevent data loss caused by simultaneous communication, a backoff mechanism is implemented in the software. On one hand, the CD (carrier sense) signal of the nRF905 RF chip is used to generate random delays to avoid simultaneous signal transmission. On the other hand, when one sensor node establishes a communication channel with another, other data-transmitting nodes will increase the number of data transmissions. 3.2 Sensor Node Software After initialization, the sensor node first sends a command requesting the base station node to assign a level, and simultaneously starts a timer for wake-up. Then, it enters a low-power mode, waiting for external events to wake it up. If the number of times the sensor sends a request for level assignment from the base station node reaches the set limit, and the node's level in the network is still not determined, the node will broadcast information to surrounding sensor nodes. When the number of broadcasts reaches the set value, the sensor node determines its own level and information about nodes directly connected to it based on the received information, and sends this information to the base station node. External interrupt events for the sensor node include data reception events, timer interrupt events, and state change events. When a sensor node detects a sudden change in state, it wakes up from a low-power state and promptly collects environmental parameters (including state variables, temperature values, and node voltage values), then sends this data out. This data packet reaches the base station node via single or multi-hop transmission and is displayed on the host computer software. 3.3 Host Computer Processing Software To monitor the entire network, a user-friendly human-machine interface needs to be established on the host computer. Visual Basic (VB) is used to design the human-machine interface. The MSComm control in VB is used to implement serial communication between the host and slave computers, and other controls are used to analyze, display, and operate the wireless sensor network. The host computer main program primarily initializes some variables and controls, then waits for serial port data. Data reception and transmission are both completed by interrupt routines, the process of which is shown in Figure 4. [align=center] Figure 4 Serial Port Interrupt Flow of the Host Computer[/align] After receiving a complete data packet, the host computer performs different processing based on the keywords in the data packet. When sending data, the path for relayed data is calculated based on the saved network data. To conserve the energy of the base station nodes, much of the data processing in the network is performed on the host computer. 4. Experimental Results After the system was developed, experiments were designed to evaluate the self-organizing network effect and network performance. The primary focus of the experiment was the networking of randomly distributed sensor nodes under a custom organization protocol. To evaluate the self-organizing effect, the base station nodes were first connected to the host computer via serial port, and the host computer processing software was opened. Then, the sensor nodes were powered on and arranged manually or randomly. Using the host computer processing software, the entire network topology and the environmental parameters of the network nodes could be clearly seen. When the host computer processing software detected a sensor node in the network, it displayed and saved the sensor node data on the host computer. Figure 5 shows the interface display when 11 sensor nodes were freely networked in the system demonstration. The networking time was approximately 3 minutes. The black curve in Figure 5 represents the data transmission path. Clicking on a node would pop up the node's information acquisition card. The information acquisition card reflects the node's status, temperature, voltage, and remaining energy, allowing for direct remote control of the node. [align=center]Figure 5 Network Topology and Data Transmission Route[/align] In the experiment to test network performance, sensor nodes were distributed level by level. The network topology, with its maximum hop count, can be clearly seen through the host computer software. Once the network is formed, each node can be remotely controlled via the host computer interface. When a node experiences a sudden state change, it is woken up via an interrupt, and data is transmitted level by level to the base station node based on energy priority, with corresponding displays on the host computer interface. When a new sensor node joins the network, the system promptly reflects the new addition. When the system detects that a sensor node has failed due to a power supply voltage lower than its operating voltage or human error, it removes the node's topology and related information from the network. Detection methods include manual refresh and timed sampling. Data transmitted within the network is stored in the network database for easy retrieval. The host computer software can also reset the network, allowing all sensor nodes to re-network. Conclusion This paper first proposes a self-organizing protocol for wireless sensor networks. Then, it designs miniature sensor nodes using the MSP430F149 and nRF905, and implements a low-power wireless network with the following characteristics: ① It automatically generates a multi-level mesh network using information carried by wireless communication and automatically generates data transmission paths according to the principle of energy priority. ② It adopts a response and backoff mechanism to prevent data loss caused by multiple sensor nodes sending data to a single node. ③ The wireless communication is bidirectional, allowing not only passive display of information from each sensor node but also active remote control of each sensor node. ④ It uses hardware supporting low-power operating modes, combined with intelligent control strategies in software, to achieve low system power consumption and extend network lifespan as much as possible.