digidotcom / xbee-python

Python library to interact with Digi International's XBee radio frequency modules.
Mozilla Public License 2.0
185 stars 93 forks source link

Node timeout doesn't work in my script #283

Closed fealvares closed 1 year ago

fealvares commented 1 year ago

My discovery does not finish after exced the node timeout after discovering the last node.

My discovery configurations:

self.xnet = self.xbee.get_network()
        # discovery nodes settings
        self.xnet.set_deep_discovery_options(deep_mode=NeighborDiscoveryMode.CASCADE,
                                             del_not_discovered_nodes_in_last_scan=False)
        self.xnet.set_deep_discovery_timeouts(node_timeout=25, time_bw_requests=10, time_bw_scans=20)

Am I doing a misapllication?

The discovery is taking too much time to finish.

tatianaleon commented 1 year ago

Hi @fealvares,

I am not sure of what you mean with "My discovery does not finish after exceed the node timeout after discovering the last node" and later you add "The discovery is taking too much time to finish". What is exactly happening? Are you using the deep discovery? Are you registering a callback for the end of the process (add_discovery_process_finished_callback())? Are you waiting for the process checking is_discovery_running()? The code example it is not complete.

The "deep" discovery process usually takes more time than the standard discovery process, although it offers more information about the network (connections, quality) and does not generate so much traffic. The time to discover the full network with this mechanism depends on the node timeout but it is not the only parameter involved. See Deep discovery for more information. If you are using start_discovery_process(deep=True) in a DigiMesh network, with the configuration:

The discovery will wait 25s per node to get its neighbors, 10s between node requests, and 20 seconds between scans (by default 1 scan if you are not passing n_deep_scans=<n> to start_discovery_process) That is, if you have N nodes in your network, the time per discovery scan, DS, is:

DS ~= N*25 + (N-1)*10

And the total discovery time with S number of scans, DT, is:

DT ~= S*DS + (S-1)*20

For example, 2 scans with a network with 5 nodes:

DS ~= 5*25 + (5-1)*10 ~= 165s
DT ~= 2*165 + (2-1)*20 ~= 350s

Hope this helps. Tatiana

fealvares commented 1 year ago

Hi Tatiana,

I thought the discovery nodes would end when the scan reach the node timeout if it didn't find any nodes, so after discover a node and pass 25 seconds without discovering a new node I was expecting the end of the scan.

I'm registering a callback for the end of process, its prints in my log when the scan stops. My dev team requested it to show in our dashboard when the discover is over.

I understood how the deep discovery timeout works now, thanks.

I'm doing some test with the discovery nodes in a farm that has more than 50 xbees, acutally are two customers farms that their mesh network are connected. Its take about 15 minutes to conclude the discovery :)

I run the deep scan to discorver my network, I do this beacuse it was the only way I found to get the link quality. Does the lib have other way to get the link quality? If I could get the link quality without the deep scan, I would use the simple discovery instead.

Att, Felipe

tatianaleon commented 1 year ago

Hi @fealvares

I thought the discovery nodes would end when the scan reach the node timeout if it didn't find any nodes, so after discover a node and pass 25 seconds without discovering a new node I was expecting the end of the scan.

You are right, if there is only one node in the network (your local node) and only one scan, the discovery will take that 25 seconds.

I'm registering a callback for the end of process, its prints in my log when the scan stops. My dev team requested it to show in our dashboard when the discover is over.

Just for you to know, you can register callbacks for the end of the discovery process, for new discovered devices, but also for beginning and end of each scan or for network modifications (see Network modifications sample)

I'm doing some test with the discovery nodes in a farm that has more than 50 xbees, acutally are two customers farms that their mesh network are connected. Its take about 15 minutes to conclude the discovery :)

You can reduce your time values, but keep in mind this it is going to generate more traffic in the network.

I run the deep scan to discorver my network, I do this beacuse it was the only way I found to get the link quality. Does the lib have other way to get the link quality? If I could get the link quality without the deep scan, I would use the simple discovery instead.

The library does not include any other way. You can use other methods such as the DB or a test link. You have to implement them with the library API for your application and I am not sure if this will give you the quality of all the connections, since only the local node can perform them.

I do not know why you need the whole network connections quality. It is useful to better position nodes on a deployment, to check the network health or to identify bottle necks in the communication, for example. I mean, if one node fails and the network is well setup, the network will find a different path to the destination (see DigiMesh networking) and in the mean time the "bad" node can be fixed. For this purposes, you will have to monitor the network and that imply time and not a quick response.

DigiMesh network

Best Regards, Tatiana

fealvares commented 1 year ago

Hi Tatiana,

We need the network quality connections to our after sales team can indentify if a communication problem is related to radio or something else.

It's make sense not to be a quick response when I want to analyze my network.

I will change the deep discovery to the standard discovery, and also a new feature to do a deep scan only when it is necessary, I think it will be the better solution.

Thanks a lot for you help Tatiana.

Att, Felipe