一、基础要求
1.搭建拓扑
这里是代码
#! /usr/bin/python
from mininet.net import Mininet
from mininet.node import Controller,RemoteController,OVSController
from mininet.node import CPULimitedHost, Host, Node
from mininet.node import OVSKernelSwitch, UserSwitch
from mininet.node import IVSSwitch
from mininet.cli import CLI
from mininet.log import setLogLevel, info
from subprocess import call
def Lab3():
net = Mininet( topo=None,
build=False,
ipBase='192.168.0.0/24')
info( ' *** Add Controller *** \n')
c0 = net.addController( name = 'c0',
controller = Controller,
protocol = 'tcp',
port = 6633 )
info( ' *** Add Swithc *** \n')
s1 = net.addSwitch( 's1', cls=OVSKernelSwitch)
s2 = net.addSwitch( 's2', cls=OVSKernelSwitch)
info( ' *** Add Host *** \n')
h1 = net.addHost( 'h1', cls = Host, ip = '192.168.0.101',defaultRoute = None)
h2 = net.addHost( 'h2', cls = Host, ip = '192.168.0.102',defaultRoute = None)
h3 = net.addHost( 'h3', cls = Host, ip = '192.168.0.103',defaultRoute = None)
h4 = net.addHost( 'h4', cls = Host, ip = '192.168.0.104',defaultRoute = None)
info( ' *** Add Links *** \n')
net.addLink(s1,h1)
net.addLink(s1,h2)
net.addLink(s2,h3)
net.addLink(s2,h4)
net.addLink(s1,s2)
info( ' *** Staring NetWork *** \n')
net.build()
info( ' *** Staring Controllers *** \n')
c0.start()
info( ' *** Staring Switches *** \n')
s1.start([c0])
s2.start([c0])
info( ' *** Post Configure Switch and Hosts *** \n')
CLI(net)
net.stop()
if __name__ == '__main__' :
setLogLevel( 'info' )
Lab3()
2.查看并分析抓包信息
|name | 价格 | 数量 | |-|-|-| 香蕉 | $1 | 5 | 苹果 | $1 | 6 | 草莓 | $1 | 7 | 标签:info,mininet,OpenFlow,实践,Host,实验,import,net,cls From: https://www.cnblogs.com/Blog1520338630/p/16747438.html