Ejemplo n.º 1
0
    def instantiateConsumer(self, pHost, pDataPackage):
        """
      Issues MiniNDN commands to set up a consumer for a data package
      """
        global g_bIsMockExperiment
        if (pHost):
            # Consumer program usage: consumer <interest> <hostName> <payload> <timestamp>
            sSecSinceLast = (datetime.now() -
                             self.hshConsumers[str(pHost)]).total_seconds()
            if (sSecSinceLast < c_sConsumerCooldownSec):
                logging.info(
                    '[RandomTalks.instantiateConsumer] Will wait seconds=%.2f'
                    % (c_sConsumerCooldownSec - sSecSinceLast))
                time.sleep(c_sConsumerCooldownSec - sSecSinceLast)

            strInterest = RandomTalks.getChunksFilter(pDataPackage.strOrig,
                                                      pDataPackage.nType,
                                                      pDataPackage.nID)
            strCmd = 'ndncatchunks %s' % strInterest
            if (not g_bIsMockExperiment):
                getPopen(pHost, strCmd, shell=True)

            self.nBytesConsumed += pDataPackage.nPayloadSize
            logging.info(
                '[RandomTalks.instantiateConsumer] %s ConsumerCmd: %s' %
                (pHost.name, strCmd))
        else:
            logging.critical(
                '[RandomTalks.instantiateConsumer] Host is nil! host=%s' %
                str(pHost))
Ejemplo n.º 2
0
def run():
    Minindn.cleanUp()
    Minindn.verifyDependencies()
    topo = Topo()
    # Setup topo
    info("Setup\n")
    a = topo.addHost('a')
    b = topo.addHost('b')
    c = topo.addHost('c')
    topo.addLink(a, b, delay='10ms', bw=10)
    topo.addLink(b, c, delay='10ms', bw=10)
    ndn = Minindn(topo=topo)
    ndn.start()
    info("Configuring NFD\n")
    nfds = AppManager(ndn, ndn.net.hosts, Nfd, logLevel="DEBUG")
    #nlsr = AppManager(ndn, ndn.net.hosts, Nlsr, logLevel="DEBUG")
    # This is a fancy way of setting up the routes without violating DRY;
    # the important bit to note is the Nfdc command
    links = {"a": ["b"], "b": ["c"]}
    for first in links:
        for second in links[first]:
            host1 = ndn.net[first]
            host2 = ndn.net[second]
            interface = host2.connectionsTo(host1)[0][0]
            #info(interface)
            interface_ip = interface.IP()
            Nfdc.createFace(host1, interface_ip)
            Nfdc.registerRoute(host1, PREFIX, interface_ip, cost=0)
    info("Starting pings...\n")
    pingserver_log = open("/tmp/minindn/c/ndnpingserver.log", "w")
    pingserver = getPopen(ndn.net["c"],
                          "ndnpingserver {}".format(PREFIX),
                          stdout=pingserver_log,
                          stderr=pingserver_log)
    ping1 = getPopen(ndn.net["a"],
                     "ndnping {} -c 5".format(PREFIX),
                     stdout=PIPE,
                     stderr=PIPE)
    ping1.wait()
    info(ping1.stdout.read())
    interface = ndn.net["b"].connectionsTo(ndn.net["a"])[0][0]
    info("Failing link\n")
    interface.config(delay="10ms", bw=10, loss=100)
    ping2 = getPopen(ndn.net["a"],
                     "ndnping {} -c 5".format(PREFIX),
                     stdout=PIPE,
                     stderr=PIPE)
    ping2.wait()
    info(ping2.stdout.read())
    interface.config(delay="10ms", bw=10, loss=0)
    MiniNDNCLI(ndn.net)
    info("Finished!\n")
    ndn.stop()
 def start(self, command, logfile, envDict=None):
     if self.process is None:
         self.logfile = open('{}/{}'.format(self.logDir, logfile), 'w')
         self.process = getPopen(self.node,
                                 command.split(),
                                 envDict,
                                 stdout=self.logfile,
                                 stderr=self.logfile)
Ejemplo n.º 4
0
    def instantiateProducer(self, pHost, pDataPackage):
        """
      Issues MiniNDN commands to instantiate a producer
      """
        global g_bIsMockExperiment
        if (pHost):

            nTTL = self.pDataManager.getTTLForDataType(pDataPackage.nType)
            strFilter = RandomTalks.getChunksFilter(pDataPackage.strOrig,
                                                    pDataPackage.nType,
                                                    pDataPackage.nID)
            strFilePath = DataManager.nameForPayloadFile(
                pDataPackage.nPayloadSize, self.strPayloadPath)
            strCmd = 'ndnputchunks %s -f %d < %s' % (strFilter, nTTL,
                                                     strFilePath)
            if (not g_bIsMockExperiment):
                getPopen(pHost, strCmd, shell=True)

            self.lstRunningPutChunks.append(strFilter)
            logging.info('[RandomTalks.instantiateProducer] ProducerCmd: ' +
                         strCmd)
        else:
            logging.critical(
                '[RandomTalks.instantiateProducer] Producer is nil!')
