Ejemplo n.º 1
0
def main(args):
    if not args.onos_ip:
        controller = ONOSCluster('c0', 3)
        onosIp = controller.nodes()[0].IP()
    else:
        controller = RemoteController('c0', ip=args.onos_ip)
        onosIp = args.onos_ip

    topo = ClosTopo(args)

    net = Mininet(topo=topo, build=False, controller=[controller])

    net.build()
    collectorIntf = Intf('veth_1', node=net.nameToNode["s12"])
    net.start()

    print "Network started"

    # Always generate background pings.
    sleep(3)
    for (h1, h2) in combinations(net.hosts, 2):
        h1.startPingBg(h2)
        h2.startPingBg(h1)

    print "Background ping started"

    # Increase the MTU size for INT operation
    if args.pipeconf_id.endswith("int") or args.pipeconf_id.endswith("full"):
        setMTU(net, JUMBO_MTU)

    for h in net.hosts:
        h.startIperfServer()

    print "Iperf servers started"

    if args.bg_traffic:
        sleep(4)
        print "Starting iperf clients..."
        net.hosts[0].startIperfClient(net.hosts[-1],
                                      flowBw="400k",
                                      numFlows=50,
                                      duration=10)

    generateNetcfg(onosIp, net, args)

    if args.netcfg_sleep > 0:
        print "Waiting %d seconds before pushing config to ONOS..." \
              % args.netcfg_sleep
        sleep(args.netcfg_sleep)

    print "Pushing config to ONOS..."
    call(("%s/onos-netcfg" % RUN_PACK_PATH, onosIp, TEMP_NETCFG_FILE))

    if not args.onos_ip:
        ONOSCLI(net)
    else:
        CLI(net)

    net.stop()
    call(("rm", "-f", TEMP_NETCFG_FILE))
Ejemplo n.º 2
0
def main(args):
    if not args.onos_ip:
        controller = ONOSCluster('c0', 3)
        onosIp = controller.nodes()[0].IP()
    else:
        controller = RemoteController('c0', ip=args.onos_ip)
        onosIp = args.onos_ip

    topo = ClosTopo(args)

    net = Mininet(topo=topo, build=False, controller=[controller])

    net.build()
    # Add an interface that the collector is connected to
    collectorIntf1 = Intf('veth_11', node=net.nameToNode["s11"])
    collectorIntf2 = Intf('veth_21', node=net.nameToNode["s12"])
    net.start()

    print "Network started"

    # Always generate background pings.
    sleep(3)
    for (h1, h2) in combinations(net.hosts, 2):
        h1.startPingBg(h2)
        h2.startPingBg(h1)

    print "Background ping started"

    for h in net.hosts:
        h.startIperfServer()

    print "Iperf servers started"

    if args.bg_traffic:
        sleep(4)
        print "Starting iperf clients..."
        for (h1, h2) in combinations(net.hosts, 2):
            h1.startIperfClient(h2, flowBw="10k", numFlows=10, duration=999999)
            h2.startIperfClient(h1, flowBw="10k", numFlows=10, duration=999999)

    generateNetcfg(onosIp, net, args)

    if args.netcfg_sleep > 0:
        print "Waiting %d seconds before pushing config to ONOS..." \
              % args.netcfg_sleep
        sleep(args.netcfg_sleep)

    print "Pushing config to ONOS..."
    call(("%s/onos-netcfg" % RUN_PACK_PATH, onosIp, TEMP_NETCFG_FILE))

    if not args.onos_ip:
        ONOSCLI(net)
    else:
        CLI(net)

    net.stop()
    call(("rm", "-f", TEMP_NETCFG_FILE))
