def mcnFailure(ndn, nfds, nlsrs, args): Experiment.checkConvergence(ndn, ndn.net.hosts, args.ctime, quit=True) if args.nPings != 0: Experiment.setupPing(ndn.net.hosts, 'ifs-rl') pingedDict = Experiment.startPctPings(ndn.net, args.nPings, args.pctTraffic) PING_COLLECTION_TIME_BEFORE_FAILURE = 60 PING_COLLECTION_TIME_AFTER_RECOVERY = 120 time.sleep(PING_COLLECTION_TIME_BEFORE_FAILURE) mcn = max(ndn.net.hosts, key=lambda host: len(host.intfNames())) info('Bringing down node {}\n'.format(mcn.name)) nlsrs[mcn.name].stop() nfds[mcn.name].stop() time.sleep(args.ctime) info('Bringing up node {}\n'.format(mcn.name)) nfds[mcn.name].start() nlsrs[mcn.name].start() # Restart pings if args.nPings != 0: Experiment.setupPing([mcn], 'ifs-rl') for nodeToPing in pingedDict[mcn]: NDNPingClient.ping(mcn, nodeToPing, PING_COLLECTION_TIME_AFTER_RECOVERY) time.sleep(PING_COLLECTION_TIME_AFTER_RECOVERY) Experiment.checkConvergence(ndn, ndn.net.hosts, args.ctime, quit=True)
def multipleFailure(ndn, nfds, nlsrs, args): Experiment.checkConvergence(ndn, ndn.net.hosts, args.ctime, quit=True) Experiment.setupPing(ndn.net.hosts, Nfdc.STRATEGY_BEST_ROUTE) PING_COLLECTION_TIME_BEFORE_FAILURE = 60 FAILURE_INTERVAL = 60 RECOVERY_INTERVAL = 60 # Number of pings required to make it through the full experiment nInitialPings = (PING_COLLECTION_TIME_BEFORE_FAILURE + len(ndn.net.hosts) * (FAILURE_INTERVAL + RECOVERY_INTERVAL)) print('Scheduling with {} initial pings'.format(nInitialPings)) pingedDict = Experiment.startPctPings(ndn.net, nInitialPings, args.pctTraffic) time.sleep(PING_COLLECTION_TIME_BEFORE_FAILURE) nNodesRemainingToFail = len(ndn.net.hosts) for host in ndn.net.hosts: # Fail the node info('Bringing down node {}\n'.format(host.name)) nlsrs[host.name].stop() nfds[host.name].stop() # Stay in failure state for FAILURE_INTERVAL seconds time.sleep(FAILURE_INTERVAL) # Bring the node back up start_time = time.time() info('Bringing up node {}\n'.format(host.name)) nfds[host.name].start() nlsrs[host.name].start() Experiment.setupPing([host], Nfdc.STRATEGY_BEST_ROUTE) recovery_time = int(time.time() - start_time) # Number of pings required to reach the end of the test nNodesRemainingToFail -= 1 nPings = ((RECOVERY_INTERVAL - recovery_time) + nNodesRemainingToFail * (FAILURE_INTERVAL + RECOVERY_INTERVAL)) info('Scheduling with {} remaining pings\n'.format(nPings)) # Restart pings for nodeToPing in pingedDict[host]: NDNPing.ping(host, nodeToPing, nPings=nPings) time.sleep(RECOVERY_INTERVAL - recovery_time) Experiment.checkConvergence(ndn, ndn.net.hosts, args.ctime, quit=True)
ndn = Minindn(parser=getParser()) args = ndn.args ndn.start() nfds = AppManager(ndn, ndn.net.hosts, Nfd) nlsrs = AppManager(ndn, ndn.net.hosts, Nlsr, sync=args.sync, security=args.security, faceType=args.faceType, nFaces=args.faces, routingType=args.routingType) Experiment.checkConvergence(ndn, ndn.net.hosts, args.ctime, quit=True) firstNode = ndn.net.hosts[0] if args.security: firstNode.cmd('ndnsec-set-default /ndn/{}-site/%C1.Operator/op'.format( firstNode.name)) info('Testing advertise\n') firstNode.cmd('nlsrc advertise /testPrefix') time.sleep(30) for host in ndn.net.hosts: if host.name != firstNode.name: if (int(host.cmd('nfdc fib | grep testPrefix | wc -l')) != 1 or int(host.cmd('nlsrc status | grep testPrefix | wc -l'))