本文整理汇总了Python中mininet.log.info函数的典型用法代码示例。如果您正苦于以下问题:Python info函数的具体用法?Python info怎么用?Python info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了info函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: bwtest
def bwtest(cpuLimits, period_us=100000, seconds=5):
"""Example/test of link and CPU bandwidth limits
cpu: cpu limit as fraction of overall CPU time"""
topo = TreeTopo(depth=1, fanout=2)
results = {}
for sched in "rt", "cfs":
print "*** Testing with", sched, "bandwidth limiting"
for cpu in cpuLimits:
host = custom(CPULimitedHost, sched=sched, period_us=period_us, cpu=cpu)
try:
net = Mininet(topo=topo, host=host)
except:
info("*** Skipping host %s\n" % sched)
break
net.start()
net.pingAll()
hosts = [net.getNodeByName(h) for h in topo.hosts()]
client, server = hosts[0], hosts[-1]
server.cmd("iperf -s -p 5001 &")
waitListening(client, server, 5001)
result = client.cmd("iperf -yc -t %s -c %s" % (seconds, server.IP())).split(",")
bps = float(result[-1])
server.cmdPrint("kill %iperf")
net.stop()
updated = results.get(sched, [])
updated += [(cpu, bps)]
results[sched] = updated
return results
示例2: start_oe
def start_oe(self):
'''
start the existing LINC switch
'''
#starting Switch
cmd = "linc:start_switch({}).\r\n".format(self.lincId)
self.write_to_cli(cmd)
#hanlding taps interfaces related to the switch
crossConnectJSON = {}
linkConfig = []
for i in range(0,len(self.deletedCrossConnects)):
crossConnect = self.deletedCrossConnects.pop()
tap = None
if isinstance(crossConnect.intf1.node, LINCSwitch):
intf = crossConnect.intf2
tapPort = crossConnect.intf1.port
else:
intf = crossConnect.intf1
tapPort = crossConnect.intf2.port
tap = LINCSwitch.findTap(self, tapPort)
if tap:
LINCSwitch.setupInts([tap])
intf.node.attach(tap)
self.crossConnects.append(crossConnect)
linkConfig.append(crossConnect.json())
#Sending crossConnect info to the ONOS.
crossConnectJSON['links'] = linkConfig
with open("crossConnect.json", 'w') as fd:
json.dump(crossConnectJSON, fd, indent=4, separators=(',', ': '))
info('*** Pushing crossConnect.json to ONOS\n')
output = quietRun('%s/tools/test/bin/onos-topo-cfg %s\
Topology.json' % (self.onosDir, self.controllers[ 0 ].ip), shell=True)
示例3: host3
def host3(net):
info('Configuring host 3\n')
host = net.getNodeByName('h3')
host.setMAC('00:00:00:00:01:03')
gw('LAN',host)
#apagar = raw_input('Deseja zerar arquivos de log do IDS? sim|nao (um backup sera feito)\n')
ids(host, 'sim')
示例4: sdnnet
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()
示例5: sdnTopo
def sdnTopo(interface_name):
CONTROLLER_IP='10.0.0.200'
net = Mininet( topo=None, build=False)
# Create nodes
h1 = net.addHost( 'h1', ip='10.0.0.1/8' )
h2 = net.addHost( 'h2', ip='10.0.0.2/8' )
# Create switches
s1 = net.addSwitch( 's1')
net.addLink(h1, s1, )
net.addLink(h2, s1, )
# Add Controllers
odl_ctrl = net.addController( 'c0', controller=RemoteController, ip=CONTROLLER_IP)
info( "*** Creation de l'architecture réseau\n" )
net.build()
# Connect each switch to a different controller
s1.start( [odl_ctrl] )
info( "*** Ajout de l'interface",interface_name,"au switch" )
_intf = Intf( interface_name, node=s1)
net.start()
CLI( net )
net.stop()
示例6: run
def run(self, test, *args, **kwargs):
"Perform a complete start/test/stop cycle."
self.start()
info("*** Running test\n")
result = test(*args, **kwargs)
self.stop()
return result
示例7: __init__
def __init__( self, mininet, stdin=sys.stdin, script=None ):
self.mn = mininet
self.nodelist = self.mn.controllers + self.mn.switches + self.mn.hosts
self.nodemap = {} # map names to Node objects
for node in self.nodelist:
self.nodemap[ node.name ] = node
# Attempt to handle input
self.stdin = stdin
self.inPoller = poll()
self.inPoller.register( stdin )
self.inputFile = script
Cmd.__init__( self )
info( '*** Starting CLI:\n' )
if self.inputFile:
self.do_source( self.inputFile )
return
while True:
try:
# Make sure no nodes are still waiting
for node in self.nodelist:
while node.waiting:
node.sendInt()
node.monitor()
if self.isatty():
quietRun( 'stty sane' )
self.cmdloop()
break
except KeyboardInterrupt:
output( '\nInterrupt\n' )
示例8: run
def run (self):
setLogLevel("info")
OVSKernelSwitch.setup()#"Make sure Open vSwitch is installed and working"
info("****creating network****\n")
self.net = Mininet(listenPort = 6666)
controller = RemoteController("mirrorController", ip = "127.0.0.1")
self.net.addController(controller)
while core.running:
try:
time.sleep(3)
if not core.running: break
'''
self.net.pingAll()
if len(self.addswitches)!=0:
for i in self.addswitches:
print self.addswitches[i].dpctl('show')
'''
if self.rectopolyreply==1:
mutex.acquire()
self.createtoptly()
self.rectopolyreply=0
mutex.release()
except exceptions.KeyboardInterrupt:
break
except:
log.exception("Exception SendMes running ")
break
self.net.stop()
示例9: waitListening
def waitListening( client=None, server='127.0.0.1', port=80, timeout=None ):
"""Wait until server is listening on port.
returns True if server is listening"""
runCmd = ( client.cmd if client else
partial( quietRun, shell=True ) )
if not runCmd( 'which telnet' ):
raise Exception('Could not find telnet' )
# pylint: disable=maybe-no-member
serverIP = server if isinstance( server, basestring ) else server.IP()
cmd = ( 'echo A | telnet -e A %s %s' % ( serverIP, port ) )
time = 0
result = runCmd( cmd )
while 'Connected' not in result:
if 'No route' in result:
rtable = runCmd( 'route' )
error( 'no route to %s:\n%s' % ( server, rtable ) )
return False
if timeout and time >= timeout:
error( 'could not connect to %s on port %d\n' % ( server, port ) )
return False
debug( 'waiting for', server, 'to listen on port', port, '\n' )
info( '.' )
sleep( .5 )
time += .5
result = runCmd( cmd )
return True
示例10: test_ping_with_background_traffice
def test_ping_with_background_traffice(network, round_count=1, round_duration=5, ping_interval=1.0, background=True):
"""
h1 执行 ping 测试延时
h2 执行 netperf 测试带宽利用率
:param background:
:param network: mininet class
:param round_count: 循环次数
:param round_duration: 循环时间每轮
:param ping_interval: ping包采样间隔
:return:
"""
result = ""
h1 = network.get("h1")
popens = {}
if background: # backgroud traffice, 每轮增加10秒时延
h1.cmd("netperf -H h3 -l %s &" % (round_count * (round_duration + 5)))
sleep(3) # wait 2 second to reach tcp max output
for r in range(round_count):
print ("*** ROUND %s" % r)
for h in [h1]:
ping_cmd = "ping -c%s -i%s h3 " % (int(round_duration / ping_interval), ping_interval)
info("<%s>: popen cmd: %s \n" % (h.name, ping_cmd))
popens[h] = h.popen(ping_cmd)
# Monitor them and print output
for host, line in pmonitor(popens):
if host:
if line.find("icmp_seq") != -1:
debug("<%s>: %s\n" % (host.name, line.strip())) # suppressed ping output to debug level
else:
info("<%s>: %s\n" % (host.name, line.strip()))
result += "<%s>: %s\n" % (host.name, line.strip())
debug("\n".join(os.popen('tc -s -d qdisc show dev s1-eth3').readlines()))
return result
示例11: test01_04_ecn_red
def test01_04_ecn_red(network, bw=10, latency=50, qlen=200, duration=10):
"""
测试结果记录在 ecn_result/2016-06-28_ecn_red.txt
# 设置 使用 red ecn 以及不使用, 并使用 mesure_delay_and_output() 测试
:param network:
:param bw: # 10Mbps 带宽
:param latency: # 50ms 延时
:param qlen: # 队列长度
:param duration: # 运行时间
:return:
"""
# print_mininet_objs(net)
result_all = {}
# result_all dict 追加入01 结果
result_all.update(test01_base(network, "TEST01", bw=bw, latency=latency, qlen=qlen, duration=duration))
# result_all dict 追加入03 04 05 结果
for testname, redminmax in zip(["TEST02", "TEST03", "TEST04"],
["min 50000 max 150000 avpkt 1500",
"min 65000 max 150000 avpkt 1500",
"min 75000 max 150000 avpkt 1500"
]):
# result_all = result1.copy()
# if testname == "TEST02": continue
result_all.update(
test02_04_base_ecn_red(network, testname, redminmax, bw=bw, latency=latency, qlen=qlen, duration=duration))
info("\n\n\n*** all result here ***\n\n\b")
ecn_util.dump_result(result_all)
return result_all
示例12: test02_04_base_ecn_red
def test02_04_base_ecn_red(network, testname, redminmax, bw=10, latency=50, qlen=200, duration=10):
"""
独立复制出的 03 04 实验, 用于enc抓包测试
:param redminmax: # red参数设置
:param testname: # 测试名称
:param network:
:param bw:
:param latency:
:param qlen:
:param duration:
:return:
"""
result = {}
def run_this_bench():
return ecn_util.mesure_ping_and_netperf(network, round_count=1, round_duration=duration, ping_interval=0.1)
# ecn 参数变化测试 02 03 04
testfullname = "%s ECN:%s qlen:%s bw:%sMbps lat:%sms redminmax:%s" % (
testname, True, qlen, bw, latency, redminmax)
info("*** setup %s \n" % testfullname)
test01_06_setup_queue_and_latency(network, ecn=True, bw=bw, queue_len=qlen, latency=latency,
redminmax=redminmax)
info("*** running %s ...\n" % testfullname)
result[testfullname] = run_this_bench()
ecn_util.dump_result(result)
return result
示例13: test01_base
def test01_base(network, testname, bw=10, latency=50, qlen=200, duration=10):
"""
# 设置 使用 red ecn 以及不使用, 并使用 mesure_delay_and_output() 测试
:param testname: # 测试名称
:param network:
:param bw: # 10Mbps 带宽
:param latency: # 50ms 延时
:param qlen: # 队列长度
:param duration: # 运行时间
:return:
"""
# print_mininet_objs(net)
result = {}
red_ecn = False
def run_this_bench():
return ecn_util.mesure_ping_and_netperf(network, round_count=1, round_duration=duration, ping_interval=0.1)
# 无ecn测试 TEST01
default_minmax = ""
testfullname = "%s ECN:%s qlen:%s bw:%sMbps lat:%sms no red:%s" % (
testname, red_ecn, qlen, bw, latency, "")
info("*** setup %s\n" % testfullname)
test01_06_setup_queue_and_latency(network, ecn=red_ecn, bw=bw, queue_len=qlen, latency=latency,
redminmax=default_minmax)
info("*** running %s ...\n" % testfullname)
result[testfullname] = run_this_bench()
ecn_util.dump_result(result)
return result
示例14: assign_iface
def assign_iface(cls, nodes, phys, **params):
"""Assign virtual interfaces for all nodes
:param nodes: list of wireless nodes
:param phys: list of phys
:param **params: ifb - Intermediate Functional Block device"""
log_filename = '/tmp/mininetwifi-fakelb.log'
cls.logging_to_file("%s" % log_filename)
try:
debug("\n*** Configuring interfaces with appropriated network"
"-namespaces...\n")
for node in nodes:
for wlan in range(0, len(node.params['wpan'])):
node.wpanPhyID[wlan] = cls.wpanPhyID
cls.wpanPhyID += 1
phy = cls.getPhy(phys[0])
os.system('iwpan phy phy%s set netns %s' % (phy, node.pid))
node.cmd('ip link set %s down' % cls.wlan_list[0])
node.cmd('ip link set %s name %s'
% (cls.wlan_list[0], node.params['wpan'][wlan]))
cls.wlan_list.pop(0)
except:
logging.exception("Warning:")
info("Warning! Error when loading fakelb. "
"Please run sudo 'mn -c' before running your code.\n")
info("Further information available at %s.\n" % log_filename)
exit(1)
示例15: moduleDeps
def moduleDeps( subtract=None, add=None ):
"""Handle module dependencies.
subtract: string or list of module names to remove, if already loaded
add: string or list of module names to add, if not already loaded"""
subtract = subtract if subtract is not None else []
add = add if add is not None else []
if type( subtract ) is str:
subtract = [ subtract ]
if type( add ) is str:
add = [ add ]
for mod in subtract:
if mod in lsmod():
info( '*** Removing ' + mod + '\n' )
rmmodOutput = rmmod( mod )
if rmmodOutput:
error( 'Error removing ' + mod + ': "%s">\n' % rmmodOutput )
exit( 1 )
if mod in lsmod():
error( 'Failed to remove ' + mod + '; still there!\n' )
exit( 1 )
for mod in add:
if mod not in lsmod():
info( '*** Loading ' + mod + '\n' )
modprobeOutput = modprobe( mod )
if modprobeOutput:
error( 'Error inserting ' + mod +
' - is it installed and available via modprobe?\n' +
'Error was: "%s"\n' % modprobeOutput )
if mod not in lsmod():
error( 'Failed to insert ' + mod + ' - quitting.\n' )
exit( 1 )
else:
debug( '*** ' + mod + ' already loaded\n' )