Ejemplo n.º 5
0
def runExperiment():
    setLogLevel('info')

    info("Starting network")
    ndnwifi = MinindnWifi()
    a = ndnwifi.net["sta1"]
    b = ndnwifi.net["sta2"]
    # Test for model-based mobility
    if ndnwifi.args.modelMob:
        ndnwifi.startMobilityModel(model='GaussMarkov')
    #Test for replay based mobility
    if ndnwifi.args.mobility:
        info("Running with mobility...")

        p1, p2, p3, p4 = dict(), dict(), dict(), dict()
        p1 = {'position': '40.0,30.0,0.0'}
        p2 = {'position': '40.0,40.0,0.0'}
        p3 = {'position': '31.0,10.0,0.0'}
        p4 = {'position': '200.0,200.0,0.0'}

        ndnwifi.net.mobility(a, 'start', time=1, **p1)
        ndnwifi.net.mobility(b, 'start', time=2, **p2)
        ndnwifi.net.mobility(a, 'stop', time=12, **p3)
        ndnwifi.net.mobility(b, 'stop', time=22, **p4)
        ndnwifi.net.stopMobility(time=23)
        ndnwifi.startMobility(time=0, mob_rep=1, reverse=False)

    ndnwifi.start()
    info("Starting NFD")
    sleep(2)
    nfds = AppManager(ndnwifi, ndnwifi.net.stations, Nfd)

    info("Starting pingserver...")
    ping_server_proc = getPopen(b, "ndnpingserver /example")
    Nfdc.createFace(a, b.IP())
    Nfdc.registerRoute(a, "/example", b.IP())

    info("Starting ping...")
    NDNPingClient.ping(a, "/example", 10)

    # Start the CLI
    MiniNDNWifiCLI(ndnwifi.net)
    ndnwifi.net.stop()
    ndnwifi.cleanUp()
Ejemplo n.º 6
0
def runExperiment():
    setLogLevel('info')

    info("Starting network")
    ndnwifi = MinindnWifi(
        controller=lambda name: RemoteController(
            name, ip='127.0.0.1', port=6633),
        topoFile='/home/vagrant/icnsimulations/topologies/topo-tiny.conf')

    ndnwifi.start()
    sleep(2)

    nApId = 1
    for pAp in ndnwifi.net.aps:
        strApId = '1000000000' + str(nApId).zfill(6)
        subprocess.call(
            ['ovs-vsctl', 'set-controller',
             str(pAp), 'tcp:127.0.0.1:6633'])
        subprocess.call([
            'ovs-vsctl', 'set', 'bridge',
            str(pAp), 'other-config:datapath-id=' + strApId
        ])
        nApId += 1

    # Set IPs for access points
    nNextIP = 4
    lstIntfSet = []
    for pAp in ndnwifi.net.aps:
        lstIntf = pAp.intfList()
        for pIntf in lstIntf:
            strIntf = pIntf.name
            if (strIntf != 'lo') and (strIntf not in lstIntfSet):
                strIP = '10.0.0.' + str(nNextIP) + '/24'
                info('AP=%s; Intf=%s; IP=%s\n' % (str(pAp), strIntf, strIP))
                pAp.setIP(strIP, intf=pIntf)
                nNextIP += 1
                lstIntfSet.append(strIntf)

    # Set IPs for hosts
    for pStation in ndnwifi.net.stations:
        lstIntf = pStation.intfList()
        for pIntf in lstIntf:
            strIntf = pIntf.name
            if (strIntf != 'lo') and (strIntf not in lstIntfSet):
                strIP = '10.0.0.' + str(nNextIP) + '/24'
                info('STATION=%s; Intf=%s; IP=%s\n' %
                     (str(pStation), strIntf, strIP))
                pStation.setIP(strIP, intf=pIntf)
                nNextIP += 1
                lstIntfSet.append(strIntf)

    info("Starting NFD\n")
    nfds = AppManager(ndnwifi, ndnwifi.net.stations + ndnwifi.net.aps, Nfd)
    # nlsrs = AppManager(ndnwifi, ndnwifi.net.aps, Nlsr)

    # Create faces linking every node and instantiate producers
    info("Creating faces and instantiating producers...\n")
    hshProducers = {}
    for pHostOrig in ndnwifi.net.stations + ndnwifi.net.aps:
        for pHostDest in ndnwifi.net.stations + ndnwifi.net.aps:
            if (pHostDest != pHostOrig):
                info('Register, pHostOrig=%s; pHostDest=%s\n' %
                     (str(pHostOrig), str(pHostDest)))
                Nfdc.createFace(pHostOrig, pHostDest.IP())
                Nfdc.registerRoute(pHostOrig, interestFilterForHost(pHostDest),
                                   pHostDest.IP())

        getPopen(pHostOrig, 'producer %s &' % interestFilterForHost(pHostOrig))

    # cons = ndnwifi.net.stations['h0']
    # getPopen(cons, 'consumer-with-timer h0')

    # Start the CLI
    if (c_bShowCli):
        MiniNDNWifiCLI(ndnwifi.net)

    ndnwifi.net.stop()
    ndnwifi.cleanUp()
