本文整理汇总了Python中mininet.cli.CLI属性的典型用法代码示例。如果您正苦于以下问题:Python cli.CLI属性的具体用法?Python cli.CLI怎么用?Python cli.CLI使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类mininet.cli
的用法示例。
在下文中一共展示了cli.CLI属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_POXAntiArpPoison
# 需要导入模块: from mininet import cli [as 别名]
# 或者: from mininet.cli import CLI [as 别名]
def test_POXAntiArpPoison():
"""TODO Test AntiArpPoison controller."""
topo = L3EthStar()
controller = POXAntiArpPoison
net = Mininet(
topo=topo,
controller=controller,
link=TCLink, listenPort=OF_MISC['switch_debug_port'])
net.start()
time.sleep(1) # allow mininet to init processes
plc1, plc2, plc3 = net.get('plc1', 'plc2', 'plc3')
target_ip1 = plc2.IP()
target_ip2 = plc3.IP()
attacker_interface = 'plc1-eth0'
# plc1_cmd = 'scripts/attacks/arp-mitm.sh %s %s %s' % ( target_ip1,
# target_ip2, attacker_interface)
# plc1.cmd(plc1_cmd)
CLI(net)
net.stop()
示例2: test_POXL2Pairs
# 需要导入模块: from mininet import cli [as 别名]
# 或者: from mininet.cli import CLI [as 别名]
def test_POXL2Pairs():
"""Test build-in forwarding.l2_pairs controller
that adds flow entries using only MAC info.
"""
topo = L3EthStar()
controller = POXL2Pairs
net = Mininet(
topo=topo,
controller=controller,
link=TCLink, listenPort=OF_MISC['switch_debug_port'])
net.start()
CLI(net)
net.stop()
示例3: test_RemoteController
# 需要导入模块: from mininet import cli [as 别名]
# 或者: from mininet.cli import CLI [as 别名]
def test_RemoteController():
"""Test L3EthStar with a remote controller
eg: pox controller
"""
topo = L3EthStarAttack()
net = Mininet(
topo=topo,
controller=None,
link=TCLink, listenPort=OF_MISC['switch_debug_port'])
net.addController(
'c0',
controller=RemoteController,
ip='127.0.0.1',
port=OF_MISC['controller_port'])
net.start()
CLI(net)
net.stop()
示例4: test_POXL2PairsRtt
# 需要导入模块: from mininet import cli [as 别名]
# 或者: from mininet.cli import CLI [as 别名]
def test_POXL2PairsRtt():
"""Test build-in forwarding.l2_pairs controller RTT
that adds flow entries using only MAC info.
"""
topo = L3EthStar()
controller = POXL2Pairs
net = Mininet(
topo=topo,
controller=controller,
link=TCLink, listenPort=OF_MISC['switch_debug_port'])
net.start()
time.sleep(1) # allow mininet to init processes
deltas = []
for i in range(5):
first_rtt, second_rtt = _arp_cache_rtts(net, 'plc1', 'plc2')
assert_greater(
first_rtt, second_rtt,
c.ASSERTION_ERRORS['no_learning'])
deltas.append(first_rtt - second_rtt)
# CLI(net)
net.stop()
示例5: test_POXL2LearningRtt
# 需要导入模块: from mininet import cli [as 别名]
# 或者: from mininet.cli import CLI [as 别名]
def test_POXL2LearningRtt():
"""Test build-in forwarding.l2_learning controller RTT
that adds flow entries using only MAC info.
"""
topo = L3EthStar()
controller = POXL2Learning
net = Mininet(
topo=topo,
controller=controller,
link=TCLink, listenPort=OF_MISC['switch_debug_port'])
net.start()
time.sleep(1) # allow mininet to init processes
deltas = []
for i in range(5):
first_rtt, second_rtt = _arp_cache_rtts(net, 'plc1', 'plc2')
assert_greater(
first_rtt, second_rtt,
c.ASSERTION_ERRORS['no_learning'])
deltas.append(first_rtt - second_rtt)
# CLI(net)
net.stop()
示例6: __init__
# 需要导入模块: from mininet import cli [as 别名]
# 或者: from mininet.cli import CLI [as 别名]
def __init__(self, mininet, stdin=sys.stdin, script=None):
"""Start and run interactive or batch mode CLI
mininet: Mininet network object
stdin: standard input for CLI
script: script to run in batch mode"""
self.mn = mininet
# Local variable bindings for py command
self.locals = {'net': mininet}
# Attempt to handle input
self.stdin = stdin
self.inPoller = poll()
self.inPoller.register(stdin)
self.inputFile = script
Cmd.__init__(self, stdin=self.stdin)
lg.info('*** Starting CLI:\n')
if self.inputFile:
self.do_source(self.inputFile)
return
self.initReadline()
self.run()
示例7: test_MininetTopoFromNxGraph
# 需要导入模块: from mininet import cli [as 别名]
# 或者: from mininet.cli import CLI [as 别名]
def test_MininetTopoFromNxGraph():
graph = build_nx_graph()
# Build a test graph
topo = MininetTopoFromNxGraph(graph)
net = Mininet(topo=topo, link=TCLink, listenPort=6634)
net.start()
print
net.pingAll()
# CLI(net)
net.stop()
示例8: test_L3EthStarBuild
# 需要导入模块: from mininet import cli [as 别名]
# 或者: from mininet.cli import CLI [as 别名]
def test_L3EthStarBuild():
"""Test L3EthStar build process with custom L3_LINKOPTS"""
topo = L3EthStar()
net = Mininet(
topo=topo, link=TCLink,
listenPort=OF_MISC['switch_debug_port'])
net.start()
CLI(net)
net.stop()
示例9: test_L3EthStarArpMitm
# 需要导入模块: from mininet import cli [as 别名]
# 或者: from mininet.cli import CLI [as 别名]
def test_L3EthStarArpMitm():
"""plc1 ARP poisoning MITM attack using ettercap,
You can pass IP target to the dedicated script.
"""
open(TEMP_DIR + '/l3/plc1arppoisoning.out', 'w').close()
topo = L3EthStar()
net = Mininet(
topo=topo, link=TCLink,
listenPort=OF_MISC['switch_debug_port'])
net.start()
plc1, plc2, plc3 = net.get('plc1', 'plc2', 'plc3')
target_ip1 = plc2.IP()
target_ip2 = plc3.IP()
attacker_interface = 'plc1-eth0'
plc1_cmd = 'scripts/attacks/arp-mitm.sh %s %s %s' % (
target_ip1,
target_ip2, attacker_interface)
plc1.cmd(plc1_cmd)
plc2_cmd = 'ping -c5 %s' % plc3.IP()
plc2.cmd(plc2_cmd)
plc1.cmd('tcpdump &')
# CLI(net)
net.stop()
示例10: test_Workshop
# 需要导入模块: from mininet import cli [as 别名]
# 或者: from mininet.cli import CLI [as 别名]
def test_Workshop():
"""Ideal link double MITM"""
topo = L3EthStarAttack()
net = Mininet(
topo=topo, link=TCLink,
listenPort=OF_MISC['switch_debug_port'])
net.start()
plc1, attacker, hmi = net.get('plc1', 'attacker', 'hmi')
plc2, plc3, plc4 = net.get('plc2', 'plc3', 'plc4')
CLI(net)
# PASSIVE remote ARP poisoning
target_ip1 = plc1.IP()
target_ip2 = hmi.IP()
attacker_interface = 'attacker-eth0'
attacker_cmd = 'scripts/attacks/arp-mitm.sh %s %s %s &' % (
target_ip1,
target_ip2,
attacker_interface)
attacker.cmd(attacker_cmd)
target_ip1 = plc3.IP()
target_ip2 = plc4.IP()
attacker_interface = 'plc2-eth0'
attacker_cmd = 'scripts/attacks/arp-mitm.sh %s %s %s &' % (
target_ip1,
target_ip2,
attacker_interface)
plc2.cmd(attacker_cmd)
CLI(net)
net.stop()
示例11: cli_net
# 需要导入模块: from mininet import cli [as 别名]
# 或者: from mininet.cli import CLI [as 别名]
def cli_net(self):
return CLI(self.net)
示例12: default
# 需要导入模块: from mininet import cli [as 别名]
# 或者: from mininet.cli import CLI [as 别名]
def default(self, line: str):
"""Called on an input line when the command prefix is not recognized.
Overridden to run shell commands when a node is the first CLI argument.
Past the first CLI argument, node names are automatically replaced with
corresponding addresses if possible.
We select only one IP version for these automatic replacements.
The chosen IP version chosen is first restricted by the addresses
available on the first node.
Then, we choose the IP version that enables every replacement.
We use IPv4 as a tie-break."""
first, args, line = self.parseline(line)
if first in self.mn:
if not args:
lg.error("*** Enter a command for node: %s <cmd>" % first)
return
node = self.mn[first]
rest = args.split(' ')
hops = [h for h in rest if h in self.mn]
v4_support, v6_support = address_pair(self.mn[first])
v4_map = {}
v6_map = {}
for hop in hops:
ip, ip6 = address_pair(self.mn[hop],
v4_support is not None,
v6_support is not None)
if ip is not None:
v4_map[hop] = ip
if ip6 is not None:
v6_map[hop] = ip6
ip_map = v4_map if len(v4_map) >= len(v6_map) else v6_map
node.sendCmd(' '.join([ip_map.get(r, r) for r in rest]))
self.waitForNode(node)
else:
lg.error('*** Unknown command: %s\n' % line)
示例13: CLI
# 需要导入模块: from mininet import cli [as 别名]
# 或者: from mininet.cli import CLI [as 别名]
def CLI(self):
CLI(self)
示例14: parseArgs
# 需要导入模块: from mininet import cli [as 别名]
# 或者: from mininet.cli import CLI [as 别名]
def parseArgs( self ):
"""Parse command-line args and return options object.
returns: opts parse options dict"""
if '--custom' in sys.argv:
index = sys.argv.index( '--custom' )
if len( sys.argv ) > index + 1:
filename = sys.argv[ index + 1 ]
self.parseCustomFile( filename )
else:
raise Exception( 'Custom file name not found' )
desc = ( "The %prog utility creates Mininet network from the\n"
"command line. It can create parametrized topologies,\n"
"invoke the Mininet CLI, and run tests." )
usage = ( '%prog [options]\n'
'(type %prog -h for details)' )
opts = OptionParser( description=desc, usage=usage )
addDictOption( opts, TOPOS, TOPODEF, 'topo' )
addDictOption( opts, LINKS, LINKDEF, 'link' )
opts.add_option( '--custom', type='string', default=None,
help='read custom topo and node params from .py' +
'file' )
self.options, self.args = opts.parse_args()
# We don't accept extra arguments after the options
if self.args:
opts.print_help()
exit()
开发者ID:PacktPublishing,项目名称:Python-Network-Programming-Cookbook-Second-Edition,代码行数:35,代码来源:miniedit.py
示例15: execute
# 需要导入模块: from mininet import cli [as 别名]
# 或者: from mininet.cli import CLI [as 别名]
def execute():
# Create Mininet instance.
net = Mininet()
# Add the SDN controller to the network.
c1 = net.addController(name='c1', controller=RemoteController,
ip='127.0.0.1')
# Add hosts to the network.
h0=net.addHost('h0')
h1=net.addHost('h1')
# Add switches to the network.
s0=net.addSwitch('s0')
s1=net.addSwitch('s1')
s2=net.addSwitch('s2')
# Creating links between the switches in the network
net.addLink(s0, s1)
net.addLink(s1, s2)
net.addLink(s0, s2)
# Connect hosts to the relevant switches in the network.
net.addLink(h0, s0)
net.addLink(h1, s1)
# Start execution.
net.start()
CLI( net )
开发者ID:PacktPublishing,项目名称:Python-Network-Programming-Cookbook-Second-Edition,代码行数:33,代码来源:10_2_sdn_opendaylight.py