Pass code check.
This commit is contained in:
+7
-15
@@ -26,20 +26,19 @@ def startpings( host, targetips ):
|
|||||||
targetips.append( '10.0.0.200' )
|
targetips.append( '10.0.0.200' )
|
||||||
|
|
||||||
targetips = ' '.join( targetips )
|
targetips = ' '.join( targetips )
|
||||||
|
|
||||||
# BL: Not sure why loopback intf isn't up!
|
# BL: Not sure why loopback intf isn't up!
|
||||||
host.cmd( 'ifconfig lo up' )
|
host.cmd( 'ifconfig lo up' )
|
||||||
|
|
||||||
|
|
||||||
# Simple ping loop
|
# Simple ping loop
|
||||||
cmd = ( 'while true; do '
|
cmd = ( 'while true; do '
|
||||||
' for ip in %s; do ' % targetips +
|
' for ip in %s; do ' % targetips +
|
||||||
' echo -n %s "->" $ip ' % host.IP() +
|
' echo -n %s "->" $ip ' % host.IP() +
|
||||||
' `ping -c1 -w 1 $ip | grep packets` ;'
|
' `ping -c1 -w 1 $ip | grep packets` ;'
|
||||||
' sleep 1;'
|
' sleep 1;'
|
||||||
' done; '
|
' done; '
|
||||||
'done &' )
|
'done &' )
|
||||||
|
|
||||||
print ( '*** Host %s (%s) will be pinging ips: %s' %
|
print ( '*** Host %s (%s) will be pinging ips: %s' %
|
||||||
( host.name, host.IP(), targetips ) )
|
( host.name, host.IP(), targetips ) )
|
||||||
|
|
||||||
@@ -47,7 +46,7 @@ def startpings( host, targetips ):
|
|||||||
|
|
||||||
def multiping( netsize, chunksize, seconds):
|
def multiping( netsize, chunksize, seconds):
|
||||||
"Ping subsets of size chunksize in net of size netsize"
|
"Ping subsets of size chunksize in net of size netsize"
|
||||||
|
|
||||||
# Create network and identify subnets
|
# Create network and identify subnets
|
||||||
topo = SingleSwitchTopo( netsize )
|
topo = SingleSwitchTopo( netsize )
|
||||||
net = Mininet( topo=topo )
|
net = Mininet( topo=topo )
|
||||||
@@ -60,13 +59,13 @@ def multiping( netsize, chunksize, seconds):
|
|||||||
poller = poll()
|
poller = poll()
|
||||||
for fd in fds:
|
for fd in fds:
|
||||||
poller.register( fd, POLLIN )
|
poller.register( fd, POLLIN )
|
||||||
|
|
||||||
# Start pings
|
# Start pings
|
||||||
for subnet in subnets:
|
for subnet in subnets:
|
||||||
ips = [ host.IP() for host in subnet ]
|
ips = [ host.IP() for host in subnet ]
|
||||||
for host in subnet:
|
for host in subnet:
|
||||||
startpings( host, ips )
|
startpings( host, ips )
|
||||||
|
|
||||||
# Monitor output
|
# Monitor output
|
||||||
endTime = time() + seconds
|
endTime = time() + seconds
|
||||||
while time() < endTime:
|
while time() < endTime:
|
||||||
@@ -78,17 +77,10 @@ def multiping( netsize, chunksize, seconds):
|
|||||||
# Stop pings
|
# Stop pings
|
||||||
for host in hosts:
|
for host in hosts:
|
||||||
host.cmd( 'kill %while' )
|
host.cmd( 'kill %while' )
|
||||||
|
|
||||||
net.stop()
|
net.stop()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
setLogLevel( 'info' )
|
setLogLevel( 'info' )
|
||||||
multiping( netsize=20, chunksize=4, seconds=10 )
|
multiping( netsize=20, chunksize=4, seconds=10 )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -8,13 +8,13 @@ monitoring them
|
|||||||
from mininet.topo import SingleSwitchTopo
|
from mininet.topo import SingleSwitchTopo
|
||||||
from mininet.net import Mininet
|
from mininet.net import Mininet
|
||||||
from mininet.log import setLogLevel
|
from mininet.log import setLogLevel
|
||||||
from mininet.util import quietRun
|
|
||||||
|
|
||||||
from time import time, sleep
|
from time import time
|
||||||
from select import poll, POLLIN
|
from select import poll, POLLIN
|
||||||
from subprocess import Popen, PIPE
|
from subprocess import Popen, PIPE
|
||||||
|
|
||||||
def monitorFiles( outfiles, seconds, timeoutms ):
|
def monitorFiles( outfiles, seconds, timeoutms ):
|
||||||
|
"Monitor set of files and return [(host, line)...]"
|
||||||
devnull = open( '/dev/null', 'w' )
|
devnull = open( '/dev/null', 'w' )
|
||||||
tails, fdToFile, fdToHost = {}, {}, {}
|
tails, fdToFile, fdToHost = {}, {}, {}
|
||||||
for h, outfile in outfiles.iteritems():
|
for h, outfile in outfiles.iteritems():
|
||||||
@@ -63,7 +63,7 @@ def monitorTest( N=3, seconds=3 ):
|
|||||||
h.cmd( 'echo >', outfiles[ h ] )
|
h.cmd( 'echo >', outfiles[ h ] )
|
||||||
h.cmd( 'echo >', errfiles[ h ] )
|
h.cmd( 'echo >', errfiles[ h ] )
|
||||||
# Start pings
|
# Start pings
|
||||||
h.cmdPrint('ping', server.IP(),
|
h.cmdPrint('ping', server.IP(),
|
||||||
'>', outfiles[ h ],
|
'>', outfiles[ h ],
|
||||||
'2>', errfiles[ h ],
|
'2>', errfiles[ h ],
|
||||||
'&' )
|
'&' )
|
||||||
@@ -79,5 +79,3 @@ def monitorTest( N=3, seconds=3 ):
|
|||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
setLogLevel('info')
|
setLogLevel('info')
|
||||||
monitorTest()
|
monitorTest()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+26
-27
@@ -12,34 +12,33 @@ from mininet.util import dumpNodeConnections
|
|||||||
from mininet.log import setLogLevel
|
from mininet.log import setLogLevel
|
||||||
|
|
||||||
class SingleSwitchTopo(Topo):
|
class SingleSwitchTopo(Topo):
|
||||||
"Single switch connected to n hosts."
|
"Single switch connected to n hosts."
|
||||||
def __init__(self, n=2, **opts):
|
def __init__(self, n=2, **opts):
|
||||||
Topo.__init__(self, **opts)
|
Topo.__init__(self, **opts)
|
||||||
switch = self.add_switch('s1')
|
switch = self.add_switch('s1')
|
||||||
for h in range(n):
|
for h in range(n):
|
||||||
# Each host gets 50%/n of system CPU
|
# Each host gets 50%/n of system CPU
|
||||||
host = self.add_host('h%s' % (h + 1),
|
host = self.add_host('h%s' % (h + 1),
|
||||||
cpu=.5/n)
|
cpu=.5 / n)
|
||||||
# 10 Mbps, 5ms delay, 10% loss
|
# 10 Mbps, 5ms delay, 10% loss
|
||||||
self.add_link(host, switch,
|
self.add_link(host, switch,
|
||||||
bw=10, delay='5ms', loss=10, use_htb=True)
|
bw=10, delay='5ms', loss=10, use_htb=True)
|
||||||
|
|
||||||
def perfTest():
|
def perfTest():
|
||||||
"Create network and run simple performance test"
|
"Create network and run simple performance test"
|
||||||
topo = SingleSwitchTopo(n=4)
|
topo = SingleSwitchTopo(n=4)
|
||||||
net = Mininet(topo=topo,
|
net = Mininet(topo=topo,
|
||||||
host=CPULimitedHost, link=TCLink)
|
host=CPULimitedHost, link=TCLink)
|
||||||
net.start()
|
net.start()
|
||||||
print "Dumping host connections"
|
print "Dumping host connections"
|
||||||
dumpNodeConnections(net.hosts)
|
dumpNodeConnections(net.hosts)
|
||||||
print "Testing network connectivity"
|
print "Testing network connectivity"
|
||||||
net.pingAll()
|
net.pingAll()
|
||||||
print "Testing bandwidth between h1 and h4"
|
print "Testing bandwidth between h1 and h4"
|
||||||
h1 = net.getNodeByName('h1')
|
h1, h4 = net.getNodeByName('h1', 'h4')
|
||||||
h4 = net.getNodeByName('h4')
|
net.iperf((h1, h4))
|
||||||
net.iperf((h1, h4))
|
net.stop()
|
||||||
net.stop()
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
setLogLevel('info')
|
setLogLevel('info')
|
||||||
perfTest()
|
perfTest()
|
||||||
|
|||||||
Reference in New Issue
Block a user