MCPcopy Create free account
hub / github.com/mininet/mininet / pmonitorTest

Function pmonitorTest

examples/popenpoll.py:14–33  ·  view source on GitHub ↗

Run pings and monitor multiple hosts using pmonitor

( N=3, seconds=10 )

Source from the content-addressed store, hash-verified

12
13
14def pmonitorTest( N=3, seconds=10 ):
15 "Run pings and monitor multiple hosts using pmonitor"
16 topo = SingleSwitchTopo( N )
17 net = Mininet( topo, waitConnected=True )
18 net.start()
19 hosts = net.hosts
20 info( "Starting test...\n" )
21 server = hosts[ 0 ]
22 popens = {}
23 for h in hosts:
24 popens[ h ] = h.popen('ping', server.IP() )
25 info( "Monitoring output for", seconds, "seconds\n" )
26 endTime = time() + seconds
27 for h, line in pmonitor( popens, timeoutms=500 ):
28 if h:
29 info( '<%s>: %s' % ( h.name, line ) )
30 if time() >= endTime:
31 for p in popens.values():
32 p.send_signal( SIGINT )
33 net.stop()
34
35
36if __name__ == '__main__':

Callers 1

popenpoll.pyFile · 0.85

Calls 8

startMethod · 0.95
stopMethod · 0.95
SingleSwitchTopoClass · 0.90
MininetClass · 0.90
pmonitorFunction · 0.90
popenMethod · 0.45
IPMethod · 0.45
valuesMethod · 0.45

Tested by

no test coverage detected