Ejemplo n.º 7
0
def runExperiment():
    setLogLevel('info')

    dtBegin = datetime.now()
    info("Starting network")
    ndn = Minindn(
        topoFile='/home/vagrant/icnsimulations/topologies/wired-topo4.conf')
    # ndn = Minindn(topoFile='/home/vagrant/icnsimulations/topologies/wired-switch.conf', controller=lambda name: RemoteController(name, ip='127.0.0.1', port=6633))

    ndn.start()

    # Properly connect switches to the SDN controller
    # nApId = 1
    # for pSwitch in ndn.net.switches:
    #     info('Setting up switch=%s\n3 vsctl', 'set-controller', str(pSwitch), 'tcp:127.0.0.1:6633'])
    #     subprocess.call(['ovs-vsctl', 'set', 'bridge', str(pSwitch), 'other-config:datapath-id='+strApId])
    #     nApId += 1

    # Properly set IPs for all interfaces
    # nNextIP = 10
    # lstIntfSet = []
    # for pNode in ndn.net.switches + ndn.net.hosts:
    #     lstIntf = pNode.intfList()
    #     for pIntf in lstIntf:
    #         strIntf = pIntf.name
    #         if (strIntf != 'lo') and (strIntf not in lstIntfSet):
    #             strIP = '10.0.0.' + str(nNextIP) + '/24'
    #             info('Node=%s; Interface=%s; IP=%s\n' % (str(pNode), strIntf, strIP))
    #             pNode.setIP(strIP, intf=pIntf)
    #             nNextIP += 1
    #             lstIntfSet.append(strIntf)
    '''
    Node=sw1; Interface=sw1-eth1; IP=10.0.0.10/24
    Node=sw1; Interface=sw1-eth2; IP=10.0.0.11/24
    Node=sw2; Interface=sw2-eth1; IP=10.0.0.12/24
    Node=sw2; Interface=sw2-eth2; IP=10.0.0.13/24
    Node=d0; Interface=d0-eth0; IP=10.0.0.14/24
    Node=d0; Interface=d0-eth1; IP=10.0.0.15/24
    Node=h0; Interface=h0-eth0; IP=10.0.0.16/24
    Node=v0; Interface=v0-eth0; IP=10.0.0.17/24
    '''

    info("Starting NFD and NLSR\n")
    sleep(2)

    nfds = AppManager(ndn, ndn.net.hosts, Nfd, logLevel=c_strNFDLogLevel)
    nlsrs = AppManager(ndn, ndn.net.hosts, Nlsr, logLevel=c_strNLSRLogLevel)

    # Create faces linking every node and instantiate producers
    info("Creating faces and instantiating producers...\n")
    hshProducers = {}
    nHostsSet = 1
    for pHostOrig in ndn.net.hosts:
        info('Register, pHostOrig=%s %d/%d\n' %
             (str(pHostOrig), nHostsSet, len(ndn.net.hosts)))
        for pHostDest in ndn.net.hosts:
            if (pHostDest != pHostOrig):
                Nfdc.createFace(pHostOrig, pHostDest.IP())
                Nfdc.registerRoute(pHostOrig, interestFilterForHost(pHostDest),
                                   pHostDest.IP())

        getPopen(pHostOrig, 'producer %s &' % interestFilterForHost(pHostOrig))
        nHostsSet += 1

    # nPeriodMs = 700
    # nMaxPackets = 1000
    # for pHost in ndn.net.hosts:
    #     getPopen(pHost, 'consumer-with-timer %s %d %d' % (str(pHost), nPeriodMs, nMaxPackets

    for pHost in ndn.net.hosts:
        strCmd1 = 'export HOME=/tmp/minindn/%s; ' % str(pHost)
        strCmd2 = 'consumer-with-queue %s /home/vagrant/icnsimulations/topologies/queue_wired-topo4.txt &' % (
            str(pHost))
        strCmd = strCmd1 + strCmd2
        info('cmd: %s\n' % strCmd)
        # pHost.cmd(strCmd)
        getPopen(
            pHost,
            'consumer-with-queue %s /home/vagrant/icnsimulations/topologies/queue_wired-topo4.txt &'
            % (str(pHost)))

    dtDelta = datetime.now() - dtBegin
    info('Done setting up, took %.2f seconds\n' % dtDelta.total_seconds())

    # Start the CLI
    if (c_bShowCli):
        MiniNDNCLI(ndn.net)

    ndn.net.stop()
    ndn.cleanUp()