Skip to content
Snippets Groups Projects
Commit d9ef1c38 authored by Rishi Sharma's avatar Rishi Sharma
Browse files

Communication_test

parent 3f688ea6
No related branches found
No related tags found
No related merge requests found
...@@ -102,4 +102,4 @@ class Communication: ...@@ -102,4 +102,4 @@ class Communication:
to_send = self.encrypt(data) to_send = self.encrypt(data)
id = str(uid).encode() id = str(uid).encode()
self.peer_sockets[id].send(to_send) self.peer_sockets[id].send(to_send)
print("Message sent") print("{} sent the message to {}.".format(self.uid, uid))
...@@ -7,11 +7,11 @@ from decentralizepy.mappings.Linear import Linear ...@@ -7,11 +7,11 @@ from decentralizepy.mappings.Linear import Linear
def f(rank, m_id, total_procs, filePath, mapping): def f(rank, m_id, total_procs, filePath, mapping):
c = Communication(rank, m_id, total_procs, filePath, mapping) c = Communication(rank, m_id, total_procs, filePath, mapping)
c.connect_neighbours([i for i in range(total_procs) if i != mapping.get_uid(rank, m_id)]) c.connect_neighbours([i for i in range(total_procs) if i != c.uid])
send = {} send = {}
send["message"] = "Hi I am rank {}".format(rank) send["message"] = "Hi I am rank {}".format(rank)
c.send((rank + 1) % total_procs, send) c.send((c.uid + 1) % total_procs, send)
print(rank, c.receive()) print(c.uid, c.receive())
if __name__ == "__main__": if __name__ == "__main__":
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment