Teaching Computer Networking With Mininet
Teaching Computer Networking With Mininet
Teaching Computer Networking With Mininet
2. Hands-on Lab
presentation, lab, coffee break
Bob Lantz
Open Networking Laboratory
Introduction to Mininet
Platforms for Network/Systems Teaching
Network Emulator Architecture
Mininet: Basic Usage, CLI, API
Example Demos: Network Security
Conclusion and Questions
Experiential Learning for Networking
"Learning by doing" is memorable and leads
to mastery.
firefox httpd
init init
VM Server
Very Simple Network using
Lightweight Virtualization
firefox httpd
10.0.0.1 10.0.0.2
Network Namespace 1 eth0 eth0 Network Namespace 2
10.0.0.1 10.0.0.2
Network Namespace 1 eth0 eth0 Network Namespace 2
veth1 veth2
Software
Root Namespace Switch
Creating it with Linux
sudo bash
# Create host namespaces # Configure network
ip netns add h1 ip netns exec h1 ifconfig h1-eth0 10.1
ip netns add h2 ip netns exec h1 ifconfig lo up
# Create switch ip netns exec h2 ifconfig h2-eth0 10.2
ovs-vsctl add-br s1 ip netns exec h1 ifconfig lo up
# Create links ifconfig s1-eth1 up
ip link add h1-eth0 type veth peer name s1-eth1 ifconfig s1-eth2 up
ip link add h2-eth0 type veth peer name s1-eth2 # Test network
ip link show ip netns exec h1 ping -c1 10.2
# Move host ports into namespaces
ip link set h1-eth0 netns h1
ctrl’er
ip link set h2-eth0 netns h2
ip netns exec h1 ip link show
ip netns exec h2 ip link show
# Connect switch ports to OVS
s1
ovs-vsctl add-port s1 s1-eth1
ovs-vsctl add-port s1 s1-eth2
ovs-vsctl show
# Set up OpenFlow controller h2
h1
ovs-vsctl set-controller s1 tcp:127.0.0.1
10.0.0.1 10.0.0.2
ovs-controller ptcp: &
ovs-vsctl show
Wouldn’t it be great if...
We had a simple command-line tool and/or API
that did this for us automatically?
10
M
bp
s,
50
m
s
h1 h2
10.0.0.1 10.0.0.2
20% of CPU
Low-level API: Nodes and Links
h1 = Host( 'h1' )
h2 = Host( 'h2' )
s1 = OVSSwitch( 's1', inNamespace=False )
c0 = Controller( 'c0', inNamespace=False )
Link( h1, s1 )
Link( h2, s1 )
h1.setIP( '10.1/8' )
h2.setIP( '10.2/8' )
c0.start()
s1.start( [ c0 ] )
print h1.cmd( 'ping -c1', h2.IP() )
s1.stop()
c0.stop()
Mid-level API: Network object
net = Mininet()
h1 = net.addHost( 'h1' )
h2 = net.addHost( 'h2' )
s1 = net.addSwitch( 's1' )
c0 = net.addController( 'c0' )
net.addLink( h1, s1 )
net.addLink( h2, s1 )
net.start()
print h1.cmd( 'ping -c1', h2.IP() )
CLI( net )
net.stop()
High-level API: Topology templates
class SingleSwitchTopo( Topo ):
"Single Switch Topology"
def build( self, count=1):
hosts = [ self.addHost( 'h%d' % i )
for i in range( 1, count + 1 ) ]
s1 = self.addSwitch( 's1' )
for h in hosts:
self.addLink( h, s1 )
internet
dhcp
slow link 10.0.0.50
h1
10.0.0.10 (good DHCP
Switch (500 ms delay)
(client/ server)
victim)
evil
10.0.0.66
(malicious
DHCP+DNS+
WWW server)
Security Demo #2: BGP
More Demos!
MiniEdit
Consoles.py
Cluster prototype
Introduction to Mininet
Platforms for Network/Systems Teaching
Network Emulator Architecture
Mininet: Basic Usage, CLI, API
Example Demos: Network Security
Conclusion and Questions
Conclusion and Questions
Network Emulators can facilitate teaching networking via realistic live
demos, interactive labs and course assignments
- inexpensive, interactive, real apps and OS, reasonably accurate
- downloadable, fast setup
Mininet is a lightweight virtualization/container based emulator
- modest hardware requirements, fast startup, hundreds of nodes
- command line tool, CLI, simple Python API
- SDN as well as Ethernet/IP networking as well as SD
- install using VM, Ubuntu package, or source
2. Hands-on Lab
presentation, lab, coffee break
Controller Controller
App
App
Switch
Host
Example
class Host( Node ):
"A host is simply a Node"
pass
What do you want to customize?
class Node( object ):
def config( self, mac=None, ip=None,
defaultRoute=None, lo='up', **_params ):
prio = 0
DEMO: controllers.py
Customizing Controller()
from mininet.node import Controller
from os import environ