mirror of
https://gitlab.com/manzerbredes/esds.git
synced 2025-04-07 02:26:28 +02:00
Update platform parser
This commit is contained in:
parent
6a2319e07c
commit
da78abb61c
2 changed files with 25 additions and 9 deletions
|
@ -43,7 +43,7 @@ class YAMLPlatformFile:
|
||||||
else:
|
else:
|
||||||
return([int(elt[0])])
|
return([int(elt[0])])
|
||||||
|
|
||||||
def parse_link_bw(self,bw):
|
def parse_bw(self,bw):
|
||||||
for i,c in enumerate(bw):
|
for i,c in enumerate(bw):
|
||||||
if not c.isdigit() and c != ".":
|
if not c.isdigit() and c != ".":
|
||||||
break
|
break
|
||||||
|
@ -56,7 +56,7 @@ class YAMLPlatformFile:
|
||||||
number=number*8 if unit == "Bps" else number
|
number=number*8 if unit == "Bps" else number
|
||||||
return(number)
|
return(number)
|
||||||
|
|
||||||
def parse_link_lat(self,lat):
|
def parse_lat(self,lat):
|
||||||
for i,c in enumerate(lat):
|
for i,c in enumerate(lat):
|
||||||
if not c.isdigit() and c != ".":
|
if not c.isdigit() and c != ".":
|
||||||
break
|
break
|
||||||
|
@ -72,22 +72,26 @@ class YAMLPlatformFile:
|
||||||
if len(words) == 4:
|
if len(words) == 4:
|
||||||
return((
|
return((
|
||||||
self.parse_link_range(words[0]),
|
self.parse_link_range(words[0]),
|
||||||
self.parse_link_bw(words[1]),
|
self.parse_bw(words[1]),
|
||||||
self.parse_link_lat(words[2]),
|
self.parse_lat(words[2]),
|
||||||
self.parse_link_range(words[3])))
|
self.parse_link_range(words[3])))
|
||||||
elif len(words) == 2:
|
elif len(words) == 2:
|
||||||
return((
|
return((
|
||||||
range(0,self.default["node_count"]),
|
range(0,self.default["node_count"]),
|
||||||
self.parse_link_bw(words[0]),
|
self.parse_bw(words[0]),
|
||||||
self.parse_link_lat(words[1]),
|
self.parse_lat(words[1]),
|
||||||
range(0,self.default["node_count"])))
|
range(0,self.default["node_count"])))
|
||||||
return(None)
|
return(None)
|
||||||
|
|
||||||
|
def parse_txperf(self,txperf):
|
||||||
|
elts=txperf.split()
|
||||||
|
return((self.parse_bw(elts[0]),self.parse_lat(elts[1])))
|
||||||
|
|
||||||
def parse_interfaces(self):
|
def parse_interfaces(self):
|
||||||
interfaces=self.platform["interfaces"]
|
interfaces=self.platform["interfaces"]
|
||||||
node_count=self.default["node_count"]
|
node_count=self.default["node_count"]
|
||||||
for i in interfaces:
|
for i in interfaces:
|
||||||
is_wired=interfaces[i]["wireless"]
|
is_wired=not interfaces[i]["wireless"]
|
||||||
links=list()
|
links=list()
|
||||||
if type(interfaces[i]["links"]) == list:
|
if type(interfaces[i]["links"]) == list:
|
||||||
for link in interfaces[i]["links"]:
|
for link in interfaces[i]["links"]:
|
||||||
|
@ -95,13 +99,23 @@ class YAMLPlatformFile:
|
||||||
else:
|
else:
|
||||||
links.append(self.parse_link(interfaces[i]["links"]))
|
links.append(self.parse_link(interfaces[i]["links"]))
|
||||||
##### Create network matrix
|
##### Create network matrix
|
||||||
|
BW=np.full((node_count,node_count),0)
|
||||||
|
LAT=np.full((node_count,node_count),0)
|
||||||
for link in links:
|
for link in links:
|
||||||
BW=np.full((node_count,node_count),0)
|
|
||||||
LAT=np.full((node_count,node_count),0)
|
|
||||||
for n1 in link[0]:
|
for n1 in link[0]:
|
||||||
for n2 in link[3]:
|
for n2 in link[3]:
|
||||||
BW[n1][n2]=link[1]
|
BW[n1][n2]=link[1]
|
||||||
LAT[n1][n2]=link[2]
|
LAT[n1][n2]=link[2]
|
||||||
|
|
||||||
|
##### Set txperfs for wireless interfaces
|
||||||
|
if not is_wired:
|
||||||
|
txperfs=interfaces[i]["txperfs"]
|
||||||
|
for node in range(0,node_count):
|
||||||
|
txperf=txperfs[0] if len(txperfs) == 1 else txperfs[node]
|
||||||
|
bw,lat=self.parse_txperf(txperf)
|
||||||
|
BW[node][node]=bw
|
||||||
|
LAT[node][node]=lat
|
||||||
|
|
||||||
self.default["interfaces"][i]={
|
self.default["interfaces"][i]={
|
||||||
"is_wired": is_wired,
|
"is_wired": is_wired,
|
||||||
"bandwidth": BW,
|
"bandwidth": BW,
|
||||||
|
|
|
@ -14,6 +14,8 @@ interfaces:
|
||||||
wireless: yes
|
wireless: yes
|
||||||
links:
|
links:
|
||||||
- 0 1Bps 10s 0
|
- 0 1Bps 10s 0
|
||||||
|
txperfs:
|
||||||
|
- 1Bps 10s
|
||||||
eth0:
|
eth0:
|
||||||
wireless: no
|
wireless: no
|
||||||
links: 5Mbps 10s
|
links: 5Mbps 10s
|
Loading…
Add table
Reference in a new issue