Пример #1
0
def printExperimentNames(option, opt, value, parser):
    experimentNames = ExperimentManager.getExperimentNames()

    print "Mini-NDN experiments:"
    for experiment in experimentNames:
        print "  %s" % experiment

    sys.exit()
Пример #2
0
def parse_args():
    """

    :rtype : object
    """
    usage = """Usage: minindn [template_file] [ -t | --testbed ]
    If no template_file is given, ndn_utils/default-topology.conf (given sample file)
    will be used.
    If --testbed is used, minindn will run the NDN Project Testbed.
    """

    parser = optparse.OptionParser(usage)

    parser.add_option("--ctime", action="store", dest="ctime", type="int", default=60,
    help="Specify convergence time for the topology (Default: 60 seconds)")

    parser.add_option("--experiment", action="store", dest="experiment",
    help="Runs the specified experiment")

    parser.add_option("--faces", action="store", dest="faces", type="int", default=3,
    help="Specify number of faces 0-60")

    parser.add_option("--hr", action="store_true", dest="hr", default=False,
    help="--hr is used to turn on hyperbolic routing")

    parser.add_option("--list-experiments", action="callback", callback=printExperimentNames,
    help="Lists the names of all available experiments")

    parser.add_option("--no-cli", action="store_false", dest="isCliEnabled", default=True,
    help="Run experiments and exit without showing the command line interface")

    parser.add_option("--nPings", action="store", dest="nPings", type="int", default=300,
    help="Number of pings to perform between each node in the experiment")

    parser.add_option("-t", "--testbed", action="store_true", dest="testbed", default=False,
    help="instantiates NDN Testbed")

    parser.add_option("--work-dir", action="store", dest="workDir", default="/tmp",
    help="Specify the working directory; default is /tmp")

    parser.add_option('--version', '-V', action='callback', callback=printVersion,
    help='Displays version information')

    (args, arg) = parser.parse_args()

    options = ProgramOptions()
    options.ctime = args.ctime
    options.experimentName = args.experiment
    options.nFaces = args.faces
    options.hr = args.hr
    options.isCliEnabled = args.isCliEnabled
    options.nPings = args.nPings
    options.testbed = args.testbed
    options.workDir = args.workDir

    if options.experimentName is not None and options.experimentName not in ExperimentManager.getExperimentNames():
        print("No experiment named %s" % options.experimentName)
        sys.exit()

    if len(arg) == 0 or len(arg) > 2:
        options.templateFile = ''
    else:
        options.templateFile = arg[0]

    return options