Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a variation of "get_classical" that can receive a message from any host #145

Closed
SDABIS opened this issue Oct 17, 2022 · 11 comments
Closed
Assignees
Labels
enhancement New feature or request unitaryhack unitaryhack-bounty Unitary Hack Issue

Comments

@SDABIS
Copy link

SDABIS commented Oct 17, 2022

Hi.
I'm trying to implement a simple network with QuNetSim, but I'm having trouble with the function "get_classical".
I want my nodes to listen to incoming messages, but "get_classical" requires that I indicate which host to listen to. My current solution is to create a loop with every possible other host and call "get_classical" with a small "wait_time", but this seems like a poor solution.
Is there a way to listen to any classical packet (in my example there is no need for this functionality for quantum channels) sent by any host?
Thank you.

@SDABIS SDABIS added the enhancement New feature or request label Oct 17, 2022
@lavanya-m-k
Copy link

I would like to work on this issue. Can you please assign it to me?

@stephendiadamo
Copy link
Collaborator

Sure will do.

@stephendiadamo
Copy link
Collaborator

Before implementing this feature, since it's a bit tricky, it would be good if you write out how you plan to solve it first. I can give you some tips on how it can be done.

@san-gh
Copy link
Contributor

san-gh commented Jun 3, 2023

@stephendiadamo can I open a PR too since this issue is still open?

@stephendiadamo
Copy link
Collaborator

@lavanya-m-k what's your status with this one? Do you have a solution in mind?

@san-gh I have to check if we can reward two people with the same prize. I guess it's fine to make a PR too. But it would be good to know in advance how you plan to solve this one, since it's a bit tricky.

Thanks

@san-gh
Copy link
Contributor

san-gh commented Jun 3, 2023

Ok so, regarding the approach.
What I have understood up till about the workings of get_classical without a seq_num is that for wait=0 it synchronously fetches all the msgs of the particular host and for wait > 0 it puts in a request with the ClassicalStorage and waits using queue's timeout. And these requests are resolved when a new message is added to the ClassicalStorage.

Since the requirement is to listen for messages from any host, I want to specifically make a new function get_classical_any_host so that after it starts listening it returns the messages from the last host that sent a msg to the ClassicalStorage. For that, I want to create a variable last_msg_added_to_host in the ClassicalStorage that gets updated when a new message is added. I would want to use this host_id in _get_all_from_sender & _get_with_seq_num_from_sender. I hope that since the message adding and servicing requests happen within the same critical section, it should not create any thread-related issues.

How does this sound? @stephendiadamo
Please let me know if I understood it correctly or some hints at a better approach.

@stephendiadamo
Copy link
Collaborator

stephendiadamo commented Jun 3, 2023

That sounds pretty good to me. And it incorporates waiting for such a message to arrive?

For the PR we'll need to add a test case as well, since it is a library function rather than a one-off simulation.

@san-gh

@san-gh
Copy link
Contributor

san-gh commented Jun 3, 2023

Yes, I will incorporate wait using a queue timeout the same way as get_classical.

Ok, so will it be enough to add test cases to ./integration_tests/test_classical_storage.py and integration_tests/host.py?
@stephendiadamo

@stephendiadamo
Copy link
Collaborator

@san-gh yes that will be fine for the tests. Thanks!

@lavanya-m-k lavanya-m-k removed their assignment Jun 4, 2023
@lavanya-m-k
Copy link

@stephendiadamo I was occupied with other issues till now. Will start this today and post my approach soon. If @san-gh already has a solution and wants to create PR @san-gh can proceed with that.

@san-gh
Copy link
Contributor

san-gh commented Jun 13, 2023

Hey @stephendiadamo , sorry to bother you but could you please assign this issue to me ? And if it has been solved to your satisfaction mark it as closed ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request unitaryhack unitaryhack-bounty Unitary Hack Issue
Projects
None yet
Development

No branches or pull requests

4 participants