Disclosure of Invention
In order to solve the technical problem, the invention provides a short data message sending method based on a Zigbee network, which can directly carry a short data message to be sent in a route request message when a Zigbee device searches for a route, so as to achieve the purposes of reducing the sending times and improving the response time.
The technical scheme provided by the invention is as follows:
the invention discloses a short data message sending method based on a Zigbee network, which comprises the following steps: s100, broadcasting a routing request message from a source node to surrounding adjacent nodes; s200, when any node receives the routing request message, judging whether the current node is a target node; if yes, executing the next step; s300, if the current node is the target node, further judging whether the routing request message carries a short data message; s400, when the routing request message is judged to carry the short data message, the routing request message is analyzed, and the short data message is obtained.
When the Zigbee equipment searches for the route, the short data message to be sent is directly carried in the route request message, so that the purposes of reducing the sending times and improving the response time are achieved.
Further preferably, the step S100 further comprises, before the step S: s000, modifying the routing request message, and adding a flag bit to a frame control domain of the head of the routing request message; the flag bit is used for marking whether the routing request message carries a short data message.
The invention modifies the original route request message to lead the original route request message to carry the short data message incidentally, and when the route searching is successful, the short data message reaches the target node, thereby improving the response time of data sending.
Further preferably, the step S300 of determining whether the routing request packet carries a short data packet further includes the steps of: s310, analyzing the routing request message to obtain a flag bit in a frame control domain of the head of the routing request message; s320, judging whether the value of the flag bit is a preset value, if so, carrying a short data message by the routing request message.
The invention modifies the frame control field of the head part of the routing request message, increases the flag bit for marking whether the short data message is carried, has small modification on the basis of the prior message format, and is convenient for the target node to judge, separate and analyze the short data message.
Further preferably, the step S200 further includes the steps of: s500, if the current node is not the target node, broadcasting the routing request message to the surrounding adjacent nodes.
Further preferably, the step S400 further includes the steps of: s600, when the routing request message is judged not to carry the short data message, a routing response message is fed back from the current node to the initiating node.
The invention also discloses a short data message sending device based on the Zigbee network, which comprises the following components: the message broadcasting module is used for broadcasting the routing request message from the source node to the nodes adjacent to the periphery; the first judging module is used for judging whether the current node is a target node or not when any node receives the routing request message; the second judging module is used for further judging whether the routing request message carries a short data message or not when judging that the current node is a target node; and the processing module is used for analyzing the routing request message and acquiring the short data message when the routing request message is judged to carry the short data message.
Further preferably, the method further comprises the following steps: the message modification module is used for modifying the routing request message and adding a flag bit to a frame control domain of the head of the routing request message; the flag bit is used for marking whether the routing request message carries a short data message.
Further preferably, the second determination module further includes: the analysis submodule is used for analyzing the routing request message and obtaining a flag bit in a frame control domain of the head of the routing request message; and the flag bit judgment submodule is used for judging whether the value of the flag bit is a preset value or not, and when the value of the flag bit is the preset value, the routing request message carries a short data message.
Further preferably, the message broadcasting module is further configured to broadcast the routing request message to neighboring nodes through the current node if the current node is not the target node.
Further preferably, the method further comprises the following steps: and the message feedback module is used for feeding back a route response message from the current node to the initiating node when the route request message is judged not to carry the short data message.
Compared with the prior art, the method adds a little short data message to be sent to the target node between the head and the load in the original Zigbee routing request message, the short data message and the routing request message use the same message head and broadcast to the adjacent nodes around in a multicast mode, after the routing is successfully found, the routing request message is already sent to the target node, and the target node directly takes out the short data message from the routing request message for analysis and processing, so that the message sending times are reduced, and the data sending response time is prolonged.
Detailed Description
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following description will be made with reference to the accompanying drawings. It is obvious that the drawings in the following description are only some examples of the invention, and that for a person skilled in the art, other drawings and embodiments can be derived from them without inventive effort.
For the sake of simplicity, the drawings only schematically show the parts relevant to the present invention, and they do not represent the actual structure as a product. In addition, in order to make the drawings concise and understandable, components having the same structure or function in some of the drawings are only schematically illustrated or only labeled. In this document, "one" means not only "only one" but also a case of "more than one".
Fig. 1 is a schematic diagram illustrating main steps of a short data packet sending method based on a Zigbee network according to the present invention, and as shown in fig. 1, a short data packet sending method based on a Zigbee network includes the steps of: s100, broadcasting a routing request message from a source node to surrounding adjacent nodes; s200, when any node receives the routing request message, judging whether the current node is a target node; if yes, executing the next step; s300, if the current node is the target node, further judging whether the routing request message carries a short data message; s400, when the routing request message is judged to carry the short data message, the routing request message is analyzed, and the short data message is obtained.
Specifically, for a node with routing capability, when a request for sending a data frame from a higher layer of the network layer is received and there is no entry corresponding to the destination node in the routing table, it initiates a route discovery process. The source node first creates a route request packet (RREQ), i.e., a route request message, and broadcasts it to surrounding nodes using multicast (multi. After the route is found and the corresponding route information is established, the corresponding data message is sent to the destination node. Here, the source node has to send a packet twice, one is a routing request packet and one is a data packet. If the data packet to be sent is a short data packet, the information content of the data packet is short, and the data packet is separately transmitted after the header information is added according to the conventional method, the payload ratio is low, and communication resources are wasted because one short data packet needs to be sent twice for transmitting, thereby resulting in low communication efficiency.
When the short data message is transmitted, the short data message to be transmitted is directly carried in the routing request message when the Zigbee equipment searches for the route, and when the route searching is successful, the short data message directly reaches the target node, so that the transmitting times are reduced, and the response time of data transmission is improved.
Fig. 2 is a schematic step diagram of an embodiment of a short data packet sending method based on a Zigbee network according to the present invention. As shown in fig. 2, preferably, the step S100 further includes, before the step, the steps of: s000, modifying the routing request message, and adding a flag bit to a frame control domain of the head of the routing request message; the flag bit is used for marking whether the routing request message carries a short data message.
Specifically, a short message to be sent to the destination address is added between the header and the payload in the original zigbee route discovery message, as shown in table 1, the Piggyback short message is the storage location of the short data message.
TABLE 1
The invention modifies the original route request message to lead the original route request message to carry the short data message incidentally, and when the route searching is successful, the short data message reaches the target node, thereby improving the response time of data sending.
Preferably, as shown in fig. 2, the step S300 "determining whether the route request packet carries a short data packet" further includes the steps of: s310, analyzing the routing request message to obtain a flag bit in a frame control domain of the head of the routing request message; s320, judging whether the value of the flag bit is a preset value, if so, carrying a short data message by the routing request message.
TABLE 2
Specifically, the Frame Control Field of the original route request message is shown in table 2, and the present invention modifies the Frame Control Field of the message header to obtain the modified route request message, as shown in table 3.
TABLE 3
As shown in table 3, a Piggyback Flag is added in the frame control field, and when the value is 1, the short data packet corresponding to the routing request packet is carried in the routing request packet, and when the value is 0, the short data packet is not carried in the routing request packet.
The invention modifies the frame control field of the head part of the routing request message, increases the flag bit for marking whether the short data message is carried, has small modification on the basis of the prior message format, and is convenient for the target node to judge, separate and analyze the short data message.
Preferably, the step S200 further includes the steps of: s500, if the current node is not the target node, broadcasting the routing request message to the surrounding adjacent nodes.
Preferably, the step S400 further includes the steps of: s600, when the routing request message is judged not to carry the short data message, a routing response message is fed back from the current node to the initiating node.
Specifically, if the current routing request packet does not carry the short data packet, a routing response packet is fed back to the originating node according to the prior art, and the routing response packet is used for establishing a path between the source node and the target node.
Fig. 3 is a flowchart of a short data packet sending method based on a Zigbee network according to the present invention. As shown in fig. 3, the specific workflow of the present invention is as follows:
30. and starting.
31. A route request message is broadcast from a source node to surrounding neighboring nodes.
32. When any node receives the routing request message, judging whether the current node is a target node or not; if yes, go to step 33; otherwise, step 35 is executed.
33. Further judging whether the routing request message carries a short data message or not; if yes, go to step 34; otherwise, step 36 is executed.
34. And analyzing the routing request message to obtain the short data message.
35. And broadcasting the routing request message to the surrounding adjacent nodes.
36. And feeding back a routing response message from the current node to the initiating node.
Fig. 4 is a schematic diagram illustrating major components of a short data packet sending apparatus based on a Zigbee network according to the present invention. As shown in fig. 4, a short data packet sending apparatus based on a Zigbee network includes: a message broadcasting module 100, configured to broadcast a routing request message from a source node to neighboring nodes around; a first determining module 200, configured to determine whether a current node is a target node when any node receives the routing request packet; a second judging module 300, configured to further judge whether the routing request packet carries a short data packet when it is judged that the current node is a target node; the processing module 400 is configured to, when it is determined that the short data packet is carried in the routing request packet, parse the routing request packet, and obtain the short data packet.
When the short data message is transmitted, firstly, when the Zigbee equipment searches for the route, the short data message to be transmitted is directly carried in the route request message, and when the route searching is successful, the short data message directly reaches the target node, so that the transmitting times are reduced, and the response time of data transmission is improved.
Fig. 5 is a schematic diagram illustrating a complete configuration of a short data packet sending apparatus based on a Zigbee network according to the present invention. Preferably, as shown in fig. 5, the method further includes: a message modification module 500, configured to modify a routing request message and add a flag bit to a frame control field of a header of the routing request message; the flag bit is used for marking whether the routing request message carries a short data message.
Preferably, as shown in fig. 5, the second determining module 300 further includes: the parsing submodule 301 is configured to parse the routing request packet to obtain a flag bit in a frame control field of a header of the routing request packet; the flag bit determining submodule 302 is configured to determine whether the value of the flag bit is a preset value, and when the value of the flag bit is the preset value, the routing request packet carries a short data packet.
Preferably, the message broadcasting module 100 is further configured to broadcast the route request message to neighboring nodes through the current node if the current node is not the target node.
Preferably, as shown in fig. 5, the method further includes: a message feedback module 600, configured to feed back a route response message from the current node to the initiating node when it is determined that the route request message does not carry the short data message.
It should be noted that the information interaction, execution process, and other contents between the modules in the apparatus are based on the same concept as the method embodiment, and specific contents may refer to the description in the method embodiment of the present invention, and are not described herein again.
The invention adds a little short data message to be sent to a target node between the head part and the load in the original Zigbee routing request message, the short data message and the routing request message use the same message head and broadcast to the adjacent nodes around in a multicast mode, when the routing is successful, the routing request message is already sent to the target node, and the target node directly takes out the short data message from the routing request message for analysis and processing, thereby reducing the message sending times and improving the response time of data sending.
It should be noted that the above embodiments can be freely combined as necessary. The foregoing is only a preferred embodiment of the present invention, and it should be noted that, for those skilled in the art, various modifications and decorations can be made without departing from the principle of the present invention, and these modifications and decorations should also be regarded as the protection scope of the present invention.