Relative distance without anchors

I am not an expert in this field, so I apologize in advance if the question is trivial or misplaced. I have to design a (small) network in which each node is able to read the distance from all the others. My idea is to program the modules so as to make a switch between “receiver” and “responder”, using the code shown here ( My problem is that when the switch is made from responder to receiver, the code is stuck. In particular, I noticed that the problem occurs when I pass from dwt_setrxtimeout(0) (for the responder) to dwt_setrxtimeout(65000) (for the receiver).

I ask you if anyone has managed to design a network that performs the same functions and if you can advise me some reference with which to deepen.

Thank you!