Using latest version of mininet
refs: #2851
Change-Id: Ica4936cb98245a0b1a22d8ceada4e7a0f6dbddc8
diff --git a/ndn/conf_parser.py b/ndn/conf_parser.py
new file mode 100644
index 0000000..62cc8fa
--- /dev/null
+++ b/ndn/conf_parser.py
@@ -0,0 +1,125 @@
+import ConfigParser, re
+
+class confNDNHost():
+
+ def __init__(self, name, app='', params='', cpu=None, cores=None, cache=None):
+ self.name = name
+ self.app = app
+ self.uri_tuples = params
+ self.cpu = cpu
+ self.cores = cores
+ 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) + \
+ ' Radius: ' + str(self.radius) + \
+ ' Angle: ' + str(self.angle) + \
+ ' NLSR Parameters: ' + self.nlsrParameters
+
+class confNDNLink():
+
+ def __init__(self,h1,h2,linkDict=None):
+ self.h1 = h1
+ self.h2 = h2
+ self.linkDict = linkDict
+
+ def __repr__(self):
+ return 'h1: ' + self.h1 + ' h2: ' + self.h2 + ' params: ' + str(self.linkDict)
+
+def parse_hosts(conf_arq):
+ 'Parse hosts section from the conf file.'
+ config = ConfigParser.RawConfigParser()
+ config.read(conf_arq)
+
+ hosts = []
+
+ items = config.items('nodes')
+
+ #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]
+
+ rest = item[1].split()
+
+ app = rest.pop(0)
+
+ uris = rest
+ params = {}
+ cpu = None
+ cores = 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]
+ else:
+ params[uri.split('=')[0]] = uri.split('=')[1]
+
+ hosts.append(confNDNHost(name, app, params, cpu, cores, cache))
+
+ return hosts
+
+def parse_links(conf_arq):
+ 'Parse links section from the conf file.'
+ arq = open(conf_arq,'r')
+
+ links = []
+
+ while True:
+ line = arq.readline()
+ if line == '[links]\n':
+ break
+
+ while True:
+ line = arq.readline()
+ if line == '':
+ break
+
+ args = line.split()
+
+ #checks for non-empty line
+ if len(args) == 0:
+ continue
+
+ h1, h2 = args.pop(0).split(':')
+
+ link_dict = {}
+
+ for arg in args:
+ arg_name, arg_value = arg.split('=')
+ key = arg_name
+ value = arg_value
+ if key in ['bw','jitter','max_queue_size']:
+ value = int(value)
+ if key in ['loss']:
+ value = float(value)
+ link_dict[key] = value
+
+ links.append(confNDNLink(h1,h2,link_dict))
+
+
+ return links
diff --git a/ndn/nfd.py b/ndn/nfd.py
index b33fc37..6fea538 100644
--- a/ndn/nfd.py
+++ b/ndn/nfd.py
@@ -21,8 +21,8 @@
self.ndnFolder = "%s/.ndn" % self.homeFolder
self.clientConf = "%s/client.conf" % self.ndnFolder
- # Copy nfd.conf file from mini-ndn/ndn_utils to the node's home
- node.cmd("sudo cp ~/mini-ndn/ndn_utils/nfd.conf %s" % self.confFile)
+ # Copy nfd.conf file from /usr/local/etc/mini-ndn to the node's home
+ node.cmd("sudo cp /usr/local/etc/mini-ndn/nfd.conf %s" % self.confFile)
# Open the conf file and change socket file name
node.cmd("sudo sed -i 's|nfd.sock|%s.sock|g' %s" % (node.name, self.confFile))
@@ -31,7 +31,7 @@
node.cmd("sudo mkdir %s" % self.ndnFolder)
# Copy the client.conf file and change the unix socket
- node.cmd("sudo cp ~/mini-ndn/ndn_utils/client.conf.sample %s" % self.clientConf)
+ node.cmd("sudo cp /usr/local/etc/mini-ndn/client.conf.sample %s" % self.clientConf)
node.cmd("sudo sed -i 's|nfd.sock|%s.sock|g' %s" % (node.name, self.clientConf))
# Change home folder
diff --git a/ndn/nlsr.py b/ndn/nlsr.py
index cda91ea..d376531 100644
--- a/ndn/nlsr.py
+++ b/ndn/nlsr.py
@@ -42,8 +42,8 @@
ROUTING_LINK_STATE = "ls"
ROUTING_HYPERBOLIC = "hr"
- def __init__(self, node, home):
- node.cmd("sudo cp %s/mini-ndn/ndn_utils/nlsr.conf nlsr.conf" % home)
+ def __init__(self, node):
+ node.cmd("sudo cp /usr/local/etc/mini-ndn/nlsr.conf nlsr.conf")
self.node = node
parameters = node.nlsrParameters