Disclosure of Invention
The invention aims to overcome the defects of the prior art and provides a method and a system for realizing packet broadcasting based on LoRaWAN (LoRaWAN). the same data is synchronously downlink to a plurality of terminal nodes to realize broadcast control and multicast control.
The technical scheme adopted by the invention for solving the technical problems is as follows:
in one aspect, a method for implementing packet broadcasting based on LoRaWAN includes:
each LoRaWAN terminal node is preset with a plurality of identities; the plurality of identities comprise a unicast identity, a broadcast identity and at least one reserved multicast identity; each identity comprises a device address DevAddr, NwkSKey used for data frame verification and AppSKey used for data frame encryption; the equipment address of the unicast identity of each LoRaWAN terminal node is different; the broadcast identity equipment addresses of all LoRaWAN terminal nodes are the same;
each LoRaWAN terminal node reports a multicast identity to a LoRaWAN server and monitors a configuration request of the LoRaWAN server; the LoRaWAN server performs multicast configuration storage and configuration release management;
the LoRaWAN server sends broadcast messages to LoRaWAN end nodes to configure the multicast identities of the LoRaWAN end nodes.
Preferably, the sending, by the LoRaWAN server, a broadcast message to the LoRaWAN end node to configure the multicast identity of the LoRaWAN end node includes:
the LoRaWAN server sends a broadcast message to the LoRaWAN terminal node; the equipment address of the broadcast message is filled as the equipment address of the broadcast identity; the MAC layer load FRMPayload of the broadcast message comprises a unicast identity device address of a LoRaWAN terminal node needing multicast and a device address of multicast identity to be set;
receiving the broadcast message by the LoRaWAN terminal node, judging whether the equipment address of the broadcast message is the equipment address of the broadcast identity, and if so, judging whether the FRMPayload field comprises the equipment address of the unicast identity; and if so, acquiring the equipment address of the corresponding multicast identity.
Preferably, before the determining, by the LoRaWAN terminal node, whether the device address of the broadcast message is the device address of the broadcast identity, the method further includes:
judging whether the equipment address of the broadcast message is the equipment address of the unicast identity of the equipment address, if so, indicating that the received message is the unicast message, and responding to a corresponding request; if not, judging whether the equipment address of the broadcast message is the equipment address of the broadcast identity.
Preferably, the reporting of the multicast identity to the LoRaWAN server by the LoRaWAN terminal node includes:
when the terminal node is restarted or initialized, the current multicast identity is reported to a LoRaWAN server by a unicast identity;
the message for reporting the multicast identity by the terminal node comprises the address of the multicast identity, NwkSKey for data verification and AppSKey for data frame encryption.
Preferably, the configuration storage and configuration release management of the multicast performed by the LoRaWAN server includes:
the LoRaWAN server receives a broadcast group creating request and adds any LoRaWAN terminal node into any broadcast group;
the LoRaWAN server stores the mapping relation between the terminal nodes and the broadcast groups according to the setting of the broadcast groups;
and the LoRaWAN server monitors the multicast identity report of the terminal node, updates the state in the broadcast group in real time, and determines the multicast configuration message to be issued by combining the mapping relation.
Preferably, in the process of message interaction between the LoRaWAN server and the LoRaWAN terminal node, NwkSKey for data frame verification and appkey for data frame encryption are both encrypted or decrypted using AES 128.
In another aspect, a system for implementing packet broadcasting based on LoRaWAN includes: a plurality of LoRaWAN terminal nodes and LoRaWAN servers;
each LoRaWAN terminal node is preset with a plurality of identities; the plurality of identities comprise a unicast identity, a broadcast identity and at least one reserved multicast identity; each identity comprises a device address DevAddr, NwkSKey used for verifying the data frame and AppSKey used for encrypting the data frame; the equipment address of the unicast identity of each LoRaWAN terminal node is different; the broadcast identity equipment addresses of all LoRaWAN terminal nodes are the same;
the LoRaWAN terminal node and LoRaWAN server interaction method comprises the following steps:
each LoRaWAN terminal node reports a multicast identity to a LoRaWAN server and monitors a configuration request of the LoRaWAN server; and the LoRaWAN server updates the multicast identity state and the multicast configuration command set.
The LoRaWAN server LoRaWAN terminal nodes send broadcast messages to configure the multicast identities of the LoRaWAN terminal nodes.
Preferably, the sending, by the LoRaWAN server, a broadcast message to the LoRaWAN end node to configure the multicast identity of the LoRaWAN end node includes:
the LoRaWAN server sends a broadcast message to the LoRaWAN terminal node; the equipment address of the broadcast message is filled as the equipment address of the broadcast identity; the MAC layer load FRMPayload of the broadcast message comprises a continuous data group consisting of a unicast identity device address of a LoRaWAN terminal node needing multicasting and a device address of multicast identity to be set;
receiving the broadcast message by the LoRaWAN terminal node, judging whether the equipment address of the broadcast message is the equipment address of the broadcast identity, and if so, judging whether the FRMPayload field comprises the equipment address of the unicast identity; and if so, acquiring the equipment address of the corresponding multicast identity.
Preferably, the system further comprises: one or more LoRaWAN gateway devices; the LoRaWAN gateway is arranged between the LoRaWAN terminal node and the LoRaWAN server and is respectively connected with the LoRaWAN terminal node and the LoRaWAN server to realize message forwarding.
Preferably, if the LoRaWAN gateway device comprises a plurality of LoRaWAN gateway devices, the LoRaWAN server intermittently transmits the LoRaWAN gateway device in a preset delay mode so as to avoid frequency point collision.
The invention has the following beneficial effects:
(1) the invention relates to a method and a system for realizing packet broadcasting based on LoRaWAN.A LoRaWAN terminal node performs broadcasting configuration to a LoRaWAN server by presetting the same broadcasting identity, so that the LoRaWAN server can synchronously perform data downloading and setting on a plurality of terminal nodes;
(2) the invention relates to a method and a system for realizing packet broadcasting based on LoRaWAN.A LoRaWAN server rapidly configures multicast identity of LoRaWAN terminal nodes by sending broadcast messages to the LoRaWAN terminal nodes, thereby realizing dynamic grouping of the terminal nodes, sending multicast messages to a group of LoRaWAN terminal nodes through the multicast identity, and realizing differential control of each group of terminal nodes; compared with a unicast configuration mode, the method can dynamically allocate a batch of terminal nodes in a broadcast mode, so that the probability of packet loss caused by frequency point collision is reduced, and the configuration efficiency is improved;
(3) the invention relates to a method and a system for realizing packet broadcasting based on LoRaWAN.A same LoRaWAN terminal node can configure a plurality of multicast identities through broadcast messages, thereby forming a plurality of groups with different other LoRaWAN terminal nodes, and realizing independent control of each group;
(4) according to the method and the system for realizing the block broadcasting based on the LoRaWAN, the node side of the LoRaWAN terminal utilizes the AES128 with the MAC to encrypt, multiple identities share the encryption, so that the resource consumption can be saved, and the data security problem is guaranteed; the LoRaWAN terminal node uses the same AES128 encryption means, each multicast identity has independent safety guarantee, and after receiving the response parameter designed by the LoRaWAN server in the configuration identity message, the LoRaWAN terminal node can automatically delay and report the identity by channel alternation according to the parameter so as to respond to the server, so that the success rate and the efficiency of the whole configuration closed loop are improved.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Referring to fig. 1, in one aspect, the present invention provides a method for implementing packet broadcasting based on LoRaWAN, including:
s101, presetting a plurality of identities for each LoRaWAN terminal node; the plurality of identities comprise a unicast identity, a broadcast identity and at least one reserved multicast identity; each identity comprises a device address DevAddr, NwkSKey used for data frame verification and AppSKey used for data frame encryption; the equipment address of the unicast identity of each LoRaWAN terminal node is different; the broadcast identity equipment addresses of all LoRaWAN terminal nodes are the same;
s102, each LoRaWAN terminal node reports a multicast identity to a LoRaWAN server and monitors a configuration request of the LoRaWAN server; the LoRaWAN server updates the multicast identity state and the multicast configuration command set;
s103, the LoRaWAN server sends broadcast messages to the LoRaWAN terminal nodes to configure the multicast identities of the LoRaWAN terminal nodes.
Specifically, referring to fig. 2, reporting a multicast identity to a LoRaWAN server and monitoring a configuration request of the server by a LoRaWAN terminal node includes:
the LoRaWAN terminal node starts monitoring broadcast and multicast messages.
The LoRaWAN terminal node sends self multicast identity information to the LoRaWAN server in a unicast identity; the multicast identity information comprises a device address DevAddr of the multicast identity, NwkSKey used for data frame verification and AppSKey used for data frame encryption.
It should be noted that, if the device address of the multicast identity of the LoRaWAN terminal node is not configured by the LoRaWAN server, the device address sent by the LoRaWAN terminal node to the LoRaWAN server is an initialized address; otherwise, the address is the previously configured device address.
Specifically, the updating of the multicast identity state and the multicast configuration command set by the LoRaWAN server includes:
the server receives self multicast identity information reported by the unicast identity of the node, compares the self multicast identity information with the broadcast group state configured by the user at the server, if the self multicast identity information is inconsistent with the broadcast group state configured by the user at the server, the server adds a multicast configuration command needing to be updated into a command set sent by the broadcast, and if the self multicast identity information is consistent with the broadcast group state, the server is regarded as that the terminal node and the server are kept synchronous without further setting.
For example, a broadcast group a with a multicast address of 00000001 is stored in the LoRaWAN server, where the broadcast group a includes the LoRaWAN end node 1, and if the multicast identity reported by the LoRaWAN end node 1 to the LoRaWAN server is the multicast address 00000001 of the broadcast group a, it indicates that the actual configuration of the current device 1 is consistent with the server, that is, in a synchronous state, otherwise, it indicates that the configuration is inconsistent.
Specifically, before the LoRaWAN server updates the multicast identity status and the multicast configuration command set, the method further includes:
creating and managing a broadcast group, and setting the identity and a corresponding key of the broadcast group;
adding LoRaWAN terminal nodes into a broadcast group, and performing relational mapping storage on the unicast identities of the nodes needing to be added into the broadcast group and the broadcast group identities;
specifically, when a broadcast group is created and managed, dynamic deletion and addition of terminal nodes will also trigger the change of the expected broadcast identity, and in order to further perform configuration synchronization, the server will also update the stored multicast configuration command set;
flow chart for LoRaWAN Server creation and management of broadcast groups see FIG. 3
Referring to fig. 4, after the LoRaWAN server creates a broadcast group and updates a configuration command set to be issued, a broadcast configuration message may be sent to the LoRaWAN terminal node according to a specific user operation or a preset time, which specifically includes:
the LoRaWAN terminal node opens a receiving window to wait for receiving data;
the server assembles a broadcast issuing message according to the command set and sends a configuration command message to a broadcast identity preset by the terminal node;
receiving downlink data and analyzing the data by the LoRaWAN terminal node; judging whether the equipment address of the data packet is the equipment address of the unicast identity; if yes, responding to the command content or performing other processing; if not, judging whether the equipment address of the data packet is the equipment address of the multicast identity; if so, respond to the command content or perform other processing.
According to the above process, further, the sending, by the LoRaWAN server, a broadcast message to the LoRaWAN end node to configure the multicast identity of the LoRaWAN end node specifically includes:
the LoRaWAN server sends a broadcast message to the LoRaWAN terminal node; the equipment address of the broadcast message is filled as the equipment address of the broadcast identity; the MAC layer load FRMPayload of the broadcast message comprises unicast identity equipment addresses of a plurality of LoRaWAN terminal nodes needing to be multicast, equipment addresses of multicast identities to be set, identity keys and response parameters;
receiving the broadcast message by the LoRaWAN terminal node, judging whether the equipment address of the broadcast message is the equipment address of the broadcast identity, and if so, judging whether the FRMPayload field comprises the equipment address of the unicast identity; if yes, the device address of the corresponding multicast identity is obtained from the FRMPayload field.
Specifically, in the above process, the unicast identity device addresses of the plurality of LoRaWAN terminal nodes that need to perform multicast, the device address of the multicast identity to be set, the identity key, and the response parameter, that is, the broadcast delivery message assembled according to the command set uses a specific protocol as a sub-protocol of the frmpapayload for communication, and as shown in fig. 5, the method includes:
an operation identifier ctl of the command set is used for identifying whether the broadcast configuration message is an 'addition' or 'deletion' identity;
the multicast identity key set keys _ dit contained in the command set is used for identity key selection configured by the subsequent terminal nodes of the protocol, can contain a plurality of multicast identity keys, and takes the sequence serial number as a selection identifier;
the multicast identity address set addrs _ dit contained in the command set is used for identity address selection configured by a protocol subsequent terminal node, can contain a plurality of multicast identity addresses, and takes a sequence number as a selection identifier;
the terminal nodes needing configuration and the multicast setting information set cmd _ payload thereof contained in the command set are used for loading specific terminal nodes and corresponding multicast identity configuration thereof, and each configuration information contains selection of a multicast identity key and address in the command set so as to represent actual configuration of each terminal node.
The response parameters are filled after the configuration information of each terminal node in the cmd _ payload is preset by the server, and are used for determining the time for reporting a new multicast identity after the device applies multicast configuration, wherein the time comprises the factor ack _ option which can determine the delay time reported by the terminal node and the communication frequency used for reporting.
After the multicast identity of the LoRaWAN terminal node is configured through the broadcast message, the LoRaWAN server can send the multicast message to the LoRaWAN terminal nodes in the same group through the multicast identity. The multicast message is sent in the same flow as the broadcast message, but only the LoRaWAN terminal node with the corresponding multicast identity responds to the command content to perform corresponding processing.
It should be noted that, in the process of message interaction between the LoRaWAN server and the LoRaWAN terminal node, NwkSKey used for data frame verification and appkey used for data frame encryption are both encrypted or decrypted using AES 128. In specific implementation, in order to ensure data security and analyze a message, NwkSKey and AppSKey of unicast identity of each LoRaWAN terminal node are set to be different; the NwkSKey and the AppSKey of the broadcast identity of each LoRaWAN terminal node are set to be the same; the NwkSKey and the AppSKey of the multicast identity of each LoRaWAN terminal node in the same multicast are set to be the same, and the NwkSKey and the AppSKey of the multicast identity of different groups of LoRaWAN terminal nodes are set to be different.
As will be described below with a specific example.
The number of the LoRaWAN end nodes is 100, and the 100 end nodes need to be broadcasted in groups, wherein 30 end nodes need to downlink data messages < 111111 > through a multicast identity (group 1), 50 end nodes need to downlink data < 222222 > through a multicast identity (group 2), and 20 end nodes need to downlink data messages < 333333 > through a multicast identity (group 3).
The realization process is as follows:
1. hardware pre-configuration:
1.1 the LoRaWAN terminal node burns record LoRaWAN CLASS C code, has set up 3 identities in the code, presume that the equipment address of the unicast identity of these 100 terminal nodes is 10000000 ~ 10000099 respectively, and the equipment address of broadcast identity all is FFFFFF, and equipment address power-on of multicast identity is all acquiescently initialized to 00000000 and is reserved waiting to use.
And 1.2, binding the LoRaWAN terminal node to the LoRaWAN server to ensure that the LoRaWAN terminal node can normally carry out conventional communication with the LoRaWAN server.
2. And respectively adding broadcast groups 1, 2 and 3 in the LoRaWAN server, and respectively adding corresponding nodes into the broadcast groups according to the requirements.
3. The LoRaWAN server issues the multicast identity adding flow through the broadcast message.
Framing is realized through a LoRaWAN server interface, 100 terminal nodes are grouped, a Devraddr in a downlink frame is replaced by a broadcast identity device address (FFFFFFFF), and a multicast command is shown in figure 6.
The frame format of each node of the packet frame arrangement refers to the protocol frame in fig. 5.
Here, since the configuration command is "add" for the end node for the initialization packet, the ctl field is 1 in the protocol frame, indicating an add identity operation.
Secondly, the multicast identity key set and the multicast identity address are assumed to be in one-to-one correspondence, and the key _ fact and addrs _ fact parts in the protocol frame are as shown in table 1 below.
TABLE 1
The specific command information of the first two groups of nodes in this example is shown in table 2 below, which indicates the specific content of cmd _ payload in the protocol frame.
TABLE 2
As can be seen from Table 2, in this embodiment, the end nodes with the unicast device address DEVADDR of 10000000-10000030 are set as group 1, the end nodes with the unicast device address DEVADDR of 10000031-10000080 are set as group 2, and similarly, the end nodes with the unicast device address DEVADDR of 10000081-10000100 are set as group 3.
After the LoRaWAN server groups the frame, the LoRaWAN server directly sends the frame to the gateway equipment, and the gateway equipment broadcasts the data frame to the air after receiving the corresponding message frame.
At this time, after receiving the data frame, the LoRaWAN terminal node determines DevAddr first after removing a series of operations such as parsing of standard LoRaWAN, and since the terminal nodes all have the broadcast identity ffffff, s receives the remaining data frame, and then operates on the data frame in FRMPayload. And then the terminal node firstly judges whether the identity 1 is matched with the equipment address of the unicast identity of the terminal node, if so, the specific value in the group 1 is assigned to the multicast identity, and thus, the first part of configuring the multicast identity is completed.
In the case of a multi-gateway device, the LoRaWAN server delays transmission of the downstream frame to the gateway.
4. LoRaWAN server refers to the flow of sending multicast messages.
Because the value of the multicast identity is already configured in the above steps, next framing in the LoRaWAN server replaces the DevAddr as the value of the multicast identity terminal device, fills the specific content of the corresponding packet, and then sends the packet to the gateway device, and the gateway device sends the packet to the air, where the framing format is as shown in fig. 7.
After receiving the corresponding frame, the terminal node also first determines whether the DevAddr is consistent with itself, then starts to receive the specific content in the corresponding frmpapayload, and makes a corresponding response or other operations.
On the other hand, referring to fig. 8, the system for implementing packet broadcasting based on LoRaWAN of the present invention includes: a plurality of LoRaWAN terminal nodes 801 and LoRaWAN server 802;
each LoRaWAN terminal node is preset with a plurality of identities; the plurality of identities comprise a unicast identity, a broadcast identity and at least one reserved multicast identity; each identity comprises a device address DevAddr, NwkSKey used for verifying the data frame and AppSKey used for encrypting the data frame; the equipment address of the unicast identity of each LoRaWAN terminal node is different; the broadcast identity equipment addresses of all LoRaWAN terminal nodes are the same;
the LoRaWAN terminal node and LoRaWAN server interaction method comprises the following steps:
each LoRaWAN terminal node reports a multicast identity to a LoRaWAN server and monitors a configuration request of the LoRaWAN server; and the LoRaWAN server updates the multicast identity state and the multicast configuration command set.
The LoRaWAN server sends broadcast messages to LoRaWAN end nodes to configure the multicast identities of the LoRaWAN end nodes.
The method includes that the LoRaWAN server sends broadcast messages to the LoRaWAN terminal nodes to configure multicast identities of the LoRaWAN terminal nodes, and specifically includes the following steps:
the LoRaWAN server sends a broadcast message to the LoRaWAN terminal node; the equipment address of the broadcast message is filled as the equipment address of the broadcast identity; the MAC layer load FRMPayload of the broadcast message comprises a unicast identity device address of a LoRaWAN terminal node needing multicast and a device address of multicast identity to be set;
receiving the broadcast message by the LoRaWAN terminal node, judging whether the equipment address of the broadcast message is the equipment address of the broadcast identity, and if so, judging whether the FRMPayload field comprises the equipment address of the unicast identity; and if so, acquiring the equipment address of the corresponding multicast identity.
Further, the system also includes one or more LoRaWAN gateway devices 803; the LoRaWAN gateway is arranged between the LoRaWAN terminal node and the LoRaWAN server and is respectively connected with the LoRaWAN terminal node and the LoRaWAN server to realize message forwarding. If the number of the LoRaWAN gateway devices is multiple, the LoRaWAN server may perform intermittent transmission according to an appropriate delay method (for example, by setting a delay parameter) to avoid frequency point collision and perform delayed transmission to avoid frequency point collision.
The specific implementation and interactive flow of the LoRaWAN terminal node and the LoRaWAN server in the LoRaWAN-based packet broadcasting system are consistent with the LoRaWAN-based packet broadcasting method, and the description is not repeated here.
The principle and the implementation mode of the invention are explained by applying specific embodiments in the invention, and the description of the embodiments is only used for helping to understand the method and the core idea of the invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.