示例#1
0
class CpuLimitedNdnHost(CPULimitedHost, NdnHostCommon):
    '''CPULimitedNDNHost is a Host that always runs NFD and extends CPULimitedHost.
       It should be used when one wants to limit the resources of NDN routers and hosts '''

    def __init__(self, name, sched='cfs', **kwargs):

        CPULimitedHost.__init__(self, name, sched, **kwargs)
        if not NdnHost.inited:
            NdnHostCommon.init()

        # Create home directory for a node
        self.homeFolder = "%s/%s" % (self.params['workdir'], self.name)
        self.cmd("mkdir -p %s" % self.homeFolder)
        self.cmd("cd %s" % self.homeFolder)

        self.nfd = Nfd(self)
        self.nfd.start()

        self.peerList = {}

    def config(self, app=None, cpu=None, cores=None, cache=None, **params):

        r = CPULimitedHost.config(self,cpu,cores, **params)

        self.setParam(r, 'app', app=app)
        self.setParam(r, 'cache', cache=cache)

        return r

    def terminate(self):
        "Stop node."
        self.nfd.stop()
        Host.terminate(self)
示例#2
0
class NdnHost(Host, NdnHostCommon):
    "NDNHost is a Host that always runs NFD"

    def __init__(self, name, **kwargs):

        Host.__init__(self, name, **kwargs)
        if not NdnHost.inited:
            NdnHostCommon.init()

        # Create home directory for a node
        self.homeFolder = "%s/%s" % (self.params['workdir'], self.name)
        self.cmd("mkdir -p %s" % self.homeFolder)
        self.cmd("cd %s" % self.homeFolder)

        self.nfd = Nfd(self)
        self.nfd.start()

        self.peerList = {}

    def config(self, app=None, cache=None, **params):

        r = Node.config(self, **params)

        self.setParam(r, 'app', app=app)
        self.setParam(r, 'cache', cache=cache)

        return r

    def terminate(self):
        "Stop node."
        self.nfd.stop()
        Host.terminate(self)
示例#3
0
class NdnHost(Host, NdnHostCommon):
    "NDNHost is a Host that always runs NFD"

    def __init__(self, name, **kwargs):
        privateDirs = [('/usr/local/etc/ndn', '/tmp/%(name)s/usr/local/etc/ndn'),  ]
        kwargs['privateDirs'] = privateDirs

        Host.__init__(self, name, **kwargs)
        if not NdnHost.inited:
            NdnHostCommon.init()

        self.nfd = Nfd(self)
        self.nfd.start()

        self.peerList = {}

    def config(self, fib=None, app=None, cache=None, **params):

        r = Node.config(self, **params)

        self.setParam(r, 'app', fib=fib)   # why is this not app=app, to be investigated
        self.setParam(r, 'fib', app=app)   # and this fib=fib
        self.setParam(r, 'cache', cache=cache)

        return r

    def terminate(self):
        "Stop node."
        self.nfd.stop()
        Host.terminate(self)
示例#4
0
class CpuLimitedNdnHost(CPULimitedHost, NdnHostCommon):
    '''CPULimitedNDNHost is a Host that always runs NFD and extends CPULimitedHost.
       It should be used when one wants to limit the resources of NDN routers and hosts '''

    def __init__(self, name, sched='cfs', **kwargs):

        CPULimitedHost.__init__(self, name, sched, **kwargs)
        if not NdnHost.inited:
            NdnHostCommon.init()

        self.nfd = Nfd(self)
        self.nfd.start()

        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)   #????? shoud it be app=app
        self.setParam(r, 'fib', app=app)
        self.setParam(r, 'cache', cache=cache)

        return r

    def terminate(self):
        "Stop node."
        self.nfd.stop()
        Host.terminate(self)
