mirror of
https://gitlab.com/manzerbredes/esds.git
synced 2025-04-19 03:59:45 +00:00
Remove interface name from registers
This commit is contained in:
parent
fa09187031
commit
b75498604a
3 changed files with 17 additions and 19 deletions
20
esds.py
20
esds.py
|
@ -252,8 +252,12 @@ class Simulator:
|
||||||
for node in self.nodes:
|
for node in self.nodes:
|
||||||
s=node["state"]
|
s=node["state"]
|
||||||
states[s]=states[s]+1 if s in states else 1
|
states[s]=states[s]+1 if s in states else 1
|
||||||
if self.sharing["eth0"][node.node_id] > 0:
|
node_key="n"+str(node.node_id)
|
||||||
sharing["n"+str(node.node_id)]=str(int(self.sharing["eth0"][node.node_id]))
|
for interface in self.sharing.keys():
|
||||||
|
if self.sharing[interface][node.node_id] > 0:
|
||||||
|
if node_key not in sharing:
|
||||||
|
sharing[node_key] = ""
|
||||||
|
sharing[node_key]+=str(int(self.sharing[interface][node.node_id]))
|
||||||
print("Node number per state: ",end="")
|
print("Node number per state: ",end="")
|
||||||
for key in states:
|
for key in states:
|
||||||
print(key+"="+str(states[key]), end=" ")
|
print(key+"="+str(states[key]), end=" ")
|
||||||
|
@ -315,18 +319,12 @@ class Simulator:
|
||||||
node["state"]="running"
|
node["state"]="running"
|
||||||
if node.rargs == "clock":
|
if node.rargs == "clock":
|
||||||
node.rqueue.put(("read",self.time))
|
node.rqueue.put(("read",self.time))
|
||||||
elif node.rargs == "wlan0_ncom":
|
elif node.rargs[0:5] == "ncom_": # ncom_<interface> register
|
||||||
|
interface=node.rargs[5:]
|
||||||
count=0
|
count=0
|
||||||
# Count number of communication on wlan0
|
# Count number of communication on wlan0
|
||||||
for event in self.events:
|
for event in self.events:
|
||||||
if event[0] == 0 and event[2][1] == node.node_id and event[2][2] == "wlan0":
|
if event[0] == 0 and event[2][1] == node.node_id and event[2][2] == interface:
|
||||||
count+=1
|
|
||||||
node.rqueue.put(("read",count))
|
|
||||||
elif node.rargs == "eth0_ncom":
|
|
||||||
count=0
|
|
||||||
# Count number of communication on eth0
|
|
||||||
for event in self.events:
|
|
||||||
if event[0] == 0 and event[2][1] == node.node_id and event[2][2] == "eth0":
|
|
||||||
count+=1
|
count+=1
|
||||||
node.rqueue.put(("read",count))
|
node.rqueue.put(("read",count))
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
def execute(api):
|
def execute(api):
|
||||||
api.log("eth0 is {}".format(api.read("eth0_ncom")))
|
api.log("eth0 is {}".format(api.read("ncom_eth0")))
|
||||||
api.wait(624)
|
api.wait(624)
|
||||||
api.log("eth0 is {}".format(api.read("eth0_ncom")))
|
api.log("eth0 is {}".format(api.read("ncom_eth0")))
|
||||||
api.wait(624)
|
api.wait(624)
|
||||||
# Now we are at 624*2=1248 (first sender start a communication)
|
# Now we are at 624*2=1248 (first sender start a communication)
|
||||||
api.wait(1) # Let the communication starts
|
api.wait(1) # Let the communication starts
|
||||||
api.log("eth0 is {}".format(api.read("eth0_ncom"))) # Should print 1
|
api.log("eth0 is {}".format(api.read("ncom_eth0"))) # Should print 1
|
||||||
api.wait(1) # Now second sender start a communication
|
api.wait(1) # Now second sender start a communication
|
||||||
api.log("eth0 is {}".format(api.read("eth0_ncom"))) # Should print 2
|
api.log("eth0 is {}".format(api.read("ncom_eth0"))) # Should print 2
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
def execute(api):
|
def execute(api):
|
||||||
api.log("wlan0 is {}".format(api.read("wlan0_ncom")))
|
api.log("wlan0 is {}".format(api.read("ncom_wlan0")))
|
||||||
api.wait(624)
|
api.wait(624)
|
||||||
api.log("wlan0 is {}".format(api.read("wlan0_ncom")))
|
api.log("wlan0 is {}".format(api.read("ncom_wlan0")))
|
||||||
api.wait(624)
|
api.wait(624)
|
||||||
# Now we are at 624*2=1248 (first sender start a communication)
|
# Now we are at 624*2=1248 (first sender start a communication)
|
||||||
api.wait(1) # Let the communication starts
|
api.wait(1) # Let the communication starts
|
||||||
api.log("wlan0 is {}".format(api.read("wlan0_ncom"))) # Should print 1
|
api.log("wlan0 is {}".format(api.read("ncom_wlan0"))) # Should print 1
|
||||||
api.wait(1) # Second sender start a communication
|
api.wait(1) # Second sender start a communication
|
||||||
api.log("wlan0 is {}".format(api.read("wlan0_ncom"))) # Should print 2
|
api.log("wlan0 is {}".format(api.read("ncom_wlan0"))) # Should print 2
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue