Compare commits

..

1 Commits

Author SHA1 Message Date
Brian O'Connor d30be628e9 adding hwintf_topo example 2013-10-23 13:51:07 -07:00
13 changed files with 85 additions and 29 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
Mininet Installation/Configuration Notes
----------------------------------------
Mininet 2.1.0p2
Mininet 2.1.0
---
The supported installation methods for Mininet are 1) using a
+2 -2
View File
@@ -1,6 +1,6 @@
Mininet 2.1.0p2 License
Mininet 2.1.0 License
Copyright (c) 2013-2014 Open Networking Laboratory
Copyright (c) 2013 Open Networking Laboratory
Copyright (c) 2009-2012 Bob Lantz and The Board of Trustees of
The Leland Stanford Junior University
+4 -4
View File
@@ -3,7 +3,7 @@ Mininet: Rapid Prototyping for Software Defined Networks
*The best way to emulate almost any network on your laptop!*
Version 2.1.0p2
Version 2.1.0
### What is Mininet?
@@ -66,9 +66,9 @@ Mininet includes:
`mn -c`
### New features in 2.1.0p2
### New features in 2.1.0
Mininet 2.1.0p2 provides a number of bug fixes as well as
Mininet 2.1.0 provides a number of bug fixes as well as
several new features, including:
* Convenient access to `Mininet()` as a dict of nodes
@@ -127,7 +127,7 @@ Mininet to change the networking world!
### Credits
The Mininet 2.1.0p2 Team:
The Mininet 2.1.0 Team:
* Bob Lantz
* Brian O'Connor
+61
View File
@@ -0,0 +1,61 @@
#!/usr/bin/python
"""
This example shows how to add an interface (for example a real
hardware interface) to a Mininet topology.
"""
import sys
from mininet.cli import CLI
from mininet.log import setLogLevel, info
from mininet.net import Mininet
from mininet.topo import Topo
from mininet.link import Intf, Link
from mininet.examples.hwintf import checkIntf
class NoneIntf( Intf ):
"A dummy interface with a blank name that doesn't do any configuration"
def __init__( self, name, **params ):
self.name = ''
class HWIntfLink( Link ):
"A dummy link that doesn't touch either interface"
def makeIntfPair( cls, intf1, intf2 ):
pass
def delete( self ):
pass
class HWIntfTopo( Topo ):
"Simple one switch, two host topology with hwintf added to switch"
def __init__(self, intf, **opts):
Topo.__init__(self, **opts)
sw = self.addSwitch( 's1' )
h1 = self.addHost( 'h1' )
h2 = self.addHost( 'h2' )
self.addLink( sw, h1 )
self.addLink( sw, h2 )
self.addLink( sw, sw, cls=HWIntfLink, intfName1=intf, cls2=NoneIntf )
def run():
# Get hwintf from command line args, and verify that it is not used
intfName = sys.argv[ 1 ] if len( sys.argv ) > 1 else 'eth1'
checkIntf( intfName )
topo = HWIntfTopo( intf=intfName )
net = Mininet( topo=topo )
net.start()
CLI( net )
net.stop()
if __name__ == '__main__':
setLogLevel( 'info' )
run()
+3 -3
View File
@@ -63,9 +63,9 @@ def fixNetworkManager( root, intf ):
print '*** Adding', line.strip(), 'to', cfile
with open( cfile, 'a' ) as f:
f.write( line )
# Probably need to restart network-manager to be safe -
# hopefully this won't disconnect you
root.cmd( 'service network-manager restart' )
# Probably need to restart network-manager to be safe -
# hopefully this won't disconnect you
root.cmd( 'service network-manager restart' )
def connectToInternet( network, switch='s1', rootip='10.254', subnet='10.0/8'):
"""Connect the network to the internet
+1 -1
View File
@@ -55,7 +55,7 @@ def sshd( network, cmd='/usr/sbin/sshd', opts='-D',
if not switch:
switch = network[ 's1' ] # switch to use
if not routes:
routes = [ '10.0.0.0/24' ]
routes = [ '10.0.0.0/24' ]
connectToRootNS( network, switch, ip, routes )
for host in network.hosts:
host.cmd( cmd + ' ' + opts + '&' )
+1 -2
View File
@@ -331,8 +331,7 @@ class CLI( Cmd ):
node = self.mn[ first ]
rest = args.split( ' ' )
# Substitute IP addresses for node names in command
# If updateIP() returns None, then use node name
rest = [ self.mn[ arg ].defaultIntf().updateIP() or arg
rest = [ self.mn[ arg ].defaultIntf().updateIP()
if arg in self.mn else arg
for arg in rest ]
rest = ' '.join( rest )
+1 -1
View File
@@ -57,7 +57,7 @@ class StreamHandlerNoNewline( logging.StreamHandler ):
class Singleton( type ):
"""Singleton pattern from Wikipedia
See http://en.wikipedia.org/wiki/Singleton_Pattern
See http://en.wikipedia.org/wiki/SingletonPattern#Python
Intended to be used as a __metaclass_ param, as shown for the class
below."""
+1 -1
View File
@@ -102,7 +102,7 @@ from mininet.util import macColonHex, ipStr, ipParse, netParse, ipAdd
from mininet.term import cleanUpScreens, makeTerms
# Mininet version: should be consistent with README and LICENSE
VERSION = "2.1.0p2"
VERSION = "2.1.0"
class Mininet( object ):
"Network emulation with hosts spawned in network namespaces."
+1
View File
@@ -9,6 +9,7 @@ TODO: missing xterm test
import unittest
import pexpect
import os
from time import sleep
from mininet.util import quietRun
class testWalkthrough( unittest.TestCase ):
+1 -1
View File
@@ -8,7 +8,7 @@ version = 'Mininet ' + co( 'PYTHONPATH=. bin/mn --version', shell=True )
version = version.strip()
# Find all Mininet path references
lines = co( "grep -or 'Mininet \w\+\.\w\+\.\w\+[+]*' *", shell=True )
lines = co( "grep -or 'Mininet \w\.\w\.\w\w*' *", shell=True )
error = False
+4 -3
View File
@@ -140,7 +140,8 @@ def depend():
run( 'sudo apt-get -y update' )
run( 'sudo apt-get install -y'
' kvm cloud-utils genisoimage qemu-kvm qemu-utils'
' e2fsprogs dnsmasq'
' e2fsprogs '
' landscape-client'
' python-setuptools mtools zip' )
run( 'sudo easy_install pexpect' )
@@ -580,8 +581,8 @@ OVFTemplate = """<?xml version="1.0"?>
</References>
<DiskSection>
<Info>Virtual disk information</Info>
<Disk ovf:capacity="%d" ovf:capacityAllocationUnits="byte"
ovf:diskId="vmdisk1" ovf:fileRef="file1"
<Disk ovf:capacity="%d" ovf:capacityAllocationUnits="byte"
ovf:diskId="vmdisk1" ovf:fileRef="file1"
ovf:format="http://www.vmware.com/interfaces/specifications/vmdk.html"/>
</DiskSection>
<NetworkSection>
+4 -10
View File
@@ -3,8 +3,6 @@
# This script is intended to install Mininet into
# a brand-new Ubuntu virtual machine,
# to create a fully usable "tutorial" VM.
#
# optional argument: Mininet branch to install
set -e
echo `whoami` ALL=NOPASSWD: ALL | sudo tee -a /etc/sudoers > /dev/null
sudo sed -i -e 's/Default/#Default/' /etc/sudoers
@@ -27,16 +25,11 @@ fi
if [ -e /etc/rc.local.backup ]; then
sudo mv /etc/rc.local.backup /etc/rc.local
fi
# Fetch Mininet
# Install Mininet
sudo apt-get -y install git-core openssh-server
git clone git://github.com/mininet/mininet
# Optionally check out branch
if [ "$1" != "" ]; then
pushd mininet
git checkout -b $1 $1
popd
fi
# Install Mininet
cd mininet
cd
time mininet/util/install.sh
# Finalize VM
time mininet/util/install.sh -tc
@@ -45,3 +38,4 @@ time mininet/util/install.sh -tc
# echo "export NOX_CORE_DIR=~/noxcore/build/src/" >> .bashrc
#fi
echo "Done preparing Mininet VM."