def setupPing(hosts, strategy):
     for host in hosts:
         host.cmd('mkdir -p ping-data')
         Nfdc.setStrategy(host, '/ndn/', strategy)
         prefix = getSafeName('/ndn/{}-site/{}'.format(
             host.name, host.name))
         NDNPing.startPingServer(host, prefix)
Esempio n. 2
0
    def configureUsers(self):
        for user in self.users:
            host = self.users[user]['host']
            userName = host.name
            userPrefix = self.users[user]['userPrefix']
            serviceGroup = '/discovery/{}'.format(self.users[user]['service'])
            print("Starting user node:{}".format(userPrefix))

            cmd = 'export NDN_LOG=ndnsd.*=TRACE'  #:psync.*=TRACE'
            host.cmd(cmd)

            host.cmd('nlsrc advertise {}'.format(userPrefix))
            host.cmd('nlsrc advertise {}'.format(serviceGroup))

            Nfdc.setStrategy(host, serviceGroup, Nfdc.STRATEGY_MULTICAST)
            self.users[user]["logFile"] = '{}/{}/{}.log'.format(
                self.args.workDir, userName, 'ndnsd')

            # Consumer discovers repo and prefixes repo serves using ndnsd
            cmd = 'ndnsd-consumer -s {} -c 1 -p 1 &> {} &'.format(
                "repo", self.users[user]['logFile'])
            host.cmd(cmd)
            time.sleep(3)
Esempio n. 3
0
    def configureSensor(self):
        for sensor in self.sensors:
            host = self.sensors[sensor]['host']
            sensorName = host.name
            sensorPrefix = self.sensors[sensor]['sensorPrefix']
            serviceGroup = '/discovery/{}'.format(
                self.sensors[sensor]['service'])
            print("starting sensor {}".format(sensorName))

            cmd = 'export NDN_LOG=ndnsd.*=TRACE'  #:psync.*=TRACE'
            host.cmd(cmd)

            host.cmd('nlsrc advertise {}'.format(sensorPrefix))
            host.cmd('nlsrc advertise {}'.format(serviceGroup))

            Nfdc.setStrategy(host, serviceGroup, Nfdc.STRATEGY_MULTICAST)
            self.sensors[sensor]["logFile"] = '{}/{}/{}.log'.format(
                self.args.workDir, sensorName, 'ndnsd')

            # Sensor discovers repo using ndnsd
            cmd = 'ndnsd-consumer -s {} -c 1 -p 1 &> {} &'.format(
                "repo", self.sensors[sensor]['logFile'])
            host.cmd(cmd)
            time.sleep(3)
Esempio n. 4
0
    def configureRepo(self):
        # Configure repo for service-group: "/discovery/repo/"
        for repo in self.repos:  #repo is a dictionary
            host = self.repos[repo]['host']
            repoName = host.name
            hostInfoFile = '{}/{}/ndnsd_{}.info'.format(
                self.args.workDir, repoName, repoName)
            repoAppPrefix = self.repos[repo]['repoPrefix']
            servedPrefix = self.repos[repo]['servedPrefixes']
            Popen(
                ['cp', '/usr/local/etc/ndn/ndnsd_default.info', hostInfoFile],
                stdout=PIPE,
                stderr=PIPE).communicate()

            editNdnsdConf(host, hostInfoFile, 'required.serviceName', "repo")
            editNdnsdConf(host, hostInfoFile, 'required.appPrefix',
                          repoAppPrefix)
            editNdnsdConf(host, hostInfoFile, 'details.appPrefix',
                          repoAppPrefix)
            # send the list of servedPrefix, and editNdnsdConf will handle the rest
            editNdnsdConf(host, hostInfoFile, 'details.servedPrefix',
                          servedPrefix, True)

            host.cmd('nlsrc advertise {}'.format(self.repo_group))
            host.cmd('nlsrc advertise {}'.format(repoAppPrefix))
            # host.cmd('nlsrc advertise {}/insert'.format(repoAppPrefix))
            # host.cmd('nlsrc advertise {}/delete'.format(repoAppPrefix))
            Nfdc.setStrategy(host, self.repo_group, Nfdc.STRATEGY_MULTICAST)

            cmd = 'export NDN_LOG=ndnsd.*=TRACE'
            host.cmd(cmd)
            cmd = 'ndnsd-producer {} 1 &> ndnsd.log &'.format(hostInfoFile)
            host.cmd(cmd)
            time.sleep(3)
            # start repo on the repo node
            self.repo_obj.startRepo(host, repoAppPrefix)
