QuNetSim icon indicating copy to clipboard operation
QuNetSim copied to clipboard

If "get_next_classical" timeouts, successive calls won't read any messages

Open SDABIS opened this issue 2 years ago • 2 comments

Describe the bug Hi. I'm trying to implement a network in which one node is listening to multiple neighbors. My current implementation makes multiple calls to "get_next_classical", but I encountered a bug: if a call to "get_next_classical" timeouts without receiving a message, any successive call to "get_next_classical" will also timeout, regardless if any message has arrived.

To Reproduce Steps to reproduce the behavior:

  1. Create a template code
  2. Protocol_1 performs sleep(3), and then host.send_classical(receiver, s, await_ack=True)
  3. Protocol_2 performs host.get_next_classical(sender, wait=2).
  4. Protocol_2 performs host.get_next_classical(sender)

Expected behavior Step 3 should always timeout, since Protocol_1 sleeps for 3 seconds. The second call to "get_next_classical" should wait for 1 second, and then return the message when Protocol_1 sends it.

What I encountered is that this second call to "get_next_classical" never reads the incoming message.

SDABIS avatar Oct 18 '22 14:10 SDABIS

The behaviour I would expect in this code is that the first call to get_next_classical times out after 2 seconds and the next call is made, which doesn't wait at all. What if you had put wait=2 in the second call? It could also be that the first message arrives between the first and second call. Does the second call return nothing? I'll test this myself in the coming days.

stephendiadamo avatar Oct 18 '22 23:10 stephendiadamo

Thank you for looking into it. Changing the second call to "wait=2" does not change anything: it also timeouts without reading the message. In both cases, the call returns "None".

SDABIS avatar Oct 19 '22 07:10 SDABIS