<s> """<STR_LIT>""" <EOL> import sys <EOL> from mininet . net import Mininet <EOL> from mininet . cli import CLI <EOL> from mininet . log import lg <EOL> from mininet . node import Node <EOL> from mininet . topolib import TreeTopo <EOL> from mininet . util import waitListening <EOL> def TreeNet ( depth = <NUM_LIT:1> , fanout = <NUM_LIT:2> , ** kwargs ) : <EOL> "<STR_LIT>" <EOL> topo = TreeTopo ( depth , fanout ) <EOL> return Mininet ( topo , ** kwargs ) <EOL> def connectToRootNS ( network , switch , ip , routes ) : <EOL> """<STR_LIT>""" <EOL> root = Node ( '<STR_LIT:root>' , inNamespace = False ) <EOL> intf = network . addLink ( root , switch ) . intf1 <EOL> root . setIP ( ip , intf = intf ) <EOL> network . start ( ) <EOL> for route in routes : <EOL> root . cmd ( '<STR_LIT>' + route + '<STR_LIT>' + str ( intf ) ) <EOL> def sshd ( network , cmd = '<STR_LIT>' , opts = '<STR_LIT>' , <EOL> ip = '<STR_LIT>' , routes = None , switch = None ) : <EOL> """<STR_LIT>""" <EOL> if not switch : <EOL> switch = network [ '<STR_LIT>' ] <EOL> if not routes : <EOL> routes = [ '<STR_LIT>' ] <EOL> connectToRootNS ( network , switch , ip , routes ) <EOL> for host in network . hosts : <EOL> host . cmd ( cmd + '<STR_LIT:U+0020>' + opts + '<STR_LIT:&>' ) <EOL> print "<STR_LIT>" <EOL> for server in network . hosts : <EOL> waitListening ( server = server , port = <NUM_LIT> , timeout = <NUM_LIT:5> ) <EOL> print <EOL> print "<STR_LIT>" <EOL> print <EOL> for host in network . hosts : <EOL> print host . name , host . IP ( ) <EOL> print <EOL> print "<STR_LIT>" <EOL> CLI ( network ) <EOL> for host in network . hosts : <EOL> host . cmd ( '<STR_LIT>' + cmd ) <EOL> network . stop ( ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> lg . setLogLevel ( '<STR_LIT:info>' ) <EOL> net = TreeNet ( depth = <NUM_LIT:1> , fanout = <NUM_LIT:4> ) <EOL> argvopts = '<STR_LIT:U+0020>' . join ( sys . argv [ <NUM_LIT:1> : ] ) if len ( sys . argv ) > <NUM_LIT:1> else ( <EOL> '<STR_LIT>' ) <EOL> sshd ( net , opts = argvopts ) </s>
