Open zoopp opened 2 years ago
You are correct, this is a hole in the library that hasn't been addressed, issue 216. There is no "upstream" notification from the link layer to the network layer (or the application layer for that matter) which should be along some kind of "control packets" rather than strictly "data packets."
I was considering adding control_request(**kwargs: Any)
, control_indication(**kwargs: Any)
, etc., type functions to the client and server classes that could pass content around. In fact they were once used for add_peer
and delete_peer
functions, but that was it, and it was simpler to just call those functions what they were rather than more checking to see what arguments were provided.
Mhm, just so I understand correctly, these control_
methods would act just as a way to pass custom messages between downstream/upstream directly connected "elements"? Am I right in thinking that this only helps with cohesion/code structure? Apart from that, I don't fully understand how it would help with solving this issue.
Even with that, I would think we'd still need a loop/task that periodically reaps stale entries from the NetworkServiceAccessPoint.pending_nets
dictionary.
I noticed a communication issue when making use of the foreign device functionality. Suppose we have the following setup:
The bacpypes application registers as a foreign device to the BBMD, which is also a router, in order to communicate with devices present in network number 1.
What I noticed is that if the foreign device registration completes before any requests is sent out to those devices then things are fine but if communication is attempted without having an active foreign device registration first then the bacpypes application won't be able to communicate with those devices during its lifetime.
I've tracked the issue down to the NetworkServiceAccessPoint class. The NSAP keeps lists of packets waiting for a network path and while there are no known network paths it adds new packets to the lists (here and here).
The first time a packet for a never-before seen network is sent, the NSAP broadcasts a WhoIsRouterToNetwork and when the IAmRouterToNetwork response comes back, any pending packets are sent out.
However, if the IAmRouterToNetwork never arrives (i.e. because foreign device registration is pending) then no subsequent attempts to discover a path will be made and the bacpypes application won't be able to reach those devices from this point forward (unless we're lucky and an "unsolicited" IAmRouterToNetwork comes our way but I wouldn't count on it):
My initial train of thought would be to have some form of time-to-live functionality around both path discovery as well as pending packet retention. This way, if we periodically "expire" packets pending network path discovery then we could re-attempt it in the future using the same functionality that we have now.
What are your thoughts on this?