wifi.wifihelper.SetRemoteStationManager(
        "ns3::ConstantRateWifiManager", "DataMode",
        ns.core.StringValue("OfdmRate54Mbps"))
    wifi.add(h2)

    info('*** Configuring hosts\n')
    h0.setIP('192.168.123.1/24')
    h1.setIP('192.168.123.2/24')
    h2.setIP('192.168.123.3/24')

    mininet.ns3.start()

    info('*** Testing network connectivity\n')
    net.pingAll()

    info('*** Starting TCP iperf server on h2\n')
    h2.sendCmd("iperf -s")

    info(
        '*** Testing bandwidth between h0 and h2 while h1 is not transmitting\n'
    )
    h0.cmdPrint("iperf -c 192.168.123.3")

    info(
        '*** Testing bandwidth between h0 and h2 while h1 is transmitting at 6Mbps\n'
    )
    h1.sendCmd("iperf -c 192.168.123.3")
    h0.cmdPrint("iperf -c 192.168.123.3")

    CLI(net)
예제 #2
0
def scratchNet(cname='controller', cargs='-v ptcp:'):
    "Create network from scratch using Open vSwitch."

    info("*** Creating nodes\n")
    controller = Node('c0', inNamespace=False)
    switch = Node('s0', inNamespace=False)
    switch1 = Node('s1', inNamespace=False)
    h0 = Node('h0')
    h1 = Node('h1')
    h2 = Node('h2')
    h3 = Node('h3')
    h4 = Node('h4')
    h5 = Node('h5')
    h6 = Node('h6')
    h7 = Node('h7')

    info("*** Creating links\n")
    Link(h0, switch)
    Link(h1, switch)
    Link(h2, switch)
    Link(h3, switch)
    Link(h4, switch1)
    Link(h5, switch1)
    Link(h6, switch1)
    Link(h7, switch1)
    info("*** Configuring hosts\n")
    h0.setIP('192.168.123.1/24')
    h1.setIP('192.168.123.2/24')
    h2.setIP('192.168.123.3/24')
    h3.setIP('192.168.123.4/24')
    h4.setIP('192.168.123.5/24')
    h5.setIP('192.168.123.6/24')
    h6.setIP('192.168.123.7/24')
    h7.setIP('192.168.123.8/24')
    info(str(h0) + '\n')
    info(str(h1) + '\n')
    info(str(h2) + '\n')
    info(str(h3) + '\n')
    info(str(h4) + '\n')
    info(str(h5) + '\n')
    info(str(h6) + '\n')
    info(str(h7) + '\n')

    info("*** Starting network using Open vSwitch\n")
    controller.cmd(cname + ' ' + cargs + '&')
    switch.cmd('ovs-vsctl del-br dp0')
    switch.cmd('ovs-vsctl add-br dp0')
    switch1.cmd('ovs-vsctl del-br dp0')
    switch1.cmd('ovs-vsctl add-br dp0')

    net.addLink(switch, switch1, delay='5ms', loss=20)
    for intf in switch.intfs.values():
        print switch.cmd('ovs-vsctl add-port dp0 %s' % intf)
    for intf in switch1.intfs.values():
        print switch1.cmd('ovs-vsctl add-port dp0 %s' % intf)

    # Note: controller and switch are in root namespace, and we
    # can connect via loopback interface
    switch.cmd('ovs-vsctl set-controller dp0 tcp:127.0.0.1:6633')
    switch1.cmd('ovs-vsctl set-controller dp0 tcp:127.0.0.1:6633')

    linkopts = dict(bw=10,
                    delay='5ms',
                    loss=20,
                    max_queue_size=1000,
                    use_htb=True)
    info('*** Waiting for switch to connect to controller')
    while 'is_connected' not in quietRun('ovs-vsctl show'):
        sleep(1)
        info('.')
    info('\n')

    info("*** Running test\n")

    h0.sendCmd(
        ' /home/amellalghamdi/Desktop/cse223bFinalProject/lib/kv_server 1 239.0.2.1 9000 1 2 3 4 >&1 > `ifconfig | grep eth | cut -f1 -d`.out1`'
    )
    h1.cmdPrint(
        ' /home/amellalghamdi/Desktop/cse223bFinalProject/lib/kv_server 2 239.0.2.1 9000 1 2 3 4 >&1 > `ifconfig | grep eth | cut -f1 -d`.out2`'
    )
    h2.cmdPrint(
        '/home/amellalghamdi/Desktop/cse223bFinalProject/lib/kv_server 3 239.0.2.1 9000 1 2 3 4 >&1 > `ifconfig | grep eth | cut -f1 -d`.out3'
    )
    h3.cmdPrint(
        ' /home/amellalghamdi/Desktop/cse223bFinalProject/lib/kv_server 4 239.0.2.1 9000 1 2 3 4 >&1 > `ifconfig | grep eth | cut -f1 -d`.out4'
    )

    info("*** Stopping network\n")
    #controller.cmd( 'kill %' + cname )
    #switch.cmd( 'ovs-vsctl del-br dp0' )
    #switch.deleteIntfs()
    #switch1.cmd( 'ovs-vsctl del-br dp0' )
    #switch1.deleteIntfs()
    info('\n')