Ejemplo n.º 3
0
def main(args):
    topo = ClosTopo()

    if not args.onos_ip:
        controller = ONOSCluster('c0', 3)
        onosIp = controller.nodes()[0].IP()
    else:
        controller = RemoteController('c0', ip=args.onos_ip, port=args.onos_port)
        onosIp = args.onos_ip

    net = Mininet(topo=topo, build=False, controller=[controller])
    print net.switches


    net.build()
    switch = net.switches[0]
    Intf( 'eth0', node=switch )
    print net.switches

    net.start()

    print "Network started"

    '''
    # Generate background traffic.
    sleep(3)
    for (h1, h2) in combinations(net.hosts, 2):
        h1.startPingBg(h2)
        h2.startPingBg(h1)
    
    print "Background ping started"
    '''

    for h in net.hosts:
        h.startIperfServer()

    print "Iperf servers started"

    # sleep(4)
    # print "Starting traffic from h1 to h3..."
    # net.hosts[0].startIperfClient(net.hosts[-1], flowBw="200k", numFlows=100, duration=10)

    print "Setting netcfg..."
    call(("onos-netcfg", onosIp,
          "%s/tools/test/topos/simple-cfg.json" % ONOS_ROOT))

    if not args.onos_ip:
        ONOSCLI(net)
    else:
        CLI(net)

    net.stop()
Ejemplo n.º 4
0
def main(args):
    if not args.onos_ip:
        controller = ONOSCluster('c0', 3)
        onosIp = controller.nodes()[0].IP()
    else:
        controller = RemoteController('c0', ip=args.onos_ip)
        onosIp = args.onos_ip

    topo = ClosTopo(args)

    net = Mininet(topo=topo, build=False, controller=[controller])

    net.build()
    net.start()

    print "Network started"

    # Generate background traffic.
    sleep(3)
    for (h1, h2) in combinations(net.hosts, 2):
        h1.startPingBg(h2)
        h2.startPingBg(h1)

    print "Background ping started"

    for h in net.hosts:
        h.startIperfServer()

    print "Iperf servers started"

    # sleep(4)
    # print "Starting traffic from h1 to h3..."
    # net.hosts[0].startIperfClient(net.hosts[-1], flowBw="200k", numFlows=100, duration=10)

    generateNetcfg(onosIp, net, args)

    if args.netcfg_sleep > 0:
        print "Waiting %d seconds before pushing config to ONOS..." % args.netcfg_sleep
        sleep(args.netcfg_sleep)

    print "Pushing config to ONOS..."
    call(("%s/onos-netcfg" % RUN_PACK_PATH, onosIp, TEMP_NETCFG_FILE))

    if not args.onos_ip:
        ONOSCLI(net)
    else:
        CLI(net)

    net.stop()
    call(("rm", "-f", TEMP_NETCFG_FILE))
Ejemplo n.º 5
0
def run(topo, controllers=None, link=TCLink, autoSetMacs=True):
    if not topo:
        print 'Need to provide a topology'
        exit(1)

    args = parse_args()

    if not controllers and len(args.ipAddrs) > 0:
        controllers = args.ipAddrs

    if not controllers and args.clusterSize < 1:
        print 'Need to provide a list of controller IPs, or define a cluster size.'
        exit(1)

    setLogLevel('info')

    if args.clusterSize > 0:
        if 'ONOS_ROOT' not in os.environ:
            print "Environment var $ONOS_ROOT not set (needed to import onos.py)"
            exit(1)
        sys.path.append(os.environ["ONOS_ROOT"] + "/tools/dev/mininet")
        from onos import ONOSCluster, ONOSOVSSwitch, ONOSCLI
        controller = ONOSCluster('c0', args.clusterSize)
        onosAddr = controller.nodes()[0].IP()
        net = ONOSMininet(topo=topo,
                          controller=controller,
                          switch=ONOSOVSSwitch,
                          link=link,
                          autoSetMacs=autoSetMacs)
        cli = ONOSCLI
    else:
        onosAddr = controllers[0]
        net = ONOSMininet(topo=topo,
                          controllers=controllers,
                          link=link,
                          autoSetMacs=autoSetMacs)
        cli = CLI

    net.start()

    if len(args.netcfgJson) > 0:
        if not os.path.isfile(args.netcfgJson):
            error('*** WARNING no such netcfg file: %s\n' % args.netcfgJson)
        else:
            info('*** Setting netcfg: %s\n' % args.netcfgJson)
            call(("onos-netcfg", onosAddr, args.netcfgJson))

    cli(net)
    net.stop()
