summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--esds/platform.py18
-rw-r--r--esds/simulator.py15
-rw-r--r--example/platform.yaml5
-rwxr-xr-xexample/platform_test.py8
-rwxr-xr-xexample/simulator.py4
-rw-r--r--tests/api_log_5n/platform.yaml1
-rw-r--r--tests/api_read_clock_2n/platform.yaml1
-rw-r--r--tests/api_read_eth0_ncom_2s1r/platform.yaml1
-rw-r--r--tests/api_read_order_ncom_1s2r/platform.yaml1
-rw-r--r--tests/api_read_wlan0_ncom_2s1r/platform.yaml1
-rw-r--r--tests/api_receivet0_eth0_1s1r/platform.yaml1
-rw-r--r--tests/api_receivet_eth0_1s1r/platform.yaml1
-rw-r--r--tests/api_send0_eth0_1s1r/platform.yaml1
-rw-r--r--tests/api_send_4interfaces_1s2r/platform.yaml4
-rw-r--r--tests/api_send_eth0_1s1r/platform.yaml1
-rw-r--r--tests/api_send_eth0_2s1r/platform.yaml1
-rw-r--r--tests/api_send_eth0_3s1r/platform.yaml1
-rw-r--r--tests/api_send_wlan0_1s2r/platform.yaml1
-rw-r--r--tests/api_send_wlan0_2s1r/platform.yaml1
-rw-r--r--tests/api_sendt_eth0_1s1r/platform.yaml1
-rw-r--r--tests/api_sendt_wlan0_1s2r/platform.yaml1
-rw-r--r--tests/api_wait_2n/platform.yaml1
-rw-r--r--tests/api_wait_end_3n/platform.yaml1
-rw-r--r--tests/breakpoints_auto_1n/platform.yaml1
-rw-r--r--tests/breakpoints_manual_1n/platform.yaml1
-rw-r--r--tests/breakpoints_manual_no_callback_1n/platform.yaml1
-rw-r--r--tests/hidden_node_2s1r/platform.yaml1
-rw-r--r--tests/mobility_eth0_bandwidth_1s1r/platform.yaml2
-rw-r--r--tests/mobility_eth0_bandwidth_2s1r/platform.yaml1
-rw-r--r--tests/mobility_eth0_latency_1s1r/platform.yaml1
-rw-r--r--tests/mobility_eth0_latency_2s1r/platform.yaml1
-rw-r--r--tests/mobility_wlan0_bandwidth_1s1r/platform.yaml1
-rw-r--r--tests/mobility_wlan0_latency_1s1r/platform.yaml1
33 files changed, 64 insertions, 18 deletions
diff --git a/esds/platform.py b/esds/platform.py
index 40f8301..b8b8b6e 100644
--- a/esds/platform.py
+++ b/esds/platform.py
@@ -58,7 +58,8 @@ class YAMLPlatformFile:
"node_count": 0,
"implementations": [],
"arguments": [],
- "groups": dict(),
+ "groups": dict(), # {node_id} => group
+ "nodes_interfaces": dict(), # {node_id} => [interfaces]
"interfaces": dict()
}
@@ -103,6 +104,10 @@ class YAMLPlatformFile:
def parse_interfaces(self):
interfaces=self.platform["interfaces"]
node_count=self.default["node_count"]
+ ##### Init nodes interfaces
+ for node in range(0,self.default["node_count"]):
+ self.default["nodes_interfaces"][node]=list()
+ ##### Parse interfaces
for i in interfaces:
if interfaces[i]["type"] not in ["wireless","wired"]:
self.parsing_error("Invalid interface type \""+interfaces[i]["type"]+"\"")
@@ -112,6 +117,13 @@ class YAMLPlatformFile:
self.parsing_error("Invalide type of links in interface "+i)
for link in interfaces[i]["links"]:
links.append(self.parse_link(link))
+ ##### Assign interfaces to nodes
+ if "nodes" in interfaces[i]:
+ r=UnitsParser.node_range(str(interfaces[i]["nodes"]),self.default["node_count"])
+ for node in r:
+ self.default["nodes_interfaces"][node].append(i)
+ else:
+ self.parsing_error("missing nodes section on interface "+i)
##### Create network matrix
BW=np.full((node_count,node_count),0)
LAT=np.full((node_count,node_count),0)
@@ -220,9 +232,9 @@ class YAMLPlatformFile:
simulator=Simulator(self.default["interfaces"])
for node_id in range(0,self.default["node_count"]):
if node_id in self.default["groups"]:
- simulator.create_node(self.default["implementations"][node_id], args=self.default["arguments"][node_id],grp=self.default["groups"][node_id])
+ simulator.create_node(self.default["implementations"][node_id],self.default["nodes_interfaces"][node_id], args=self.default["arguments"][node_id],grp=self.default["groups"][node_id])
else:
- simulator.create_node(self.default["implementations"][node_id], args=self.default["arguments"][node_id])
+ simulator.create_node(self.default["implementations"][node_id],self.default["nodes_interfaces"][node_id], args=self.default["arguments"][node_id])
##### Run simulation
simulator.run(
breakpoints=self.default["breakpoints"],
diff --git a/esds/simulator.py b/esds/simulator.py
index 2253a49..30534de 100644
--- a/esds/simulator.py
+++ b/esds/simulator.py
@@ -75,11 +75,15 @@ class Simulator:
event[2][5]=new_duration
self.netmat=netmat
- def create_node(self, src, args=None, grp="def"):
+ def create_node(self, src, interfaces=[], args=None, grp="def"):
"""
Create a node thread and run it
"""
- node=Node(src, self.netmat.keys(), grp)
+ for intf in interfaces:
+ if intf not in self.netmat.keys():
+ self.log("Cannot create node "+str(Node.available_node_id)+": interface "+ intf + " unknown")
+ exit(1)
+ node=Node(src, interfaces, grp)
self.nodes.append(node)
thread=threading.Thread(target=node.run,args=[args]) # There must be "daemon=True" as a parameter, but we removed it to be compatible with older version of python
thread.start()
@@ -324,6 +328,9 @@ class Simulator:
"""
nsrc=self.nodes[src]
if self.netmat[interface]["is_wired"]:
+ if interface not in self.nodes[dst]["interfaces"]:
+ self.log("Cannot create communication from node "+str(src)+ " to "+str(dst)+", interface "+interface+" not available on node "+str(dst))
+ exit(1)
self.log("Send "+str(datasize)+" bytes to n"+str(dst)+" on "+interface,node=nsrc)
if not self.nodes[dst]["turned_on"] and receiver_required:
return(False)
@@ -334,7 +341,7 @@ class Simulator:
else:
self.log("Send "+str(datasize)+" bytes on "+interface,node=nsrc)
for dst in self.list_receivers(nsrc,interface):
- if self.nodes[dst]["turned_on"]:
+ if interface in self.nodes[dst]["interfaces"] and self.nodes[dst]["turned_on"]:
duration=datasize*8/self.netmat[interface]["bandwidth"][src,dst]+self.netmat[interface]["latency"][src,dst]
if src == dst:
# This event (where src == dst) is used to notify the sender when data is received!
@@ -347,7 +354,7 @@ class Simulator:
return(True)
def list_receivers(self,node,interface):
"""
- Deduce reachable receivers from the bandwidth matrix
+ Deduce reachable receivers from the bandwidth matrix (sender is included in the list!)
"""
selector = self.netmat[interface]["bandwidth"][node.node_id,] > 0
return np.arange(0,selector.shape[0])[selector]
diff --git a/example/platform.yaml b/example/platform.yaml
index ea3f760..7632e50 100644
--- a/example/platform.yaml
+++ b/example/platform.yaml
@@ -39,10 +39,12 @@ nodes:
##### Interfaces Section #####
interfaces:
- # Each entry for each node interfaces
+ # Each entry defines an network interface
wlan0:
# Interface type (wired/wireless)
type: "wireless"
+ # Now specify the nodes on which the interface is available
+ nodes: all
# List of links between nodes on this interface
# Syntax infos:
# 1MBps = 1 megaBYTE per seconds
@@ -57,5 +59,6 @@ interfaces:
# Example of a wired interface
eth0:
type: "wired"
+ nodes: all
links:
- all 5Mbps 10s all \ No newline at end of file
diff --git a/example/platform_test.py b/example/platform_test.py
deleted file mode 100755
index 2573b32..0000000
--- a/example/platform_test.py
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/usr/bin/env python
-
-from esds.helpers.platform import YAMLPlatformFile
-
-
-
-s=YAMLPlatformFile("platform.yaml")
-s.run() \ No newline at end of file
diff --git a/example/simulator.py b/example/simulator.py
index 20eb878..7b62c77 100755
--- a/example/simulator.py
+++ b/example/simulator.py
@@ -32,11 +32,11 @@ s=esds.Simulator({"wlan0":{"bandwidth":B, "latency":L, "is_wired":False},"eth0":
##### Instantiate nodes
uptime=180 # 180s uptime
-s.create_node("sender",args=uptime) # Load sender.py for the first node with 5 as argument (first row in B and L)
+s.create_node("sender",interfaces=["wlan0","eth0"],args=uptime) # Load sender.py for the first node with 5 as argument (first row in B and L)
# Aguments can be passed to nodes via: s.create_node("sender",args="my argument")
for n in range(0,n-1): # Load receiver.py for the remaining nodes
- s.create_node("receiver",args=uptime)
+ s.create_node("receiver",interfaces=["wlan0","eth0"],args=uptime)
##### Run the simulation
#s.run(debug=True) # Generate a "esds.debug" file
diff --git a/tests/api_log_5n/platform.yaml b/tests/api_log_5n/platform.yaml
index c5e5f0a..65e248d 100644
--- a/tests/api_log_5n/platform.yaml
+++ b/tests/api_log_5n/platform.yaml
@@ -6,5 +6,6 @@ nodes:
interfaces:
eth0:
type: "wired"
+ nodes: all
links:
- all 5Bps 0s all \ No newline at end of file
diff --git a/tests/api_read_clock_2n/platform.yaml b/tests/api_read_clock_2n/platform.yaml
index c153050..3fffeb0 100644
--- a/tests/api_read_clock_2n/platform.yaml
+++ b/tests/api_read_clock_2n/platform.yaml
@@ -6,5 +6,6 @@ nodes:
interfaces:
eth0:
type: "wired"
+ nodes: all
links:
- all 2Bps 0s all \ No newline at end of file
diff --git a/tests/api_read_eth0_ncom_2s1r/platform.yaml b/tests/api_read_eth0_ncom_2s1r/platform.yaml
index 4b47dee..fa882dc 100644
--- a/tests/api_read_eth0_ncom_2s1r/platform.yaml
+++ b/tests/api_read_eth0_ncom_2s1r/platform.yaml
@@ -10,5 +10,6 @@ nodes:
interfaces:
eth0:
type: "wired"
+ nodes: all
links:
- all 3bps 0s all \ No newline at end of file
diff --git a/tests/api_read_order_ncom_1s2r/platform.yaml b/tests/api_read_order_ncom_1s2r/platform.yaml
index 1c98280..85f231c 100644
--- a/tests/api_read_order_ncom_1s2r/platform.yaml
+++ b/tests/api_read_order_ncom_1s2r/platform.yaml
@@ -10,6 +10,7 @@ nodes:
interfaces:
wlan0:
type: "wireless"
+ nodes: all
links:
- all 1Bps 0s all
txperfs:
diff --git a/tests/api_read_wlan0_ncom_2s1r/platform.yaml b/tests/api_read_wlan0_ncom_2s1r/platform.yaml
index e44f077..9b7d346 100644
--- a/tests/api_read_wlan0_ncom_2s1r/platform.yaml
+++ b/tests/api_read_wlan0_ncom_2s1r/platform.yaml
@@ -10,6 +10,7 @@ nodes:
interfaces:
wlan0:
type: "wireless"
+ nodes: all
links:
- all 3bps 0s all
txperfs:
diff --git a/tests/api_receivet0_eth0_1s1r/platform.yaml b/tests/api_receivet0_eth0_1s1r/platform.yaml
index 72f9ccb..41df873 100644
--- a/tests/api_receivet0_eth0_1s1r/platform.yaml
+++ b/tests/api_receivet0_eth0_1s1r/platform.yaml
@@ -7,5 +7,6 @@ nodes:
interfaces:
eth0:
type: "wired"
+ nodes: all
links:
- all 1Bps 0s all \ No newline at end of file
diff --git a/tests/api_receivet_eth0_1s1r/platform.yaml b/tests/api_receivet_eth0_1s1r/platform.yaml
index 72f9ccb..41df873 100644
--- a/tests/api_receivet_eth0_1s1r/platform.yaml
+++ b/tests/api_receivet_eth0_1s1r/platform.yaml
@@ -7,5 +7,6 @@ nodes:
interfaces:
eth0:
type: "wired"
+ nodes: all
links:
- all 1Bps 0s all \ No newline at end of file
diff --git a/tests/api_send0_eth0_1s1r/platform.yaml b/tests/api_send0_eth0_1s1r/platform.yaml
index 72f9ccb..41df873 100644
--- a/tests/api_send0_eth0_1s1r/platform.yaml
+++ b/tests/api_send0_eth0_1s1r/platform.yaml
@@ -7,5 +7,6 @@ nodes:
interfaces:
eth0:
type: "wired"
+ nodes: all
links:
- all 1Bps 0s all \ No newline at end of file
diff --git a/tests/api_send_4interfaces_1s2r/platform.yaml b/tests/api_send_4interfaces_1s2r/platform.yaml
index 1665f05..b0c4391 100644
--- a/tests/api_send_4interfaces_1s2r/platform.yaml
+++ b/tests/api_send_4interfaces_1s2r/platform.yaml
@@ -7,6 +7,7 @@ nodes:
interfaces:
wlan0:
type: "wireless"
+ nodes: all
links:
- all 1Bps 0s all
- 0 0bps 0s 2 # Sender cannot reach n2 on wlan0
@@ -14,15 +15,18 @@ interfaces:
- all 1Bps 0s
wlan1:
type: "wireless"
+ nodes: all
links:
- all 1Bps 0s all # Sender can reach n1 AND n2 on wlan1
txperfs:
- all 1Bps 0s
eth0:
type: "wired"
+ nodes: all
links:
- all 1Bps 0s all
eth1:
type: "wired"
+ nodes: all
links:
- all 2Bps 0s all # On eth1 sender can reach receiver twice faster than eth0 \ No newline at end of file
diff --git a/tests/api_send_eth0_1s1r/platform.yaml b/tests/api_send_eth0_1s1r/platform.yaml
index c795e5a..1aa4509 100644
--- a/tests/api_send_eth0_1s1r/platform.yaml
+++ b/tests/api_send_eth0_1s1r/platform.yaml
@@ -7,5 +7,6 @@ nodes:
interfaces:
eth0:
type: "wired"
+ nodes: all
links:
- all 1Bps 0s all
diff --git a/tests/api_send_eth0_2s1r/platform.yaml b/tests/api_send_eth0_2s1r/platform.yaml
index c68ead2..2671172 100644
--- a/tests/api_send_eth0_2s1r/platform.yaml
+++ b/tests/api_send_eth0_2s1r/platform.yaml
@@ -7,5 +7,6 @@ nodes:
interfaces:
eth0:
type: "wired"
+ nodes: all
links:
- all 1Bps 0s all \ No newline at end of file
diff --git a/tests/api_send_eth0_3s1r/platform.yaml b/tests/api_send_eth0_3s1r/platform.yaml
index a18f5bc..2902f7c 100644
--- a/tests/api_send_eth0_3s1r/platform.yaml
+++ b/tests/api_send_eth0_3s1r/platform.yaml
@@ -7,5 +7,6 @@ nodes:
interfaces:
eth0:
type: "wired"
+ nodes: all
links:
- all 1Bps 0s all \ No newline at end of file
diff --git a/tests/api_send_wlan0_1s2r/platform.yaml b/tests/api_send_wlan0_1s2r/platform.yaml
index c2e3b80..0f13311 100644
--- a/tests/api_send_wlan0_1s2r/platform.yaml
+++ b/tests/api_send_wlan0_1s2r/platform.yaml
@@ -7,6 +7,7 @@ nodes:
interfaces:
wlan0:
type: "wireless"
+ nodes: all
links:
- all 1Bps 0s all
txperfs:
diff --git a/tests/api_send_wlan0_2s1r/platform.yaml b/tests/api_send_wlan0_2s1r/platform.yaml
index fb8d102..999a7e9 100644
--- a/tests/api_send_wlan0_2s1r/platform.yaml
+++ b/tests/api_send_wlan0_2s1r/platform.yaml
@@ -7,6 +7,7 @@ nodes:
interfaces:
wlan0:
type: "wireless"
+ nodes: all
links:
- all 1Bps 0s all
txperfs:
diff --git a/tests/api_sendt_eth0_1s1r/platform.yaml b/tests/api_sendt_eth0_1s1r/platform.yaml
index 72f9ccb..41df873 100644
--- a/tests/api_sendt_eth0_1s1r/platform.yaml
+++ b/tests/api_sendt_eth0_1s1r/platform.yaml
@@ -7,5 +7,6 @@ nodes:
interfaces:
eth0:
type: "wired"
+ nodes: all
links:
- all 1Bps 0s all \ No newline at end of file
diff --git a/tests/api_sendt_wlan0_1s2r/platform.yaml b/tests/api_sendt_wlan0_1s2r/platform.yaml
index c2e3b80..0f13311 100644
--- a/tests/api_sendt_wlan0_1s2r/platform.yaml
+++ b/tests/api_sendt_wlan0_1s2r/platform.yaml
@@ -7,6 +7,7 @@ nodes:
interfaces:
wlan0:
type: "wireless"
+ nodes: all
links:
- all 1Bps 0s all
txperfs:
diff --git a/tests/api_wait_2n/platform.yaml b/tests/api_wait_2n/platform.yaml
index aa0d2cd..184219d 100644
--- a/tests/api_wait_2n/platform.yaml
+++ b/tests/api_wait_2n/platform.yaml
@@ -6,5 +6,6 @@ nodes:
interfaces:
eth0:
type: "wired"
+ nodes: all
links:
- all 2bps 0s all \ No newline at end of file
diff --git a/tests/api_wait_end_3n/platform.yaml b/tests/api_wait_end_3n/platform.yaml
index bfd65ba..2a81a7c 100644
--- a/tests/api_wait_end_3n/platform.yaml
+++ b/tests/api_wait_end_3n/platform.yaml
@@ -6,5 +6,6 @@ nodes:
interfaces:
eth0:
type: "wired"
+ nodes: all
links:
- all 2bps 0s all \ No newline at end of file
diff --git a/tests/breakpoints_auto_1n/platform.yaml b/tests/breakpoints_auto_1n/platform.yaml
index 6d015b4..0581342 100644
--- a/tests/breakpoints_auto_1n/platform.yaml
+++ b/tests/breakpoints_auto_1n/platform.yaml
@@ -12,5 +12,6 @@ nodes:
interfaces:
eth0:
type: "wired"
+ nodes: all
links:
- all 2bps 0s all \ No newline at end of file
diff --git a/tests/breakpoints_manual_1n/platform.yaml b/tests/breakpoints_manual_1n/platform.yaml
index 5b86f85..8f16214 100644
--- a/tests/breakpoints_manual_1n/platform.yaml
+++ b/tests/breakpoints_manual_1n/platform.yaml
@@ -12,5 +12,6 @@ nodes:
interfaces:
eth0:
type: "wired"
+ nodes: all
links:
- all 2bps 0s all \ No newline at end of file
diff --git a/tests/breakpoints_manual_no_callback_1n/platform.yaml b/tests/breakpoints_manual_no_callback_1n/platform.yaml
index 220f9b8..d27ed2f 100644
--- a/tests/breakpoints_manual_no_callback_1n/platform.yaml
+++ b/tests/breakpoints_manual_no_callback_1n/platform.yaml
@@ -9,5 +9,6 @@ nodes:
interfaces:
eth0:
type: "wired"
+ nodes: all
links:
- all 2bps 0s all \ No newline at end of file
diff --git a/tests/hidden_node_2s1r/platform.yaml b/tests/hidden_node_2s1r/platform.yaml
index 3febd8e..6e0ca2a 100644
--- a/tests/hidden_node_2s1r/platform.yaml
+++ b/tests/hidden_node_2s1r/platform.yaml
@@ -7,6 +7,7 @@ nodes:
interfaces:
wlan0:
type: "wireless"
+ nodes: all
links:
- all 1Bps 0s all
- 0,2 0bps 0s 2,0 # Node 0 and 2 are out of range
diff --git a/tests/mobility_eth0_bandwidth_1s1r/platform.yaml b/tests/mobility_eth0_bandwidth_1s1r/platform.yaml
index 145baf4..88580f2 100644
--- a/tests/mobility_eth0_bandwidth_1s1r/platform.yaml
+++ b/tests/mobility_eth0_bandwidth_1s1r/platform.yaml
@@ -31,11 +31,13 @@ nodes:
interfaces:
wlan0:
type: "wireless"
+ nodes: all
links:
- all 1Bps 0s all
txperfs:
- all 1Bps 0s
eth0:
type: "wired"
+ nodes: all
links:
- all 1Bps 0s all \ No newline at end of file
diff --git a/tests/mobility_eth0_bandwidth_2s1r/platform.yaml b/tests/mobility_eth0_bandwidth_2s1r/platform.yaml
index 6ebc1ad..6759762 100644
--- a/tests/mobility_eth0_bandwidth_2s1r/platform.yaml
+++ b/tests/mobility_eth0_bandwidth_2s1r/platform.yaml
@@ -33,5 +33,6 @@ nodes:
interfaces:
eth0:
type: "wired"
+ nodes: all
links:
- all 1Bps 0s all \ No newline at end of file
diff --git a/tests/mobility_eth0_latency_1s1r/platform.yaml b/tests/mobility_eth0_latency_1s1r/platform.yaml
index df1ff46..d0926a0 100644
--- a/tests/mobility_eth0_latency_1s1r/platform.yaml
+++ b/tests/mobility_eth0_latency_1s1r/platform.yaml
@@ -32,5 +32,6 @@ nodes:
interfaces:
eth0:
type: "wired"
+ nodes: all
links:
- all 1Bps 0s all \ No newline at end of file
diff --git a/tests/mobility_eth0_latency_2s1r/platform.yaml b/tests/mobility_eth0_latency_2s1r/platform.yaml
index b35ab2e..800ccf8 100644
--- a/tests/mobility_eth0_latency_2s1r/platform.yaml
+++ b/tests/mobility_eth0_latency_2s1r/platform.yaml
@@ -34,5 +34,6 @@ nodes:
interfaces:
eth0:
type: "wired"
+ nodes: all
links:
- all 1Bps 0s all \ No newline at end of file
diff --git a/tests/mobility_wlan0_bandwidth_1s1r/platform.yaml b/tests/mobility_wlan0_bandwidth_1s1r/platform.yaml
index c0231a8..982ce58 100644
--- a/tests/mobility_wlan0_bandwidth_1s1r/platform.yaml
+++ b/tests/mobility_wlan0_bandwidth_1s1r/platform.yaml
@@ -31,6 +31,7 @@ nodes:
interfaces:
wlan0:
type: "wireless"
+ nodes: all
links:
- all 1Bps 0s all
txperfs:
diff --git a/tests/mobility_wlan0_latency_1s1r/platform.yaml b/tests/mobility_wlan0_latency_1s1r/platform.yaml
index ba70d98..1358e1f 100644
--- a/tests/mobility_wlan0_latency_1s1r/platform.yaml
+++ b/tests/mobility_wlan0_latency_1s1r/platform.yaml
@@ -31,6 +31,7 @@ nodes:
interfaces:
wlan0:
type: "wireless"
+ nodes: all
links:
- all 1Bps 0s all
txperfs: