Remove interface names from list_receivers()

This commit is contained in:
Loic Guegan 2022-06-11 10:36:19 +02:00
parent b75498604a
commit 4a11e56d28

16
esds.py
View file

@ -322,7 +322,7 @@ class Simulator:
elif node.rargs[0:5] == "ncom_": # ncom_<interface> register
interface=node.rargs[5:]
count=0
# Count number of communication on wlan0
# Count number of communication on interface
for event in self.events:
if event[0] == 0 and event[2][1] == node.node_id and event[2][2] == interface:
count+=1
@ -391,7 +391,7 @@ class Simulator:
self.sharing[interface][dst]=new_sharing
self.sort_events()
def handle_interferences(self,sender,receiver):
def handle_interferences(self,sender,receiver, interface):
"""
Interferences are detected by looking for conflicts between
new events and existing events.
@ -402,7 +402,7 @@ class Simulator:
for event in self.events:
event_type=event[0]
com=event[2]
if event_type==0 and com[2] == "wlan0":
if event_type==0 and com[2] == interface:
com_sender=int(com[0])
com_receiver=int(com[1])
select=False
@ -422,7 +422,7 @@ class Simulator:
if len(selector) != 0:
self.events=self.events[~np.array(selector)]
for node in notify:
self.log("Interferences on wlan0",node=node)
self.log("Interferences on "+interface,node=node)
return status
def sync_event(self, node):
@ -464,21 +464,21 @@ class Simulator:
nsrc["state"]="request" # Try later when node is on
else:
self.log("Send "+str(datasize)+" bytes on "+interface,node=src)
for dst in self.list_wireless_receivers(nsrc):
for dst in self.list_receivers(nsrc,interface):
if self.nodes[dst]["turned_on"]:
duration=datasize*8/self.netmat[interface]["bandwidth"][src,dst]+self.netmat[interface]["latency"][src,dst]
if src == dst:
self.add_event(0,duration+self.time,(src,dst,interface,data,datasize,duration,datasize,self.time))
elif not self.interferences:
self.add_event(0,duration+self.time,(src,dst,interface,data,datasize,duration,datasize,self.time))
elif not self.handle_interferences(src,dst):
elif not self.handle_interferences(src,dst, interface):
self.add_event(0,duration+self.time,(src,dst,interface,data,datasize,duration,datasize,self.time))
def list_wireless_receivers(self,node):
def list_receivers(self,node,interface):
"""
Deduce reachable receivers from the bandwidth matrix
"""
selector = self.netmat["wlan0"]["bandwidth"][node.node_id,] > 0
selector = self.netmat[interface]["bandwidth"][node.node_id,] > 0
return np.arange(0,selector.shape[0])[selector]