I've got a bit of a puzzle here that sits at the intersection of mathematics and technology. Hopefully this doesn't fall into brainteaser territory - I'm not sure a neat solution is possible!

I have two devices. Each one has a short token they would like to share. I am happy for either device to get the other's token; they don't both need both tokens.

Each device can transmit or receive locally, but it can't do both at the same time. A transmission takes 1-2 seconds. Both devices know the time (very accurately) but have no other knowledge of each other.

I can see a flakey solution here - start in receive mode for a random number of seconds, then enter transmit mode for one transmission, then repeat with a new random number. Sooner or later (probably sooner) a full transmit window will be captured in the other device's receive window; there is some risk of transmit collisions and partial receives, but the bigger the range of that wait window the less likely this becomes (and the token is a known length + has a check digit; partial receives are easily discarded).

My solution works, but feels very inelegant. It occurs to me this problem probably exists in many domains and may even have a name / common approach. Could anybody steer me in the right direction? Obviously it would be better if the devices could have a known master / slave relationship, or if one could transmit on odd seconds and one on evens; but there are dozens of these devices and no way of knowing which two will end up next to each other trying to pair.

I've tried to abstract away a lot of the details but happy to provide more where it would be helpful.



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.