本文整理汇总了Python中mininet.net.Mininet.stop方法的典型用法代码示例。如果您正苦于以下问题:Python Mininet.stop方法的具体用法?Python Mininet.stop怎么用?Python Mininet.stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mininet.net.Mininet
的用法示例。
在下文中一共展示了Mininet.stop方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testCPULimits
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import stop [as 别名]
def testCPULimits( self ):
"Verify topology creation with CPU limits set for both schedulers."
CPU_FRACTION = 0.1
CPU_TOLERANCE = 0.8 # CPU fraction below which test should fail
hopts = { 'cpu': CPU_FRACTION }
#self.runOptionsTopoTest( N, hopts=hopts )
mn = Mininet( SingleSwitchOptionsTopo( n=N, hopts=hopts ),
host=CPULimitedHost, switch=self.switchClass,
waitConnected=True )
mn.start()
results = mn.runCpuLimitTest( cpu=CPU_FRACTION )
mn.stop()
hostUsage = '\n'.join( 'h%s: %s' %
( n + 1,
results[ (n - 1) * 5 : (n * 5) - 1 ] )
for n in range( N ) )
hoptsStr = ', '.join( '%s: %s' % ( opt, value )
for opt, value in hopts.items() )
msg = ( '\nTesting cpu limited to %d%% of cpu per host\n'
'cpu usage percent per host:\n%s\n'
'Topo = SingleSwitchTopo, %s hosts\n'
'hopts = %s\n'
'host = CPULimitedHost\n'
'Switch = %s\n'
% ( CPU_FRACTION * 100, hostUsage, N, hoptsStr,
self.switchClass ) )
for pct in results:
#divide cpu by 100 to convert from percentage to fraction
self.assertWithinTolerance( pct/100, CPU_FRACTION,
CPU_TOLERANCE, msg )
示例2: cs461net
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import stop [as 别名]
def cs461net():
stophttp()
"Create a simple network for cs461"
r = get_ip_setting()
if r == -1:
exit("Couldn't load config file for ip addresses, check whether %s exists" % IPCONFIG_FILE)
else:
info( '*** Successfully loaded ip settings for hosts\n %s\n' % IP_SETTING)
topo = CS461Topo()
info( '*** Creating network\n' )
net = Mininet( topo=topo, controller=RemoteController, ipBase=IPBASE )
net.start()
server1, server2, client, router = net.get( 'server1', 'server2', 'client', 'sw0')
s1intf = server1.defaultIntf()
s1intf.setIP('%s/8' % IP_SETTING['server1'])
s2intf = server2.defaultIntf()
s2intf.setIP('%s/8' % IP_SETTING['server2'])
clintf = client.defaultIntf()
clintf.setIP('%s/8' % IP_SETTING['client'])
for host in server1, server2, client:
set_default_route(host)
starthttp( server1 )
starthttp( server2 )
CLI( net )
stophttp()
net.stop()
示例3: simpleTest
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import stop [as 别名]
def simpleTest():
"Create and test a simple network"
topo = DiamondTopo(k=4)
net = Mininet(topo=topo,link=TCLink,controller=RemoteController)
if args.sim!=1:
print "Adding real interfaces"
s1 = net.getNodeByName('s1')
s3 = net.getNodeByName('s3')
addRealIntf(net,args.intf1,s1)
addRealIntf(net,args.intf2,s3)
opts = '-D -o UseDNS=no -u0'
rootnode=sshd(net, opts=opts)
h2 = net.getNodeByName('h2')
h2.cmd('iperf -s -p 5001 -i 1 > iperf-recv_TCP.txt &')
h2.cmd('iperf -s -p 5003 -u -i 1 > iperf-recv_UDP.txt &')
else:
net.start()
CLI(net)
os.system('killall -9 iperf' )
if args.sim!=1:
net.hosts[0].cmd('killall -9 dhcpd')
for host in net.hosts:
host.cmd('kill %'+ '/usr/sbin/sshd')
stopNAT(rootnode)
net.stop()
示例4: setupNetwork
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import stop [as 别名]
def setupNetwork():
"Create network"
topo = MyTopo()
network = Mininet(topo=topo, autoSetMacs=True, controller=None)
network.start()
CLI( network )
network.stop()
示例5: output
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import stop [as 别名]
def output(partIdx):
"""Uses the student code to compute the output for test cases."""
outputString = ""
if partIdx == 0: # This is agPA2
"Set up link parameters"
print "a. Setting link parameters"
"--- core to aggregation switches"
linkopts1 = {"bw": 50, "delay": "5ms"}
"--- aggregation to edge switches"
linkopts2 = {"bw": 30, "delay": "10ms"}
"--- edge switches to hosts"
linkopts3 = {"bw": 10, "delay": "15ms"}
"Creating network and run simple performance test"
print "b. Creating Custom Topology"
topo = CustomTopo(linkopts1, linkopts2, linkopts3, fanout=3)
print "c. Firing up Mininet"
net = Mininet(topo=topo, link=TCLink)
net.start()
h1 = net.get("h1")
h27 = net.get("h27")
print "d. Starting Test"
# Start pings
outputString = h1.cmd("ping", "-c6", h27.IP())
print "e. Stopping Mininet"
net.stop()
return outputString.strip()
示例6: main
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import stop [as 别名]
def main():
net = Mininet(controller=None)
# add hosts
h1 = net.addHost("h1", ip="172.16.10.1/24")
h2 = net.addHost("h2", ip="172.16.10.2/24")
# add switch 1
sw1 = net.addSwitch("sw1", target_name="p4dockerswitch", cls=P4DockerSwitch, sai_port=25000, pcap_dump=True)
# add switch 2
sw2 = net.addSwitch("sw2", target_name="p4dockerswitch", cls=P4DockerSwitch, sai_port=25001, pcap_dump=True)
# add links
if StrictVersion(VERSION) <= StrictVersion("2.2.0"):
net.addLink(sw1, h1, port1=1)
net.addLink(sw1, sw2, port1=2, port2=2)
net.addLink(sw2, h2, port1=1)
else:
net.addLink(sw1, h1, port1=1, fast=False)
net.addLink(sw1, sw2, port1=2, port2=2, fast=False)
net.addLink(sw2, h2, port1=1, fast=False)
net.start()
print "Waiting 10 seconds for switches to intialize..."
time.sleep(10)
cfg_switch1()
cfg_switch2()
CLI(net)
net.stop()
示例7: multiSwitchTest
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import stop [as 别名]
def multiSwitchTest():
topo = MultiSwitchTopo(depth=2, fanout=4)
#net = Mininet(topo, controller=OVSController)
net = Mininet(topo, controller=lambda name: RemoteController(name, ip='192.168.56.1'))
net.start()
print "Dumping host connections"
dumpNodeConnections(net.hosts)
print "Testing network connectivity"
net.pingAll()
receivers = ["00:11:22:33:44:00",
"00:11:22:33:44:04",
"00:11:22:33:44:08",
"00:11:22:33:44:0c"]
for host in net.hosts:
if host.defaultIntf().MAC() in receivers:
startLogReceiver(host)
else:
startLogSender(host)
for host in net.hosts:
if not (host.defaultIntf().MAC() in receivers):
runGenerator(host)
for host in net.hosts:
if host.defaultIntf().MAC() in receivers:
stopLogReceiver(host)
else:
stopLogSender(host)
net.stop()
示例8: bufferbloat
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import stop [as 别名]
def bufferbloat(**kwargs):
# Linux uses CUBIC-TCP by default that doesn't have the usual sawtooth
# behaviour. For those who are curious, replace reno with cubic
# see what happens...
# sysctl -a | grep cong should list some interesting parameters.
os.system("sysctl -w net.ipv4.tcp_congestion_control=reno")
# create the topology and network
topo = BBTopo(int(kwargs['queue_size']), int(kwargs['ping_RTT']))
net = Mininet(topo=topo, host=CPULimitedHost, link=TCLink, controller= OVSController)
net.start()
# This dumps the topology and how nodes are interconnected through
# links.
dumpNodeConnections(net.hosts)
# This performs a basic all pairs ping test.
net.pingAll()
# Start all the monitoring processes
start_tcpprobe("cwnd.txt")
# TODO: Start monitoring the queue sizes. Since the switch I
# created is "s0", I monitor one of the interfaces. Which
# interface? The interface numbering starts with 1 and increases.
# Depending on the order you add links to your network, this
# number may be 1 or 2. Ensure you use the correct number.
# qmon = start_qmon(...)
qmon = start_qmon(iface='s0-eth2', outfile='%s/q.txt' % ".")
# TODO: Start iperf, pings, and the webserver.
# start_iperf(net), ...
start_iperf(net, kwargs['congestion_window'])
start_webserver(net)
start_ping(net)
# TODO: measure the time it takes to complete webpage transfer
# from h1 to h2 (say) 4-5 times. Hint: check what the following
# command does: curl -o /dev/null -s -w %{time_total} google.com
# Now use the curl command to fetch webpage from the webserver you
# spawned on host h1 (not from google!)
print "starting timing tester"
timing_results = timing_tester(net)
# TODO: compute average (and standard deviation) of the fetch
# times. You don't need to plot them. Just print them
# here and explain your observations in the Questions part
# in Part 2, where you analyze your measurements.
print timing_results[0]
print "Ave fetching time: %.4f" % numpy.average(numpy.array(timing_results).astype(numpy.float))
print "std dev. of fetching times: %.4f" % numpy.std(numpy.array(timing_results).astype(numpy.float))
# Stop probing
stop_tcpprobe()
qmon.terminate()
net.stop()
# Ensure that all processes you create within Mininet are killed.
# Sometimes they require manual killing.
Popen("pgrep -f webserver.py | xargs kill -9", shell=True).wait()
示例9: main
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import stop [as 别名]
def main():
# All b/w are in megabits
max_bw = 1000
# B/w of queue 1 and queue 2
values = [3,1,4]
topo = MyTopo(max_bw)
net = Mininet(topo, link = TCLink, controller = partial(RemoteController, ip = '127.0.0.1', port = 6633))
net.start()
# Queue set in between h1 and s1
cmd = 'ovs-vsctl -- set Port s2-eth4 [email protected] -- \
[email protected] create QoS type=linux-htb other-config:max-rate=1000000000 [email protected],[email protected],[email protected],[email protected] -- \
[email protected] create Queue other-config:min-rate=%d other-config:max-rate=%d -- \
[email protected] create Queue other-config:min-rate=%d other-config:max-rate=%d -- \
[email protected] create Queue other-config:min-rate=%d other-config:max-rate=%d -- \
[email protected] create Queue other-config:min-rate=%d other-config:max-rate=%d' % \
(max_bw * 10**6, max_bw * 10**6, \
values[0] * 10**6, values[0] * 10**6, \
values[1] * 10**6, values[1] * 10**6, \
values[2] * 10**6, values[2] * 10**6)
sp.call(cmd, shell = True)
CLI(net)
net.stop()
示例10: emptyNet
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import stop [as 别名]
def emptyNet():
"Create an empty network and add nodes to it."
net = Mininet( topo=None,
build=False)
net.addController( 'c0',
controller=RemoteController,
ip='0.0.0.0' )
h1 = net.addHost( 'h1', ip='10.0.0.1' )
h2 = net.addHost( 'h2', ip='10.0.0.2' )
h3 = net.addHost( 'h3', ip='10.0.0.3' )
s1 = net.addSwitch( 's1', cls=OVSSwitch )
net.addLink( h1, s1 )
net.addLink( h2, s1 )
net.addLink( h3, s1 )
net.start()
s1.cmd('ifconfig s1 inet 10.0.0.10')
CLI( net )
net.stop()
示例11: perfTest
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import stop [as 别名]
def perfTest():
topo = crazy_switches()
net = Mininet(topo=topo, controller=lambda name: RemoteController( 'c0', '127.0.0.1' ),
host=CPULimitedHost, link=TCLink)
net.start()
CLI(net)
net.stop()
示例12: run_cellsim_topology
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import stop [as 别名]
def run_cellsim_topology():
print_welcome_message()
os.system( "killall -q controller" )
os.system( "killall -q cellsim" )
os.system( "killall -q mysender" )
os.system( "killall -q myreceiver" )
topo = ProtoTester()
net = Mininet(topo=topo, host=Host, link=Link)
net.start()
sender = net.getNodeByName('sender')
LTE = net.getNodeByName('LTE')
receiver = net.getNodeByName('receiver')
set_all_IP(net, sender, LTE, receiver)
#Dump connections
#dumpNodeConnections(net.hosts)
#display_routes(net, sender, LTE, receiver)
#run_cellsim(LTE)
run_datagrump(sender, receiver)
run_cellsim(LTE)
# CLI(net)
net.stop()
示例13: test
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import stop [as 别名]
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()
示例14: myNet
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import stop [as 别名]
def myNet():
#OpenDayLight controller
CONTROLLER1_IP='127.0.0.1'
#Floodlight controller
net = Mininet( topo=None, build=False)
# Create nodes
h1 = net.addHost( 'h1', mac='01:00:00:00:01:00', ip='192.168.0.1/24' )
# Create switches
s1 = net.addSwitch( 's1', listenPort=6634, mac='00:00:00:00:00:01' )
print "*** Creating links"
net.addLink(h1, s1 )
# Add Controllers
c0 = net.addController( 'c0', controller=RemoteController, ip=CONTROLLER1_IP, port=6633)
net.build()
# Connect each switch to a different controller
s1.start([c0])
s1.cmdPrint('ovs-vsctl show')
CLI( net )
net.stop()
示例15: sdnnet
# 需要导入模块: from mininet.net import Mininet [as 别名]
# 或者: from mininet.net.Mininet import stop [as 别名]
def sdnnet(opt):
topo = SDNTopo()
info( '*** Creating network\n' )
net = Mininet( topo=topo, controller=MyController, link=TCLink)
host = []
for i in range (8):
host.append(net.get( 'host%d' % i ))
net.start()
core_sw = []
for i in range (2):
name_suffix = '%s' % NWID + '0c' + '%02d' % i
net.get('sw' + name_suffix).attach('tap%s0' % NWID)
for i in range (8):
host[i].defaultIntf().setIP('192.168.10.10%d/24' % i)
root = []
for i in range (8):
root.append(net.get( 'root%d' % i ))
for i in range (8):
host[i].intf('host%d-eth1' % i).setIP('1.1.%d.1/24' % i)
root[i].intf('root%d-eth0' % i).setIP('1.1.%d.2/24' % i)
stopsshd ()
startsshds ( host )
if opt=="cli":
CLI(net)
stopsshd()
net.stop()