Method for pairing nodes
Disclosed is a method for pairing nodes, which including: sending, by a node to be paired, a pairing request packet whose sending address is a MAC address of itself to a relay node as its parent node; adding, by a relay node receiving the pairing request packet, the MAC address of the node to be paired to a refugee table after determining that it can provide a relay service for the node to be paired; changing, by the relay node, a receiving address of the pairing request packet to a MAC address of its parent node if it is a non-root node, and then forwarding uplink; returning, by the relay node, a pairing approval packet with receiving address being the MAC address of the node to be paired if it is a root node; wherein a pairing is successful if the node to be paired receives the pairing approval packet.
1 . A method for pairing nodes, comprising:
sending, by a node to be paired, a pairing request packet to its parent node, wherein a sending address of the pairing request packet is a MAC address of the node to be paired, a receiving address of the pairing request packet is a MAC address of the parent node of the node to be paired, and the parent node of the node to be paired is a relay node of a mesh network system,
filling, by the node to be paired, an address 1 field in a null data frame with the MAC address of the parent node of the node to be paired, filling an address 2 field with the MAC address of the node to be paired, setting a first preset bit of the address 3 field to a first preset value to define the null data frame as a handshake frame, setting a plurality of second preset bits of an address 3 field to a third preset value to define a type of the handshake frame as a pairing request, so as to generate and send the pairing request packet;
adding, by a relay node, the MAC address of the node to be paired to a refugee table maintained by the relay node, after the relay node receiving the pairing request packet determines that it can provide a relay service for the node to be paired, wherein the refugee table is a table that stores MAC addresses of all subordinate nodes for which the relay node provides relay services;
changing, by the relay node, the receiving address of the pairing request packet received to a MAC address of its parent node if the relay node is a non-root node, and then forwarding the pairing request packet uplink, until the relay node receiving the pairing request packet is a root node; and
returning, by the relay node, a pairing approval packet if the relay node is the root node, wherein a receiving address of the pairing approval packet is the MAC address of the node to be paired, and a sending address of the pairing approval packet is a MAC address of itself;
wherein a pairing is successful if the node to be paired receives the pairing approval packet.
2 . The method for pairing nodes according to claim 1 , further comprising:
changing, by the relay node receiving the pairing approval packet, the sending address of the pairing approval packet to a MAC address of itself when it confirms that the sending address of the pairing approval packet is a MAC address of its parent node and the receiving address is contained in the refugee table stored by itself, and then forwarding the pairing approval packet downlink, until the pairing approval packet is forwarded to the node to be paired.
3 . The method for pairing nodes according to claim 1 , further comprising:
returning, by the relay node receiving the pairing request packet, a pairing rejection packet when it determines that it cannot provide the relay service for the node to be paired, wherein a receiving address of the pairing rejection packet is the MAC address of the node to be paired, and a sending address of the pairing rejection packet is a MAC address of itself;
wherein the pairing fails if the node to be paired receives the pairing rejection packet.
4 . The method for pairing nodes according to claim 3 , wherein the pairing fails if it times out.
5 . The method for pairing nodes according to claim 3 , wherein the returning, by the relay node receiving the pairing request packet, the pairing rejection packet when it determines that it cannot provide the relay service for the node to be paired further comprises:
filling, by the relay node receiving the pairing request packet, an address 1 field in a null data frame with the MAC address of the node to be paired, filling an address 2 field with the MAC address of the root node, setting a first preset bits of an address 3 field to a first preset value to define the null data frame as a handshake frame, and setting a plurality of second preset bits of the address 3 field to a second preset value to define a type of the handshake frame as a pairing rejection, so as to generate and return the pairing rejection packet.
6 . The method for pairing nodes according to claim 1 , further comprising:
setting the node to be paired to only receive various types of packets that meet a filtering condition, wherein the filtering condition is that a sending address of each type of packets is the MAC address of the parent node of the node to be paired and a receiving address of each type of packets is the MAC address of the node to be paired.
7 . The method for pairing nodes according to claim 1 , further comprising:
obtaining, by the node to be paired, a received signal strength indication (RSSI) value between each relay node and an access point in the mesh network system and a RSSI value between the node to be paired and each relay node based on multiple beacon packets or multiple probe response packets obtained by a scanning procedure; and
selecting, by the node to be paired, a relay node as its parent node based on the RSSI value between each relay node and the access point and the RSSI value between the node to be paired and each relay node.
8 . The method for pairing nodes according to claim 1 , wherein the returning, by the relay node, a pairing approval packet if the relay node is the root node further comprises:
filling, by the root node, an address 1 field in a null data frame with the MAC address of the node to be paired, filling an address 2 field with the MAC address of the root node, setting a first preset bit of an address 3 field to a first preset value to define the null data frame as a handshake frame, setting a plurality of second preset bits of the address 3 field to a fourth preset value to define a type of the handshake frame as pairing approval, so as to generate and return the pairing approval packet.
9 . A method for pairing nodes, comprising:
sending, by a node to be paired, a pairing request packet to its parent node, wherein a sending address of the pairing request packet is the MAC address of the node to be paired, a receiving address of the pairing request packet is the parent node of the node to be paired, and the parent node of the node to be paired is a relay node of a mesh network system;
adding, by the relay node receiving the pairing request packet, the MAC address of the node to be paired to a refugee table maintained by the relay node, when the relay node is a non-root node, changing the receiving address of the pairing request packet to a MAC address of the relay node's parent node, and then forwarding the pairing request packet uplink, until the relay node receiving the pairing request packet is a root node;
when the relay node receiving the pairing request packet is the root node, adding, the MAC address of the node to be paired to a refugee table stored by itself after determining that it can provide a relay service for the node to be paired, and returning a pairing approval packet, wherein a receiving address of the pairing approval packet is the MAC address of the node to be paired, a sending address of the pairing approval packet is a MAC address of itself, and the refugee table contains MAC addresses of all subordinate nodes that the relay node provides relay services for; and
changing, by a relay node receiving the pairing approval packet, the sending address of the pairing approval packet to a MAC address of itself when confirming that the sending address of the pairing approval packet is the MAC address of its parent node, and then forwarding the pairing approval packet downlink, until the pairing approval packet is forwarded to the node to be paired;
wherein a pairing is successful if the node to be paired receives the pairing approval packet;
when the relay node receiving the pairing request packet is the root node, returning a pairing rejection packet after determining that it cannot provide the relay service for the node to be paired, wherein a receiving address of the pairing rejection packet is the MAC address of the node to be paired, and a sending address of the pairing rejection packet is a MAC address of itself;
deleting, by a relay node receiving the pairing approval packet, the MAC address of the node to be paired from the refugee table stored by itself when confirming that the sending address of the pairing rejection packet is the MAC address of its parent node, and changing the sending address of the pairing rejection packet to a MAC address of itself, and then forwarding the pairing rejection packet downlink, until the pairing rejection packet is forwarded to the node to be paired;
wherein the pairing fails if the node to be paired receives the pairing rejection packet.
10 . The method for pairing nodes according to claim 9 , wherein the pairing fails if it times out.
11 . A method for pairing nodes, comprising:
sending, by a node to be paired, a pairing request packet to its parent node, wherein a sending address of the pairing request packet is a MAC address of the node to be paired;
wherein a receiving address of the pairing request packet is a MAC address of the parent node of the node to be paired,
and wherein the parent node of the node to be paired is a relay node of a mesh network system,
wherein the sending, by the node to be paired, the pairing request packet further comprises:
filling, by the node to be paired, an address 1 field in a null data frame with the MAC address of the parent node of the node to be paired,
filling an address 2 field with the MAC address of the node to be paired,
setting a first preset bit of an address 3 field to a first preset value to define the null data frame as a handshake frame, and
setting a plurality of second preset bits of the address 3 field to a third preset value to define a type of the handshake frame as a pairing request,
so as to generate and send the pairing request packet;
adding, by a relay node receiving the pairing request packet, the MAC address of the node to be paired to a refugee table stored by itself after determining that it can provide a relay service for the node to be paired, and returning a pairing approval packet to the node to be paired, wherein a receiving address of the pairing approval packet is the MAC address of the node to be paired;
wherein a sending address of the pairing approval packet is a MAC address of the relay node, and wherein the refugee table contains MAC addresses of all subordinate nodes that the relay node provides relay services for;
if the relay node receiving the pairing request packet is a non-root node, sending, by the relay node receiving the pairing request packet, a pairing notification packet whose receiving address is a MAC address of a parent node of the relay node and whose source address is the MAC address of the node to be paired, so that the parent node of the relay node receiving the pairing request packet adds the MAC address of the node to be paired to a refugee table stored by itself after receiving the pairing notification packet, and changes the receiving address of the pairing notification packet to a MAC address of its parent node, and then forwards the pairing notification packet uplink, until the pairing notification packet is forwarded to a root node; and
adding, by the relay node receiving the pairing request packet, the MAC address of the node to be paired to a refugee table stored by itself if the relay node is the root node;
wherein a pairing is successful if the node to be paired receives the pairing approval packet.
12 . The method for pairing nodes according to claim 11 , further comprising:
returning, by the relay node receiving the pairing request packet, a pairing rejection packet to the node to be paired after determining that it cannot provide the relay service for the node to be paired, wherein a receiving address of the pairing rejection packet is the MAC address of the node to be paired, and a sending address of the pairing rejection packet is a MAC address of itself;
wherein the pairing fails if the node to be paired receives the pairing rejection packet.