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 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 runExperiment():
    setLogLevel('info')

    info("Starting network")
    topo = Topo()
    sta1 = topo.addStation("sta1", range=150, speed=5)
    sta2 = topo.addStation("sta2", range=200)
    ap1 = topo.addAccessPoint("ap1", position="150,150,0", range=150)
    topo.addLink(sta1, ap1, delay="10ms")
    topo.addLink(sta2, ap1, delay="10ms")
    ndnwifi = MinindnWifi(topo=topo)
    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': '150.0,150.0,0.0'}
        p2 = {'position': '140.0,130.0,0.0'}

        p3 = {'position': '250.0,250.0,0.0'}
        p4 = {'position': '301.0,301.0,0.0'}

        ndnwifi.net.mobility(a, 'start', time=1, **p1)
        ndnwifi.net.mobility(a, 'stop', time=12, **p3)
        ndnwifi.net.mobility(b, 'start', time=2, **p2)
        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...")
    NDNPing.startPingServer(b, "/example")
    Nfdc.createFace(a, b.IP())
    Nfdc.registerRoute(a, "/example", b.IP())

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

    # Start the CLI
    MiniNDNWifiCLI(ndnwifi.net)
    ndnwifi.net.stop()
    ndnwifi.cleanUp()
Esempio n. 4
0
 def routeAdd(self, node, neighborIPs):
     """
     Add route from a node to its neighbors for each prefix/s  advertised by destination node
     :param Node node: source node (Mininet net.host)
     :param IP neighborIPs: IP addresses of neighbors
     """
     neighbors = self.routes[node.name]
     for route in neighbors:
         destination = route[0]
         cost = int(route[1])
         nextHop = route[2]
         defaultPrefix = "/ndn/{}-site/{}".format(destination, destination)
         prefixes = [defaultPrefix] + self.namePrefixes[destination]
         for prefix in prefixes:
             # Register routes to all the available destination name prefix/s
             nfdc.registerRoute(node, prefix, neighborIPs[nextHop], \
                                nfdc.PROTOCOL_UDP, cost=cost)
Esempio 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...")
    NDNPing.startPingServer(b, "/example")
    Nfdc.createFace(a, b.IP())
    Nfdc.registerRoute(a, "/example", b.IP())

    info("Starting ping...")
    NDNPing.ping(a, "/example", nPings=10)

    sleep(10)
    # Start the CLI
    MiniNDNWifiCLI(ndnwifi.net)
    ndnwifi.net.stop()
    ndnwifi.cleanUp()
Esempio n. 6
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. 7
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. 8
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. 9
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()
Esempio n. 10
0
 def createFaces(self):
     for ip in self.neighborIPs:
         Nfdc.createFace(self.node, ip, self.faceType, isPermanent=True)
Esempio n. 11
0
def run():
    PREFIX = "/ndn/test/"
    Minindn.cleanUp()
    Minindn.verifyDependencies()
    topo = Topo()
    # Setup topo
    print("Setup")
    c1 = topo.addHost('c1')
    i1 = topo.addHost('i1')

    i2 = topo.addHost('i2')
    i3 = topo.addHost('i3')
    i4 = topo.addHost('i4')
    i5 = topo.addHost('i5')

    i6 = topo.addHost('i6')
    p1 = topo.addHost('p1')

    topo.addLink(c1, i1, bw=10)

    topo.addLink(i1, i2, bw=4, delay='40ms')
    topo.addLink(i1, i3, bw=4, delay='10ms')
    topo.addLink(i1, i4, bw=4, delay='40ms')
    topo.addLink(i1, i5, bw=4, delay='40ms')

    topo.addLink(i2, i6, bw=7, delay='7ms')
    topo.addLink(i3, i6, bw=7, delay='7ms')
    topo.addLink(i4, i6, bw=7, delay='7ms')
    topo.addLink(i5, i6, bw=7, delay='7ms')

    topo.addLink(i6, p1, bw=10)
    ndn = Minindn(topo=topo)
    ndn.start()
    nfds = AppManager(ndn, ndn.net.hosts, Nfd)
    # Setup routes to C2
    # This is not functional but I'm saving this as an example for the future :)
    # for host1 in ndn.net.hosts:
    #     for host2 in ndn.net.hosts:
    #         if 'p' in host1.name and not 'p' in host2.name:
    #             return
    #         elif 'i' in host1.name and 'c' in host2.name:
    #             return
    #         else:
    #             interface = host2.connectionsTo(host1)[0]
    #             interface_ip = interface.IP()
    #             Nfdc.registerRoute(host1, PREFIX, interface_ip)
    links = {"c1": ["i1", "i2"], "i1": ["p1"], "i2": ["p2"]}
    for first in links:
        for second in links[first]:
            host1 = ndn.net[first]
            host2 = ndn.net[second]
            interface = host2.connectionsTo(host1)[0]
            interface_ip = interface.IP()
            Nfdc.registerRoute(host1, PREFIX, interface_ip)
    interface = host2.connectionsTo(host1)[0]
    interface_ip = interface.IP()
    Nfdc.registerRoute(host1, PREFIX, interface_ip)

    # Run small thing before to ensure info caching, large afterwards?
    # print("Setup round")
    # getPopen(ndn.net["c1"], "ndn-traffic-client -c 5 cons_conf")
    # getPopen(ndn.net["p1"], "ndn-traffic-server -c 5 prod_conf")
    # # TODO: Traffic generator!
    # sleep(5)  # ?
    # nfds["i3"].stop()
    # tempshark = Tshark(ndn["c1"])
    # tempshark.start()

    # print("Round 1")
    # time1 = time()
    # getPopen(ndn.net["c1"], "ndn-traffic-client -c 20 cons_conf")
    # getPopen(ndn.net["p1"], "ndn-traffic-server -c 20 prod_conf")
    # # Wait on processes to close, end
    # time2 = time()
    # print("Time elapsed: {} s".format(time2 - time1))
    MiniNDNCLI(ndn.net)
