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
diff --git a/mininet/net.py b/mininet/net.py
index 2d6bca6..847850b 100644
--- a/mininet/net.py
+++ b/mininet/net.py
@@ -164,7 +164,7 @@
if topo and build:
self.build()
- def isCCNhost(self, node):
+ def isNdnhost(self, node):
if 'fib' in node.params:
return True
else:
@@ -260,8 +260,8 @@
for host in self.hosts:
info( host.name + ' ' )
intf = host.defaultIntf()
- if self.isCCNhost(host):
- host.configCCN()
+ if self.isNdnhost(host):
+ host.configNdn()
host.configDefault(ip=None,mac=None)
elif intf:
host.configDefault( defaultRoute=intf )
@@ -315,7 +315,7 @@
params = topo.linkInfo( srcName, dstName )
srcPort, dstPort = topo.port( srcName, dstName )
self.addLink( src, dst, srcPort, dstPort, **params )
- if self.isCCNhost(src):
+ if self.isNdnhost(src):
src.setIP(ipStr(ipParse(self.ccnNetBase) + 1) + '/30', intf=src.name + '-eth' + str(srcPort))
dst.setIP(ipStr(ipParse(self.ccnNetBase) + 2) + '/30', intf=dst.name + '-eth' + str(dstPort))
self.ccnNetBase=nextCCNnet(self.ccnNetBase)
diff --git a/mininet/node.py b/mininet/node.py
index 8749987..84e0bc6 100644
--- a/mininet/node.py
+++ b/mininet/node.py
@@ -717,153 +717,6 @@
mountCgroups()
cls.inited = True
-class CCNHost( Host ):
- "CCNHost is a Host that always runs the ccnd daemon"
-
- def __init__( self, name, **kwargs ):
-
-
- Host.__init__( self, name, **kwargs )
- if not CCNHost.inited:
- CCNHost.init()
-
- self.cmd("export CCND_DEBUG=6")
- self.cmd("export CCND_LOG=./log.{0}".format(self.name))
- #pdb.set_trace()
-# print self.params['cache']
- if self.params['cache'] != None:
- self.cmd("export CCND_CAP={0}".format(self.params['cache']))
-
- self.cmd("export CCN_LOCAL_SOCKNAME=/tmp/.sock.ccnx.{0}".format(self.name))
- self.cmd("ccndstart")
- self.peerList = {}
-
- def config( self, fib=None, app=None, cache=None, **params ):
-
- r = Node.config( self, **params )
-
- self.setParam( r, 'app', fib=fib )
- self.setParam( r, 'fib', app=app)
- self.setParam( r, 'cache', cache=cache )
-
- return r
-
- def configCCN(self):
-
- self.buildPeerIP()
- self.setFIB()
-
- def buildPeerIP(self):
- for iface in self.intfList():
- link = iface.link
- if link:
- node1, node2 = link.intf1.node, link.intf2.node
- if node1 == self:
- self.peerList[node2.name] = link.intf2.node.IP(link.intf2)
- else:
- self.peerList[node1.name] = link.intf1.node.IP(link.intf1)
-
-
- def setFIB(self):
-
- for name in self.params['fib']:
- if not name:
- pass
- else:
- self.insert_fib(name[0],self.peerList[name[1]])
-
-
- def insert_fib(self, uri, host):
- self.cmd('ccndc add {0} tcp {1}'.format(uri,host))
- # self.cmd('ccndc add {0} udp {1}'.format(uri,host))
-
- def terminate( self ):
- "Stop node."
- self.cmd('ccndstop')
- self.cmd('killall -r zebra ospf')
- Host.terminate(self)
-
- inited = False
-
-
- @classmethod
- def init( cls ):
- "Initialization for CCNHost class"
- cls.inited = True
-
-class CPULimitedCCNHost( CPULimitedHost ):
- '''CPULimitedCCNHost is a Host that always runs the ccnd daemon and extends CPULimitedHost.
- It should be used when one wants to limit the resources of CCN routers and hosts '''
-
-
- def __init__( self, name, sched='cfs', **kwargs ):
-
- CPULimitedHost.__init__( self, name, sched, **kwargs )
- if not CCNHost.inited:
- CCNHost.init()
-
- self.cmd("export CCND_DEBUG=6")
- self.cmd("export CCND_LOG=./log.{0}".format(self.name))
- if self.params['cache'] != None:
- self.cmd("export CCND_CAP={0}".format(self.params['cache']))
-
- self.cmd("export CCN_LOCAL_SOCKNAME=/tmp/.sock.ccnx.{0}".format(self.name))
- self.cmd("ccndstart")
- self.peerList = {}
-
- def config( self, fib=None, app=None, cpu=None, cores=None, cache=None, **params):
-
- r = CPULimitedHost.config(self,cpu,cores, **params)
-
- self.setParam( r, 'app', fib=fib )
- self.setParam( r, 'fib', app=app)
- self.setParam( r, 'cache', cache=cache)
-
- return r
-
- def configCCN(self):
-
- self.buildPeerIP()
- self.setFIB()
-
- def buildPeerIP(self):
- for iface in self.intfList():
- link = iface.link
- if link:
- node1, node2 = link.intf1.node, link.intf2.node
- if node1 == self:
- self.peerList[node2.name] = link.intf2.node.IP(link.intf2)
- else:
- self.peerList[node1.name] = link.intf1.node.IP(link.intf1)
-
-
- def setFIB(self):
-
- for name in self.params['fib']:
- if not name:
- pass
- else:
- self.insert_fib(name[0],self.peerList[name[1]])
-
-
- def insert_fib(self, uri, host):
- self.cmd('ccndc add {0} tcp {1}'.format(uri,host))
-# self.cmd('ccndc add {0} udp {1}'.format(uri,host))
-
- def terminate( self ):
- "Stop node."
- self.cmd('ccndstop')
- self.cmd('killall -r zebra ospf')
- Host.terminate(self)
-
- inited = False
-
-
- @classmethod
- def init( cls ):
- "Initialization for CCNHost class"
- cls.inited = True
-
# Some important things to note:
#
# The "IP" address which setIP() assigns to the switch is not