Example #1
0
File: PS8.py Project: cookt/mit
        return PS8_ls.LSRouter(loc, address=address)

if __name__ == '__main__':

    parser = argparse.ArgumentParser()
    parser.add_argument("-n", "--numnodes", type=int, default=12, help="number of nodes")
    parser.add_argument("-t", "--simtime", type=int, default=2000, help="simulation time")
    parser.add_argument("-r", "--rand", action="store_true", default=False, help="use randomly generated topology")
    parser.add_argument("-p", "--protocol", type=str, default="dv", choices=["dv", "ls"], help="routing protocol (dv or ls)")
    parser.add_argument("-s", "--tests", action="store_true", default=False, help="run tests")

    args = parser.parse_args()

    if args.tests:
        if args.protocol == "dv":
            PS8_tests.verify_routes(DVRouterNetwork)
        elif args.protocol == "ls":
            PS8_tests.verify_routes(LSRouterNetwork)

    else:
        if args.rand == True:
            print "Generating random graph"
            rg = RandomGraph(args.numnodes)
            (NODES, LINKS) = rg.genGraph()
        else:
            print "Using default graph"
            NODES =(('A',0,0), ('B',1,0), ('C',2,0), ('D',3,0),
                    ('E',0,1), ('F',1,1), ('G',2,1), ('H',3,1))
            LINKS = (('A','B'),('A','E'),('B','F'),
                     ('C','D'),('C','F'),('C','G'),
                     ('D','G'),('D','H'),('F','G'),('G','H'))
Example #2
0
    #                      default=0.0, help="link packet loss probability")

    (opt, args) = parser.parse_args()

    if opt.rand == True:
        rg = RandomGraph(opt.numnodes)
        (NODES, LINKS) = rg.genGraph()
    else:
        # build the deterministic test network
        #   A---B   C---D
        #   |   | / | / |
        #   E   F---G---H
        # format: (name of node, x coord, y coord)

        NODES = (('A', 0, 0), ('B', 1, 0), ('C', 2, 0), ('D', 3, 0),
                 ('E', 0, 1), ('F', 1, 1), ('G', 2, 1), ('H', 3, 1))

        # format: (link start, link end)
        LINKS = (('A', 'B'), ('A', 'E'), ('B', 'F'), ('E', 'F'), ('C', 'D'),
                 ('C', 'F'), ('C', 'G'), ('D', 'G'), ('D', 'H'), ('F', 'G'),
                 ('G', 'H'))

    # setup graphical simulation interface
    if opt.gui == True:
        net = LSRouterNetwork(opt.simtime, NODES, LINKS, 0)
        sim = NetSim()
        sim.SetNetwork(net)
        sim.MainLoop()
    else:
        PS8_tests.verify_routes(LSRouterNetwork)
Example #3
0
                        default=False,
                        help="use randomly generated topology")
    parser.add_argument("-p",
                        "--protocol",
                        type=str,
                        default="dv",
                        choices=["dv", "ls"],
                        help="routing protocol (dv or ls)")
    parser.add_argument("-s",
                        "--tests",
                        action="store_true",
                        default=False,
                        help="run tests")
    parser.add_argument("-v",
                        "--verbose",
                        action="store_true",
                        default=False,
                        help="verbose output")

    args = parser.parse_args()

    if args.tests:
        if args.protocol == "dv":
            PS8_tests.verify_routes(DVRouterNetwork, args.verbose)
        elif args.protocol == "ls":
            PS8_tests.verify_routes(LSRouterNetwork, args.verbose)
    else:
        print(
            "Without wx, GUI testing is unavailable.  You can use the staff tests (with the -s option) or write your own in PS8.py."
        )