Reputation: 1
I downloaded the Mininet VM and I have two windows 7 vms. I want to use two windows 7 vms as hosts in Mininet. I searched the internet and found that I can use the hwintf.py example to use other vms as hosts in mininet. I tried using but still didn't work. I want to use pox as my controller. Please help. Below is the code of my 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()
Upvotes: 0
Views: 3000
Reputation: 177
If you don't need Mininet hosts you shouldn't use Mininet. Alternatively, you could use standalone Open vSwitches.
Open vSwitch VM Commands:
$ 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
Topology:
+-------------+ +------------------+ +--------------+
| 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 | |
| +------------+ |
| |
+------------------+
Upvotes: 2