The monitoring objects of modern monitoring systems are more and more complex and more and more dispersed, and signal acquisition terminals are distributed. Each signal acquisition terminal often uses a small, flexible, easy-to-control and cost-effective embedded system to form a relatively independent data acquisition system, and then transmits the data to the host computer through the network for unified analysis and processing [1]. The network communication protocol and software responsible for data transmission play an important role in the entire monitoring system. However, the electromagnetic interference of the surrounding environment and the CPU of the host computer may be occupied, which may cause network congestion, connection interruption, etc., if the software cannot find the fault in time. And the corresponding processing will directly affect the stability of the entire system, resulting in data acquisition interruption, and even paralyzed the system. Using the real-time operating system VxWorks to support multi-tasking, this paper proposes a network communication mode based on buffer queue, and adds network status monitoring function, which enables the system to respond quickly to network disconnection and other faults. The stability and reliability of network communication.
2 VxWorks and distributed data acquisition system introductionVxWorks is a high-performance, real-time operating system with microkernels that can be cut by Wind River Systems. It is suitable for all popular target CPU platforms, supports a wide range of network communication protocols, and provides developers with Efficient real-time multitasking scheduling, terminal management, real-time system resources and real-time inter-task communication are one of the most widely used real-time operating systems in the embedded world [2]. VxWorks uses a real-time network protocol stack compatible with 4.4BSD TCP/IP, making network development easy and portable. With VxWorks' good support for multitasking and Socket, network communication can be easily realized.
Figure 1 is a schematic diagram of the structure of a distributed monitoring system based on TCP/IP protocol. The system can be divided into three hierarchical structures: server, sampling node, and sensor. The sensor is responsible for collecting signals and converting the physical signals into electrical signals; the sampling node first preprocesses the signals, then converts the signals into digital signals through the A/D chip, and finally transmits them to the server through the network; the server is responsible for receiving, analyzing, and Store and display the results. The transmission and reception of data between the server and the sampling node through the TCP/IP protocol, the quality of the network communication program directly affects the stability and reliability of the entire system. TCP/IP protocol is a set of complete network communication protocols widely used at present. It can be used on a variety of channels and underlying protocols. It is a group of network communication that can realize heterogeneous interconnection based on any specific hardware platform. Protocols are widely used in network communications [3-4].
The specific performance is that the message queue is initially empty, and the data sending task is blocked on the message queue. When the network is normal, each time a new message unit arrives, the data sending task immediately sends the data packet pointed by the message unit; At some point, the network is unstable or temporarily blocked due to the influence of the external environment. The data packet cannot be sent in time. The data packet can be cached in the Buffer, and its address information is cached in the message queue without being lost. Send it out after normal. The network communication mode based on the buffer queue is shown in Figure 3. Depending on the urgency of the information to be transmitted, different tasks may choose to write message units to the cache queue based on FIFO or priority.
In the experiment, an ordinary PC is used as the upper computer server, and the sampling node and the server are connected by a 100 Mbps switch. All the acquisition channels of the sampling node are fully open, and the maximum sampling rate is set. The server queries the node status every 5 seconds. At this time, the data transmission rate is about 65 Mbit/s, and the system continuously runs for 8 hours. The experimental results show that the number of packets received by the server is the same as the number of packets sent by the sampling node, and the data transmission loss rate is 0.0%.
3 network monitoring principleWhen the network is interrupted, the system software should be able to detect network failures as soon as possible and still operate normally after the network is restored. Therefore, the software should have network monitoring functions to monitor network connectivity in real time. A relatively simple way to monitor network connectivity is to continuously send ICMP (Internet Control Message Protocol) packets to the sampling nodes through the server. If the response is received, the network connectivity is established, and vice versa. Although this method is simple, when there are many nodes, a large number of ICMP packets will occupy CPU resources and reduce the efficiency of the server, so this method is not feasible. Figure 4 is a schematic diagram of the network monitoring we designed.
In order to avoid affecting the real-time transmission of data, the two sides of the communication establish two socket ports, one is used as a data channel to transmit data information, the other is used as a monitoring channel, the response signal is transmitted, and the connectivity of the network is monitored; the monitoring channel is responsible for management. And maintain data channels. The monitoring tasks run on the node and server side are infinite loop tasks, which run every few seconds. In each cycle, the sampling node initiates a connection to the server. After receiving the connection request from the sampling node, the server establishes a connection with it and sends a signal command to it. After receiving the signal command, the sampling node sends a response signal to the server. If the server can receive the response signal within the T_wait time, it determines that the network is unobstructed, otherwise the network is considered to be interrupted. If the network is disconnected at a certain moment, after re-establishing the connection, the server will send a reconnection command to the sampling node. After receiving the reconnection command, the sampling node will close the original data transmission socket and re-establish the data transmission channel with the server.
During the experiment, the network connection and disconnection were simulated by plugging and unplugging the network cable. The result shows that the network cable is unplugged when the system performs data transmission. If it is connected within 20 seconds, the data will not be lost because the sampling node has a certain buffering capacity, and the network can still work normally. If the network cable is unplugged, it takes more than 20 seconds. Then connect the Internet cable, the connection between the sampling node and the server will be re-established, the network can still work normally, but the data will be lost due to the buffer queue overflow; if the network cable is unplugged for more than 30 minutes, the sampling node will determine the network interruption and record. The fault automatically shuts down the system. After the network cable is plugged in, the server remotely starts the sampling node through the network, and the system continues to work normally.
4 summaryUtilizing VxWorks' good support for multitasking and network, this paper proposes a network communication mode with network status monitoring based on buffer queue, which has been applied in the distributed monitoring system we developed. The network communication mode enables the system to cope with certain network failures and improve system reliability. This mode can also be easily applied to other embedded network development, and has broad application prospects. The author of this paper innovates: This kind of buffer queue-based network communication mode with network status monitoring function makes full use of VxWorks' good support for multi-task and network. Message queue not only synchronizes tasks, but also acts as a cache queue. To cache data, the system can cope with certain network fluctuations; the working mode of the monitoring task enables the system to quickly detect and respond to network failures, and still operate normally after network troubleshooting.
Water Purifier,Intelligent Temperature Control Water Purifier,Water Filter Purifier,Home Use Water Purifier
Shandong Sangle Group Co.,Ltd. , https://www.sangle-group.com