Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 3
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)
Exemplo n.º 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)
Exemplo n.º 5
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)
Exemplo n.º 6
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)
Exemplo n.º 7
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)
Exemplo n.º 8
0
    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 = {}
Exemplo n.º 9
0
    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 = {}
Exemplo n.º 10
0
    def __init__(self, name, **kwargs):

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

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

        self.peerList = {}
Exemplo n.º 11
0
    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 = {}
Exemplo n.º 12
0
    def __init__(self, name, **kwargs):

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

        # Hacky quick fix
        if self.params.get('workdir') is None:
            self.params['workdir'] = '/tmp'
            self.params['params'] = {}

        # 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 = {}
Exemplo n.º 13
0
    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 = {}
Exemplo n.º 14
0
    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 = {}
Exemplo n.º 15
0
    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 = {}
Exemplo n.º 16
0
def build_sumo_vndn(vndnTopo, ssid, channel, mode, wmediumd, interference,
                    cluster, placement, servers, tunnelType, ctime, nPings,
                    pctTraffic, experimentName, nlsrSecurity):

    "Create a network."
    net = Mininet_wifi(host=NdnHost,
                       station=NdnStation,
                       car=NdnCar,
                       controller=Controller,
                       accessPoint=UserAP,
                       link=wmediumd,
                       wmediumd_mode=interference)

    info("*** Creating nodes\n")

    for carName in vndnTopo.hosts():
        if 'car' in str(carName):
            net.addCar(carName, wlans=1, **vndnTopo.nodeInfo(carName))
            #net.addCar(carName, **vndnTopo.nodeInfo(carName))

    e1 = net.addAccessPoint('e1',
                            ssid='vanet-ssid',
                            mac='00:00:00:11:00:01',
                            mode='g',
                            channel='1',
                            passwd='123456789a',
                            encrypt='wpa2',
                            position='3279.02,3736.27,0')
    e2 = net.addAccessPoint('e2',
                            ssid='vanet-ssid',
                            mac='00:00:00:11:00:02',
                            mode='g',
                            channel='6',
                            passwd='123456789a',
                            encrypt='wpa2',
                            position='2320.82,3565.75,0')

    c1 = net.addController('c1')

    info("*** Setting bgscan\n")
    net.setBgscan(signal=-45, s_inverval=5, l_interval=10)

    info("*** Configuring Propagation Model\n")
    net.setPropagationModel(model="logDistance", exp=2)

    info("*** Configuring wifi nodes\n")
    net.configureWifiNodes()

    net.addLink(e1, e2)

    for car in net.cars:
        #net.addLink(car, intf=car.params['wlan'][1],
        #            cls=mesh, ssid='mesh-ssid', channel=5)
        net.addLink(car, cls=adhoc, ssid='mesh-ssid', mode='g', channel=5)

    net.useExternalProgram(program=sumo, port=8813, config_file='map.sumocfg')

    info("*** Starting network\n")
    net.build()
    c1.start()
    e1.start([c1])
    e2.start([c1])
    '''i = 1
    for car in net.cars:
        car.setIP('192.168.0.%s/24' % str(i),
                  intf='%s-wlan0' % car)
        car.setIP('192.168.1.%s/24' % str(i),
                  intf='%s-mp1' % car)
	i+=1	
    '''
    for car in net.cars:
        car.nfd = Nfd(car, 65536)
        car.nfd.start()
        #Nfdc.setStrategy(car, "/vanet", "vanet")
        #cmd = "nfdc strategy set /vanet ndn:/localhost/nfd/strategy/vanet/"

    info("*** Running CLI\n")
    MiniNdnWifiCLI(net)

    info("*** Stopping network\n")
    net.stop()

    info('Cleaning up...')
    call(["nfd-stop"])
    call(["sudo", "mn", "--clean"])
    call(["sudo", "pkill", "sumo"])
    sys.exit(1)
Exemplo n.º 17
0
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
Exemplo n.º 18
0
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