Ejemplo n.º 6
0
def main(args):
    topo = ClosTopo()

    if not args.onos_ip:
        controller = ONOSCluster('c0', 3)
        onosIp = controller.nodes()[0].IP()
    else:
        controller = RemoteController('c0', ip=args.onos_ip, port=args.onos_port)
        onosIp = args.onos_ip

    net = Mininet(topo=topo, build=False, controller=[controller])

    net.build()
    net.start()

    print "Network started"

    # Generate background traffic.
    sleep(3)
    for (h1, h2) in combinations(net.hosts, 2):
        h1.startPingBg(h2)
        h2.startPingBg(h1)

    print "Background ping started"

    for h in net.hosts:
        h.startIperfServer()

    print "Iperf servers started"

    # sleep(4)
    # print "Starting traffic from h1 to h3..."
    # net.hosts[0].startIperfClient(net.hosts[-1], flowBw="200k", numFlows=100, duration=10)

    print "Setting netcfg..."
    call(("onos-netcfg", onosIp,
          "%s/tools/test/topos/bmv2-demo-cfg.json" % ONOS_ROOT))

    if not args.onos_ip:
        ONOSCLI(net)
    else:
        CLI(net)

    net.stop()
Ejemplo n.º 7
0
                        default='simple_switch')
    parser.add_argument('--onos_ip',
                        help='ONOS-BMv2 controller IP address',
                        type=str,
                        action="store",
                        required=False)
    return parser.parse_args()


if __name__ == '__main__':
    # from mininet.log import setLogLevel
    # setLogLevel("info")

    args = get_args()

    if not args.onos_ip:
        controller = ONOSCluster('c0', 3)
        onosIp = controller.nodes()[0].IP()
    else:
        controller = RemoteController('c0', ip=args.onos_ip)
        onosIp = args.onos_ip

    exercise = ExerciseRunner(args.topo, args.log_dir, args.pcap_dir,
                              args.switch_json, args.behavioral_exe,
                              args.onos_ip, args.quiet)

    print "Pushing config to ONOS..."
    call(("%s/onos-netcfg" % RUN_PACK_PATH, onosIp, TEMP_NETCFG_FILE))

    exercise.run_exercise()
Ejemplo n.º 8
0
def run(topo, controllers=None, link=TCLink, autoSetMacs=True):
    if not topo:
        print 'Need to provide a topology'
        exit(1)

    parser = ArgumentParser(description='ONOS Mininet ' + type(topo).__name__)
    parser.add_argument(
        '--cluster-size',
        help='Starts an ONOS cluster with the given number of instances',
        type=int,
        action='store',
        dest='clusterSize',
        required=False,
        default=0)
    parser.add_argument(
        '--netcfg',
        help='Relative path of the JSON file to be used with netcfg',
        type=str,
        action='store',
        dest='netcfgJson',
        required=False,
        default='')
    parser.add_argument('ipAddrs',
                        metavar='IP',
                        type=str,
                        nargs='*',
                        help='List of controller IP addresses',
                        default=[])
    args = parser.parse_args()

    if not controllers and len(args.ipAddrs) > 0:
        controllers = args.ipAddrs

    if not controllers and args.clusterSize < 1:
        print 'Need to provide a list of controller IPs, or define a cluster size.'
        exit(1)

    setLogLevel('info')

    if args.clusterSize > 0:
        if 'ONOS_ROOT' not in os.environ:
            print "Environment var $ONOS_ROOT not set (needed to import onos.py)"
            exit(1)
        sys.path.append(os.environ["ONOS_ROOT"] + "/tools/dev/mininet")
        from onos import ONOSCluster, ONOSOVSSwitch, ONOSCLI
        controller = ONOSCluster('c0', args.clusterSize)
        onosAddr = controller.nodes()[0].IP()
        net = ONOSMininet(topo=topo,
                          controller=controller,
                          switch=ONOSOVSSwitch,
                          link=link,
                          autoSetMacs=autoSetMacs)
        cli = ONOSCLI
    else:
        onosAddr = controllers[0]
        net = ONOSMininet(topo=topo,
                          controllers=controllers,
                          link=link,
                          autoSetMacs=autoSetMacs)
        cli = CLI

    net.start()

    if len(args.netcfgJson) > 0:
        if not os.path.isfile(args.netcfgJson):
            error('*** WARNING no such netcfg file: %s\n' % args.netcfgJson)
        else:
            info('*** Setting netcfg: %s\n' % args.netcfgJson)
            call(("onos-netcfg", onosAddr, args.netcfgJson))

    cli(net)
    net.stop()