Debug send_cancel

This commit is contained in:
Loic Guegan 2022-08-15 11:30:17 +02:00
parent e0dbebe31d
commit 371749159b

View file

@ -9,9 +9,9 @@ class Simulator:
Event types: Event types:
- 0 send (0,timestamp,(src,dst,interface,data,datasize,duration,datasize_remaining,start_timestamp, perform_delivery, receiver_required), 2) - 0 send (0,timestamp,(src,dst,interface,data,datasize,duration,datasize_remaining,start_timestamp, perform_delivery, receiver_required), 2)
- 1 timeout (1,timestamp,node_id,3) - 1 timeout (1,timestamp,node_id,3)
- 2 breakpoint_manual (3,timestamp,0,1) - 2 breakpoint_manual (2,timestamp,0,1)
- 3 breakpoint_auto (4,timestamp,0,1) - 3 breakpoint_auto (3,timestamp,0,1)
- 4 notify (5,timestamp,node_id,0) - 4 notify (4,timestamp,node_id,0)
Very important notes: Very important notes:
@ -231,14 +231,18 @@ class Simulator:
self.sync_node_blocking(sender_node) self.sync_node_blocking(sender_node)
elif node["request"] == "send_cancel": elif node["request"] == "send_cancel":
selector=list() selector=list()
sharing_to_update=list()
for event in self.events: for event in self.events:
if event[0]==0 and int(event[2][0]) == node.node_id: if event[0]==0 and int(event[2][0]) == node.node_id:
selector.append(True) selector.append(True)
if self.netmat[event[2][2]]["is_wired"]: if self.netmat[event[2][2]]["is_wired"]:
self.update_sharing(int(event[2][1]),-1,event[2][2]) sharing_to_update.append((int(event[2][1]),event[2][2]))
else: else:
selector.append(False) selector.append(False)
self.events=self.events[~np.array(selector)] self.events=self.events[~np.array(selector)]
# Now Update receiver of cancel communication sharing (since update_sharing sort event, selector would have been invalidated if done before)
for com in sharing_to_update:
self.update_sharing(com[0],-1,com[1])
node["state"]="running" node["state"]="running"
node.rqueue.put(("send_cancel",0)) node.rqueue.put(("send_cancel",0))
node.sync() node.sync()
@ -246,6 +250,7 @@ class Simulator:
def update_sharing(self, dst, amount,interface): def update_sharing(self, dst, amount,interface):
""" """
Manage bandwidth sharing on wired interfaces Manage bandwidth sharing on wired interfaces
THIS FUNCTION SORT EVENTS SO BE CAREFUL SINCE IT CAN INVALIDATE SELECTORS
""" """
sharing=self.sharing[interface][dst] sharing=self.sharing[interface][dst]
new_sharing=sharing+amount new_sharing=sharing+amount