创建拓扑,参考一下代码和“OpenDaylight二层转发机制实验”链接

cuili@cuili-OptiPlex-3020:~$ cd /home/cuili/mininet
cuili@cuili-OptiPlex-3020:~/mininet$ ls
bin           custom  doc       LICENSE   mininet.egg-info  mnexec.1   setup.py
build         debian  examples  Makefile  mn.1              mnexec.c   util
CONTRIBUTORS  dist    INSTALL   mininet   mnexec            README.md
cuili@cuili-OptiPlex-3020:~/mininet$ cd custom
cuili@cuili-OptiPlex-3020:~/mininet/custom$ ls
README  topo-2sw-2host.py
cuili@cuili-OptiPlex-3020:~/mininet/custom$ vi topo-2sw-2host.py 
""Custom topology example

Two directly connected switches plus a host for each switch:

   host --- switch --- switch --- host

Adding the 'topos' dict with a key/value pair to generate our newly defined
topology enables one to pass in '--topo=mytopo' from the command line.
"""

from mininet.topo import Topo

class MyTopo( Topo ):
    "Simple topology example."


    def __init__( self ):
        "Create custom topo."

        # Initialize topology
        Topo.__init__( self )

        # Add hosts and switches
        leftHost = self.addHost( 'h1' )

        rightHost = self.addHost( 'h2' )

(在文档中有提示,执行以下命令启动Mininet,生成测试拓扑结构:



cuili@cuili-OptiPlex-3020:~/mininet/custom$ sudo apt-get install screen 此步骤也许会存在

(切记:容易错误原因在于topo-2sw_2host.py --topo mytopo 


cuili@cuili-OptiPlex-3020:~/mininet/custom$ sudo screen mn --custom /home/cuili/mininet/custom/topo-2sw-2host.py --topo mytopo --controller=remote,ip=172.16.75.117,port=6633 --switch ovsk,protocols=OpenFlow10
*** Creating network
*** Adding controller
*** Adding hosts:
h1 h2 
*** Adding switches:
s3 s4 
*** Adding links:
(h1, s3) (s3, s4) (s4, h2) 
*** Configuring hosts
h1 h2 
*** Starting controller
c0 
*** Starting 2 switches
s3 s4 ...
*** Starting CLI:
mininet> 


执行ctrl+a+d命令切换到系统命令行。

输入ovs-vsctl show命令查看Mininet是否与OpenDaylight连通。

[detached from 26530.pts-7.cuili-OptiPlex-3020]
cuili@cuili-OptiPlex-3020:~/mininet/custom$ ovs-vsctl show
ovs-vsctl: unix:/usr/local/var/run/openvswitch/db.sock: database connection failed (Permission denied)


 抓包验证

步骤1.在OpenDaylight虚拟机上执行以下命令开始抓包。(在老大电脑上重新开一个虚拟机)

步骤2.在Mininet命令行中查看当前已生成2个交换机和4个主机。

如果当前是在系统命令行,则执行screen –r命令切换到mininet命令行。执行以下命

令查看交换机和主机

cuili@cuili-OptiPlex-3020:~/mininet/custom$ screen -r
There is no screen to be resumed.

cuili@cuili-OptiPlex-3020:~/mininet/custom$ sudo screen mn --custom /home/cuili/mininet/custom/topo-2sw-2host.py --topo mytopo --controller=remote,ip=172.16.75.117,port=6633 --switch ovsk,protocols=OpenFlow10
*** Creating network
*** Adding controller
*** Adding hosts:
h1 h2 
*** Adding switches:
s3 s4 
*** Adding links:
(h1, s3) (s3, s4) (s4, h2) 
*** Configuring hosts
h1 h2 
*** Starting controller
c0 
*** Starting 2 switches
s3 s4 ...
*** Starting CLI:
mininet> nodes
available nodes are: 
c0 h1 h2 s3 s4
mininet> h1 ping h2
PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.
64 bytes from 10.0.0.2: icmp_seq=1 ttl=64 time=0.507 ms
64 bytes from 10.0.0.2: icmp_seq=2 ttl=64 time=0.434 ms
^C
--- 10.0.0.2 ping statistics ---
22 packets transmitted, 22 received, 0% packet loss, time 21001ms
rtt min/avg/max/mdev = 0.156/0.411/0.560/0.137 ms
mininet> 
*** Configuring hosts
h1 h2
*** Starting controller
c0
*** Starting 2 switches
s3 s4 ...
*** Starting CLI:
mininet> nodes
available nodes are:
c0 h1 h2 s3 s4
mininet> h1 ping h2
PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.
64 bytes from 10.0.0.2: icmp_seq=1 ttl=64 time=0.507 ms
64 bytes from 10.0.0.2: icmp_seq=2 ttl=64 time=0.434 ms
64 bytes from 10.0.0.2: icmp_seq=3 ttl=64 time=0.440 ms
^C
--- 10.0.0.2 ping statistics ---
22 packets transmitted, 22 received, 0% packet loss, time 21001ms
rtt min/avg/max/mdev = 0.156/0.411/0.560/0.137 ms
mininet> 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值