示例#5
0
class NdnHost(Host, NdnHostCommon):
    "NDNHost is a Host that always runs NFD"

    def __init__(self, name, **kwargs):

        Host.__init__(self, name, **kwargs)
        if not NdnHost.inited:
            NdnHostCommon.init()

        # Create home directory for a node
        self.homeFolder = "%s/%s" % (self.params['workdir'], self.name)
        self.cmd("mkdir -p %s" % self.homeFolder)
        self.cmd("cd %s" % self.homeFolder)

        self.nfd = Nfd(self)
        self.nfd.start()

        self.peerList = {}

    def config(self, app=None, cache=None, **params):

        r = Node.config(self, **params)

        self.setParam(r, 'app', app=app)
        self.setParam(r, 'cache', cache=cache)

        return r

    def terminate(self):
        "Stop node."
        self.nfd.stop()
        Host.terminate(self)
示例#6
0
class CpuLimitedNdnHost(CPULimitedHost, NdnHostCommon):
    '''CPULimitedNDNHost is a Host that always runs NFD and extends CPULimitedHost.
       It should be used when one wants to limit the resources of NDN routers and hosts '''

    def __init__(self, name, sched='cfs', **kwargs):

        CPULimitedHost.__init__(self, name, sched, **kwargs)
        if not NdnHost.inited:
            NdnHostCommon.init()

        # Create home directory for a node
        self.homeFolder = "%s/%s" % (self.params['workdir'], self.name)
        self.cmd("mkdir -p %s" % self.homeFolder)
        self.cmd("cd %s" % self.homeFolder)

        self.nfd = Nfd(self)
        self.nfd.start()

        self.peerList = {}

    def config(self, app=None, cpu=None, cores=None, cache=None, **params):

        r = CPULimitedHost.config(self,cpu,cores, **params)

        self.setParam(r, 'app', app=app)
        self.setParam(r, 'cache', cache=cache)

        return r

    def terminate(self):
        "Stop node."
        self.nfd.stop()
        Host.terminate(self)
示例#7
0
class NdnStation(Station, NdnHostCommon):
    "NDNStation is a Host that always runs NFD, and is wifi-enabled"

    def __init__(self, name, **kwargs):

        Host.__init__(self, name, **kwargs)
        if not NdnHost.inited:
            NdnHostCommon.init()

        # Create home directory for a node
        self.homeFolder = "%s/%s" % (self.params['workdir'], self.name
                                     )  # Xian: using workDir will occur erro
        self.cmd("mkdir -p %s" % self.homeFolder)
        self.cmd("cd %s" % self.homeFolder)

        self.nfd = Nfd(self)
        print "ndn_host.py--------------------------Ndnhost() cla---- init"
        self.nfd.start()

        self.peerList = {}

    def config(self, app=None, cache=None, **params):

        r = Node.config(self, **params)

        self.setParam(r, 'app', app=app)
        self.setParam(r, 'cache', cache=cache)
        print "ndn_host.py------------NdnHost cla-----config() method-----------"
        return r

    def terminate(self):
        "Stop node."
        self.nfd.stop()
        Host.terminate(self)
示例#8
0
文件: node.py 项目: agawande/mn-ndn
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.nfd = Nfd(self)
        self.nfd.start()

        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 )   #????? shoud it be app=app
        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):
        # TODO: Fix key error caused by NLSR configuration parameters
        return

        for name in self.params['fib']:
            if not name:
                pass
            else:
                self.insert_fib(name[0],self.peerList[name[1]])

	#for radius in self.params['radius']:
         #   if not radius:
          #      pass
           # else:
	#	print(radius)

    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.nfd.stop()
        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
示例#9
0
文件: node.py 项目: agawande/mn-ndn
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.nfd = Nfd(self)
        self.nfd.start()

        self.peerList = {}


    def config( self, fib=None, app=None, cache=None, **params ):

        r = Node.config( self, **params )

        self.setParam( r, 'app', fib=fib)   # why is this not app=app
        self.setParam( r, 'fib', app=app)   # and this fib=fib
	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):
        # TODO: Fix key error caused by NLSR configuration parameters
        return

        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.nfd.stop()
        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