summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2022-06-09 21:48:32 +0200
committerLoic Guegan <manzerbredes@mailbox.org>2022-06-09 21:48:32 +0200
commitc2e6aad09f893e4c8cb5cb9243c32a0d6d0d1e12 (patch)
treebebdb575f200c7ea75f3115a81deecd5b797c4ff /tests
Init ESDS repository
Diffstat (limited to 'tests')
-rw-r--r--tests/README.md6
-rw-r--r--tests/hidden_node_2s1r/out4
-rw-r--r--tests/hidden_node_2s1r/receiver.py5
-rw-r--r--tests/hidden_node_2s1r/sender.py4
-rwxr-xr-xtests/hidden_node_2s1r/simulator.py22
-rw-r--r--tests/mobility_eth0_bandwidth_1s1r/out4
-rw-r--r--tests/mobility_eth0_bandwidth_1s1r/receiver.py5
-rw-r--r--tests/mobility_eth0_bandwidth_1s1r/sender.py4
-rwxr-xr-xtests/mobility_eth0_bandwidth_1s1r/simulator.py38
-rw-r--r--tests/mobility_eth0_bandwidth_2s1r/out6
-rw-r--r--tests/mobility_eth0_bandwidth_2s1r/receiver.py5
-rw-r--r--tests/mobility_eth0_bandwidth_2s1r/sender.py4
-rwxr-xr-xtests/mobility_eth0_bandwidth_2s1r/simulator.py41
-rw-r--r--tests/mobility_eth0_bandwidth_2s1r/yoctosim.debug37
-rw-r--r--tests/mobility_eth0_latency_1s1r/out5
-rw-r--r--tests/mobility_eth0_latency_1s1r/receiver.py5
-rw-r--r--tests/mobility_eth0_latency_1s1r/sender.py4
-rwxr-xr-xtests/mobility_eth0_latency_1s1r/simulator.py39
-rw-r--r--tests/mobility_eth0_latency_2s1r/out7
-rw-r--r--tests/mobility_eth0_latency_2s1r/receiver.py5
-rw-r--r--tests/mobility_eth0_latency_2s1r/sender.py4
-rwxr-xr-xtests/mobility_eth0_latency_2s1r/simulator.py42
-rw-r--r--tests/mobility_eth0_latency_2s1r/yoctosim.debug51
-rw-r--r--tests/mobility_wlan0_bandwidth_1s1r/out4
-rw-r--r--tests/mobility_wlan0_bandwidth_1s1r/receiver.py5
-rw-r--r--tests/mobility_wlan0_bandwidth_1s1r/sender.py4
-rwxr-xr-xtests/mobility_wlan0_bandwidth_1s1r/simulator.py38
-rw-r--r--tests/mobility_wlan0_latency_1s1r/out5
-rw-r--r--tests/mobility_wlan0_latency_1s1r/receiver.py5
-rw-r--r--tests/mobility_wlan0_latency_1s1r/sender.py4
-rwxr-xr-xtests/mobility_wlan0_latency_1s1r/simulator.py39
-rwxr-xr-xtests/run.sh48
-rw-r--r--tests/simple_breakpoints_auto_1n/node.py8
-rw-r--r--tests/simple_breakpoints_auto_1n/out9
-rwxr-xr-xtests/simple_breakpoints_auto_1n/simulator.py20
-rw-r--r--tests/simple_breakpoints_manual_1n/node.py4
-rw-r--r--tests/simple_breakpoints_manual_1n/out7
-rwxr-xr-xtests/simple_breakpoints_manual_1n/simulator.py20
-rw-r--r--tests/simple_breakpoints_manual_no_callback_1n/node.py4
-rw-r--r--tests/simple_breakpoints_manual_no_callback_1n/out3
-rwxr-xr-xtests/simple_breakpoints_manual_no_callback_1n/simulator.py17
-rw-r--r--tests/simple_log_5n/node.py7
-rw-r--r--tests/simple_log_5n/out21
-rwxr-xr-xtests/simple_log_5n/simulator.py19
-rw-r--r--tests/simple_read_clock_2n/node.py7
-rw-r--r--tests/simple_read_clock_2n/out7
-rwxr-xr-xtests/simple_read_clock_2n/simulator.py16
-rw-r--r--tests/simple_read_eth0_ncom_2s1r/out9
-rw-r--r--tests/simple_read_eth0_ncom_2s1r/receiver.py12
-rw-r--r--tests/simple_read_eth0_ncom_2s1r/sender.py9
-rwxr-xr-xtests/simple_read_eth0_ncom_2s1r/simulator.py17
-rw-r--r--tests/simple_read_wlan0_ncom_2s1r/out11
-rw-r--r--tests/simple_read_wlan0_ncom_2s1r/receiver.py12
-rw-r--r--tests/simple_read_wlan0_ncom_2s1r/sender.py9
-rwxr-xr-xtests/simple_read_wlan0_ncom_2s1r/simulator.py17
-rw-r--r--tests/simple_receivet_eth0_1s1r/out8
-rw-r--r--tests/simple_receivet_eth0_1s1r/receiver.py15
-rw-r--r--tests/simple_receivet_eth0_1s1r/sender.py6
-rwxr-xr-xtests/simple_receivet_eth0_1s1r/simulator.py16
-rw-r--r--tests/simple_receivet_eth0_1s1r/yoctosim.debug43
-rw-r--r--tests/simple_send_eth0_1s1r/out11
-rw-r--r--tests/simple_send_eth0_1s1r/receiver.py20
-rw-r--r--tests/simple_send_eth0_1s1r/sender.py7
-rwxr-xr-xtests/simple_send_eth0_1s1r/simulator.py16
-rw-r--r--tests/simple_send_eth0_2s1r/out7
-rw-r--r--tests/simple_send_eth0_2s1r/receiver.py13
-rw-r--r--tests/simple_send_eth0_2s1r/sender.py5
-rwxr-xr-xtests/simple_send_eth0_2s1r/simulator.py17
-rw-r--r--tests/simple_send_eth0_3s1r/out40
-rw-r--r--tests/simple_send_eth0_3s1r/receiver.py19
-rw-r--r--tests/simple_send_eth0_3s1r/sender.py37
-rwxr-xr-xtests/simple_send_eth0_3s1r/simulator.py18
-rw-r--r--tests/simple_send_wlan0_1s2r/out16
-rw-r--r--tests/simple_send_wlan0_1s2r/receiver.py29
-rw-r--r--tests/simple_send_wlan0_1s2r/sender.py6
-rwxr-xr-xtests/simple_send_wlan0_1s2r/simulator.py17
-rw-r--r--tests/simple_send_wlan0_2s1r/out6
-rw-r--r--tests/simple_send_wlan0_2s1r/receiver.py5
-rw-r--r--tests/simple_send_wlan0_2s1r/sender.py4
-rwxr-xr-xtests/simple_send_wlan0_2s1r/simulator.py17
-rw-r--r--tests/simple_sendt_eth0_1s1r/out11
-rw-r--r--tests/simple_sendt_eth0_1s1r/receiver.py11
-rw-r--r--tests/simple_sendt_eth0_1s1r/sender.py14
-rwxr-xr-xtests/simple_sendt_eth0_1s1r/simulator.py16
-rw-r--r--tests/simple_sendt_wlan0_1s2r/out7
-rw-r--r--tests/simple_sendt_wlan0_1s2r/receiver.py13
-rw-r--r--tests/simple_sendt_wlan0_1s2r/sender.py8
-rwxr-xr-xtests/simple_sendt_wlan0_1s2r/simulator.py17
-rw-r--r--tests/simple_wait_2n/node.py9
-rw-r--r--tests/simple_wait_2n/out9
-rwxr-xr-xtests/simple_wait_2n/simulator.py16
-rw-r--r--tests/simple_wait_end_3n/node.py10
-rw-r--r--tests/simple_wait_end_3n/out7
-rwxr-xr-xtests/simple_wait_end_3n/simulator.py17
94 files changed, 1327 insertions, 0 deletions
diff --git a/tests/README.md b/tests/README.md
new file mode 100644
index 0000000..9cf09c6
--- /dev/null
+++ b/tests/README.md
@@ -0,0 +1,6 @@
+# Tests
+**Test folders names convention:**
+- **m** senders and **n** receivers is written `<m>s<n>r` *(ex: 1s5r)*
+- **n** nodes is written `<n>n` *(ex: 5n)*
+- Tests names follow the following format `<title>_<m>s<n>r` or `<title>_<n>n` *(ex: simple_send_rcv_1s5r, ping_pong_2n)*
+- Tests that test **elementary API functions** should start with the **simple** keyword
diff --git a/tests/hidden_node_2s1r/out b/tests/hidden_node_2s1r/out
new file mode 100644
index 0000000..0922147
--- /dev/null
+++ b/tests/hidden_node_2s1r/out
@@ -0,0 +1,4 @@
+[t=0.000,src=n0] Send 1 bytes on wlan0
+[t=0.000,src=n2] Send 1 bytes on wlan0
+[t=0.000,src=n1] Interferences on wlan0
+[t=1.000,src=esds] Simulation ends
diff --git a/tests/hidden_node_2s1r/receiver.py b/tests/hidden_node_2s1r/receiver.py
new file mode 100644
index 0000000..0b48f12
--- /dev/null
+++ b/tests/hidden_node_2s1r/receiver.py
@@ -0,0 +1,5 @@
+#!/usr/bin/env python
+
+def execute(api):
+ pass
+
diff --git a/tests/hidden_node_2s1r/sender.py b/tests/hidden_node_2s1r/sender.py
new file mode 100644
index 0000000..80f0fc2
--- /dev/null
+++ b/tests/hidden_node_2s1r/sender.py
@@ -0,0 +1,4 @@
+#!/usr/bin/env python
+
+def execute(api):
+ api.send("wlan0","Hello World!",1,1)
diff --git a/tests/hidden_node_2s1r/simulator.py b/tests/hidden_node_2s1r/simulator.py
new file mode 100755
index 0000000..63ca502
--- /dev/null
+++ b/tests/hidden_node_2s1r/simulator.py
@@ -0,0 +1,22 @@
+#!/usr/bin/env python
+
+# Load ESDS
+import sys
+sys.path.append("../../")
+import esds
+import numpy as np
+
+B=np.full((3,3),8)
+
+# Hide the nodes from each others
+B[0,2]=0
+B[2,0]=0
+
+L=np.full((3,3),0)
+s=esds.Simulator(B,L)
+
+s.create_node("sender")
+s.create_node("receiver")
+s.create_node("sender")
+
+s.run()
diff --git a/tests/mobility_eth0_bandwidth_1s1r/out b/tests/mobility_eth0_bandwidth_1s1r/out
new file mode 100644
index 0000000..e0a3d04
--- /dev/null
+++ b/tests/mobility_eth0_bandwidth_1s1r/out
@@ -0,0 +1,4 @@
+[t=0.000,src=n0] Send 1 bytes to n1 on eth0
+[t=0.500,src=esds] Network update!
+[t=0.750,src=n1] Receive 1 bytes on eth0
+[t=0.750,src=esds] Simulation ends
diff --git a/tests/mobility_eth0_bandwidth_1s1r/receiver.py b/tests/mobility_eth0_bandwidth_1s1r/receiver.py
new file mode 100644
index 0000000..0b48f12
--- /dev/null
+++ b/tests/mobility_eth0_bandwidth_1s1r/receiver.py
@@ -0,0 +1,5 @@
+#!/usr/bin/env python
+
+def execute(api):
+ pass
+
diff --git a/tests/mobility_eth0_bandwidth_1s1r/sender.py b/tests/mobility_eth0_bandwidth_1s1r/sender.py
new file mode 100644
index 0000000..753ccce
--- /dev/null
+++ b/tests/mobility_eth0_bandwidth_1s1r/sender.py
@@ -0,0 +1,4 @@
+#!/usr/bin/env python
+
+def execute(api):
+ api.send("eth0","Hello World!",1,1)
diff --git a/tests/mobility_eth0_bandwidth_1s1r/simulator.py b/tests/mobility_eth0_bandwidth_1s1r/simulator.py
new file mode 100755
index 0000000..f7a0072
--- /dev/null
+++ b/tests/mobility_eth0_bandwidth_1s1r/simulator.py
@@ -0,0 +1,38 @@
+#!/usr/bin/env python
+
+# Load ESDS
+import sys
+sys.path.append("../../")
+import esds
+import numpy as np
+
+########## Scenario ##########
+# Notations:
+# - Remaining communication duration (last communication ends minus current simulated time) = C
+# - Last communication duration (previous row) = U
+# - Last remaining data size (previous row) = D
+# - Current remaining data (current row) = R
+# - Initial data size (first row) = I
+# - Bandwidth = BW
+# - Latency = L
+# |-------------------+------------+----------------+----------------------+--------------------------+-------------------------|
+# | Simulated time(s) | Latency(s) | Bandwidth(bps) | Remaining data (bit) | Communcation duration(s) | Communcation ends at(s) |
+# |-------------------+------------+----------------+----------------------+--------------------------+-------------------------|
+# | 0 | 0 | 8 | 8 | 1 | 1 |
+# | 0.5 | 0 | 16 | C/U*D = 4 | R/I * L + R/BW = 0.25 | 0.75 |
+# | 0.75 | 0 | 16 | | | |
+# |-------------------+------------+----------------+----------------------+--------------------------+-------------------------|
+##############################
+
+B=np.full((2,2),8)
+L=np.full((2,2),0)
+s=esds.Simulator(B,L)
+
+s.create_node("sender")
+s.create_node("receiver")
+
+def callback(simulator):
+ simulator.log("Network update!")
+ simulator.update_network(simulator.B*2,simulator.L)
+
+s.run(breakpoints_every=1/2,breakpoint_callback=callback)
diff --git a/tests/mobility_eth0_bandwidth_2s1r/out b/tests/mobility_eth0_bandwidth_2s1r/out
new file mode 100644
index 0000000..7138457
--- /dev/null
+++ b/tests/mobility_eth0_bandwidth_2s1r/out
@@ -0,0 +1,6 @@
+[t=0.000,src=n0] Send 1 bytes to n2 on eth0
+[t=0.000,src=n1] Send 1 bytes to n2 on eth0
+[t=1.000,src=esds] Network update!
+[t=1.500,src=n2] Receive 1 bytes on eth0
+[t=1.500,src=n2] Receive 1 bytes on eth0
+[t=1.500,src=esds] Simulation ends
diff --git a/tests/mobility_eth0_bandwidth_2s1r/receiver.py b/tests/mobility_eth0_bandwidth_2s1r/receiver.py
new file mode 100644
index 0000000..0b48f12
--- /dev/null
+++ b/tests/mobility_eth0_bandwidth_2s1r/receiver.py
@@ -0,0 +1,5 @@
+#!/usr/bin/env python
+
+def execute(api):
+ pass
+
diff --git a/tests/mobility_eth0_bandwidth_2s1r/sender.py b/tests/mobility_eth0_bandwidth_2s1r/sender.py
new file mode 100644
index 0000000..273cdc2
--- /dev/null
+++ b/tests/mobility_eth0_bandwidth_2s1r/sender.py
@@ -0,0 +1,4 @@
+#!/usr/bin/env python
+
+def execute(api):
+ api.send("eth0","Hello World!",1,2)
diff --git a/tests/mobility_eth0_bandwidth_2s1r/simulator.py b/tests/mobility_eth0_bandwidth_2s1r/simulator.py
new file mode 100755
index 0000000..ba876d8
--- /dev/null
+++ b/tests/mobility_eth0_bandwidth_2s1r/simulator.py
@@ -0,0 +1,41 @@
+#!/usr/bin/env python
+
+# Load ESDS
+import sys
+sys.path.append("../../")
+import esds
+import numpy as np
+
+########## Scenario ##########
+# Notations:
+# - Remaining communication duration (last communication ends minus current simulated time) = C
+# - Last communication duration (previous row) = U
+# - Last remaining data size (previous row) = D
+# - Current remaining data (current row) = R
+# - Initial data size (first row) = I
+# - Bandwidth = BW
+# - Latency = L
+# |----------------------------------------+------------+----------------+----------------------+---------------------------+-------------------------|
+# | This table is the same for both sender | | | | | |
+# |----------------------------------------+------------+----------------+----------------------+---------------------------+-------------------------|
+# | Simulated time(s) | Latency(s) | Bandwidth(bps) | Remaining data (bit) | Communication duration(s) | Communcation ends at(s) |
+# |----------------------------------------+------------+----------------+----------------------+---------------------------+-------------------------|
+# | 0 | 0 | 8/2 | 8 | 2 | 2 |
+# | 1 | 0 | 16/2 | C/U*D = 4 | 0.5 | 1.5 |
+# | 1.5 | 0 | 16/2 | 0 | | |
+# |----------------------------------------+------------+----------------+----------------------+---------------------------+-------------------------|
+##############################
+
+B=np.full((3,3),8)
+L=np.full((3,3),0)
+s=esds.Simulator(B,L)
+
+s.create_node("sender")
+s.create_node("sender")
+s.create_node("receiver")
+
+def callback(simulator):
+ simulator.log("Network update!")
+ simulator.update_network(simulator.B*2,simulator.L)
+
+s.run(breakpoints_every=1,breakpoint_callback=callback,debug=True)
diff --git a/tests/mobility_eth0_bandwidth_2s1r/yoctosim.debug b/tests/mobility_eth0_bandwidth_2s1r/yoctosim.debug
new file mode 100644
index 0000000..b0e4327
--- /dev/null
+++ b/tests/mobility_eth0_bandwidth_2s1r/yoctosim.debug
@@ -0,0 +1,37 @@
+Python version 3.10.5 (main, Jun 6 2022, 18:49:26) [GCC 12.1.0]
+Simulation started at 1654802959.3233912
+Number of nodes is 3
+Manual breakpoints list: []
+Breakpoints every 1s
+-----------------------------------------------
+Started since 0.04s
+Simulated time 0.000s (or more precisely 0s)
+Node number per state: pending=2 terminated=1
+Node sharing: n2=2
+Ids of node in timeout mode:
+Sorted events list:
+[[3 1 array(0, dtype=object) 0]
+ [0 2.0 array([0, 2, 'eth0', 'Hello World!', 1, 2.0, 1, 0], dtype=object)
+ 1]
+ [0 2.0 array([1, 2, 'eth0', 'Hello World!', 1, 2.0, 1, 0], dtype=object)
+ 1]]
+-----------------------------------------------
+Started since 0.04s
+Simulated time 1.000s (or more precisely 1s)
+Node number per state: pending=2 terminated=1
+Node sharing: n2=2
+Ids of node in timeout mode:
+Sorted events list:
+[[0 1.5
+ array([0, 2, 'eth0', 'Hello World!', 1, 0.5, 0.5, 0], dtype=object) 1]
+ [0 1.5
+ array([1, 2, 'eth0', 'Hello World!', 1, 0.5, 0.5, 0], dtype=object) 1]
+ [3 2 array(0, dtype=object) 0]]
+-----------------------------------------------
+Started since 0.05s
+Simulated time 1.500s (or more precisely 1.5s)
+Node number per state: terminated=3
+Node sharing:
+Ids of node in timeout mode:
+Sorted events list:
+[[3 2 array(0, dtype=object) 0]]
diff --git a/tests/mobility_eth0_latency_1s1r/out b/tests/mobility_eth0_latency_1s1r/out
new file mode 100644
index 0000000..ef56e0f
--- /dev/null
+++ b/tests/mobility_eth0_latency_1s1r/out
@@ -0,0 +1,5 @@
+[t=0.000,src=n0] Send 1 bytes to n1 on eth0
+[t=0.500,src=esds] Network update!
+[t=1.000,src=esds] Network update!
+[t=1.333,src=n1] Receive 1 bytes on eth0
+[t=1.333,src=esds] Simulation ends
diff --git a/tests/mobility_eth0_latency_1s1r/receiver.py b/tests/mobility_eth0_latency_1s1r/receiver.py
new file mode 100644
index 0000000..0b48f12
--- /dev/null
+++ b/tests/mobility_eth0_latency_1s1r/receiver.py
@@ -0,0 +1,5 @@
+#!/usr/bin/env python
+
+def execute(api):
+ pass
+
diff --git a/tests/mobility_eth0_latency_1s1r/sender.py b/tests/mobility_eth0_latency_1s1r/sender.py
new file mode 100644
index 0000000..753ccce
--- /dev/null
+++ b/tests/mobility_eth0_latency_1s1r/sender.py
@@ -0,0 +1,4 @@
+#!/usr/bin/env python
+
+def execute(api):
+ api.send("eth0","Hello World!",1,1)
diff --git a/tests/mobility_eth0_latency_1s1r/simulator.py b/tests/mobility_eth0_latency_1s1r/simulator.py
new file mode 100755
index 0000000..525bb66
--- /dev/null
+++ b/tests/mobility_eth0_latency_1s1r/simulator.py
@@ -0,0 +1,39 @@
+#!/usr/bin/env python
+
+# Load ESDS
+import sys
+sys.path.append("../../")
+import esds
+import numpy as np
+
+########## Scenario ##########
+# Notations:
+# - Remaining communication duration (last communication ends minus current simulated time) = C
+# - Last communication duration (previous row) = U
+# - Last remaining data size (previous row) = D
+# - Current remaining data (current row) = R
+# - Initial data size (first row) = I
+# - Bandwidth = BW
+# - Latency = L
+# |-------------------+------------+----------------+----------------------+--------------------------+-------------------------|
+# | Simulated time(s) | Latency(s) | Bandwidth(bps) | Remaining data (bit) | Communcation duration(s) | Communcation ends at(s) |
+# |-------------------+------------+----------------+----------------------+--------------------------+-------------------------|
+# | 0 | 0 | 8 | 8 | 1 | 1 |
+# | 0.5 | 0.5 | 8 | C/U*D = 4 | R/I * L + R/BW = 0.75 | 1.25 |
+# | 1 | 1 | 8 | C/U*D = 1.33 | R/I * L + R/BW = 0.33 | 1.33 |
+# | 1.33 | 1 | 8 | | | |
+# |-------------------+------------+----------------+----------------------+--------------------------+-------------------------|
+##############################
+
+B=np.full((2,2),8)
+L=np.full((2,2),0)
+s=esds.Simulator(B,L)
+
+s.create_node("sender")
+s.create_node("receiver")
+
+def callback(simulator):
+ simulator.log("Network update!")
+ simulator.update_network(simulator.B,simulator.L+1/2)
+
+s.run(breakpoints_every=1/2,breakpoint_callback=callback)
diff --git a/tests/mobility_eth0_latency_2s1r/out b/tests/mobility_eth0_latency_2s1r/out
new file mode 100644
index 0000000..41d59fc
--- /dev/null
+++ b/tests/mobility_eth0_latency_2s1r/out
@@ -0,0 +1,7 @@
+[t=0.000,src=n0] Send 1 bytes to n2 on eth0
+[t=0.000,src=n1] Send 1 bytes to n2 on eth0
+[t=1.000,src=esds] Network update!
+[t=2.000,src=esds] Network update!
+[t=2.300,src=n2] Receive 1 bytes on eth0
+[t=2.300,src=n2] Receive 1 bytes on eth0
+[t=2.300,src=esds] Simulation ends
diff --git a/tests/mobility_eth0_latency_2s1r/receiver.py b/tests/mobility_eth0_latency_2s1r/receiver.py
new file mode 100644
index 0000000..0b48f12
--- /dev/null
+++ b/tests/mobility_eth0_latency_2s1r/receiver.py
@@ -0,0 +1,5 @@
+#!/usr/bin/env python
+
+def execute(api):
+ pass
+
diff --git a/tests/mobility_eth0_latency_2s1r/sender.py b/tests/mobility_eth0_latency_2s1r/sender.py
new file mode 100644
index 0000000..273cdc2
--- /dev/null
+++ b/tests/mobility_eth0_latency_2s1r/sender.py
@@ -0,0 +1,4 @@
+#!/usr/bin/env python
+
+def execute(api):
+ api.send("eth0","Hello World!",1,2)
diff --git a/tests/mobility_eth0_latency_2s1r/simulator.py b/tests/mobility_eth0_latency_2s1r/simulator.py
new file mode 100755
index 0000000..101004b
--- /dev/null
+++ b/tests/mobility_eth0_latency_2s1r/simulator.py
@@ -0,0 +1,42 @@
+#!/usr/bin/env python
+
+# Load ESDS
+import sys
+sys.path.append("../../")
+import esds
+import numpy as np
+
+########## Scenario ##########
+# Notations:
+# - Remaining communication duration (last communication ends minus current simulated time) = C
+# - Last communication duration (previous row) = U
+# - Last remaining data size (previous row) = D
+# - Current remaining data (current row) = R
+# - Initial data size (first row) = I
+# - Bandwidth = BW
+# - Latency = L
+# |----------------------------------------+------------+----------------+----------------------+---------------------------+-------------------------|
+# | This table is the same for both sender | | | | | |
+# |----------------------------------------+------------+----------------+----------------------+---------------------------+-------------------------|
+# | Simulated time(s) | Latency(s) | Bandwidth(bps) | Remaining data (bit) | Communication duration(s) | Communcation ends at(s) |
+# |----------------------------------------+------------+----------------+----------------------+---------------------------+-------------------------|
+# | 0 | 0 | 8/2 | 8 | 2 | 2 |
+# | 1 | 0.5 | 8/2 | C/U*D=4 | R/BW + R/I*L = 1.25 | 2.25 |
+# | 2 | 1 | 8/2 | C/U*D=0.8 | R/BW + R/I*L = 0.3 | 2.3 |
+# | 2.3 | 1 | 8/2 | 0 | | |
+# |----------------------------------------+------------+----------------+----------------------+---------------------------+-------------------------|
+##############################
+
+B=np.full((3,3),8)
+L=np.full((3,3),0)
+s=esds.Simulator(B,L)
+
+s.create_node("sender")
+s.create_node("sender")
+s.create_node("receiver")
+
+def callback(simulator):
+ simulator.log("Network update!")
+ simulator.update_network(simulator.B,simulator.L+0.5)
+
+s.run(breakpoints_every=1,breakpoint_callback=callback,debug=True)
diff --git a/tests/mobility_eth0_latency_2s1r/yoctosim.debug b/tests/mobility_eth0_latency_2s1r/yoctosim.debug
new file mode 100644
index 0000000..efe50d9
--- /dev/null
+++ b/tests/mobility_eth0_latency_2s1r/yoctosim.debug
@@ -0,0 +1,51 @@
+Python version 3.10.5 (main, Jun 6 2022, 18:49:26) [GCC 12.1.0]
+Simulation started at 1654802960.9297695
+Number of nodes is 3
+Manual breakpoints list: []
+Breakpoints every 1s
+-----------------------------------------------
+Started since 0.08s
+Simulated time 0.000s (or more precisely 0s)
+Node number per state: pending=2 terminated=1
+Node sharing: n2=2
+Ids of node in timeout mode:
+Sorted events list:
+[[3 1 array(0, dtype=object) 0]
+ [0 2.0 array([0, 2, 'eth0', 'Hello World!', 1, 2.0, 1, 0], dtype=object)
+ 1]
+ [0 2.0 array([1, 2, 'eth0', 'Hello World!', 1, 2.0, 1, 0], dtype=object)
+ 1]]
+-----------------------------------------------
+Started since 0.08s
+Simulated time 1.000s (or more precisely 1s)
+Node number per state: pending=2 terminated=1
+Node sharing: n2=2
+Ids of node in timeout mode:
+Sorted events list:
+[[3 2 array(0, dtype=object) 0]
+ [0 2.25
+ array([0, 2, 'eth0', 'Hello World!', 1, 1.25, 0.5, 0], dtype=object) 1]
+ [0 2.25
+ array([1, 2, 'eth0', 'Hello World!', 1, 1.25, 0.5, 0], dtype=object) 1]]
+-----------------------------------------------
+Started since 0.08s
+Simulated time 2.000s (or more precisely 2s)
+Node number per state: pending=2 terminated=1
+Node sharing: n2=2
+Ids of node in timeout mode:
+Sorted events list:
+[[0 2.3
+ array([0, 2, 'eth0', 'Hello World!', 1, 0.30000000000000004, 0.1, 0],
+ dtype=object) 1]
+ [0 2.3
+ array([1, 2, 'eth0', 'Hello World!', 1, 0.30000000000000004, 0.1, 0],
+ dtype=object) 1]
+ [3 3 array(0, dtype=object) 0]]
+-----------------------------------------------
+Started since 0.09s
+Simulated time 2.300s (or more precisely 2.3s)
+Node number per state: terminated=3
+Node sharing:
+Ids of node in timeout mode:
+Sorted events list:
+[[3 3 array(0, dtype=object) 0]]
diff --git a/tests/mobility_wlan0_bandwidth_1s1r/out b/tests/mobility_wlan0_bandwidth_1s1r/out
new file mode 100644
index 0000000..95cdeeb
--- /dev/null
+++ b/tests/mobility_wlan0_bandwidth_1s1r/out
@@ -0,0 +1,4 @@
+[t=0.000,src=n0] Send 1 bytes on wlan0
+[t=0.500,src=esds] Network update!
+[t=0.750,src=n1] Receive 1 bytes on wlan0
+[t=0.750,src=esds] Simulation ends
diff --git a/tests/mobility_wlan0_bandwidth_1s1r/receiver.py b/tests/mobility_wlan0_bandwidth_1s1r/receiver.py
new file mode 100644
index 0000000..0b48f12
--- /dev/null
+++ b/tests/mobility_wlan0_bandwidth_1s1r/receiver.py
@@ -0,0 +1,5 @@
+#!/usr/bin/env python
+
+def execute(api):
+ pass
+
diff --git a/tests/mobility_wlan0_bandwidth_1s1r/sender.py b/tests/mobility_wlan0_bandwidth_1s1r/sender.py
new file mode 100644
index 0000000..80f0fc2
--- /dev/null
+++ b/tests/mobility_wlan0_bandwidth_1s1r/sender.py
@@ -0,0 +1,4 @@
+#!/usr/bin/env python
+
+def execute(api):
+ api.send("wlan0","Hello World!",1,1)
diff --git a/tests/mobility_wlan0_bandwidth_1s1r/simulator.py b/tests/mobility_wlan0_bandwidth_1s1r/simulator.py
new file mode 100755
index 0000000..f7a0072
--- /dev/null
+++ b/tests/mobility_wlan0_bandwidth_1s1r/simulator.py
@@ -0,0 +1,38 @@
+#!/usr/bin/env python
+
+# Load ESDS
+import sys
+sys.path.append("../../")
+import esds
+import numpy as np
+
+########## Scenario ##########
+# Notations:
+# - Remaining communication duration (last communication ends minus current simulated time) = C
+# - Last communication duration (previous row) = U
+# - Last remaining data size (previous row) = D
+# - Current remaining data (current row) = R
+# - Initial data size (first row) = I
+# - Bandwidth = BW
+# - Latency = L
+# |-------------------+------------+----------------+----------------------+--------------------------+-------------------------|
+# | Simulated time(s) | Latency(s) | Bandwidth(bps) | Remaining data (bit) | Communcation duration(s) | Communcation ends at(s) |
+# |-------------------+------------+----------------+----------------------+--------------------------+-------------------------|
+# | 0 | 0 | 8 | 8 | 1 | 1 |
+# | 0.5 | 0 | 16 | C/U*D = 4 | R/I * L + R/BW = 0.25 | 0.75 |
+# | 0.75 | 0 | 16 | | | |
+# |-------------------+------------+----------------+----------------------+--------------------------+-------------------------|
+##############################
+
+B=np.full((2,2),8)
+L=np.full((2,2),0)
+s=esds.Simulator(B,L)
+
+s.create_node("sender")
+s.create_node("receiver")
+
+def callback(simulator):
+ simulator.log("Network update!")
+ simulator.update_network(simulator.B*2,simulator.L)
+
+s.run(breakpoints_every=1/2,breakpoint_callback=callback)
diff --git a/tests/mobility_wlan0_latency_1s1r/out b/tests/mobility_wlan0_latency_1s1r/out
new file mode 100644
index 0000000..b1a2b0f
--- /dev/null
+++ b/tests/mobility_wlan0_latency_1s1r/out
@@ -0,0 +1,5 @@
+[t=0.000,src=n0] Send 1 bytes on wlan0
+[t=0.500,src=esds] Network update!
+[t=1.000,src=esds] Network update!
+[t=1.333,src=n1] Receive 1 bytes on wlan0
+[t=1.333,src=esds] Simulation ends
diff --git a/tests/mobility_wlan0_latency_1s1r/receiver.py b/tests/mobility_wlan0_latency_1s1r/receiver.py
new file mode 100644
index 0000000..0b48f12
--- /dev/null
+++ b/tests/mobility_wlan0_latency_1s1r/receiver.py
@@ -0,0 +1,5 @@
+#!/usr/bin/env python
+
+def execute(api):
+ pass
+
diff --git a/tests/mobility_wlan0_latency_1s1r/sender.py b/tests/mobility_wlan0_latency_1s1r/sender.py
new file mode 100644
index 0000000..80f0fc2
--- /dev/null
+++ b/tests/mobility_wlan0_latency_1s1r/sender.py
@@ -0,0 +1,4 @@
+#!/usr/bin/env python
+
+def execute(api):
+ api.send("wlan0","Hello World!",1,1)
diff --git a/tests/mobility_wlan0_latency_1s1r/simulator.py b/tests/mobility_wlan0_latency_1s1r/simulator.py
new file mode 100755
index 0000000..525bb66
--- /dev/null
+++ b/tests/mobility_wlan0_latency_1s1r/simulator.py
@@ -0,0 +1,39 @@
+#!/usr/bin/env python
+
+# Load ESDS
+import sys
+sys.path.append("../../")
+import esds
+import numpy as np
+
+########## Scenario ##########
+# Notations:
+# - Remaining communication duration (last communication ends minus current simulated time) = C
+# - Last communication duration (previous row) = U
+# - Last remaining data size (previous row) = D
+# - Current remaining data (current row) = R
+# - Initial data size (first row) = I
+# - Bandwidth = BW
+# - Latency = L
+# |-------------------+------------+----------------+----------------------+--------------------------+-------------------------|
+# | Simulated time(s) | Latency(s) | Bandwidth(bps) | Remaining data (bit) | Communcation duration(s) | Communcation ends at(s) |
+# |-------------------+------------+----------------+----------------------+--------------------------+-------------------------|
+# | 0 | 0 | 8 | 8 | 1 | 1 |
+# | 0.5 | 0.5 | 8 | C/U*D = 4 | R/I * L + R/BW = 0.75 | 1.25 |
+# | 1 | 1 | 8 | C/U*D = 1.33 | R/I * L + R/BW = 0.33 | 1.33 |
+# | 1.33 | 1 | 8 | | | |
+# |-------------------+------------+----------------+----------------------+--------------------------+-------------------------|
+##############################
+
+B=np.full((2,2),8)
+L=np.full((2,2),0)
+s=esds.Simulator(B,L)
+
+s.create_node("sender")
+s.create_node("receiver")
+
+def callback(simulator):
+ simulator.log("Network update!")
+ simulator.update_network(simulator.B,simulator.L+1/2)
+
+s.run(breakpoints_every=1/2,breakpoint_callback=callback)
diff --git a/tests/run.sh b/tests/run.sh
new file mode 100755
index 0000000..8720736
--- /dev/null
+++ b/tests/run.sh
@@ -0,0 +1,48 @@
+#!/usr/bin/env bash
+
+RED='\033[0;31m'
+GREEN='\033[0;32m'
+YELLOW='\033[0;33m'
+BOLD='\033[1m'
+NC='\033[0m' # No Color
+
+wai=$(dirname $(readlink -f "$0")) # Current script directory
+tests=$(find ${wai}/ -maxdepth 1 -mindepth 1 -type d) # Find tests
+out=$(mktemp)
+test_timeout=20
+
+for test in ${tests}
+do
+ printf "%-50s%s %s" "- $(basename $test)" "=>"
+ cd $test
+ timeout $test_timeout ./simulator.py &> "$out"
+
+ # Ensure timeout
+ if [ $? -eq 124 ]
+ then
+ echo -e "${RED}${BOLD}failed${NC}"
+ echo "------------- Test timeout (should not exceed ${test_timeout}s) -------------"
+ cat "$out";
+ rm "$out"
+ exit 2
+ fi
+
+ # Ensure test output
+ if $(diff "$out" ./out &>/dev/null)
+ then
+ echo -e "${GREEN}${BOLD}passed${NC}"
+ else
+ echo -e "${RED}${BOLD}failed${NC}"
+ echo "------------- Expected -------------"
+ cat out
+ echo "------------- Got -------------"
+ cat "$out";
+ rm "$out"
+ exit 1
+ fi
+
+ # Prepare for next test
+ cd - &>/dev/null
+done
+
+rm "$out"
diff --git a/tests/simple_breakpoints_auto_1n/node.py b/tests/simple_breakpoints_auto_1n/node.py
new file mode 100644
index 0000000..e812c01
--- /dev/null
+++ b/tests/simple_breakpoints_auto_1n/node.py
@@ -0,0 +1,8 @@
+#!/usr/bin/env python
+
+def execute(api):
+ if api.node_id == 0:
+ api.send("eth0","Hello",5,1)
+ else:
+ api.receive("eth0")
+
diff --git a/tests/simple_breakpoints_auto_1n/out b/tests/simple_breakpoints_auto_1n/out
new file mode 100644
index 0000000..e8fce88
--- /dev/null
+++ b/tests/simple_breakpoints_auto_1n/out
@@ -0,0 +1,9 @@
+[t=0.000,src=n0] Send 5 bytes to n1 on eth0
+[t=3.300,src=esds] Hello Callback!
+[t=6.600,src=esds] Hello Callback!
+[t=9.900,src=esds] Hello Callback!
+[t=13.200,src=esds] Hello Callback!
+[t=16.500,src=esds] Hello Callback!
+[t=19.800,src=esds] Hello Callback!
+[t=20.000,src=n1] Receive 5 bytes on eth0
+[t=20.000,src=esds] Simulation ends
diff --git a/tests/simple_breakpoints_auto_1n/simulator.py b/tests/simple_breakpoints_auto_1n/simulator.py
new file mode 100755
index 0000000..c5e3b02
--- /dev/null
+++ b/tests/simple_breakpoints_auto_1n/simulator.py
@@ -0,0 +1,20 @@
+#!/usr/bin/env python
+
+# Load ESDS
+import sys
+sys.path.append("../../")
+import esds
+import numpy as np
+
+n=2
+B=np.full((2,2),n)
+L=np.full((2,2),0)
+s=esds.Simulator(B,L)
+
+s.create_node("node")
+s.create_node("node")
+
+def callback(simulator):
+ simulator.log("Hello Callback!")
+
+s.run(breakpoints_every=3.3,breakpoint_callback=callback)
diff --git a/tests/simple_breakpoints_manual_1n/node.py b/tests/simple_breakpoints_manual_1n/node.py
new file mode 100644
index 0000000..f8c5633
--- /dev/null
+++ b/tests/simple_breakpoints_manual_1n/node.py
@@ -0,0 +1,4 @@
+#!/usr/bin/env python
+
+def execute(api):
+ api.log("Running")
diff --git a/tests/simple_breakpoints_manual_1n/out b/tests/simple_breakpoints_manual_1n/out
new file mode 100644
index 0000000..40c44b7
--- /dev/null
+++ b/tests/simple_breakpoints_manual_1n/out
@@ -0,0 +1,7 @@
+[t=0.000,src=n0] Running
+[t=0.000,src=n1] Running
+[t=1.000,src=esds] Hello Callback!
+[t=2.000,src=esds] Hello Callback!
+[t=3.000,src=esds] Hello Callback!
+[t=10.000,src=esds] Hello Callback!
+[t=10.000,src=esds] Simulation ends
diff --git a/tests/simple_breakpoints_manual_1n/simulator.py b/tests/simple_breakpoints_manual_1n/simulator.py
new file mode 100755
index 0000000..a0d0d2b
--- /dev/null
+++ b/tests/simple_breakpoints_manual_1n/simulator.py
@@ -0,0 +1,20 @@
+#!/usr/bin/env python
+
+# Load ESDS
+import sys
+sys.path.append("../../")
+import esds
+import numpy as np
+
+n=2
+B=np.full((n,n),n)
+L=np.full((n,n),0)
+s=esds.Simulator(B,L)
+
+s.create_node("node")
+s.create_node("node")
+
+def callback(simulator):
+ simulator.log("Hello Callback!")
+
+s.run(breakpoints=[1,2,3,10],breakpoint_callback=callback)
diff --git a/tests/simple_breakpoints_manual_no_callback_1n/node.py b/tests/simple_breakpoints_manual_no_callback_1n/node.py
new file mode 100644
index 0000000..f8c5633
--- /dev/null
+++ b/tests/simple_breakpoints_manual_no_callback_1n/node.py
@@ -0,0 +1,4 @@
+#!/usr/bin/env python
+
+def execute(api):
+ api.log("Running")
diff --git a/tests/simple_breakpoints_manual_no_callback_1n/out b/tests/simple_breakpoints_manual_no_callback_1n/out
new file mode 100644
index 0000000..defce2c
--- /dev/null
+++ b/tests/simple_breakpoints_manual_no_callback_1n/out
@@ -0,0 +1,3 @@
+[t=0.000,src=n0] Running
+[t=0.000,src=n1] Running
+[t=10.000,src=esds] Simulation ends
diff --git a/tests/simple_breakpoints_manual_no_callback_1n/simulator.py b/tests/simple_breakpoints_manual_no_callback_1n/simulator.py
new file mode 100755
index 0000000..93b1fef
--- /dev/null
+++ b/tests/simple_breakpoints_manual_no_callback_1n/simulator.py
@@ -0,0 +1,17 @@
+#!/usr/bin/env python
+
+# Load ESDS
+import sys
+sys.path.append("../../")
+import esds
+import numpy as np
+
+n=2
+B=np.full((n,n),n)
+L=np.full((n,n),0)
+s=esds.Simulator(B,L)
+
+s.create_node("node")
+s.create_node("node")
+
+s.run(breakpoints=[1,2,3,10])
diff --git a/tests/simple_log_5n/node.py b/tests/simple_log_5n/node.py
new file mode 100644
index 0000000..053c9fd
--- /dev/null
+++ b/tests/simple_log_5n/node.py
@@ -0,0 +1,7 @@
+#!/usr/bin/env python
+
+def execute(api):
+ api.log("A")
+ api.log("B")
+ api.log("C")
+ api.log("D")
diff --git a/tests/simple_log_5n/out b/tests/simple_log_5n/out
new file mode 100644
index 0000000..7d89c56
--- /dev/null
+++ b/tests/simple_log_5n/out
@@ -0,0 +1,21 @@
+[t=0.000,src=n0] A
+[t=0.000,src=n0] B
+[t=0.000,src=n0] C
+[t=0.000,src=n0] D
+[t=0.000,src=n1] A
+[t=0.000,src=n1] B
+[t=0.000,src=n1] C
+[t=0.000,src=n1] D
+[t=0.000,src=n2] A
+[t=0.000,src=n2] B
+[t=0.000,src=n2] C
+[t=0.000,src=n2] D
+[t=0.000,src=n3] A
+[t=0.000,src=n3] B
+[t=0.000,src=n3] C
+[t=0.000,src=n3] D
+[t=0.000,src=n4] A
+[t=0.000,src=n4] B
+[t=0.000,src=n4] C
+[t=0.000,src=n4] D
+[t=0.000,src=esds] Simulation ends
diff --git a/tests/simple_log_5n/simulator.py b/tests/simple_log_5n/simulator.py
new file mode 100755
index 0000000..184340a
--- /dev/null
+++ b/tests/simple_log_5n/simulator.py
@@ -0,0 +1,19 @@
+#!/usr/bin/env python
+
+# Load ESDS
+import sys
+sys.path.append("../../")
+import esds
+import numpy as np
+
+B=np.full((5,5),5)
+L=np.full((5,5),0)
+s=esds.Simulator(B,L)
+
+s.create_node("node")
+s.create_node("node")
+s.create_node("node")
+s.create_node("node")
+s.create_node("node")
+
+s.run()
diff --git a/tests/simple_read_clock_2n/node.py b/tests/simple_read_clock_2n/node.py
new file mode 100644
index 0000000..79a0b78
--- /dev/null
+++ b/tests/simple_read_clock_2n/node.py
@@ -0,0 +1,7 @@
+#!/usr/bin/env python
+
+def execute(api):
+ api.log("Clock is {}s".format(api.read("clock")))
+ api.wait(5698.1256)
+ api.log("Clock is {}s".format(api.read("clock")))
+ api.log("Clock is {}s".format(api.read("clock")))
diff --git a/tests/simple_read_clock_2n/out b/tests/simple_read_clock_2n/out
new file mode 100644
index 0000000..4fa7877
--- /dev/null
+++ b/tests/simple_read_clock_2n/out
@@ -0,0 +1,7 @@
+[t=0.000,src=n0] Clock is 0s
+[t=0.000,src=n1] Clock is 0s
+[t=5698.126,src=n0] Clock is 5698.1256s
+[t=5698.126,src=n0] Clock is 5698.1256s
+[t=5698.126,src=n1] Clock is 5698.1256s
+[t=5698.126,src=n1] Clock is 5698.1256s
+[t=5698.126,src=esds] Simulation ends
diff --git a/tests/simple_read_clock_2n/simulator.py b/tests/simple_read_clock_2n/simulator.py
new file mode 100755
index 0000000..b2c042c
--- /dev/null
+++ b/tests/simple_read_clock_2n/simulator.py
@@ -0,0 +1,16 @@
+#!/usr/bin/env python
+
+# Load ESDS
+import sys
+sys.path.append("../../")
+import esds
+import numpy as np
+
+B=np.full((2,2),2)
+L=np.full((2,2),0)
+s=esds.Simulator(B,L)
+
+s.create_node("node")
+s.create_node("node")
+
+s.run()
diff --git a/tests/simple_read_eth0_ncom_2s1r/out b/tests/simple_read_eth0_ncom_2s1r/out
new file mode 100644
index 0000000..087e62b
--- /dev/null
+++ b/tests/simple_read_eth0_ncom_2s1r/out
@@ -0,0 +1,9 @@
+[t=0.000,src=n2] eth0 is 0
+[t=624.000,src=n2] eth0 is 0
+[t=1248.000,src=n0] Send 50 bytes to n2 on eth0
+[t=1249.000,src=n2] eth0 is 1
+[t=1249.000,src=n1] Send 50 bytes to n2 on eth0
+[t=1250.000,src=n2] eth0 is 2
+[t=1513.667,src=n2] Receive 50 bytes on eth0
+[t=1514.667,src=n2] Receive 50 bytes on eth0
+[t=1514.667,src=esds] Simulation ends
diff --git a/tests/simple_read_eth0_ncom_2s1r/receiver.py b/tests/simple_read_eth0_ncom_2s1r/receiver.py
new file mode 100644
index 0000000..819fc84
--- /dev/null
+++ b/tests/simple_read_eth0_ncom_2s1r/receiver.py
@@ -0,0 +1,12 @@
+#!/usr/bin/env python
+
+def execute(api):
+ api.log("eth0 is {}".format(api.read("eth0_ncom")))
+ api.wait(624)
+ api.log("eth0 is {}".format(api.read("eth0_ncom")))
+ api.wait(624)
+ # Now we are at 624*2=1248 (first sender start a communication)
+ api.wait(1) # Let the communication starts
+ api.log("eth0 is {}".format(api.read("eth0_ncom"))) # Should print 1
+ api.wait(1) # Now second sender start a communication
+ api.log("eth0 is {}".format(api.read("eth0_ncom"))) # Should print 2
diff --git a/tests/simple_read_eth0_ncom_2s1r/sender.py b/tests/simple_read_eth0_ncom_2s1r/sender.py
new file mode 100644
index 0000000..7c9259a
--- /dev/null
+++ b/tests/simple_read_eth0_ncom_2s1r/sender.py
@@ -0,0 +1,9 @@
+#!/usr/bin/env python
+
+def execute(api):
+ api.wait(1248)
+ if api.node_id==0:
+ api.send("eth0","hello",50,2)
+ else:
+ api.wait(1)
+ api.send("eth0","hello",50,2)
diff --git a/tests/simple_read_eth0_ncom_2s1r/simulator.py b/tests/simple_read_eth0_ncom_2s1r/simulator.py
new file mode 100755
index 0000000..5294b9d
--- /dev/null
+++ b/tests/simple_read_eth0_ncom_2s1r/simulator.py
@@ -0,0 +1,17 @@
+#!/usr/bin/env python
+
+# Load ESDS
+import sys
+sys.path.append("../../")
+import esds
+import numpy as np
+
+B=np.full((3,3),3)
+L=np.full((3,3),0)
+s=esds.Simulator(B,L)
+
+s.create_node("sender")
+s.create_node("sender")
+s.create_node("receiver")
+
+s.run(interferences=False)
diff --git a/tests/simple_read_wlan0_ncom_2s1r/out b/tests/simple_read_wlan0_ncom_2s1r/out
new file mode 100644
index 0000000..93543eb
--- /dev/null
+++ b/tests/simple_read_wlan0_ncom_2s1r/out
@@ -0,0 +1,11 @@
+[t=0.000,src=n2] wlan0 is 0
+[t=624.000,src=n2] wlan0 is 0
+[t=1248.000,src=n0] Send 50 bytes on wlan0
+[t=1249.000,src=n2] wlan0 is 1
+[t=1249.000,src=n1] Send 50 bytes on wlan0
+[t=1250.000,src=n2] wlan0 is 2
+[t=1381.333,src=n1] Receive 50 bytes on wlan0
+[t=1381.333,src=n2] Receive 50 bytes on wlan0
+[t=1382.333,src=n0] Receive 50 bytes on wlan0
+[t=1382.333,src=n2] Receive 50 bytes on wlan0
+[t=1382.333,src=esds] Simulation ends
diff --git a/tests/simple_read_wlan0_ncom_2s1r/receiver.py b/tests/simple_read_wlan0_ncom_2s1r/receiver.py
new file mode 100644
index 0000000..9f652aa
--- /dev/null
+++ b/tests/simple_read_wlan0_ncom_2s1r/receiver.py
@@ -0,0 +1,12 @@
+#!/usr/bin/env python
+
+def execute(api):
+ api.log("wlan0 is {}".format(api.read("wlan0_ncom")))
+ api.wait(624)
+ api.log("wlan0 is {}".format(api.read("wlan0_ncom")))
+ api.wait(624)
+ # Now we are at 624*2=1248 (first sender start a communication)
+ api.wait(1) # Let the communication starts
+ api.log("wlan0 is {}".format(api.read("wlan0_ncom"))) # Should print 1
+ api.wait(1) # Second sender start a communication
+ api.log("wlan0 is {}".format(api.read("wlan0_ncom"))) # Should print 2
diff --git a/tests/simple_read_wlan0_ncom_2s1r/sender.py b/tests/simple_read_wlan0_ncom_2s1r/sender.py
new file mode 100644
index 0000000..b89e5e2
--- /dev/null
+++ b/tests/simple_read_wlan0_ncom_2s1r/sender.py
@@ -0,0 +1,9 @@
+#!/usr/bin/env python
+
+def execute(api):
+ api.wait(1248)
+ if api.node_id==0:
+ api.send("wlan0","hello",50,None)
+ else:
+ api.wait(1)
+ api.send("wlan0","hello",50,None)
diff --git a/tests/simple_read_wlan0_ncom_2s1r/simulator.py b/tests/simple_read_wlan0_ncom_2s1r/simulator.py
new file mode 100755
index 0000000..5294b9d
--- /dev/null
+++ b/tests/simple_read_wlan0_ncom_2s1r/simulator.py
@@ -0,0 +1,17 @@
+#!/usr/bin/env python
+
+# Load ESDS
+import sys
+sys.path.append("../../")
+import esds
+import numpy as np
+
+B=np.full((3,3),3)
+L=np.full((3,3),0)
+s=esds.Simulator(B,L)
+
+s.create_node("sender")
+s.create_node("sender")
+s.create_node("receiver")
+
+s.run(interferences=False)
diff --git a/tests/simple_receivet_eth0_1s1r/out b/tests/simple_receivet_eth0_1s1r/out
new file mode 100644
index 0000000..98756b5
--- /dev/null
+++ b/tests/simple_receivet_eth0_1s1r/out
@@ -0,0 +1,8 @@
+[t=0.000,src=n0] Send 1 bytes to n1 on eth0
+[t=1.000,src=n1] Receive 1 bytes on eth0
+[t=1.000,src=n1] Received: Hello World!
+[t=1.000,src=n0] Send 1 bytes to n1 on eth0
+[t=1.500,src=n1] Receive failed code=-1
+[t=2.000,src=n1] Receive 1 bytes on eth0
+[t=2.000,src=n1] Received: Hello World!
+[t=2.000,src=esds] Simulation ends
diff --git a/tests/simple_receivet_eth0_1s1r/receiver.py b/tests/simple_receivet_eth0_1s1r/receiver.py
new file mode 100644
index 0000000..515ff6a
--- /dev/null
+++ b/tests/simple_receivet_eth0_1s1r/receiver.py
@@ -0,0 +1,15 @@
+#!/usr/bin/env python
+
+def receivet(node,timeout):
+ ##### Simple receive
+ code, data=node.receivet("eth0",timeout)
+ msg="Received: "+data if code == 0 else "Receive failed code="+str(code)
+ node.log(msg)
+
+def execute(api):
+ # Should works
+ receivet(api,2)
+ # Should failed
+ receivet(api,0.5) # At t=1.5s
+ # Should works (priorities says that communications should occurs before timeout)
+ receivet(api,0.5) # At t=2s (timeout+receive should occur)
diff --git a/tests/simple_receivet_eth0_1s1r/sender.py b/tests/simple_receivet_eth0_1s1r/sender.py
new file mode 100644
index 0000000..0b6bdb6
--- /dev/null
+++ b/tests/simple_receivet_eth0_1s1r/sender.py
@@ -0,0 +1,6 @@
+#!/usr/bin/env python
+
+def execute(api):
+ api.send("eth0","Hello World!",1,1)
+ api.send("eth0","Hello World!",1,1)
+
diff --git a/tests/simple_receivet_eth0_1s1r/simulator.py b/tests/simple_receivet_eth0_1s1r/simulator.py
new file mode 100755
index 0000000..5ec9a25
--- /dev/null
+++ b/tests/simple_receivet_eth0_1s1r/simulator.py
@@ -0,0 +1,16 @@
+#!/usr/bin/env python
+
+# Load ESDS
+import sys
+sys.path.append("../../")
+import esds
+import numpy as np
+
+B=np.full((2,2),8)
+L=np.full((2,2),0)
+s=esds.Simulator(B,L)
+
+s.create_node("sender")
+s.create_node("receiver")
+
+s.run(debug=True)
diff --git a/tests/simple_receivet_eth0_1s1r/yoctosim.debug b/tests/simple_receivet_eth0_1s1r/yoctosim.debug
new file mode 100644
index 0000000..9d879f4
--- /dev/null
+++ b/tests/simple_receivet_eth0_1s1r/yoctosim.debug
@@ -0,0 +1,43 @@
+Python version 3.10.5 (main, Jun 6 2022, 18:49:26) [GCC 12.1.0]
+Simulation started at 1654802960.7880125
+Number of nodes is 2
+Manual breakpoints list: []
+Breakpoints every Nones
+-----------------------------------------------
+Started since 0.02s
+Simulated time 0.000s (or more precisely 0s)
+Node number per state: pending=1 request=1
+Node sharing: n1=1
+Ids of node in timeout mode:
+Sorted events list:
+[[0 1.0 array([0, 1, 'eth0', 'Hello World!', 1, 1.0, 1, 0], dtype=object)
+ 1]
+ [1 2 array(1, dtype=object) 3]]
+-----------------------------------------------
+Started since 0.04s
+Simulated time 1.000s (or more precisely 1.0s)
+Node number per state: pending=1 request=1
+Node sharing: n1=1
+Ids of node in timeout mode:
+Sorted events list:
+[[1 1.5 array(1, dtype=object) 3]
+ [0 2.0
+ array([0, 1, 'eth0', 'Hello World!', 1, 1.0, 1, 1.0], dtype=object) 1]]
+-----------------------------------------------
+Started since 0.06s
+Simulated time 1.500s (or more precisely 1.5s)
+Node number per state: pending=1 request=1
+Node sharing: n1=1
+Ids of node in timeout mode:
+Sorted events list:
+[[0 2.0
+ array([0, 1, 'eth0', 'Hello World!', 1, 1.0, 1, 1.0], dtype=object) 1]
+ [1 2.0 array(1, dtype=object) 3]]
+-----------------------------------------------
+Started since 0.08s
+Simulated time 2.000s (or more precisely 2.0s)
+Node number per state: terminated=2
+Node sharing:
+Ids of node in timeout mode:
+Sorted events list:
+[]
diff --git a/tests/simple_send_eth0_1s1r/out b/tests/simple_send_eth0_1s1r/out
new file mode 100644
index 0000000..1634d95
--- /dev/null
+++ b/tests/simple_send_eth0_1s1r/out
@@ -0,0 +1,11 @@
+[t=0.000,src=n0] Send 1 bytes to n1 on eth0
+[t=1.000,src=n1] Receive 1 bytes on eth0
+[t=1.000,src=n1] Received: Hello World!
+[t=1.000,src=n0] Send 1 bytes to n1 on eth0
+[t=2.000,src=n1] Receive 1 bytes on eth0
+[t=3.000,src=n0] Send 1 bytes to n1 on eth0
+[t=3.000,src=n1] Received: Hello World!
+[t=3.000,src=n1] Turned off
+[t=4.000,src=n1] Turned on
+[t=5.000,src=n1] Receive failed code=-1
+[t=5.000,src=esds] Simulation ends
diff --git a/tests/simple_send_eth0_1s1r/receiver.py b/tests/simple_send_eth0_1s1r/receiver.py
new file mode 100644
index 0000000..96305bf
--- /dev/null
+++ b/tests/simple_send_eth0_1s1r/receiver.py
@@ -0,0 +1,20 @@
+#!/usr/bin/env python
+
+def execute(api):
+ ##### Simple receive
+ code, data=api.receive("eth0")
+ msg="Received: "+data if code == 0 else "Receive failed code="+str(code)
+ api.log(msg)
+ ##### Test if we still receive the data when we are not receiving
+ api.wait(2)
+ code, data=api.receive("eth0")
+ msg="Received: "+data if code == 0 else "Receive failed code="+str(code)
+ api.log(msg)
+ ##### Ensure data is not receive when turned off
+ api.turn_off()
+ api.wait(1)
+ api.turn_on()
+ code, data=api.receivet("eth0",1)
+ msg="Received: "+data if code == 0 else "Receive failed code="+str(code)
+ api.log(msg)
+
diff --git a/tests/simple_send_eth0_1s1r/sender.py b/tests/simple_send_eth0_1s1r/sender.py
new file mode 100644
index 0000000..9f4aa85
--- /dev/null
+++ b/tests/simple_send_eth0_1s1r/sender.py
@@ -0,0 +1,7 @@
+#!/usr/bin/env python
+
+def execute(api):
+ api.send("eth0","Hello World!",1,1)
+ api.send("eth0","Hello World!",1,1)
+ api.wait(1) # Goto 3 seconds
+ api.send("eth0","Hello World!",1,1)
diff --git a/tests/simple_send_eth0_1s1r/simulator.py b/tests/simple_send_eth0_1s1r/simulator.py
new file mode 100755
index 0000000..f5f6ca6
--- /dev/null
+++ b/tests/simple_send_eth0_1s1r/simulator.py
@@ -0,0 +1,16 @@
+#!/usr/bin/env python
+
+# Load ESDS
+import sys
+sys.path.append("../../")
+import esds
+import numpy as np
+
+B=np.full((2,2),8)
+L=np.full((2,2),0)
+s=esds.Simulator(B,L)
+
+s.create_node("sender")
+s.create_node("receiver")
+
+s.run()
diff --git a/tests/simple_send_eth0_2s1r/out b/tests/simple_send_eth0_2s1r/out
new file mode 100644
index 0000000..4a5ebb8
--- /dev/null
+++ b/tests/simple_send_eth0_2s1r/out
@@ -0,0 +1,7 @@
+[t=0.000,src=n0] Send 1 bytes to n2 on eth0
+[t=0.000,src=n1] Send 1 bytes to n2 on eth0
+[t=2.000,src=n2] Receive 1 bytes on eth0
+[t=2.000,src=n2] Received: Hello World from 0!
+[t=2.000,src=n2] Receive 1 bytes on eth0
+[t=2.000,src=n2] Received: Hello World from 1!
+[t=2.000,src=esds] Simulation ends
diff --git a/tests/simple_send_eth0_2s1r/receiver.py b/tests/simple_send_eth0_2s1r/receiver.py
new file mode 100644
index 0000000..2f268fd
--- /dev/null
+++ b/tests/simple_send_eth0_2s1r/receiver.py
@@ -0,0 +1,13 @@
+#!/usr/bin/env python
+
+def execute(api):
+ ##### Simple receive from node 0
+ code, data=api.receive("eth0")
+ msg="Received: "+data if code == 0 else "Receive failed code="+str(code)
+ api.log(msg)
+
+ ##### Simple receive from node 1
+ code, data=api.receive("eth0")
+ msg="Received: "+data if code == 0 else "Receive failed code="+str(code)
+ api.log(msg)
+
diff --git a/tests/simple_send_eth0_2s1r/sender.py b/tests/simple_send_eth0_2s1r/sender.py
new file mode 100644
index 0000000..90daae5
--- /dev/null
+++ b/tests/simple_send_eth0_2s1r/sender.py
@@ -0,0 +1,5 @@
+#!/usr/bin/env python
+
+def execute(api):
+ api.send("eth0","Hello World from {}!".format(api.node_id),1,2)
+
diff --git a/tests/simple_send_eth0_2s1r/simulator.py b/tests/simple_send_eth0_2s1r/simulator.py
new file mode 100755
index 0000000..9faaf3d
--- /dev/null
+++ b/tests/simple_send_eth0_2s1r/simulator.py
@@ -0,0 +1,17 @@
+#!/usr/bin/env python
+
+# Load ESDS
+import sys
+sys.path.append("../../")
+import esds
+import numpy as np
+
+B=np.full((3,3),8)
+L=np.full((3,3),0)
+s=esds.Simulator(B,L)
+
+s.create_node("sender")
+s.create_node("sender")
+s.create_node("receiver")
+
+s.run()
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()
diff --git a/tests/simple_send_wlan0_1s2r/out b/tests/simple_send_wlan0_1s2r/out
new file mode 100644
index 0000000..98cc425
--- /dev/null
+++ b/tests/simple_send_wlan0_1s2r/out
@@ -0,0 +1,16 @@
+[t=0.000,src=n0] Send 1 bytes on wlan0
+[t=1.000,src=n1] Receive 1 bytes on wlan0
+[t=1.000,src=n1] Received: Hello World!
+[t=1.000,src=n2] Receive 1 bytes on wlan0
+[t=1.000,src=n2] Received: Hello World!
+[t=1.000,src=n2] Turned off
+[t=1.000,src=n0] Send 1 bytes on wlan0
+[t=2.000,src=n1] Receive 1 bytes on wlan0
+[t=2.000,src=n1] Received: Hello World!
+[t=2.000,src=n2] Turned on
+[t=2.000,src=n0] Send 1 bytes on wlan0
+[t=2.500,src=n2] Turned off
+[t=3.000,src=n1] Receive 1 bytes on wlan0
+[t=3.000,src=n1] Received: Hello World!
+[t=3.000,src=n2] Turned on
+[t=3.000,src=esds] Simulation ends
diff --git a/tests/simple_send_wlan0_1s2r/receiver.py b/tests/simple_send_wlan0_1s2r/receiver.py
new file mode 100644
index 0000000..5b86500
--- /dev/null
+++ b/tests/simple_send_wlan0_1s2r/receiver.py
@@ -0,0 +1,29 @@
+#!/usr/bin/env python
+
+def receive(node):
+ ##### Simple receive
+ code, data=node.receive("wlan0")
+ msg="Received: "+data if code == 0 else "Receive failed code="+str(code)
+ node.log(msg)
+
+
+def execute(api):
+ # Should works for all receivers
+ receive(api)
+
+ if api.node_id == 1:
+ receive(api) # Should works
+ else:
+ api.turn_off()
+ api.wait(1) # Node 2 should not receive anything during 1s
+ api.turn_on()
+
+
+ if api.node_id == 1:
+ receive(api) # Should works
+ else:
+ api.wait(0.5) # Check if started communication get cancelled on turning off
+ api.turn_off() # Node 2 should not receive anything
+ api.wait(0.5) # Node 2 should not receive anything during 0.5s
+ api.turn_on()
+
diff --git a/tests/simple_send_wlan0_1s2r/sender.py b/tests/simple_send_wlan0_1s2r/sender.py
new file mode 100644
index 0000000..ef1517b
--- /dev/null
+++ b/tests/simple_send_wlan0_1s2r/sender.py
@@ -0,0 +1,6 @@
+#!/usr/bin/env python
+
+def execute(api):
+ api.send("wlan0","Hello World!",1,1)
+ api.send("wlan0","Hello World!",1,1)
+ api.send("wlan0","Hello World!",1,1)
diff --git a/tests/simple_send_wlan0_1s2r/simulator.py b/tests/simple_send_wlan0_1s2r/simulator.py
new file mode 100755
index 0000000..3f53e63
--- /dev/null
+++ b/tests/simple_send_wlan0_1s2r/simulator.py
@@ -0,0 +1,17 @@
+#!/usr/bin/env python
+
+# Load ESDS
+import sys
+sys.path.append("../../")
+import esds
+import numpy as np
+
+B=np.full((3,3),8)
+L=np.full((3,3),0)
+s=esds.Simulator(B,L)
+
+s.create_node("sender")
+s.create_node("receiver")
+s.create_node("receiver")
+
+s.run()
diff --git a/tests/simple_send_wlan0_2s1r/out b/tests/simple_send_wlan0_2s1r/out
new file mode 100644
index 0000000..788ee42
--- /dev/null
+++ b/tests/simple_send_wlan0_2s1r/out
@@ -0,0 +1,6 @@
+[t=0.000,src=n0] Send 1 bytes on wlan0
+[t=0.000,src=n1] Send 1 bytes on wlan0
+[t=0.000,src=n0] Interferences on wlan0
+[t=0.000,src=n1] Interferences on wlan0
+[t=0.000,src=n2] Interferences on wlan0
+[t=1.000,src=esds] Simulation ends
diff --git a/tests/simple_send_wlan0_2s1r/receiver.py b/tests/simple_send_wlan0_2s1r/receiver.py
new file mode 100644
index 0000000..0b48f12
--- /dev/null
+++ b/tests/simple_send_wlan0_2s1r/receiver.py
@@ -0,0 +1,5 @@
+#!/usr/bin/env python
+
+def execute(api):
+ pass
+
diff --git a/tests/simple_send_wlan0_2s1r/sender.py b/tests/simple_send_wlan0_2s1r/sender.py
new file mode 100644
index 0000000..80f0fc2
--- /dev/null
+++ b/tests/simple_send_wlan0_2s1r/sender.py
@@ -0,0 +1,4 @@
+#!/usr/bin/env python
+
+def execute(api):
+ api.send("wlan0","Hello World!",1,1)
diff --git a/tests/simple_send_wlan0_2s1r/simulator.py b/tests/simple_send_wlan0_2s1r/simulator.py
new file mode 100755
index 0000000..9faaf3d
--- /dev/null
+++ b/tests/simple_send_wlan0_2s1r/simulator.py
@@ -0,0 +1,17 @@
+#!/usr/bin/env python
+
+# Load ESDS
+import sys
+sys.path.append("../../")
+import esds
+import numpy as np
+
+B=np.full((3,3),8)
+L=np.full((3,3),0)
+s=esds.Simulator(B,L)
+
+s.create_node("sender")
+s.create_node("sender")
+s.create_node("receiver")
+
+s.run()
diff --git a/tests/simple_sendt_eth0_1s1r/out b/tests/simple_sendt_eth0_1s1r/out
new file mode 100644
index 0000000..e6d70d5
--- /dev/null
+++ b/tests/simple_sendt_eth0_1s1r/out
@@ -0,0 +1,11 @@
+[t=0.000,src=n0] Send 1 bytes to n1 on eth0
+[t=1.000,src=n1] Receive 1 bytes on eth0
+[t=1.000,src=n1] Received: Hello World!
+[t=1.000,src=n0] Send worked!
+[t=1.000,src=n0] Send 1 bytes to n1 on eth0
+[t=1.500,src=n0] Send failed
+[t=1.500,src=n0] Send 1 bytes to n1 on eth0
+[t=2.500,src=n1] Receive 1 bytes on eth0
+[t=2.500,src=n1] Received: Hello World!
+[t=2.500,src=n0] Send worked!
+[t=2.500,src=esds] Simulation ends
diff --git a/tests/simple_sendt_eth0_1s1r/receiver.py b/tests/simple_sendt_eth0_1s1r/receiver.py
new file mode 100644
index 0000000..0d8561e
--- /dev/null
+++ b/tests/simple_sendt_eth0_1s1r/receiver.py
@@ -0,0 +1,11 @@
+#!/usr/bin/env python
+
+def receive(node):
+ ##### Simple receive
+ code, data=node.receive("eth0")
+ msg="Received: "+data if code == 0 else "Receive failed code="+str(code)
+ node.log(msg)
+
+def execute(api):
+ receive(api)
+ receive(api)
diff --git a/tests/simple_sendt_eth0_1s1r/sender.py b/tests/simple_sendt_eth0_1s1r/sender.py
new file mode 100644
index 0000000..ee2ea9d
--- /dev/null
+++ b/tests/simple_sendt_eth0_1s1r/sender.py
@@ -0,0 +1,14 @@
+#!/usr/bin/env python
+
+def sendt(node,timeout):
+ code=node.sendt("eth0","Hello World!",1,1,timeout)
+ msg="Send worked!" if code == 0 else "Send failed"
+ node.log(msg)
+
+def execute(api):
+ # Should work
+ sendt(api,2)
+ # Should not work
+ sendt(api,0.5)
+ # Should work
+ sendt(api,2)
diff --git a/tests/simple_sendt_eth0_1s1r/simulator.py b/tests/simple_sendt_eth0_1s1r/simulator.py
new file mode 100755
index 0000000..f5f6ca6
--- /dev/null
+++ b/tests/simple_sendt_eth0_1s1r/simulator.py
@@ -0,0 +1,16 @@
+#!/usr/bin/env python
+
+# Load ESDS
+import sys
+sys.path.append("../../")
+import esds
+import numpy as np
+
+B=np.full((2,2),8)
+L=np.full((2,2),0)
+s=esds.Simulator(B,L)
+
+s.create_node("sender")
+s.create_node("receiver")
+
+s.run()
diff --git a/tests/simple_sendt_wlan0_1s2r/out b/tests/simple_sendt_wlan0_1s2r/out
new file mode 100644
index 0000000..5a4f82c
--- /dev/null
+++ b/tests/simple_sendt_wlan0_1s2r/out
@@ -0,0 +1,7 @@
+[t=0.000,src=n0] Send 1 bytes on wlan0
+[t=1.000,src=n1] Receive 1 bytes on wlan0
+[t=1.000,src=n1] Received: Hello World!
+[t=1.000,src=n2] Receive 1 bytes on wlan0
+[t=1.000,src=n2] Received: Hello World!
+[t=1.000,src=n0] Send 1 bytes on wlan0
+[t=1.500,src=esds] Simulation ends
diff --git a/tests/simple_sendt_wlan0_1s2r/receiver.py b/tests/simple_sendt_wlan0_1s2r/receiver.py
new file mode 100644
index 0000000..eca49ad
--- /dev/null
+++ b/tests/simple_sendt_wlan0_1s2r/receiver.py
@@ -0,0 +1,13 @@
+#!/usr/bin/env python
+
+def receive(node):
+ ##### Simple receive
+ code, data=node.receive("wlan0")
+ msg="Received: "+data if code == 0 else "Receive failed code="+str(code)
+ node.log(msg)
+
+
+def execute(api):
+ # Should works for all receivers
+ receive(api)
+
diff --git a/tests/simple_sendt_wlan0_1s2r/sender.py b/tests/simple_sendt_wlan0_1s2r/sender.py
new file mode 100644
index 0000000..fe2dc1a
--- /dev/null
+++ b/tests/simple_sendt_wlan0_1s2r/sender.py
@@ -0,0 +1,8 @@
+#!/usr/bin/env python
+
+def execute(api):
+ # Should works
+ api.sendt("wlan0","Hello World!",1,1,2)
+ # Should not work
+ api.sendt("wlan0","Hello World!",1,1,0.5)
+
diff --git a/tests/simple_sendt_wlan0_1s2r/simulator.py b/tests/simple_sendt_wlan0_1s2r/simulator.py
new file mode 100755
index 0000000..3f53e63
--- /dev/null
+++ b/tests/simple_sendt_wlan0_1s2r/simulator.py
@@ -0,0 +1,17 @@
+#!/usr/bin/env python
+
+# Load ESDS
+import sys
+sys.path.append("../../")
+import esds
+import numpy as np
+
+B=np.full((3,3),8)
+L=np.full((3,3),0)
+s=esds.Simulator(B,L)
+
+s.create_node("sender")
+s.create_node("receiver")
+s.create_node("receiver")
+
+s.run()
diff --git a/tests/simple_wait_2n/node.py b/tests/simple_wait_2n/node.py
new file mode 100644
index 0000000..86b06de
--- /dev/null
+++ b/tests/simple_wait_2n/node.py
@@ -0,0 +1,9 @@
+#!/usr/bin/env python
+
+def execute(api):
+ api.log("Before wait")
+ api.wait(2)
+ api.log("After wait")
+ api.log("Before wait")
+ api.wait(3)
+ api.log("After wait")
diff --git a/tests/simple_wait_2n/out b/tests/simple_wait_2n/out
new file mode 100644
index 0000000..8a694cc
--- /dev/null
+++ b/tests/simple_wait_2n/out
@@ -0,0 +1,9 @@
+[t=0.000,src=n0] Before wait
+[t=0.000,src=n1] Before wait
+[t=2.000,src=n0] After wait
+[t=2.000,src=n0] Before wait
+[t=2.000,src=n1] After wait
+[t=2.000,src=n1] Before wait
+[t=5.000,src=n0] After wait
+[t=5.000,src=n1] After wait
+[t=5.000,src=esds] Simulation ends
diff --git a/tests/simple_wait_2n/simulator.py b/tests/simple_wait_2n/simulator.py
new file mode 100755
index 0000000..b2c042c
--- /dev/null
+++ b/tests/simple_wait_2n/simulator.py
@@ -0,0 +1,16 @@
+#!/usr/bin/env python
+
+# Load ESDS
+import sys
+sys.path.append("../../")
+import esds
+import numpy as np
+
+B=np.full((2,2),2)
+L=np.full((2,2),0)
+s=esds.Simulator(B,L)
+
+s.create_node("node")
+s.create_node("node")
+
+s.run()
diff --git a/tests/simple_wait_end_3n/node.py b/tests/simple_wait_end_3n/node.py
new file mode 100644
index 0000000..a8fbcd7
--- /dev/null
+++ b/tests/simple_wait_end_3n/node.py
@@ -0,0 +1,10 @@
+#!/usr/bin/env python
+
+def execute(api):
+ wait=api.node_id
+ api.log("Before wait for "+str(wait)+"s")
+ api.wait(wait) # Since 3 nodes max(wait)==2
+
+ # Ensure that wait end return back when simulation ends
+ api.wait_end()
+ api.log("Terminated")
diff --git a/tests/simple_wait_end_3n/out b/tests/simple_wait_end_3n/out
new file mode 100644
index 0000000..321b0c2
--- /dev/null
+++ b/tests/simple_wait_end_3n/out
@@ -0,0 +1,7 @@
+[t=0.000,src=n0] Before wait for 0s
+[t=0.000,src=n1] Before wait for 1s
+[t=0.000,src=n2] Before wait for 2s
+[t=2.000,src=n0] Terminated
+[t=2.000,src=n1] Terminated
+[t=2.000,src=n2] Terminated
+[t=2.000,src=esds] Simulation ends
diff --git a/tests/simple_wait_end_3n/simulator.py b/tests/simple_wait_end_3n/simulator.py
new file mode 100755
index 0000000..d4c9ec4
--- /dev/null
+++ b/tests/simple_wait_end_3n/simulator.py
@@ -0,0 +1,17 @@
+#!/usr/bin/env python
+
+# Load ESDS
+import sys
+sys.path.append("../../")
+import esds
+import numpy as np
+
+B=np.full((3,3),2)
+L=np.full((3,3),0)
+s=esds.Simulator(B,L)
+
+s.create_node("node")
+s.create_node("node")
+s.create_node("node")
+
+s.run()