Example #1
0
def test():
    topo = DssTopo()
    net = Mininet(topo, link=TCLink)
    net.start()
    
    with open("pause.test","a") as myfile:
        for x in range(0,2000):
            st1 = net.pingPairFull()
            #print 'pausing'
            time.sleep(0.01)
            pause()
            myfile.write( repr(st1[0][2][3]))
            myfile.write('\n')

    with open("noPause.test","a") as myffile:
        for x in range(0,2000):
            st1 = net.pingPairFull()
            #print 'pausing'
            time.sleep(0.01)
            #pause()
            myffile.write( repr(st1[0][2][3]))
            myffile.write('\n')

        
            


    net.stop()    
Example #2
0
def intfOptions():
    "run various traffic control commands on a single interface"
    net = Mininet( autoStaticArp=True )
    net.addController( 'c0' )
    h1 = net.addHost( 'h1' )
    h2 = net.addHost( 'h2' )
    s1 = net.addSwitch( 's1' )
    link1 = net.addLink( h1, s1, cls=TCLink )
    net.addLink( h2, s1 )
    net.start()
    
    # flush out latency from reactive forwarding delay
    net.pingAll()

    info( '\n*** Configuring one intf with bandwidth of 5 Mb\n' )
    link1.intf1.config( bw=5 )
    info( '\n*** Running iperf to test\n' )
    net.iperf()

    info( '\n*** Configuring one intf with loss of 50%\n' )
    link1.intf1.config( loss=50 )
    info( '\n' )
    net.iperf( ( h1, h2 ), l4Type='UDP' )
    
    info( '\n*** Configuring one intf with delay of 15ms\n' )
    link1.intf1.config( delay='15ms' )
    info( '\n*** Run a ping to confirm delay\n' )
    net.pingPairFull()
    
    info( '\n*** Done testing\n' )
    net.stop()
Example #3
0
def test():
    topo = DssTopo()
    net = Mininet(topo, link=TCLink)
    net.start()
    
    with open("pause.test","a") as myfile:
        for x in range(0,2000):
            st1 = net.pingPairFull()
            #print 'pausing'
            time.sleep(0.01)
            pause()
            myfile.write( repr(st1[0][2][3]))
            myfile.write('\n')

    with open("noPause.test","a") as myffile:
        for x in range(0,2000):
            st1 = net.pingPairFull()
            #print 'pausing'
            time.sleep(0.22)
            #pause()
            myffile.write( repr(st1[0][2][3]))
            myffile.write('\n')

        
            


    net.stop()    
    def build():
        
        net = Mininet( autoStaticArp=True, waitConnected=True )
        
        #define router node
        router = net.addNode('r0', cls=Router, ip = '192.168.1.1/24')
        
        #add switch nodes
        s1, s2 = [net.addSwitch(s) for s in ('s1','s2')]
        
        #add routes
        net.addLink(s1, router, intfName2 = 'ro-eth0', params2 = {'ip' : '192.168.1.1/24'})
        net.addLink(s2, router, intfName2 = 'ro-eth1', params2 = {'ip' : '10.0.0.1/8'})
        
        #add hosts
        h1 = net.addHost('h1', ip = '192.168.1.50/24', defaultRoute = 'via 192.168.1.1')
        h2 = net.addHost('h2', ip = '10.0.0.50/8', defaultRoute = 'via 10.0.0.1')
        
        #add links between hosts and switches
        #add adjustable performance link
        link1 = net.addLink(h1, s1, cls = TCLink)
        #add normal link
        net.addLink(h2, s1)
        

        "Test router"
        net.start()
        info( '*** Routing Table on Router:\n' )
        info( net[ 'r0' ].cmd( 'route' ) )


        # flush out latency from reactive forwarding delay
        net.pingAll()

        info('\n***Configure one intf with 10Mb/s bandwidth')
        link1.intf1.config( bw=10 )
        info( '\n*** Running iperf to test\n' )
        net.iperf( seconds=10 )

        info( '\n*** Configuring one intf with delay of 15ms\n' )
        link1.intf1.config( delay='15ms' )
        info( '\n*** Run a ping to confirm delay of 15ms\n' )
        net.pingPairFull()

        info( '\n*** Configuring one intf with jitter of 1ms\n' )
        link1.intf1.config( jitter='1ms' )
        info( '\n*** Run iperf to confirm 1ms jitter\n' )
        net.iperf( ( h1, h2 ), l4Type='UDP' )

        info( '\n*** Configuring one intf with loss of 50%\n' )
        link1.intf1.config( loss=50 )
        info( '\n' )
        net.iperf( ( h1, h2 ), l4Type='UDP' )

        info( '\n*** Done testing\n' )

        CLI( net )
        net.stop()
