diff options
| author | Loic Guegan <manzerbredes@mailbox.org> | 2022-06-09 21:48:32 +0200 |
|---|---|---|
| committer | Loic Guegan <manzerbredes@mailbox.org> | 2022-06-09 21:48:32 +0200 |
| commit | c2e6aad09f893e4c8cb5cb9243c32a0d6d0d1e12 (patch) | |
| tree | bebdb575f200c7ea75f3115a81deecd5b797c4ff /tests/simple_send_eth0_3s1r | |
Init ESDS repository
Diffstat (limited to 'tests/simple_send_eth0_3s1r')
| -rw-r--r-- | tests/simple_send_eth0_3s1r/out | 40 | ||||
| -rw-r--r-- | tests/simple_send_eth0_3s1r/receiver.py | 19 | ||||
| -rw-r--r-- | tests/simple_send_eth0_3s1r/sender.py | 37 | ||||
| -rwxr-xr-x | tests/simple_send_eth0_3s1r/simulator.py | 18 |
4 files changed, 114 insertions, 0 deletions
diff --git a/tests/simple_send_eth0_3s1r/out b/tests/simple_send_eth0_3s1r/out new file mode 100644 index 0000000..8cf82a6 --- /dev/null +++ b/tests/simple_send_eth0_3s1r/out @@ -0,0 +1,40 @@ +[t=0.000,src=n0] Send 1 bytes to n3 on eth0 +[t=0.000,src=n1] Send 1 bytes to n3 on eth0 +[t=0.000,src=n2] Send 1 bytes to n3 on eth0 +[t=3.000,src=n3] Receive 1 bytes on eth0 +[t=3.000,src=n3] Received: Hello World from 0! +[t=3.000,src=n3] Receive 1 bytes on eth0 +[t=3.000,src=n3] Received: Hello World from 1! +[t=3.000,src=n3] Receive 1 bytes on eth0 +[t=3.000,src=n3] Received: Hello World from 2! +[t=3.000,src=n0] Send 2 bytes to n3 on eth0 +[t=3.000,src=n1] Send 1 bytes to n3 on eth0 +[t=3.000,src=n2] Send 1 bytes to n3 on eth0 +[t=6.000,src=n3] Receive 1 bytes on eth0 +[t=6.000,src=n3] Received: Hello World from 1! +[t=6.000,src=n3] Receive 1 bytes on eth0 +[t=6.000,src=n3] Received: Hello World from 2! +[t=7.000,src=n3] Receive 2 bytes on eth0 +[t=7.000,src=n3] Received: Hello World from 0! +[t=7.000,src=n0] Send 2 bytes to n3 on eth0 +[t=7.000,src=n1] Send 2 bytes to n3 on eth0 +[t=7.000,src=n2] Send 1 bytes to n3 on eth0 +[t=10.000,src=n3] Receive 1 bytes on eth0 +[t=10.000,src=n3] Received: Hello World from 2! +[t=12.000,src=n3] Receive 2 bytes on eth0 +[t=12.000,src=n3] Received: Hello World from 0! +[t=12.000,src=n3] Receive 2 bytes on eth0 +[t=12.000,src=n3] Received: Hello World from 1! +[t=12.000,src=n0] Send 1 bytes to n3 on eth0 +[t=12.000,src=n1] Send 2 bytes to n3 on eth0 +[t=12.000,src=n2] Send 3 bytes to n3 on eth0 +[t=15.000,src=n3] Receive 1 bytes on eth0 +[t=15.000,src=n3] Received: Hello World from 0! +[t=17.000,src=n3] Receive 2 bytes on eth0 +[t=17.000,src=n3] Received: Hello World from 1! +[t=18.000,src=n3] Receive 3 bytes on eth0 +[t=18.000,src=n3] Received: Hello World from 2! +[t=18.000,src=n0] Send 5 bytes to n3 on eth0 +[t=23.000,src=n3] Receive 5 bytes on eth0 +[t=23.000,src=n3] Received: Hello World from 0! +[t=23.000,src=esds] Simulation ends diff --git a/tests/simple_send_eth0_3s1r/receiver.py b/tests/simple_send_eth0_3s1r/receiver.py new file mode 100644 index 0000000..4516d7a --- /dev/null +++ b/tests/simple_send_eth0_3s1r/receiver.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python + +def receive(node, n): + for i in range(0,n): + code, data=node.receive("eth0") + msg="Received: "+data if code == 0 else "Receive failed code="+str(code) + node.log(msg) + +def execute(api): + # Receive the first 3 send that should end at 3s + receive(api,3) + # Receive the first 3 send that should end at 7s + receive(api,3) + # Receive the first 3 send that should end at 12s + receive(api,3) + # Receive the first 3 send that should end at 18s + receive(api,3) + # Should ends at 23s + receive(api,1) diff --git a/tests/simple_send_eth0_3s1r/sender.py b/tests/simple_send_eth0_3s1r/sender.py new file mode 100644 index 0000000..d3c7bf2 --- /dev/null +++ b/tests/simple_send_eth0_3s1r/sender.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python + +# Node that bandwidths at setup in a way that 1 byte is send in 1 seconds with no sharing + +def execute(api): + # Should be completed at 3s (bandwidth divided by 3) + api.send("eth0","Hello World from {}!".format(api.node_id),1,3) # Shoud lasts 3s + + # These send should start at 3s and be completed at 7s + if api.node_id==0: + api.send("eth0","Hello World from {}!".format(api.node_id),2,3) # Should lasts 3s + 1s = 4s + else: + api.send("eth0","Hello World from {}!".format(api.node_id),1,3) # Should lasts 3s + api.wait(1) # Sync with node 0 at 7s + + # Those sends should start at 7s and be completed at 12s + if api.node_id<=1: + api.send("eth0","Hello World from {}!".format(api.node_id),2,3) # Should last 3s + 2s = 5s + # Completed at 12s since 3 nodes are sharing the bandwidth up to 10s + # then the 2 two remaining node send their last byte up to 12s + else: + api.send("eth0","Hello World from {}!".format(api.node_id),1,3) # Should last 3s + # Completed at 10s (3 nodes are sharing the bandwidth) + api.wait(2) # Sync with node 0-1 at 12s + + # Should start at 12s + # Node 0 sends 1 byte, node 1 sends 2 byte and node 2 sends 3 + # These send should end at 18s + api.send("eth0","Hello World from {}!".format(api.node_id),api.node_id+1,3) # Should lasts 3s, 5s and 6s + + # Finally a single send from node 0 + if api.node_id==0: + api.wait(3) # Since node 0 send ends at 15s we sync it to 18s + api.send("eth0","Hello World from {}!".format(api.node_id),5,3) # Should takes 5 seconds (ends at 23s) + + + diff --git a/tests/simple_send_eth0_3s1r/simulator.py b/tests/simple_send_eth0_3s1r/simulator.py new file mode 100755 index 0000000..4a5aede --- /dev/null +++ b/tests/simple_send_eth0_3s1r/simulator.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python + +# Load ESDS +import sys +sys.path.append("../../") +import esds +import numpy as np + +B=np.full((4,4),8) +L=np.full((4,4),0) +s=esds.Simulator(B,L) + +s.create_node("sender") +s.create_node("sender") +s.create_node("sender") +s.create_node("receiver") + +s.run() |
