如何将Virtualbox Machines作为主机连接到Mininet OVS交换机以进行SDN实验?

问题描述 投票:0回答:1

我下载了Mininet VM,并且有两个Windows 7虚拟机。我想在Mininet中使用两个Windows 7虚拟机作为主机。我搜索了Internet,发现可以使用hwintf.py示例将其他vms用作mininet中的主机。我尝试使用,但仍然无法正常工作。我想使用pox作为我的控制器。请帮忙。以下是我的hwintf.py的代码

#!/usr/bin/python

"""
This example shows how to add an interface (for example a real
hardware interface) to a network after the network is created.
"""

import re
import sys

from mininet.cli import CLI
from mininet.log import setLogLevel, info, error
from mininet.net import Mininet
from mininet.link import Intf
from mininet.topolib import TreeTopo
from mininet.util import quietRun

def checkIntf( intf ):
    "Make sure intf exists and is not configured."
    config = quietRun( 'ifconfig %s 2>/dev/null' % intf, shell=True )
    if not config:
        error( 'Error:', intf, 'does not exist!\n' )
        exit( 1 )
    ips = re.findall( r'\d+\.\d+\.\d+\.\d+', config )
    if ips:
        error( 'Error:', intf, 'has an IP address,'
               'and is probably in use!\n' )
        exit( 1 )

if __name__ == '__main__':
    setLogLevel( 'info' )
# try to get hw intf from the command line; by default, use eth1
intfName = sys.argv[ 1 ] if len( sys.argv ) > 1 else 'eth2'
info( '*** Connecting to hw intf: %s' % intfName )

info( '*** Checking', intfName, '\n' )
checkIntf( intfName )

info( '*** Creating network\n' )
net = Mininet()
c1 = net.addController( 'c1' )
s1 = net.addSwitch( 's1' )
h1 = net.addHost( 'h1' )
h2 = net.addHost( 'h2' )
net.addLink( h1, s1 )
net.addLink( h2, s1 )

switch = net.switches[ 0 ]
info( '*** Adding hardware interface', intfName, 'to switch',
      switch.name, '\n' )
_intf = Intf( intfName, node=switch )

info( '*** Note: you may need to reconfigure the interfaces for '
      'the Mininet hosts:\n', net.hosts, '\n' )

net.start()
CLI( net )
net.stop()
sdn mininet openflow openvswitch pox
1个回答
0
投票

如果您不需要Mininet主机,则不应使用Mininet。或者,您可以使用独立的Open vSwitches。

打开vSwitch VM命令:

$ apt install openvswitch-switch
$ apt remove openvswitch-testcontroller
$ ovs-vsctl add-br br0
$ ovs-vsctl add-port br0 eth0
$ ovs-vsctl add-port br0 eth1
$ ovs-vsctl add-controller br0 tcp:127.0.0.1:6653

拓扑:

+-------------+               +------------------+             +--------------+
|  Host 1 VM  |               |  Open vSwitch VM |             |  Host 2 VM   |
|             |               |                  |             |              |
|             |    vmnet1     |                  |     vmnet2  |              |
|          +--+--+        +---++   +-------+   +-+----+    +---+--+           |
|          |eth0 +--------+eth0+---+ br0   +---+eth1  +----+eth0  |           |
|          +-----+        +---++   +---+---+   +-+----+    +------+           |
|     10.0.0.1/8              |        |         |           10.0.0.2/8       |
|             |               |       TCP        |             |              |
|             |               |     port 6653    |             |              |
+-------------+               |     (OpenFlow)   |             +--------------+
                              |        |         |
                              |        |         |
                              |   +----+-------+ |
                              |   | SDN        | |
                              |   | Controller | |
                              |   +------------+ |
                              |                  |
                              +------------------+
© www.soinside.com 2019 - 2024. All rights reserved.