summaryrefslogtreecommitdiff
path: root/esds/simulator.py
diff options
context:
space:
mode:
Diffstat (limited to 'esds/simulator.py')
-rw-r--r--esds/simulator.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/esds/simulator.py b/esds/simulator.py
index 4f2eb71..b774468 100644
--- a/esds/simulator.py
+++ b/esds/simulator.py
@@ -202,7 +202,9 @@ class Simulator:
else:
selector_wireless.append(True)
selector_wired.append(False)
+ # Call the sender/receiver callbacks
self.notify_node_plugins(self.nodes[int(event[2][1])], "on_communication_end", event)
+ self.notify_node_plugins(self.nodes[int(event[2][0])], "on_communication_end", event)
else:
selector_wireless.append(False)
selector_wired.append(False)
@@ -235,7 +237,9 @@ class Simulator:
selector.append(True)
if self.netmat[event[2][2]]["is_wired"]:
sharing_to_update.append((int(event[2][1]),event[2][2]))
- self.notify_node_plugins(node, "on_communication_end", event)
+ self.notify_node_plugins(node, "on_communication_end", event)
+ elif int(event[2][0]) == int(event[2][1]): # If it is the sender event of a wireless communication (when sender_id==receiver_id)
+ self.notify_node_plugins(node, "on_communication_end", event)
else:
selector.append(False)
self.events=self.events[~np.array(selector)]
@@ -310,7 +314,10 @@ class Simulator:
if not (dst >=0 and dst <=len(self.nodes)):
self.log("Invalid dst used in send() or sendt(), node "+str(dst)+" not found", node=node.node_id)
exit(1)
- self.communicate(interface, node.node_id, dst, data, datasize,receiver_required)
+ if not self.communicate(interface, node.node_id, dst, data, datasize,receiver_required):
+ node["state"]="running"
+ node.rqueue.put(("send",4))
+ self.sync_node_non_blocking(node,timeout_remove_only=True)
elif node["request"] == "receive":
interface=node.rargs
if node["interfaces_queue_size"][interface] > 0:
@@ -332,6 +339,8 @@ class Simulator:
nsrc=self.nodes[src]
if self.netmat[interface]["is_wired"]:
self.log("Send "+str(datasize)+" bytes to n"+str(dst)+" on "+interface,node=src)
+ if not self.nodes[dst]["turned_on"] and receiver_required:
+ return(False)
self.update_sharing(dst,1,interface) # Update sharing first
# Note that in the following we send more data than expected to handle bandwidth sharing (datasize*8*sharing):
duration=datasize*8/(self.netmat[interface]["bandwidth"][src,dst]/self.sharing[interface][dst])+self.netmat[interface]["latency"][src,dst]
@@ -349,7 +358,7 @@ class Simulator:
self.add_event(0,duration+self.time,(src,dst,interface,data,datasize,duration,datasize,self.time,True,False))
elif not self.handle_interferences(src,dst, interface):
self.add_event(0,duration+self.time,(src,dst,interface,data,datasize,duration,datasize,self.time,True,False))
-
+ return(True)
def list_receivers(self,node,interface):
"""
Deduce reachable receivers from the bandwidth matrix