ndn: Add NFD and NLSR class abstractions
refs: #2528
Change-Id: I3241af0e85f4eec4eb640aca274ff9ca4f812656
diff --git a/mininet/conf_parser.py b/mininet/conf_parser.py
index ae514f3..62cc8fa 100644
--- a/mininet/conf_parser.py
+++ b/mininet/conf_parser.py
@@ -1,19 +1,30 @@
import ConfigParser, re
-class confCCNHost():
+class confNDNHost():
- def __init__(self, name, app='', uri_tuples='', cpu=None, cores=None, cache=None):
+ def __init__(self, name, app='', params='', cpu=None, cores=None, cache=None):
self.name = name
self.app = app
- self.uri_tuples = uri_tuples
+ self.uri_tuples = params
self.cpu = cpu
self.cores = cores
- self.cache = cache
+ self.cache = cache
+
+ # For now assume leftovers are NLSR configuration parameters
+ self.nlsrParameters = params
def __repr__(self):
- return 'Name: ' + self.name + ' App: ' + self.app + ' URIS: ' + str(self.uri_tuples) + ' CPU:' + str(self.cpu) + ' Cores:' +str(self.cores) + ' Cache: ' + str(self.cache)
+ return 'Name: ' + self.name + \
+ ' App: ' + self.app + \
+ ' URIS: ' + str(self.uri_tuples) + \
+ ' CPU: ' + str(self.cpu) + \
+ ' Cores: ' + str(self.cores) + \
+ ' Cache: ' + str(self.cache) + \
+ ' Radius: ' + str(self.radius) + \
+ ' Angle: ' + str(self.angle) + \
+ ' NLSR Parameters: ' + self.nlsrParameters
-class confCCNLink():
+class confNDNLink():
def __init__(self,h1,h2,linkDict=None):
self.h1 = h1
@@ -30,18 +41,18 @@
hosts = []
- items = config.items('hosts')
-
- #makes a first-pass read to hosts section to find empty host sections
- for item in items:
- name = item[0]
- rest = item[1].split()
- if len(rest) == 0:
- config.set('hosts', name, '_')
- #updates 'items' list
- items = config.items('hosts')
+ items = config.items('nodes')
- #makes a second-pass read to hosts section to properly add hosts
+ #makes a first-pass read to hosts section to find empty host sections
+ for item in items:
+ name = item[0]
+ rest = item[1].split()
+ if len(rest) == 0:
+ config.set('nodes', name, '_')
+ #updates 'items' list
+ items = config.items('nodes')
+
+ #makes a second-pass read to hosts section to properly add hosts
for item in items:
name = item[0]
@@ -51,66 +62,27 @@
app = rest.pop(0)
uris = rest
- uri_list=[]
+ params = {}
cpu = None
cores = None
- cache = None
+ cache = None
for uri in uris:
if re.match("cpu",uri):
cpu = float(uri.split('=')[1])
elif re.match("cores",uri):
cores = uri.split('=')[1]
- elif re.match("cache",uri):
- cache = uri.split('=')[1]
- elif re.match("mem",uri):
- mem = uri.split('=')[1]
+ elif re.match("cache",uri):
+ cache = uri.split('=')[1]
+ elif re.match("mem",uri):
+ mem = uri.split('=')[1]
else:
- uri_list.append((uri.split(',')[0],uri.split(',')[1]))
+ params[uri.split('=')[0]] = uri.split('=')[1]
- hosts.append(confCCNHost(name , app, uri_list,cpu,cores,cache))
+ hosts.append(confNDNHost(name, app, params, cpu, cores, cache))
return hosts
-def parse_routers(conf_arq):
- 'Parse routers section from the conf file.'
- config = ConfigParser.RawConfigParser()
- config.read(conf_arq)
-
- routers = []
-
- items = config.items('routers')
-
- for item in items:
- name = item[0]
-
- rest = item[1].split()
-
- uris = rest
- uri_list=[]
- cpu = None
- cores = None
- cache = None
-
- if '_' in uris:
- pass
- else:
- for uri in uris:
- if re.match("cpu",uri):
- cpu = float(uri.split('=')[1])
- elif re.match("cores",uri):
- cores = uri.split('=')[1]
- elif re.match("cache",uri):
- cache = uri.split('=')[1]
- elif re.match("mem",uri):
- mem = uri.split('=')[1]
- else:
- uri_list.append((uri.split(',')[0],uri.split(',')[1]))
-
- routers.append(confCCNHost(name=name , uri_tuples=uri_list, cpu=cpu, cores=cores))
-
- return routers
-
def parse_links(conf_arq):
'Parse links section from the conf file.'
arq = open(conf_arq,'r')
@@ -128,10 +100,10 @@
break
args = line.split()
-
- #checks for non-empty line
- if len(args) == 0:
- continue
+
+ #checks for non-empty line
+ if len(args) == 0:
+ continue
h1, h2 = args.pop(0).split(':')
@@ -147,7 +119,7 @@
value = float(value)
link_dict[key] = value
- links.append(confCCNLink(h1,h2,link_dict))
+ links.append(confNDNLink(h1,h2,link_dict))
return links