Esempio n. 5
0
 def setupPing(hosts, strategy):
     for host in hosts:
         host.cmd('mkdir -p ping-data')
         Nfdc.setStrategy(host, '/ndn/', strategy)
         host.cmd('ndnpingserver /ndn/{}-site/{} > ping-server &'.format(
             host.name, host.name))
    grh = NdnRoutingHelper(ndn.net)
    for host in exp.producer_nodes:
        hostName = host.name
        appPrefix = '/ndnsd/{}/service-info'.format(hostName)
        discoveryPrefix = '/discovery/{}'.format(exp.producers[hostName][0])
        print("Add routes for: ", hostName, appPrefix, discoveryPrefix)
        grh.addOrigin([host], [appPrefix, discoveryPrefix])
    grh.calculateNPossibleRoutes()
    # ----------------------------- adding static routes using ndn routing helper END-----------------------

    exp.startProducer()
    exp.startConsumer()
    time.sleep(10)
    # set /discovery/printers to multicast on all the nodes.
    for host in ndn.net.hosts:
        Nfdc.setStrategy(host, '/discovery/printer', Nfdc.STRATEGY_MULTICAST)
        time.sleep(1)

    #setTsharkLog(ndn)
    #time.sleep(1)

    # need to run reload at producers node
    print(
        "Staring experiment, i.e. reloading producers, approximate time to complete: {} seconds"
        .format(2 * (numberOfUpdates + jitter)))
    for host in exp.producer_nodes:
        appPrefix = '/ndnsd/{}/service-info'.format(host.name)
        cmd = 'ndnsd-reload -c {} -i {} -r {} -p {} &> {}/{}/reload.log &'.format(
            numberOfUpdates, exp.producers[host.name][1] - 10, 50, appPrefix,
            ndn.args.workDir, host.name)
        host.cmd(cmd)
Esempio n. 7
0
if __name__ == '__main__':
    setLogLevel('info')

    ndn = Minindn()
    args = ndn.args

    ndn.start()

    nfds = AppManager(ndn, ndn.net.hosts, Nfd)

    syncPrefix = "/sync"
    numUserPrefixesPerNode = 2
    maxUpdatesPerUserPrefixPerNode = 3

    for host in ndn.net.hosts:
        Nfdc.setStrategy(host, syncPrefix, Nfdc.STRATEGY_MULTICAST)
        registerRouteToAllNeighbors(ndn, host, syncPrefix)

    info('Starting psync-full-sync on all the nodes\n')
    for host in ndn.net.hosts:
        host.cmd('export NDN_LOG=examples.FullSyncApp=INFO')
        host.cmd('psync-full-sync {} {} {} {} &> psync.logs &'.format(
            syncPrefix, host.name, numUserPrefixesPerNode,
            maxUpdatesPerUserPrefixPerNode))

    info('Sleeping 5 minutes for convergence\n')
    # Estimated time for 4 node default topology
    time.sleep(300)

    totalUpdates = int(
        host.cmd('grep -r Update {}/*/psync.logs | wc -l'.format(
Esempio n. 8
0
            elif protocol == 'P2P':
                nameComponents = server[5].split("/")
                names = [
                    '/'.join(nameComponents[:i])
                    for i in range(3,
                                   len(nameComponents) + 1)
                ]
                grh.addOrigin([server[0]], names)

        grh.calculateNPossibleRoutes(nFaces=1)

        if protocol == 'StateVector':
            # State vector requires multicast as FW Strategy
            # nfdc strategy set / /localhost/nfd/strategy/multicast/%FD%03
            for host in ndn.net.hosts:
                Nfdc.setStrategy(host, "/", Nfdc.STRATEGY_MULTICAST)

    ################### IP Routing ###################
    if is_ip_eval:
        info("Adding IP routes")
        IPRoutingHelper.calcAllRoutes(ndn.net)

    ################### Start game servers ###################
    # Start all game server apps
    for server in servers:
        if protocol == "QuadTree":
            AppManager(ndn, [server[0]],
                       QuadTreeGameServer,
                       responsibility=server[6],
                       logFolder=logDir,
                       prefix=prefix,