Statistics
| Branch: | Tag: | Revision:

mininet / examples / intfoptions.py @ 37bdf14b

History | View | Annotate | Download (1.3 KB)

1
#!/usr/bin/python
2

    
3
'''
4
example of using various TCIntf options.
5
reconfigures a single interface using intf.config()
6
to use different traffic control commands to test
7
bandwidth, loss, and delay
8
'''
9

    
10
from mininet.net import Mininet
11
from mininet.log import setLogLevel, info
12
from mininet.link import TCLink
13

    
14
def intfOptions():
15
    "run various traffic control commands on a single interface"
16
    net = Mininet( autoStaticArp=True )
17
    net.addController( 'c0' )
18
    h1 = net.addHost( 'h1' )
19
    h2 = net.addHost( 'h2' )
20
    s1 = net.addSwitch( 's1' )
21
    link1 = net.addLink( h1, s1, cls=TCLink )
22
    net.addLink( h2, s1 )
23
    net.start()
24
    
25
    # flush out latency from reactive forwarding delay
26
    net.pingAll()
27

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

    
33
    info( '\n*** Configuring one intf with loss of 50%\n' )
34
    link1.intf1.config( loss=50 )
35
    info( '\n' )
36
    net.iperf( ( h1, h2 ), l4Type='UDP' )
37
    
38
    info( '\n*** Configuring one intf with delay of 15ms\n' )
39
    link1.intf1.config( delay='15ms' )
40
    info( '\n*** Run a ping to confirm delay\n' )
41
    net.pingPairFull()
42
    
43
    info( '\n*** Done testing\n' )
44
    net.stop()
45

    
46
if __name__ == '__main__':
47
    setLogLevel( 'info' )
48
    intfOptions()