Example #1
0
def topology():

    "Create a network."
    net = Mininet( controller=Controller, link=TCLink, switch=OVSKernelSwitch )

    print "*** Creating nodes"
    sta1 = net.addStation( 'sta1', mac='00:00:00:00:00:01', ip='192.168.0.1/24', position='47.28,50,0' )
    sta2 = net.addStation( 'sta2', mac='00:00:00:00:00:02', ip='192.168.0.2/24', position='54.08,50,0' )
    ap3 = net.addBaseStation( 'ap3', range=20, ssid='ap-ssid3', mode= 'b', channel= '1', position='50,50,0' )
    c4 = net.addController( 'c4', controller=Controller, port=6653 )

    print "*** Configuring wifi nodes"
    net.configureWifiNodes()

    print "*** Starting network"
    net.build()
    c4.start()
    ap3.start( [c4] )

    sta1.cmd('iw dev sta1-wlan0 interface add mon0 type monitor &')
    sta1.cmd('ifconfig mon0 up &')
    sta2.cmd('iw dev sta2-wlan0 interface add mon0 type monitor &')
    sta2.cmd('ifconfig mon0 up &')
    sta2.cmd('pushd /home/alpha/Downloads; python3 -m http.server 80 &')

    getTrace(sta1, 'clientTrace.txt')
    getTrace(sta2, 'serverTrace.txt')

    replayingNetworkBehavior.addNode(sta1)
    replayingNetworkBehavior.addNode(sta2)
    replayingNetworkBehavior(net)
   
    net.autoAssociation()

    print "*** Running CLI"
    CLI( net )

    print "*** Stopping network"
    net.stop()
Example #2
0
def topology():
    """Create a network. sta1 <--> sta2 <--> sta3"""

    print "*** Network creation"
    net = Mininet()

    print "*** Creating nodes"
    sta1 = net.addStation('sta1', range=50, position='10,10,0')
    sta2 = net.addStation('sta2', range=50, position='20,10,0')
    sta3 = net.addStation('sta3', range=50, position='30,10,0')

    print "*** Configure wmediumd"
    # This should be done right after the station has been initialized
    sta1.wmediumdIface = DynamicWmediumdIntfRef(sta1)
    sta2.wmediumdIface = DynamicWmediumdIntfRef(sta2)
    sta3.wmediumdIface = DynamicWmediumdIntfRef(sta3)

    intfrefs = [sta1.wmediumdIface, sta2.wmediumdIface, sta3.wmediumdIface]
    links = [
        WmediumdSNRLink(sta1.wmediumdIface, sta2.wmediumdIface, 15),
        WmediumdSNRLink(sta2.wmediumdIface, sta1.wmediumdIface, 15),
        WmediumdSNRLink(sta2.wmediumdIface, sta3.wmediumdIface, 15),
        WmediumdSNRLink(sta3.wmediumdIface, sta2.wmediumdIface, 15)
    ]
    WmediumdStarter.initialize(intfrefs, links, with_server=True)

    print "*** Configuring wifi nodes"
    net.configureWifiNodes()

    print "*** Start wmediumd"
    WmediumdStarter.start()

    print "*** Plotting graph ***"
    net.plotGraph(max_x=200, max_y=200)

    print "*** Enabling Mesh Routing ***"
    net.meshRouting('custom')

    print "*** Creating links"
    net.addMesh(sta1, ssid='adNet')
    net.addMesh(sta2, ssid='adNet')
    net.addMesh(sta3, ssid='adNet')

    print "*** Starting network"
    net.start()
    print "\n\n\n"
    print "*** Pinging sta2"
    sta1.cmdPrint('ping -c 1 10.0.0.2')

    print "*** Update wmediumd"
    WmediumdServerConn.connect()

    # Required when the position of the nodes are previously defined. Useful to set channel params.
    net.autoAssociation()

    CLI(net)

    print "*** Stopping network"
    net.stop()

    print "*** Stopping wmediumd"
    WmediumdServerConn.disconnect()
    WmediumdStarter.stop()
def topology():

    "Create a network."
    net = Mininet(controller=Controller, link=TCLink, switch=OVSKernelSwitch)

    print "*** Creating nodes"
    sta1 = net.addStation('sta1',
                          mac='00:00:00:00:00:01',
                          ip='192.168.0.1/24',
                          position='47.28,50,0')
    sta2 = net.addStation('sta2',
                          mac='00:00:00:00:00:02',
                          ip='192.168.0.2/24',
                          position='54.08,50,0')
    ap3 = net.addBaseStation('ap3',
                             range=20,
                             ssid='ap-ssid3',
                             mode='g',
                             channel='1',
                             position='50,50,0')
    c4 = net.addController('c4', controller=Controller, port=6653)

    print "*** Configuring wifi nodes"
    net.configureWifiNodes()

    print "*** Starting network"
    net.build()
    c4.start()
    ap3.start([c4])

    sta1.cmd('iw dev sta1-wlan0 interface add mon0 type monitor &')
    sta1.cmd('ifconfig mon0 up &')
    sta2.cmd('iw dev sta2-wlan0 interface add mon0 type monitor &')
    sta2.cmd('ifconfig mon0 up &')
    sta2.cmd('pushd /home/alpha/Downloads; python3 -m http.server 80 &')

    getTrace(sta1, 'clientTrace.txt')
    getTrace(sta2, 'serverTrace.txt')

    replayingNetworkBehavior.addNode(sta1)
    replayingNetworkBehavior.addNode(sta2)
    replayingNetworkBehavior(net)

    #sta1.cmd('tcpdump -i mon0 -s 0 -vvv -w client.pcap &&')
    #sta2.cmd('tcpdump -i mon0 -s 0 -vvv -w server.pcap &&')
    #sta1 tcpdump -i mon0 -s 0 -vvv -w client.pcap && sta1 wget http://192.168.0.2/virtualbox-5.0_5.0.20-106931~Ubuntu~xenial_amd64.deb
    #sta1.cmd('wget http://'+sta2.IP()+'/virtualbox-5.0_5.0.20-106931~Ubuntu~xenial_amd64.deb')

    #sta1.cmd('nohup ping ' + sta2.IP() + ' -c 180 > ping1.log &')
    #sta2.cmd('nohup ping ' + sta1.IP() + ' -c 180 > ping2.log &')
    #sta2.cmd('iperf -s &')
    #sta1.cmd('iperf -c ' + sta2.IP() + ' -i 0.5 -t 60 | awk \'t=120{if(NR>=7 && NR<=25) print $8; else if(NR>=26 && NR<=t+6) print $7}\' > replay1.dat')
    #sta2.cmd('iperf -c ' + sta1.IP() + ' -i 0.5 -t 60 | awk \'t=120{if(NR>=7 && NR<=25) print $8; else if(NR>=26 && NR<=t+6) print $7}\' > replay2.dat &')

    net.autoAssociation()

    print "*** Running CLI"
    CLI(net)

    print "*** Stopping network"
    net.stop()