Esempio n. 12
0
    setLogLevel('info')
    ndn = MinindnWifi()
    producers = dict()
    consumers = dict()
    producers = neb.generateNodes('P', 2)
    consumers = neb.generateNodes('C', 3)
    print(consumers, producers)
    exp = neb.NDNSDExperiment(ndn, producers, consumers, 'wifi')
    sleep(2)
    exp.startProducer()
    exp.startConsumer()

    # neb.registerRouteToAllNeighbors(ndn, hosts, '/discovery/printer')
    # set sync prefix, /discovery/printers, to multicast on all the stations.
    for node in ndn.net.stations:
        Nfdc.registerRoute(node, '/discovery/printer', '224.0.23.170')
        Nfdc.registerRoute(node, '/ndnsd', '224.0.23.170')
        Nfdc.setStrategy(node, '/discovery/printer', Nfdc.STRATEGY_MULTICAST)
        sleep(1)

    # sleep -- time for sync convergence
    sleep(10)

    # need to run reload at producers node
    print(
        "Staring experiment, i.e. reloading producers, approximate time to complete: {} seconds"
        .format(numberOfUpdates))
    for host in exp.producerNodes:
        cmd = 'ndnsd-reload -c {} -i {} -r {} &> {}/{}/reload.log &'.format(
            numberOfUpdates, exp.producers[host.name][1] - 10, 100,
            ndn.args.workDir, host.name)
def registerRouteToAllNeighbors(ndn, host, syncPrefix):
    for node in ndn.net.hosts:
        for neighbor in node.connectionsTo(host):
            ip = node.IP(neighbor[0])
            Nfdc.createFace(host, ip)
            Nfdc.registerRoute(host, syncPrefix, ip)
