Disclosure of Invention
The invention provides an application method of an ad hoc network protocol, which solves the problems that the existing protocol stack in the prior art needs to set the functions of equipment in advance, all equipment cannot be the same function, thus the network possibly has a fixed center node to cause inflexibility of the network, the position of the equipment is always unchanged for a fixed application scene, the advantages of the ad hoc network are not existed, and the time and resources consumed by the ad hoc network are still high.
The technical scheme of the invention is realized by the following steps of S1, networking through a full-peer Mesh structure, mutually and cooperatively completing network construction and route forwarding and communication by all nodes, S2, dividing the same equipment in different areas or different equipment in the same area into different networks, distinguishing the different networks through network IDs, and physically isolating the different networks through different channels, S3, carrying out data interaction between a single network and a broadcasting communication through unicast communication, carrying out unicast communication by taking a unique ID set in each equipment as a communication address when unicast communication is selected, S4, carrying out interaction by adopting a master-slave communication mechanism, carrying out communication by a set host, carrying out interaction by the nodes, waiting for a host command to respond by the nodes, and carrying out data communication with other slave nodes, S5, when the slave terminal module operates, not taking part in a supervision and network access process, carrying out data interaction with the nodes by adopting a quick binding slave communication and carrying out data interaction with the host, carrying out data interaction with the host through a management mechanism, carrying out data interaction with the host and carrying out the host management mechanism according to the state regulation and the host, completing the data interaction with the host according to the requirements.
At present, the conventional network initialization flow is as follows:
1) Determining a network coordinator. It is first determined whether a node is an FFD node, and then it is determined whether this FFD node is in another network or whether a coordinator already exists in the network. By actively scanning, a beacon request command (Beacon request command) is sent, then a scanning period is set, if no beacon is detected within the scanning period, the FFD is considered to have no coordinator within its pos, then its own Zigbee network can be established at this time, and the coordinator as the network continuously generates and broadcasts out a beacon.
2) And performing a channel scanning process. Including both energy scanning and active scanning, by first performing energy detection on a designated channel or a default channel to avoid possible interference. The measured energy values are channel ordered in an incremental manner, channels for which those energy values exceed the allowable energy level are discarded, channels for which the allowable energy level are selected and marked as available channels. And then actively scanning to search network information in the communication radius of the node. The information is broadcast in the network in the form of beacon frames which are obtained by the node by means of active channel scanning and from this information a best, relatively quiet channel is found, and from the recorded result a channel is selected which should have the least number of Zigbee networks, preferably no Zigbee devices. During the active scan, the mac layer will discard all frames received by the phy layer data service except for the beacon.
3) Configuring network parameters (setting network ID). After finding the appropriate channel, the coordinator will select a network identifier (PAN ID, value < = 0x3 FFF) for the network, which ID must be unique in the channel used and cannot collide with other Zigbee networks. The PAN ID may be obtained by listening to the IDs of other networks and then selecting an ID that does not collide, or the scanned channel may be manually specified to determine the PAN ID that does not collide with other networks later. There are two address modes in the Zigbee network, an extended address (64 bits) allocated by the IEEE organization for unique device identification and a short address (16 bits) for device identification in the local network.
As a preferred embodiment, the Mesh structure in step S1 uses a full peer-to-peer network protocol stack, and uses encryption to transmit data in the bottom layer and the data transmission process through a discrete routing algorithm, so as to ensure the security of transmitting data.
As a preferred embodiment, in the step S2, a plurality of routing nodes are disposed in different networks, and the routing nodes have autonomous selection rights for the next hop of the data packet transmitted by the routing nodes, and when the network topology changes and the path is lost, the routing nodes transmit the data packet to the optimal next hop node as much as possible.
In the step S2, when the physical isolation is performed, the physical channel is set, the user may set the range to 0x 00-0 x7f, and when the highest bit7 of the user set value is set to 1, the values of bits 0-6 are invalid, and the channel is automatically configured according to the network ID.
In a preferred embodiment, when the broadcast communication is adopted in the step S4, if the Zigbee module is set as the host, data forwarding is performed according to the address specified by the collector, and when the slave module operates, only the data of the host and the supervision are received and forwarded, and the slave does not perform data communication with other slave nodes.
As a preferred embodiment, the management flow of the host in the step S5 is that S51 is firstly performed with serial port adapting operation of resetting and powering up, then the lists are synchronized, S52 is performed with judging the connection state of the test white list node, updating the connection state, updating the topology relation, caching the original topology relation after updating the topology relation, S53 is performed with heartbeat processing, then data communication processing, and updating the connection state at the same time, and S54 is performed with network maintenance processing.
The node comprises three states, namely a first non-network-connected state and a non-registered state, wherein the second non-network-connected state and the registered state, and the third non-network-connected state and the registered state, wherein the non-network-connected state is a state that after the node is electrified, a heartbeat of a host is not found, connection of the host is not tested or connection of the host is not successfully tested, the non-registered state is a state that the node does not store host information records, the node belongs to a blank node, whether the node is network-connected or not tests whether the host exists according to the recorded host and network information, so that whether the node is network-connected or not is confirmed, and meanwhile, the network-connected state of the node is notified to the host through the process.
After the technical scheme is adopted, the invention has the beneficial effects that the function of equipment is required to be preset based on the existing protocol stack, all equipment cannot be in the same function, and the network has the defect that a fixed center node causes inflexibility of the network. Each device in the invention can dynamically identify network information and dynamically adjust the identity of the device to perform normal work, and can realize dynamic fusion under multiple networks so that the network information is not crossed, therefore, the invention can dynamically and adaptively construct a centerless dynamic network under complex environment and special scene, and ensure that the network can still normally communicate without manual intervention under the condition of dynamic fault.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Examples:
The application method of the self-networking protocol comprises the following steps of S1 networking through a full-peer Mesh structure, enabling all nodes to complete network construction and route forwarding and communication in a coordinated mode, S2 dividing the same equipment in different areas or different equipment in the same area into different networks, distinguishing the different networks through network IDs and carrying out physical network isolation through different channels in the different networks, S3 enabling a single network to carry out data interaction with broadcast communication through unicast communication, enabling a unique ID set in each equipment to serve as a communication address when unicast communication is selected, enabling the unicast communication to carry out interaction through a master-slave communication mechanism, enabling the set hosts to initiate communication through the nodes, enabling the nodes to wait for host commands to respond, enabling a slave end to not carry out data communication with other slave nodes, S5 enabling a supervision end module to take part in the network communication process through carrying out point communication of fast binding the slave end and communication, carrying out data interaction with the master end, managing the slave end communication with the nodes through the master end communication mechanism, and carrying out data interaction with the slave end node regulation and the master end communication node according to the state regulation and the master end communication state.
The application adopts a discrete routing algorithm, has fast networking speed, fast network topology response, high communication efficiency and stability, and adopts encryption transmission data transmission safety and reliability in the bottom layer and the data transmission process.
Unlike traditional Zigbee ad hoc network protocol, all nodes are completely peer-to-peer by adopting a full-peer Mesh structure for networking, and network construction, route forwarding and communication are completed in cooperation with each other. When the distributed routing algorithm is adopted, the method only records, stores and updates neighbor information, so that the method has the characteristics of 1, large network capacity, convenient network expansion, 2, rapid topology change response and strong adaptability to the environment of the difference signal. The method has the advantages of high path repair speed, high data transmission efficiency and reliability, support of rapid change and adaptation of network topology, support of rapid route repair, and no sense of route change in the communication process.
For convenience of management, when networking applications, the same devices in different areas or different devices in the same area are generally divided into different networks. Thus, the devices of the same network can communicate with each other, and the devices of different networks are isolated from each other. The different networks are uniquely distinguished by a "network ID". If the "network IDs" are different, devices with different "network IDs" are logically completely isolated. To further isolate different network devices, setting to different channels is also supported to achieve physical network isolation. When setting the physical channel, the user can set the range to be 0x 00-0 x7F. When the highest bit7 of the user set value is set to 1, the values of bit0 to bit6 are invalid, and the module automatically configures a channel according to the network ID. By default, the channel value is 0x80, the module logically uniquely divides the network according to a "network ID", and physically automatically isolates the network using different (and possibly the same) channels.
And supporting unicast communication and broadcast communication, and designating a destination address is required during unicast communication. Thus, each device is assigned a unique ID, referred to as the "native ID". When unicast communication is performed, the "local ID" of the destination ID is designated as the destination address, and unicast communication can be realized. Specific network partitions are shown in fig. 4 below.
The fact that the available channels are shown in fig. 4 as physically dividing different nodes, the network ID logically dividing different nodes, the local ID and the destination ID designating both the transmitting and receiving party, is not fully adapted to the actual application, and mainly has the following problems that if there are too many nodes initiating communication simultaneously in the network, the network blocks or loses data, in some applications, network authorization is required, and the unnecessary nodes are not allowed to participate in communication, so that the nodes can be automatically configured and automatically divided into different networks and different channels, and user participation is not required. (the network is divided to avoid too much overcrowding of the same area). Some communications need not be routed across, but need only be done locally. In order to adapt to the situation, the network management function is built in the module, the master-slave communication mechanism is the communication mode of most data acquisition systems at present, each operation process of the master-slave communication mechanism is initiated by a host, and the node only waits for a host command to respond. Therefore, in the network, only one node can be ensured to communicate at any time, so that the stability of the network is ensured. If the Zigbee module is set as the host end, the Zigbee module forwards data according to the address appointed by the collector. When the slave terminal module operates, only the data of the host terminal and the supervision terminal are received, and the data are forwarded to each other. The slave side does not communicate data with other slave nodes.
When the monitoring end module operates, the monitoring end module does not participate in the network access process and does not need to carry out multi-relay route forwarding, so that the monitoring communication adopts a point-to-point communication mechanism for quickly binding the slave and communicating to carry out data communication. The module is based on HYXQ-053B protocol stack, supports route and non-route communication mode at the same time, and adopts master-slave communication mechanism + point pair communication mechanism to combine with each other, host management network host machine to complete the following functions:
1. a unique and random network ID is generated and the network ID of the managed node is set to that ID.
2. And sending the heartbeat of the host computer to enable the node to actively attempt connection.
3. And managing the white list, and enabling the node with the network access authority to join the network.
4. And managing and actively reporting, and allowing all devices to access the network according to requirements.
5. And managing and updating the node online state. The host management flow is shown in fig. 5 below.
In the step S1, the Mesh structure networking adopts a full peer-to-peer network protocol stack, adopts encryption transmission data in the bottom layer and the data transmission process through a discrete routing algorithm, ensures the safety of the transmission data, and only records, stores and updates adjacent information when networking through the Mesh structure networking.
In the step S2, a plurality of routing nodes are arranged in different networks, each routing node has independent selection right for the next hop of the data packet transmitted by the routing node, and when the network topology changes and the path is lost, the routing node can transmit the data packet to the optimal next hop node as far as possible.
In the step S2, when the physical isolation is performed, the isolation is performed by setting a physical channel, when the physical channel is set, the user can set the range to 0x 00-0 x7f, when the highest bit7 of the user set value is set to 1, the values of bit 0-bit 6 are invalid, and the channel is automatically configured according to the network ID.
In the step S4, if the Zigbee module is set as the host, data forwarding is performed according to the address specified by the collector, and when the slave module operates, only the host and the supervisory data are received, and the data are forwarded to each other, and the slave does not perform data communication with other slave nodes.
The management flow of the host in the step S5 is that S51 is firstly conducted with serial port adapting operation of resetting and powering up, then lists are synchronized, S52 is conducted, connection states of the nodes of the test white list are judged, connection states of the nodes of the test white list are updated, the topology relations are updated, the original topology relations are cached after the topology relations are updated, S53 is conducted, after the topology relations are updated, the host sends heartbeat processing, then data communication processing is conducted, the connection states are updated at the same time when the data communication processing is conducted, and S54 is conducted finally.
The node comprises three states, namely a first non-network-access state and a second non-network-access state, wherein the first non-network-access state is a non-network-access state and the second non-network-access state is a registered state, the third non-network-access state is a network-access state and a registered state, the non-network-access state refers to a state that after the node is powered on, a heartbeat of a host is not found, connection of the host is not tested or connection of the host is not successfully tested, the non-registration state refers to a state that the node does not store host information records, the node belongs to a blank node, whether the node accesses the network or not is tested according to the recorded host and network information, and therefore whether the node accesses the network or not is confirmed. The network-unreceived means that after the node is powered on, the heartbeat of the host is not found, the host connection is not tested or the connection of the host is not tested successfully. Unregistered means that the node does not store host information records, and belongs to a blank node. The node accessing the network refers to the process that the unregistered node searches for the host, requests connection and obtains approval, and finally obtains corresponding network information.
The node is connected to the network, for the registered node, it tests whether the host exists according to the recorded host and network information, thereby confirming whether the host is connected to the network, and at the same time, the network connection state of the host node is notified to the host through the process. If the node is registered and is not connected to the network, but the host computer test fails, after the designated times of retries, the node considers that the network information is wrong or the host computer is lost, and the registration process is carried out.
The node network access logic needs to cooperate with a host to process, and the logic is divided into node processing logic and host processing logic. The design supports two networking management modes of white list management and active reporting management. In order to better ensure the accuracy and reliability of network access, the registration process of network access is divided into two modes of white list registration and active reporting registration aiming at the two modes. When the node is connected to the network, the host is preferably searched in a white list mode, and after the host is unsuccessful (and the network connection time of the active reporting mode is allowed to arrive), the host supporting the active reporting network connection is started to be searched for network connection. I.e. the white list networking priority is higher than the active reporting networking.
As shown in fig. 6, the present module manages networks and communications using a whitelist mechanism. When the white list manages the network, the node is used for judging the legitimacy of the node, and automatic networking is realized according to the white list (when the white list is reported independently, if the host is successful in networking, the node is also added into the list). When the network works, the state of the host can be normally tested only if the nodes exist in the host side list, and data communication is normally realized. During communication, the node sends out data, the data which is filtered by the white list and does not exist in the list is ignored. And the host computer issues data according to the white list, and the data request which does not exist in the list returns an error.
The foregoing description of the preferred embodiments of the invention is not intended to be limiting, but rather is intended to cover all modifications, equivalents, alternatives, and improvements that fall within the spirit and scope of the invention.