Detailed Description
      In order to make the objects, technical solutions and advantages of the present application more apparent, the following detailed description of the embodiments of the present application will be given with reference to the accompanying drawings.
      Fig. 1 shows a network architecture of a Mesh network to which the present application can be applied.
      As shown in fig. 1, the network architecture may include a plurality of node devices, where each node device communicates with each other through a WiFi protocol, the Mesh network is a tree structure, the node device 0 is a root node, two child nodes of the node device 0 are a node device 1 and a node device 2, and child nodes of the node device 1 are a node device 11 and a node device 12. The child node of the node device 2 is the node device 21. When a certain node device needs to join the used Mesh network in fig. 1, the access method of the present application is executed.
      It should be understood that the number of node devices and the network topology results in fig. 1 are merely illustrative. And (5) configuring according to implementation requirements.
      The method for accessing the Mesh network provided by the embodiment of the application will be described in detail with reference to fig. 2. The node device in the embodiment of the present application may be a node device shown in fig. 1.
      Referring to fig. 2, a flowchart of a method for accessing a Mesh network is provided in an embodiment of the present application. As shown in fig. 2, the method according to the embodiment of the present application may include the following steps:
       s201, after the power-on, the current node judges whether the current node is a root node or not, and if not, monitors a broadcast channel. 
      After the current Node is started, whether the current Node is a Root Node (Root Node) of the Mesh network can be judged through a preset zone bit or configuration information. The root node typically serves as a starting point for the network and is responsible for initializing the network topology and allocating resources. If the current node is not the root node, the monitoring mode is entered, and the scanning of the broadcast channel is started. The broadcast channel is a common channel which can be received by all nodes in the Mesh network and is used for transmitting key information such as network discovery, time synchronization and the like.
      In some possible embodiments of the present application, the current node determines whether itself is a root node, including:
       After the current node is started, a self-checking flow is executed to determine whether the current node is a root node of the Mesh network. The key detection items include the physical connection state of a WLAN (wired local area network) port and network patency. 
      And detecting physical connection, namely detecting whether the WLAN port is plugged with a network cable or not by the current node through a hardware interface (such as a PHY chip). The specific mode comprises the steps of detecting whether physical contacts of the network cable interface are closed or not (for example, 8 contacts of the RJ45 interface are all conducted or not). And reading a Link state flag Bit (such as Link Status Bit) in the hardware register, and judging whether effective physical connection is detected.
      Network patency detection, namely after confirming that physical connection exists, the current node further verifies the patency of the network. The specific mode includes sending a link layer probe frame (such as an ARP request frame or ICMP Echo Request frame) to a preset gateway address or broadcast address and waiting for a response. It is detected whether a valid response frame (e.g., ARP Reply frame or ICMP Echo Reply frame) is received within a preset timeout period. If the response frame is received, the network is judged to be unobstructed, otherwise, the network is judged to be obstructed.
      And judging the root node, namely judging the node as the root node if the current node detects that the WLAN port is plugged with a network cable and the network is unobstructed. The root node typically serves as a starting point for the Mesh network and is responsible for initializing network topology, assigning IP addresses, providing network services, etc.
      After the current node is started, the 1 st, 2 nd, 3 rd and 6 th contacts of the RJ45 interface of the WLAN port are detected to be conducted through the PHY chip, and a Link state register displays 'Link Up', so that the network cable is correctly inserted and the physical connection is normal. The current node sends an ARP request frame to a preset gateway address (e.g., 192.168.1.1), and receives an ARP reply frame of the gateway within 2 seconds, indicating that the network is clear. Because both the physical connection and the network smoothness meet the conditions, the current node judges itself as the root node and starts initializing the Mesh network.
      Through the detection flow, the current node can accurately judge whether the current node is a root node or not, so that a corresponding network initialization or access strategy is adopted. This determination method has the following technical effects:
       through double verification of physical connection detection and network smoothness detection, the accuracy of root node judgment is ensured, and network topology errors caused by misjudgment are avoided. 
      The whole judging process is automatically completed by hardware and software, manual intervention is not needed, and the deployment efficiency and flexibility of the Mesh network are improved.
      The judging mode is suitable for various wired network environments (such as Ethernet, optical fiber network and the like) and has good compatibility and expansibility.
      The root node is used as the core of the Mesh network, and the accurate judgment of the root node provides basic guarantee for the stable operation of the network, so that the network paralysis caused by the abnormality of the root node is avoided.
      By the method, the current node can efficiently and reliably finish root node judgment, and a foundation is laid for normal operation of the Mesh network.
      In some possible embodiments of the present application, the method further includes periodically sending the BEACON frame outwards when the current node determines itself to be the root node after the current node is started, and responding to the probe request frames of other nodes, wherein the frequency of sending the BEACON frame by the root node is greater than the frequency of sending the BEACON frame by other nodes in the Mesh network.
      After the current node is started, a series of initialization operations are executed, including the judgment of the roles of the current node in the network. The current node determines itself as the root node through built-in logic or interaction information with other nodes in the network. After the role is located, the current node enters a periodic working mode, and the BEACON frame is sent out at regular time intervals according to preset time intervals. The BEACON frame is a frame structure used for network discovery, node synchronization and network basic information transmission, and contains key information such as identification of a current node, a time stamp, a network state and the like, so that other nodes can find and establish connection with the BEACON frame.
      In addition to periodically transmitting BEACON frames, the current node is in a continuous listening state to receive probe request frames from other nodes. A probe request frame is a frame type used by other nodes to discover surrounding available nodes, establish a communication connection, or conduct network maintenance. After receiving the probe request frame, the current node immediately analyzes and processes the probe request frame, and then replies a corresponding probe response frame according to the content of the request and the state of the current node. The probe response frame contains detailed information of the current node, such as supported communication protocols, available resources, etc., so that the requesting node can make further connection decisions.
      In order to improve the reliability and anti-interference capability of communication, a frequency hopping mode is adopted when a current node communicates with a synchronized node. The frequency hopping technique is a technique for transmitting data by rapidly switching over a plurality of frequency channels, and can effectively avoid interference and congestion on a single frequency channel. The current node negotiates with the synchronized node and determines a hopping sequence, and then sequentially transmits and receives data on different frequency channels according to the sequence. On each frequency channel, the current node will perform short sampling and communication, then quickly switch to the next channel, and so on, completing the entire communication process.
      In Mesh networks, the root node assumes important responsibilities for network management and coordination, and thus requires greater network visibility and real-time. To achieve this, the frequency at which the root node transmits BEACON frames is set to be greater than the transmission frequency of other nodes in the network. Thus, other nodes can receive the BEACON frame of the root node more frequently, so that the change of the network state, the synchronous time information, the instruction of receiving the root node and the like can be obtained in time.
      Through the embodiment, the current node can effectively perform node discovery, synchronization and communication in the Mesh network. And periodically sending the BEACON frame and the response detection request frame, so that nodes in the network can timely discover each other and establish connection, and the topology structure of the network is maintained. The sampling frequency hopping mode improves the reliability and the anti-interference capability of communication, and ensures the stability and the accuracy of data transmission. The frequency of sending BEACON frames by the root node is higher than that of other nodes, so that network management is more efficient, information synchronization is more timely, performance and stability of the whole Mesh network are improved, and reliable network support is provided for various application scenes.
      S202, when the current node receives any frame of any online node in the existing Mesh network through a broadcast channel, time synchronization is executed according to time information carried in the frame.
      When the current node monitors the broadcast channel, once receiving a frame (such as a BEACON frame, a data frame, etc.) from any online node in the existing Mesh network, the current node analyzes timestamp information in the frame. The time stamp is usually generated by the sending node according to its local clock, and the current node uses the time stamp to compare with its own clock, and adjusts its own clock through a time synchronization algorithm (such as NTP, PTP, etc. simplified versions), so as to ensure that the time consistency is maintained with other nodes in the network. The time synchronization is the basis of node cooperation in the Mesh network, and the accuracy of operations such as data transmission, routing decision and the like is ensured.
      S203, after time synchronization is completed, a time slot number is randomly generated, and a detection request frame is sent in a time slot indicated by the generated time slot number through a broadcast channel.
      After the time synchronization is completed, the current node randomly generates a time slot number in order to avoid signal collision with other nodes. The slot number is a fixed location on the time axis that identifies the time period during which the node is transmitting. The current node transmits a probe request frame (Probe Request Frame) over a broadcast channel in a slot indicated by the generated slot number. The probe request frame contains information such as a unique identifier (such as a MAC address) of the current node, a supported protocol version, and the like, and is used for probing an online node in the existing Mesh network.
      In some possible embodiments of the present application, a method for generating a random slot number for a probe request frame to be transmitted includes:
       Splicing the frame type ID of the detection request frame to be sent, the MAC address of the current node and the current time to obtain a splicing value; 
       calculating the splicing value according to a preset hash algorithm to obtain a hash value; 
       and modeling the hash value to a preset maximum time slot number to obtain a module value, and taking the calculated module value as the time slot number of the detection request frame to be sent in the broadcast channel. 
      When generating the probe request frame, the current node first needs to determine the transmission time slot number of the frame. To ensure randomness and uniqueness of the slot assignments, the node concatenates the frame type ID of the probe request frame (used to identify the type of frame, such as a fixed identifier of the probe request frame), the MAC address of the current node (uniquely identifying the node identity), and the current timestamp (accurate to millisecond or finer granularity for introducing the time dimension). The splicing mode can be character string splicing or binary data splicing, and finally a unique splicing value is generated. The splice value integrates the frame type, the node identity and the time information, and ensures that splice values generated by different nodes at different times have uniqueness.
      For example, assuming that the frame type ID of the probe request frame is "0x01", the MAC address of the current node is "00:1A:2B:3C:4D:5E", and the current time is "2023-10-2514:30:00.123". The splice value obtained after splicing is '0x01_00:1A:2B:3C:4D:5E_2023-10-2514:30:00.123'.
      The current node uses a preset hash algorithm (such as SHA-256, MD5, etc.) to hash the splice value. The hash algorithm is an algorithm for mapping input data of any length to fixed-length output, and has irreversibility and collision resistance. By performing hash computation on the splice value, a hash value of a fixed length can be obtained. The calculation of the hash value ensures the uniqueness and unpredictability of the splice value, further enhancing the randomness of the slot allocation.
      For example, the current node hashes the splice value "0x01_00:1a:2b:3c:4d:5e_2023-10-2514:30:00.123" using the SHA-256 algorithm to obtain a 256-bit hash value (hexadecimal "a1b2c3d 4.").
      And thirdly, modeling the hash value to a preset maximum time slot number to obtain a module value, and taking the calculated module value as the time slot number of the detection request frame to be sent in the broadcast channel.
      The extension states that the current node converts the hash value to a value (e.g., converts a hexadecimal hash value to a decimal value) and then modulo the value with a preset maximum slot number (e.g., 100). The result of the modulo operation is an integer between 0 and the maximum slot number-1, called the modulus value. The module value is the time slot number of the detection request frame to be sent by the current node in the broadcast channel. By means of the hash value modulo, randomness and even distribution of the time slot numbers can be ensured, and signal collision caused by the fact that a plurality of nodes select the same time slot number is avoided.
      For example, assuming that the preset maximum slot number is 100, the current node converts the hash value "a1b2c3d 4." to the decimal value "123456789", and then performs a modulo operation on 123456789 and 100 to obtain a modulus value of 89. Therefore, the current node uses the slot number 89 as the transmission slot of the probe request frame.
      Through the steps, the current node can generate a unique splice value based on the frame type ID, the MAC address and the current time, and map the splice value into a random time slot number through a hash algorithm and a modulo operation. The time slot allocation mode has the following technical effects:
       The hash algorithm and the modulo operation ensure the randomness of the time slot numbers and avoid the conflict that a plurality of nodes select the same time slot number. The splice value integrates the frame type, the node identity and the time information, and ensures that the time slot numbers generated by different nodes at different times have uniqueness. The modular operation ensures that the time slot numbers are uniformly distributed in the broadcast channel, and the channel utilization rate is improved. The random time slot allocation reduces the probability of signal interference and improves the stability and reliability of the Mesh network. 
      S204, receiving BEACON frames or detection response frames of other nodes in the existing Mesh network through a broadcast channel, and analyzing the received frames to generate a father node list.
      After the current node sends the probe request frame, the current node continues to monitor the broadcast channel and waits for the responses of other nodes. The other nodes reply to the probe response frame (Probe Response Frame) after receiving the probe request frame. Or nodes in the Mesh network are used for actively and periodically sending BEACON frames. After receiving the probe response frame or the BEACON frame, the current node parses the information therein, such as the unique identification of the transmitting node, the signal strength, the supported protocol version, and the like. According to the analysis result, the current Node generates a Parent Node List (Parent Node List) which contains all candidate nodes possibly serving as Parent nodes and related information thereof
      S205, selecting a parent node in the parent node list as a target parent node.
      And selecting one parent node as a target parent node by the current node according to the information in the parent node list. The selection criteria may include factors such as signal strength, node loading, network topology, etc. For example, the current node may prefer the node with the strongest signal strength and lowest load as the parent node to ensure stability and efficiency of data transmission.
      In some possible embodiments of the application, selecting a parent node in the list of parent nodes as the target parent node comprises:
       And measuring the link quality between the current node and each candidate parent node, and taking the parent node with the best link quality as the target parent node. 
      Specifically, after the current node generates the parent node list, an optimal parent node needs to be selected from the current node as a target parent node, so that stability and efficiency of data transmission are ensured. The selection basis is the link quality between the current node and each candidate parent node. The measurement of link quality typically includes the following aspects:
       Signal Strength (RSSI) the current node measures signal strengths (RECEIVED SIGNAL STRENGTH Indicator) from the various candidate parent nodes via the wireless receiving module. The higher the RSSI value, the stronger the signal, and the better the link quality. 
      Signal-to-noise ratio (SNR) the current node calculates the signal-to-noise ratio of the received signal, i.e. the ratio of the signal power to the noise power. The higher the SNR value, the less noisy the signal is interfered with by the noise, the more reliable the link quality.
      And the packet loss rate is calculated by the current node by sending a detection frame or a data frame and counting the number of received response frames or acknowledgement frames. The lower the packet loss rate, the more stable the link.
      Delay-the current node measures communication delays, including propagation delays and processing delays, with each candidate parent node. The lower the delay, the more timely the data transmission.
      And the current node evaluates the link quality of each candidate parent node by combining the indexes, and selects the parent node with the best link quality as the target parent node.
      By way of illustration, assume that the parent list of the current node contains three candidate parent nodes, node A, node B, and node C.
      The signal strength measurement comprises that the RSSI value of the node A is-60 dBm, the RSSI value of the node B is-70 dBm, and the RSSI value of the node C is-55 dBm.
      The signal-to-noise ratio is calculated to be 25dB for node A, 20dB for node B, and 30dB for node C.
      And the packet loss rate statistics comprises 1% of the packet loss rate of the node A, 5% of the packet loss rate of the node B and 0.5% of the packet loss rate of the node C.
      Delay measurement is 10ms for node A, 15ms for node B, and 8ms for node C.
      After comprehensive evaluation, the current node discovers that the RSSI value of the node C is highest, the SNR is largest, the packet loss rate is lowest, and the delay is shortest, so that the node C is selected as a target father node.
      By the method, the current node can efficiently and reliably select the target father node, and guarantee is provided for stable operation and efficient communication of the Mesh network.
      S206, determining frequency points of the non-broadcast channels according to preset frequency hopping rules, and sending an association request frame to the target father node through the non-broadcast channels.
      After the current node selects the target parent node, the frequency point of the non-broadcast channel is determined according to a preset frequency hopping rule. The frequency hopping rule is a technology for avoiding interference and improving communication security in the Mesh network, and data is transmitted by switching between different frequency points. The current node transmits an association request frame to the target parent node over the non-broadcast channel on the determined frequency point (Association Request Frame). The association request frame contains detailed information of the current node, such as supported protocols, service Set Identification (SSID), etc., for requesting to establish an association with the target parent node.
      S207, after the current node and the target father node are successfully connected, the current node counts the duration of the idle state, when the duration is greater than the duration threshold, a time slot number is randomly generated, and the BEACON frame is periodically sent in the time slot indicated by the generated time slot number through the broadcast channel.
      After the current node and the target father node are successfully connected, the current node enters an idle state and waits for data transmission or signals of other nodes to be received. The current node counts the duration of the idle state, and when the duration is greater than a preset duration threshold, randomly generates a time slot number and periodically transmits the BEACON frame in the time slot indicated by the time slot number. The BEACON frame is an important frame type used for broadcasting the existence of nodes and maintaining network topology in the Mesh network, and contains information such as unique identification of the nodes, signal strength, network state and the like. Nodes of existing Mesh networks also periodically actively send BEACON frames in an idle state to maintain network topology and assist new nodes in discovering the network.
      S208, replying to the corresponding detection response frame when receiving the detection request frame from the offline node.
      When the current node operates normally in the Mesh network, the current node continuously monitors the broadcast channel. When a probe request frame is received from an offline node, the current node replies with a corresponding probe response frame. The probe response frame contains information such as unique identification of the current node, signal strength, supported protocol version, etc., for helping the offline node to understand the current network state, and possibly select the current node as its parent node.
      In some possible embodiments of the application, a timer is started after the current node successfully establishes a connection with the target parent node;
       when any frame of the target father node is received, the counter of the target father node is updated to 0; 
       When the counter of the target parent node is overtime, the current node determines to be in an offline state, stops sending the BEACON frame outwards, stops responding to the probe request frame, and monitors the broadcast channel. 
      After the current node establishes connection with the target parent node, a counter mechanism is started for monitoring the active state of the target parent node. The counter is typically a time dependent variable that records the time interval since the last frame of the target parent node was received. When the current node receives any one of the frames (e.g., data frame, control frame, or BEACON frame) of the target parent node, it indicates that the target parent node is still active. At this time, the current node resets the counter of the target parent node to 0, which indicates that the target parent node has recent activity and the link state is normal.
      By way of example, assume that the current node has established a connection with the target parent node B and a counter is started, with an initial value of 0, incremented by 1 per second. When the current node receives a data frame sent by the node B, the counter of the node B is immediately reset to 0. At this point, even if the counter has been previously incremented to 5, it is reset, indicating that the link state is normal.
      The current node will continuously monitor the counter value of the target parent node. When the counter value exceeds a preset timeout threshold (e.g., 10 seconds), indicating that the current node has not received any frames of the target parent node within a period of time, may mean that the target parent node has gone offline or that the link has failed. At this time, the current node may determine that it is offline, i.e., the connection with the target parent node has been interrupted.
      For example, assume that the target parent node B's counter timeout threshold is 10 seconds. The current node, upon receiving the node B frame, resets the counter to 0. But within the next 10 seconds the current node does not receive any more frames of the node B, causing the counter to increment to 10 and trigger a timeout. At this time, the current node determines that the node B is offline and is in an offline state itself.
      And stopping sending the BEACON frame outwards when the current node determines that the current node is in an offline state. The BEACON frame is an important frame type in the Mesh network for broadcasting the existence of nodes and maintaining the network topology. In the offline state, the current node cannot communicate with other nodes through the target parent node, so it is meaningless to continue to transmit the BEACON frame, and network resources may be wasted. Stopping sending BEACON frames may reduce unnecessary signal interference and energy consumption.
      For example, the current node immediately stops periodically transmitting BEACON frames through the non-broadcast channel after determining itself to be in an offline state. At this point, the other nodes will not be able to detect the presence of the current node through the BEACON frame.
      In the offline state, the current node also stops responding to probe request frames sent by other nodes. The probe request frame is a frame type for a new node to discover the network or an existing node to rediscover a neighbor node. Since the current node is already unable to communicate with the target parent node, it is unable to provide efficient network access or routing services for other nodes. Stopping responding to the probe request frame may avoid misleading other nodes to misunderstand that the current node is still in a usable state.
      For example, when other nodes send probe request frames to the current node, the current node does not reply to the probe response frames in an offline state. At this point, the other nodes will not receive the response of the current node, thereby recognizing that the current node may not be available.
      The current node will continue to listen to the broadcast channel even though it has stopped sending BEACON frames and responding to probe request frames. The purpose of listening to the broadcast channel is to detect if the target parent node is re-online or if there are other nodes attempting to establish a new connection. By listening to the broadcast channel, the current node can timely perceive the change of the network state and reattempt access to the network when conditions allow.
      For example, the current node is in an off-line state and continuously monitors signals on a broadcast channel. When the target parent node B comes back online and sends a BEACON frame, the current node may receive the frame and determine from this that the node B has recovered availability. At this point, the current node may attempt to reestablish a connection with the node B.
      Through the steps, when the target father node is offline or the link fails, the current node can timely sense and adjust the behavior of the current node, so that the operation efficiency and stability of the Mesh network are optimized. The specific technical effects include:
       Stopping sending the BEACON frame and responding to the probe request frame can reduce unnecessary signal interference and energy consumption, and prolong the endurance time of the node. By monitoring the broadcast channel, the current node can timely sense the change of the network state, and provide basis for subsequent re-access or route adjustment. Stopping responding to the probe request frame can avoid misleading other nodes, so that the availability of the current node can be accurately judged, and the network topology structure is optimized. The current node can dynamically adjust the self behavior according to the active state of the target father node, and the self-adaption capability and fault tolerance of the network are improved. 
      By the method, the current node can keep high-efficiency and stable operation in an off-line state, and guarantees are provided for reliability and expandability of the Mesh network.
      In some possible embodiments of the present application, the process of the current node replying to the probe response frame may include:
       After the current node is successfully accessed into the Mesh network, the current node can enter a normal network operation state. During each communication cycle, the current node may receive probe request frames from multiple neighbor nodes (e.g., requests sent when a new node attempts to access the network, or requests sent when an existing node rediscover neighbors). To avoid excessive redundant frames and unnecessary signal interference in the network, the current node adopts a "single response" strategy, i.e. only replies one probe response frame for all received probe request frames in the current period. 
      The current node continuously monitors a broadcast channel in each communication period and receives all the arriving probe request frames. No matter from which neighbor node the frames come, the current node will keep track of it, but will not reply immediately one by one.
      The current node maintains a communication period timer (e.g., one period every 100 milliseconds). At the end of each period, the current node checks whether a probe request frame is received. If multiple probe request frames are received, only one probe response frame is generated, and the frame contains the necessary information (such as MAC address, network state, supported protocol version, etc.) of the current node.
      The current node sends out the generated detection response frame through a broadcast channel. Because of the broadcasting mode, all neighbor nodes sending the detection request frame can receive the response frame, so that the information of the current node is obtained.
      By way of example, assume that the current node a has successfully accessed the Mesh network and begins to receive probe request frames within a certain period. First, node a receives the first probe request frame from node B, which records the source and timestamp of the request. Then, in a very short time, node a again receives a second probe request frame from node B and a probe request frame from node C.
      In the face of these three probe request frames, node a does not immediately reply to the three probe response frames. Instead, it will check whether the requests belong to the same cycle and determine whether they are from the same transmitting node (two requests for node B) or different transmitting nodes (requests for node B and node C). Since node a has set the policy to reply only once to the repeated request of the same transmitting node within one cycle, it ignores the second repeated request of node B (or treats it as a combined process with the first request) and prepares to combine replies to the requests of node B and node C.
      Finally, node a transmits a probe response frame containing probe request acknowledgement information for node B and node C at an appropriate point in time (e.g., after reaching a predetermined time threshold). This response frame would explicitly indicate that node a has received and processed probe requests from both nodes.
      By adopting a strategy of replying one probe response frame only for a plurality of probe request frames, the current node remarkably improves the communication efficiency and the resource utilization rate of the Mesh network. This strategy reduces redundant data transmissions in the network, reduces the risk of network congestion, and enables the network to handle a large number of probe requests more efficiently. At the same time, it also enhances the stability and reliability of the network, as network collisions and errors that may be caused by frequent transmission of probe response frames are reduced. Overall, this technology optimization provides a more efficient, stable and reliable communication environment for Mesh networks.
      The application has the following beneficial effects:
       After time synchronization is completed, the nodes randomly generate time slot numbers and send detection request frames in specific time slots instead of the continuous broadcast routing protocol discovery frames, so that the traditional hierarchical broadcast diffusion mode is broken, the number of broadcast frames in a network is greatly reduced, the occurrence of broadcast storm is fundamentally avoided, a large number of broadcast frames are prevented from occupying network bandwidth and node processing resources, and the network performance is remarkably improved. 
      The nodes which do not join the network do not passively wait for the route protocol discovery frame broadcast by the root node, but can complete time synchronization when receiving any frame of any online node by monitoring a broadcast channel, and randomly select a time slot to send a detection request frame. The active access mode is combined with the selection of random time slots, so that the node can establish contact with the nodes in the network more quickly, the time for accessing the nodes to the network is greatly shortened, the network deployment efficiency is improved, and the application experience is improved.
      After the time synchronization is completed, the node generates a father node list by receiving the BEACON frame or the detection response frame, selects a target father node from the father node list, and then sends an association request frame on a non-broadcast channel according to a frequency hopping rule to establish connection. The orderly access process combines with the frequency hopping communication mode, ensures the stability and reliability of the communication among the nodes, and avoids the problem of network performance degradation caused by unordered access and communication interference of the nodes.
      After the current node successfully establishes connection with the target father node, the current node randomly generates a time slot number to periodically send the BEACON frame when the idle state time length is longer than a time length threshold value. The method for dynamically adjusting the BEACON frame sending frequency ensures that other nodes in the network can timely find the node, avoids unnecessary BEACON frame sending, optimizes the utilization of network resources and improves the overall efficiency of the network.
      The following are examples of the apparatus of the present application that may be used to perform the method embodiments of the present application. For details not disclosed in the embodiments of the apparatus of the present application, please refer to the embodiments of the method of the present application.
      Referring to fig. 3, a schematic structural diagram of a node device according to an exemplary embodiment of the present application is shown, which is hereinafter referred to as an apparatus 3. The apparatus 3 may be implemented as all or part of a node device by software, hardware or a combination of both. The device 3 comprises a listening unit 301, a synchronizing unit 302, a transceiving unit 303, a parsing unit 304 and a selecting unit 305.
      The monitoring unit 301 is configured to determine whether the monitoring unit is a root node after the power-on, and if not, monitor a broadcast channel;
       A synchronization unit 302, configured to perform time synchronization according to time information carried in a frame when receiving any one frame of any online node in the existing Mesh network through the broadcast channel; 
       A transceiver unit 303, configured to randomly generate a time slot number after time synchronization is completed, and send a probe request frame in a time slot indicated by the generated time slot number through the broadcast channel; 
       the parsing unit 304 is configured to receive the BEACON frame or the probe response frame of other nodes in the existing Mesh network through the broadcast channel, parse the received frame, and generate a parent node list; 
       A selecting unit 305, configured to select a parent node in the parent node list as a target parent node; 
       The transceiver unit 303 is further configured to determine a frequency point of a non-broadcast channel according to a preset frequency hopping rule, and send an association request frame to the target parent node through the non-broadcast channel; 
       the transceiver unit 303 is further configured to, after successfully establishing a connection with the target parent node, count a duration of an idle state by the current node, and when the duration is greater than a duration threshold, randomly generate a timeslot number, and periodically send a BEACON frame in a timeslot indicated by the generated timeslot number through the broadcast channel; 
       the transceiver unit 303 is further configured to reply to a corresponding probe response frame when receiving a probe request frame from an offline node. 
      In one or more possible embodiments, randomly generating a slot number for a probe request frame to be transmitted includes:
       Splicing the frame type ID of the detection request frame to be sent, the MAC address of the current node and the current time to obtain a splicing value; 
       calculating the splicing value according to a preset hash algorithm to obtain a hash value; 
       and modeling the hash value to a preset maximum time slot number to obtain a module value, and taking the calculated module value as the time slot number of the detection request frame to be sent in the broadcast channel. 
      In one or more possible embodiments, the determining, by the current node, whether the current node is itself a root node includes:
       and detecting that the WLAN port is plugged with a network cable, and determining that the network is smooth as a root node. 
      In one or more possible embodiments, the selecting a parent node in the parent node list as the target parent node includes:
       And measuring the link quality between the current node and each candidate parent node, and taking the parent node with the best link quality as the target parent node. 
      In one or more possible embodiments, further comprising:
       the keep-alive unit is used for starting a timer after the current node and the target father node are successfully connected; 
       when any frame of the target father node is received, the counter of the target father node is updated to 0; 
       When the counter of the target parent node is overtime, the current node determines to be in an offline state, stops sending the BEACON frame outwards, stops responding to the probe request frame, and monitors the broadcast channel. 
      In one or more possible embodiments, the receiving the probe request frame from the offline node, replying to the corresponding probe response frame includes:
       The current node which successfully accesses the existing Mesh network receives a plurality of probe request frames in the current period, and replies a probe response frame only for the plurality of probe request frames. 
      In one or more possible embodiments,
      The transceiver unit 303 is further configured to periodically send a BEACON frame outwards when the current node determines itself to be a root node after the current node is powered on, and respond to a probe request frame of another node to communicate with a synchronized node in the used Mesh network in a frequency hopping manner, where the frequency of sending the BEACON frame by the root node is greater than the frequency of sending the BEACON frame by the other node in the Mesh network.
      It should be noted that, when the apparatus 3 provided in the foregoing embodiment performs the method of accessing the Mesh network, only the division of the foregoing functional modules is used as an example, and in practical application, the foregoing functional allocation may be performed by different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules, so as to complete all or part of the foregoing functions. In addition, the node device provided in the above embodiment and the method embodiment for accessing the Mesh network belong to the same concept, which embody the detailed implementation process in the method embodiment, and are not repeated here.
      The foregoing embodiment numbers of the present application are merely for the purpose of description, and do not represent the advantages or disadvantages of the embodiments.
      Referring to fig. 4, a computer storage medium according to an embodiment of the present application may be a magnetic disk, an optical disk, a magnetic tape, a usb disk, or the like. The computer storage medium may store a plurality of instructions (i.e., and a computer program) adapted to be loaded by a processor and to execute the steps of the method according to the embodiment shown in fig. 1, where the specific execution process may refer to the specific description of the embodiment shown in fig. 1, and details are not repeated herein.
      The present application also provides a computer program product storing at least one instruction that is loaded and executed by the processor to implement the method of accessing a Mesh network as described in the above embodiments.
      Referring to fig. 5, a schematic structural diagram of a node device is provided in an embodiment of the present application. As shown in fig. 5, the node device 500 may include at least one processor 501, at least one network interface 504, a user interface 503, a memory 505, and at least one communication bus 502.
      Wherein a communication bus 502 is used to enable connected communications between these components.
      The user interface 503 is used to perform user interaction, for example, the user interface is an input/output device such as a touch screen, a display screen, a keyboard, etc.
      The network interface 504 may optionally include a standard wired interface, a wireless interface (e.g., WI-FI interface), among others.
      Wherein the processor 501 may include one or more processing cores. The processor 501 utilizes various interfaces and lines to connect various portions of the overall node apparatus 500, perform various functions of the node apparatus 500 and process data by executing or executing instructions, programs, code sets, or instruction sets stored in the memory 505, and invoking data stored in the memory 505. Alternatively, the processor 501 may be implemented in at least one hardware form of digital signal Processing (DIGITAL SIGNAL Processing, DSP), field-Programmable gate array (Field-Programmable GATEARRAY, FPGA), programmable logic array (Programmable Logic Array, PLA). The processor 501 may integrate one or a combination of several of a central processing unit (Central Processing Unit, CPU), an image processor (Graphics Processing Unit, GPU), and a modem, etc. The CPU mainly processes an operating system, a user interface, an application program and the like, the GPU is used for rendering and drawing contents required to be displayed by the display screen, and the modem is used for processing wireless communication. It will be appreciated that the modem may not be integrated into the processor 501 and may be implemented by a single chip.
      The Memory 505 may include a random access Memory (RandomAccess Memory, RAM) or a Read-Only Memory (Read-Only Memory). Optionally, the memory 505 comprises a non-transitory computer readable medium (non-transitory computer-readable storage medium). Memory 505 may be used to store instructions, programs, code sets, or instruction sets. The memory 505 may include a stored program area that may store instructions for implementing an operating system, instructions for at least one function (e.g., a touch function, a sound playing function, an image playing function, etc.), instructions for implementing the various method embodiments described above, etc., and a stored data area that may store data related to the various method embodiments described above, etc. The memory 505 may also optionally be at least one storage device located remotely from the processor 501. As shown in fig. 5, an operating system, a network communication module, a user interface module, and application programs may be included in the memory 505, which is one type of computer storage medium.
      In the node device 500 shown in fig. 5, the user interface 503 is mainly used for providing an input interface for a user to obtain data input by the user, and the processor 501 may be used for calling an application program stored in the memory 505 and specifically executing the method shown in fig. 2, and the specific process may be shown in fig. 2 and will not be described herein.
      Those skilled in the art will appreciate that implementing all or part of the above-described methods in accordance with the embodiments may be accomplished by way of a computer program stored on a computer readable storage medium, which when executed may comprise the steps of the embodiments of the methods described above. The storage medium may be a magnetic disk, an optical disk, a read-only memory, a random access memory, or the like.
      The foregoing disclosure is illustrative of the present application and is not to be construed as limiting the scope of the application, which is defined by the appended claims.