Example #1
0
def run(args):
    topo = GridTopo(args.rows, args.cols)
    net = Mininet(topo, host=NdnHost, link=TCLink, controller=None)
    topo.assignIps(net)
    net.start()

    ndndumps = []
    if not args.no_ndndump:
        print 'Start ndndump tracers.'
        ndndumps = [ NdnDump(link) for link in net.links ]
        for ndndump in ndndumps:
            ndndump.start()

    print 'Start forwarding.'
    fws = [ host.getFw() for host in net.hosts ]
    for fw in fws:
        fw.start()
    time.sleep(5)

    print 'Start routing.'
    routs = [ host.getRout() for host in net.hosts ]
    for rout in routs:
        rout.advertise('/%s' % rout.host.name)
        rout.start()

    convergeTime = Routing.waitForConverge(net)
    if convergeTime is False:
        print 'Routing is not converged.'
        net.stop()
        exit(1)
    print 'Routing is converged in %d seconds at %d.' % (convergeTime, time.time())

    pingServers = []
    pingClients = []
    if not args.no_ping:
        print 'Start ping servers and clients.'
        for host in net.hosts:
            pingServer = NdnPingServer(host, '/%s' % host.name)
            pingServer.start()
            pingServers.append(pingServer)
            for otherHost in net.hosts:
                pingClient = NdnPing(host, '/%s' % otherHost.name)
                pingClient.start('/var/log/ndn/ndnping_%s.log' % otherHost.name)
                pingClients.append(pingClient)

    sched = scheduler(time.time, time.sleep)
    schedLinkFails(sched, net, args.linkFails)
    sched.enter(args.duration, 0, lambda:0, ())
    sched.run()

    if not args.no_ping:
        print 'Stop ping clients.'
        for pingClient in pingClients:
            pingClient.stop()
        time.sleep(1)

    net.stop()