From 3fef2bbf4ba898fc932d515b864f4d9351798ef9 Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Fri, 10 Jun 2022 21:19:43 +0200 Subject: [PATCH] Enable nodes to have multiple interfaces --- esds.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/esds.py b/esds.py index c28aa28..20763b6 100644 --- a/esds.py +++ b/esds.py @@ -5,7 +5,7 @@ import threading,importlib,queue,sys,time class Node: available_node_id=0 - def __init__(self,src): + def __init__(self,src,interfaces): """ """ @@ -16,7 +16,10 @@ class Node: self.rargs=None # Store the requests arguments self.plugins=list() # Contains all registered node plugins self.rqueue=queue.Queue() # Receive simulator acknowledgments - self.chest={"state":"running", "turned_on":True, "request": None, "interfaces":{"wlan0":queue.Queue(), "eth0":queue.Queue()}, "interfaces_queue_size":{"wlan0":0,"eth0":0}} + self.chest={"state":"running", "turned_on":True, "request": None, "interfaces":dict(), "interfaces_queue_size":dict()} + for interface in interfaces: + self.chest["interfaces"][interface]=queue.Queue() + self.chest["interfaces_queue_size"][interface]=0 self.chest_lock=threading.Lock() # To access/modify self.chest def plugin_register(self,plugin): @@ -266,7 +269,7 @@ class Simulator: """ Create a node thread and run it """ - node=Node(src) + node=Node(src, self.netmat.keys()) self.nodes.append(node) thread=threading.Thread(target=node.run, daemon=False,args=[args]) thread.start()