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, 6 insertions, 9 deletions
diff --git a/esds/simulator.py b/esds/simulator.py
index 74f126e..fc76daf 100644
--- a/esds/simulator.py
+++ b/esds/simulator.py
@@ -306,14 +306,11 @@ class Simulator:
"""
nsrc=self.nodes[src]
if self.netmat[interface]["is_wired"]:
- if self.nodes[dst]["turned_on"]:
- self.log("Send "+str(datasize)+" bytes to n"+str(dst)+" on "+interface,node=src)
- 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]
- self.add_event(0,duration+self.time,(src,dst,interface,data,datasize,duration,datasize,self.time,True))
- else:
- nsrc["state"]="call_blocking" # Try later when node is on
+ self.log("Send "+str(datasize)+" bytes to n"+str(dst)+" on "+interface,node=src)
+ 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]
+ self.add_event(0,duration+self.time,(src,dst,interface,data,datasize,duration,datasize,self.time,self.nodes[dst]["turned_on"]))
else:
self.log("Send "+str(datasize)+" bytes on "+interface,node=src)
for dst in self.list_receivers(nsrc,interface):
@@ -400,7 +397,6 @@ class Simulator:
if perform_delivery:
dst["interfaces"][interface].put((data,start_at,self.time))
dst["interfaces_queue_size"][interface]+=1
- self.update_sharing(dst.node_id,-1,interface)
self.log("Receive "+str(datasize)+" bytes on "+interface,node=int(dst_id))
# If node is receiving makes it consume (this way if there is a timeout, it will be removed!)
if dst["state"] == "call_blocking" and dst["request"] == "receive":
@@ -408,6 +404,7 @@ class Simulator:
dst["state"]="running"
dst.rqueue.put(("receive",0))
self.sync_node_non_blocking(dst,timeout_remove_only=True)
+ self.update_sharing(dst.node_id,-1,interface)
src["state"]="running"
src.rqueue.put(("send",0))
self.sync_node_non_blocking(src,timeout_remove_only=True)