Example #5
0
def intfOptions():
    "run various traffic control commands on a single interface"
    net = Mininet( autoStaticArp=True, waitConnected=True )
    
    net.addController( 'c0' )
    h1 = net.addHost( 'h1' )
    h2 = net.addHost( 'h2' )
    
    #add switch nodes
    s1, s2 = [net.addSwitch(s) for s in ('s1','s2')]
    
    #add links
    link1 = net.addLink( h1, s1, cls=TCLink )
    net.addLink( h2, s1 )
    
    net.start()

    # flush out latency from reactive forwarding delay
    net.pingAll()

    info('\n***Configure one intf with 10Mb/s bandwidth')
    link1.intf1.config( bw=10 )
    info( '\n*** Running iperf to test\n' )
    net.iperf( seconds=10 )
    
    info( '\n*** Configuring one intf with delay of 15ms\n' )
    link1.intf1.config( delay='15ms' )
    info( '\n*** Run a ping to confirm delay of 15ms\n' )
    net.pingPairFull()
    
    info( '\n*** Configuring one intf with jitter of 1ms\n' )
    link1.intf1.config( jitter='1ms' )
    info( '\n*** Run iperf to confirm 1ms jitter\n' )
    net.iperf( ( h1, h2 ), l4Type='UDP' )
    
    info( '\n*** Configuring one intf with loss of 50%\n' )
    link1.intf1.config( loss=50 )
    info( '\n' )
    net.iperf( ( h1, h2 ), l4Type='UDP' )
    
    info( '\n*** Done testing\n' )
    net.stop()
def testtopology():
    tkinter.messagebox.showinfo("Deploy topology to mininet ", "Press ok button and wait for a seconds to see result")

    with open('./stdout.txt', 'w') as outfile:
        with redirect_stdout(outfile), redirect_stderr(outfile):

            topo = CustomTopology()
            net = Mininet(topo=topo, cleanup=True)

            print('\n =================================================> Start the topology \n')
            net.start()

            print('\n =================================================> Test the topology by running a ping command \n')

            ping_all_full = net.pingAllFull()
            print('Result from ping Test: \n' + '\n' + str(ping_all_full) + '\n' + '\n % of packets dropped.\n')

            ping_pair = net.pingPairFull()
            print('Result from Regression Test : \n' + '\n' + str(ping_pair) + '\n' + '\n % of packets dropped.\n')

            print('\n ==============> Testing TCP bandwidth between: \n')

            iperf_origin = net.getNodeByName(node_1)
            iperf_destination = net.getNodeByName(node_2)

            iPerf = net.iperf([iperf_origin, iperf_destination])

            print('Result from iPerf between node ' + node_1 + ' and node ' + node_2 + '\n' + '\n' + str(iPerf) + '\n')

            stop = net.stop()
            print('Stop the network:' + str(stop) + '\n')

            clean = net.cleanup
            print('cleanup the mininet network: ' + str(clean) + '\n')

    with open('./stdout.txt') as infile:
        mnOutput.insert(END, infile.read())
topo = SingleSwitchTopo(3)
try:
    net = Mininet(topo=topo)
except:
    cleanup()
    net = Mininet(topo=topo)

print('Starting single switch network with three hosts')
net.start()
print('\nNetwork started. Press ctrl+d to close CLI.\n')
print('--Nodes--\n' + ' '.join(net.keys()))

s = net.get('h1')
a = net.get('h2')
b = net.get('h3')

for bw in [0.01, 0.1, 0.5, 1, 5]:
    print('********* ' + str(bw) + ' **************')
    for h in net.hosts:
        h.intfs[0].config(**{ 'bw' : bw, 'delay' : '1ms' })

    for cw in [3, 5, 8, 10]:
        s.cmd('ip route change 10.0.0.0/8 dev h1-eth0  proto kernel  scope link  src 10.0.0.1  initcwnd ' + str(cw))
        net.pingPairFull()

CLI(net)
print('Stopping network')
net.stop()
cleanup()