Esempio n. 14
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,
Esempio n. 15
0
def runExperiment(strTopoPath, lstDataQueue, bWifi=True):
    """
   Runs the experiment using regular MiniNDN
   """
    global g_bShowMiniNDNCli, g_bSDNEnabled
    logging.info('[runExperiment] Running MiniNDN experiment')

    if (bWifi):
        MiniNDNClass = MinindnWifi
    else:
        MiniNDNClass = Minindn

    Minindn.cleanUp()
    Minindn.verifyDependencies()

    ######################################################
    # Start MiniNDN and set controller, if any
    if (g_bSDNEnabled):
        ndn = MiniNDNClass(topoFile=strTopoPath, controller=RemoteController)
    else:
        ndn = MiniNDNClass(topoFile=strTopoPath)

    ndn.start()

    # Wifi topology uses stations instead of hosts, the idea is the same
    if (bWifi):
        lstHosts = ndn.net.stations + ndn.net.hosts

        # for pStation in ndn.net.stations:
        #    strIP = pStation.IP() + '/24'
        #    setStationIPs(pStation, strIP)
        #    logging.info('[runExperiment] station=%s, IP=%s' % (str(pStation), strIP))

        if (ndn.net.aps is not None) and (len(ndn.net.aps) > 0):
            # Connect all APs to the remote controller
            # This should be done regardless of SDN, otherwise packets will not be routed
            logging.info('[runExperiment] Setting up access points...')
            nApId = 1
            for pAp in ndn.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

                # TODO: Add priority based rules to APs if g_bSDNEnabled
                # ovs-ofctl add-flow <ap_name> dl_type=0x0800
    else:
        lstHosts = ndn.net.hosts

    #######################################################
    # Initialize NFD and set cache size based on host type
    logging.info('[runExperiment] Starting NFD on nodes')
    lstHumanHosts = []
    lstDroneHosts = []
    lstSensorHosts = []
    lstVehicleHosts = []
    for pHost in lstHosts:
        if (pHost.name[0] == 'h'):
            lstHumanHosts.append(pHost)
        elif (pHost.name[0] == 'd'):
            lstDroneHosts.append(pHost)
        elif (pHost.name[0] == 's'):
            lstSensorHosts.append(pHost)
        elif (pHost.name[0] == 'v'):
            lstVehicleHosts.append(pHost)
        else:
            raise Exception(
                '[runExperiment] Hostname=%s not recognized as human, drone, sensor or vehicle'
                % pHost.name)

    nfdsHuman = AppManager(ndn,
                           lstHumanHosts,
                           Nfd,
                           csSize=c_nHumanCacheSize,
                           logLevel=c_strNFDLogLevel)
    logging.info('[runExperiment] Cache set for humans=%d, size=%d' %
                 (len(lstHumanHosts), c_nHumanCacheSize))
    nfdsDrone = AppManager(ndn,
                           lstDroneHosts,
                           Nfd,
                           csSize=c_nDroneCacheSize,
                           logLevel=c_strNFDLogLevel)
    logging.info('[runExperiment] Cache set for drones=%d, size=%d' %
                 (len(lstDroneHosts), c_nDroneCacheSize))
    nfdsSensor = AppManager(ndn,
                            lstSensorHosts,
                            Nfd,
                            csSize=c_nSensorCacheSize,
                            logLevel=c_strNFDLogLevel)
    logging.info('[runExperiment] Cache set for sensors=%d, size=%d' %
                 (len(lstSensorHosts), c_nSensorCacheSize))
    nfdsVehicle = AppManager(ndn,
                             lstVehicleHosts,
                             Nfd,
                             csSize=c_nVehicleCacheSize,
                             logLevel=c_strNFDLogLevel)
    logging.info('[runExperiment] Cache set for vehicles=%d, size=%d' %
                 (len(lstVehicleHosts), c_nVehicleCacheSize))

    # Advertise faces
    logging.info('[runExperiment] Setting up faces for %d hosts' %
                 len(lstHosts))
    for pHostOrig in lstHosts:
        for pHostDest in lstHosts:
            if (pHostDest != pHostOrig):
                logging.debug(
                    '[runExperiment] Register, pHostOrig=%s; pHostDest=%s' %
                    (str(pHostOrig), str(pHostDest)))
                Nfdc.createFace(pHostOrig, pHostDest.IP())
                Nfdc.registerRoute(
                    pHostOrig, RandomTalks.getFilterByHostname(str(pHostDest)),
                    pHostDest.IP())

    if (not bWifi):
        ##########################################################
        # Initialize NLSR
        logging.info('[runExperiment] Starting NLSR on nodes')
        nlsrs = AppManager(ndn, lstHosts, Nlsr, logLevel=c_strNLSRLogLevel)

        ##########################################################
        # Wait for NLSR initialization, at least 30 seconds to be on the safe side
        logging.info('[runExperiment] NLSR sleep set to %d seconds' %
                     c_nNLSRSleepSec)
        time.sleep(c_nNLSRSleepSec)

    ##########################################################
    # Set up and run experiment
    logging.info('[runExperiment] Begin experiment')
    Experiment = RandomTalks(lstHosts, lstDataQueue)
    try:
        logging.info('[runExperiment] Running pingall ...')
        # ndn.net.pingAll()
        logging.info('[runExperiment] Pingall done')
        Experiment.setup()
        (dtBegin, dtEnd) = Experiment.run()
    except Exception as e:
        logging.error(
            '[runExperiment] An exception was raised during the experiment: %s'
            % str(e))
        raise

    logging.info(
        '[runExperiment] End of experiment, TimeElapsed=%s; KBytesConsumed=%.2f'
        % (str(dtEnd - dtBegin), float(Experiment.nBytesConsumed) / 1024))

    if (g_bShowMiniNDNCli):
        if (bWifi):
            MiniNDNWifiCLI(ndn.net)
        else:
            MiniNDNCLI(ndn.net)
    ndn.stop()
Esempio n. 16
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(
    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. 18
0
 def createFaces(self, node, neighborIPs):
     for ip in neighborIPs.values():
         nfdc.createFace(node, ip, self.faceType)
Esempio n. 19
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))
Esempio n. 20
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()