+ All Categories
Home > Documents > POSTECH 1/24 CSED702Y: Software Defined Networking James Won-Ki Hong Department of Computer Science...

POSTECH 1/24 CSED702Y: Software Defined Networking James Won-Ki Hong Department of Computer Science...

Date post: 21-Dec-2015
Category:
Upload: martha-henderson
View: 217 times
Download: 3 times
Share this document with a friend
Popular Tags:
24
POSTECH 1/24 CSED702Y: Software Defined Networking Software Defined Networking: Mininet Tutorial James Won-Ki Hong Department of Computer Science and Engineering POSTECH, Korea [email protected]
Transcript
Page 1: POSTECH 1/24 CSED702Y: Software Defined Networking James Won-Ki Hong Department of Computer Science and Engineering POSTECH, Korea jwkhong@postech.ac.kr.

POSTECH 1/24CSED702Y: Software Defined Networking

Software Defined Networking:Mininet Tutorial

James Won-Ki Hong

Department of Computer Science and Engineering

POSTECH, Korea

[email protected]

Page 2: POSTECH 1/24 CSED702Y: Software Defined Networking James Won-Ki Hong Department of Computer Science and Engineering POSTECH, Korea jwkhong@postech.ac.kr.

POSTECH 2/24CSED702Y: Software Defined Networking

Outline

Introduction Motivation

Installation Mininet Tutorial

Command line interface usage Application programming interface usage

Demo Demo scenarios Demo presentation

Experiences on Mininet

Page 3: POSTECH 1/24 CSED702Y: Software Defined Networking James Won-Ki Hong Department of Computer Science and Engineering POSTECH, Korea jwkhong@postech.ac.kr.

POSTECH 3/24CSED702Y: Software Defined Networking

Types of Network Testbeds

Platforms for Network/Systems Teaching

Platform Advantages Disadvantages

Hardware testbed Fast Accurate: “ground truth”

Expensive Hard to reconfigure Hard to change Hard to download

Simulator Inexpensive, flexible Detailed Easy to download Virtual time

May require app changes Might not run OS code May not be “believable” May be slow/non-interactive

Emulator Inexpensive, flexible Real code Reasonably accurate Easy to download Fast/interactive usage

Slower than hardware Possible inaccuracy from mul-

tiplexing

Page 4: POSTECH 1/24 CSED702Y: Software Defined Networking James Won-Ki Hong Department of Computer Science and Engineering POSTECH, Korea jwkhong@postech.ac.kr.

POSTECH 4/24CSED702Y: Software Defined Networking

Hardware based Network Testbed (1/2)

Very Simple Network using Full System Virtualization

h1 (10.0.0.1) h2 (10.0.0.2)s1

Page 5: POSTECH 1/24 CSED702Y: Software Defined Networking James Won-Ki Hong Department of Computer Science and Engineering POSTECH, Korea jwkhong@postech.ac.kr.

POSTECH 5/24CSED702Y: Software Defined Networking

Hardware based Network Testbed (2/2)

Problems Too much work even for creating such a simple network topology Not programmable

sudo bash# Create host namespacesip netns add h1ip netns add h2# Create switchovs-vsctl add-br s1# Create linksip link add h1-eth0 type veth peer name s1-eth1ip link add h2-eth0 type veth peer name s1-eth2ip link show# Move host ports into namespacesip link set h1-eth0 netns h1ip link set h2-eth0 netns h2ip netns exec h1 ip link showip netns exec h2 ip link show

# Connect switch ports to OVSovs-vsctl add-port s1 s1-eth1ovs-vsctl add-port s1 s1-eth2ovs-vsctl show# Set up OpenFlow controllerovs-vsctl set-controller s1 tcp:127.0.0.1ovs-controller ptcp: &ovs-vsctl show# Configure networkip netns exec h1 ifconfig h1-eth0 10.1ip netns exec h1 ifconfig lo upip netns exec h2 ifconfig h2-eth0 10.2ip netns exec h1 ifconfig lo upifconfig s1-eth1 upifconfig s1-eth2 up# Test networkip netns exec h1 ping -c1 10.2

h1 (10.0.0.1) h2 (10.0.0.2)s1

Page 6: POSTECH 1/24 CSED702Y: Software Defined Networking James Won-Ki Hong Department of Computer Science and Engineering POSTECH, Korea jwkhong@postech.ac.kr.

POSTECH 6/24CSED702Y: Software Defined Networking

Emulator based Network Testbed

What We Want is A simple command-line tool / API which can ease the work The solution should allow us to easily create topologies for varying

size, up to hundreds and thousand of nodes

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()CLI( net )

h1 (10.0.0.1) h2 (10.0.0.2)s1

Topology Generation using Mininet API

Page 7: POSTECH 1/24 CSED702Y: Software Defined Networking James Won-Ki Hong Department of Computer Science and Engineering POSTECH, Korea jwkhong@postech.ac.kr.

POSTECH 7/24CSED702Y: Software Defined Networking

Introduction to Mininet

Mininet A network emulator which creates realistic virtual network Runs real kernel, switch and application code on a single machine

Provides both Command Line Interface (CLI) and Application Pro-gramming Interface (API)• CLI: interactive commanding• API: automation

Abstraction• Host: emulated as an OS level process• Switch: emulated by using software-based switch

• E.g., Open vSwitch, SoftSwitch

Page 8: POSTECH 1/24 CSED702Y: Software Defined Networking James Won-Ki Hong Department of Computer Science and Engineering POSTECH, Korea jwkhong@postech.ac.kr.

POSTECH 8/24CSED702Y: Software Defined Networking

Mininet Installation (1/2)

Mininet VM Installation The easiest and most fool-proof way of installing Mininet Procedures

• Download the Mininet pre-installed VM image• Download and install one of the hypervisors (e.g., VirtualBox, Qemu, VMware

Workstation, VMware Fusion, or KVM)• Import VM image into selected hypervisor

Native Installation from Source Recommended OS: Ubuntu 11.10 and later Procedures

• Download source from github

• Full installation: Mininet + Open vSwtich + wireshark + etc.

• Minimum installation: + Mininet + Open vSwitch

$ git clone git://github.com/mininet/mininet

$ mininet/util/install.sh -a

$ mininet/util/install.sh -fnv

Page 9: POSTECH 1/24 CSED702Y: Software Defined Networking James Won-Ki Hong Department of Computer Science and Engineering POSTECH, Korea jwkhong@postech.ac.kr.

POSTECH 9/24CSED702Y: Software Defined Networking

Mininet Installation (2/2)

Native Installation from Package Recommended OS: Ubuntu 12.04 and later Procedures

• Remove all previously installed Mininet and Open vSwitch

• Install Mininet package according to your Ubuntu version (choose one of them!)

• Deactive OpenvSwitch controller if it is running

• You can also install additional software from mininet source

$ sudo rm -rf /usr/local/bin/mn /usr/local/bin/mnexec \ /usr/local/lib/python*/*/*mininet* \ /usr/local/bin/ovs-* /usr/local/sbin/ovs-*

$ sudo apt-get install mininet$ sudo apt-get install mininet/quantal-backports$ sudo apt-get install mininet/precise-backports

Ubuntu 13.04Ubuntu 12.10Ubuntu 12.04

$ sudo service openvswitch-controller stop$ sudo update-rc.d openvswitch-controller disable

$ git clone git://github.com/mininet/mininet$ mininet/util/install.sh -fw

Page 10: POSTECH 1/24 CSED702Y: Software Defined Networking James Won-Ki Hong Department of Computer Science and Engineering POSTECH, Korea jwkhong@postech.ac.kr.

POSTECH 10/24CSED702Y: Software Defined Networking

Mininet Tutorial (1/7)

Mininet Command Line Interface Usage Interact with hosts and switches

• Start a minimal topology

• Start a minimal topology using a remote controller

• Start a custom topology

• Display nodes

• Display links

• Dump information about all nodes

$ sudo mn

mininet> nodes

mininet> net

mininet> dump

$ sudo mn --controller=remote,ip=[IP_ADDDR],port=[listening port]

$ sudo mn --custom [topo_script_path] --topo=[topo_name]

Page 11: POSTECH 1/24 CSED702Y: Software Defined Networking James Won-Ki Hong Department of Computer Science and Engineering POSTECH, Korea jwkhong@postech.ac.kr.

POSTECH 11/24CSED702Y: Software Defined Networking

Mininet Tutorial (2/7)

Mininet Command Line Interface Usage Interact with hosts and switches

• Check the IP address of a certain node

• Print the process list from a host process

Test connectivity between hosts• Verify the connectivity by pinging from host0 to host1

• Verify the connectivity between all hosts

mininet> h1 ifconfig -a

mininet> h1 ps -a

mininet> h1 ping -c 1 h2

mininet> pingall

Page 12: POSTECH 1/24 CSED702Y: Software Defined Networking James Won-Ki Hong Department of Computer Science and Engineering POSTECH, Korea jwkhong@postech.ac.kr.

POSTECH 12/24CSED702Y: Software Defined Networking

Mininet Tutorial (3/7)

Mininet Command Line Interface Usage Run a regression test

• Traffic receive preparation

• Traffic generation from client

Link variations

Python Interpreter• Print accessible local variables

• Execute a method through invoking mininet API

$ sudo mn -link tc,bw=[bandwidth],delay=[delay_in_millisecond]

mininet> iperf -s -u -p [port_num] &

mininet> iperf -c [IP] -u -t [duration] -b [bandwidth] -p [port_num] &

$ py locals()

$ py [mininet_name_space].[method]

Page 13: POSTECH 1/24 CSED702Y: Software Defined Networking James Won-Ki Hong Department of Computer Science and Engineering POSTECH, Korea jwkhong@postech.ac.kr.

POSTECH 13/24CSED702Y: Software Defined Networking

Mininet Tutorial (4/7)

Mininet Application Programming Interface Usage Low-level API: nodes and links

• mininet.node.Node• A virtual network node, which is a simply in a network namespace

• mininet.link.Link• A basic link, which is represented as a pair of nodes

Class Method Description

Node

MAC/setMAC Return/Assign MAC address of a node or specific interface

IP/setIP Return/Assign IP address of a node or specific interface

cmd Send a command, wait for output, and return it

terminate Send kill signal to Node and clean up after it

Link Link Create a link to another node, make two new interfaces

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()

Page 14: POSTECH 1/24 CSED702Y: Software Defined Networking James Won-Ki Hong Department of Computer Science and Engineering POSTECH, Korea jwkhong@postech.ac.kr.

POSTECH 14/24CSED702Y: Software Defined Networking

Mininet Tutorial (5/7)

Mininet Application Programming Interface Usage Middle-level API: network object

• mininet.net.Mininet• Network emulation with hosts spawned in network namespaces

Class Method Description

Net

addHost Add a host to network

addSwitch Add a switch to network

addLink Link two nodes into together

addController Add a controller to network

getNodeByName Return node(s) with given name(s)

start Start controller and switches

stop Stop the controller, switches and hosts

ping Ping between all specified hosts and return all data

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()

Page 15: POSTECH 1/24 CSED702Y: Software Defined Networking James Won-Ki Hong Department of Computer Science and Engineering POSTECH, Korea jwkhong@postech.ac.kr.

POSTECH 15/24CSED702Y: Software Defined Networking

Mininet Tutorial (6/7)

Mininet Application Programming Interface Usage High-level API: topology templates

• mininet.topo.Topo• Data center network representation for structured multi-trees

Class Method Description

Topo

Methods similar to net E.g., addHost, addSwitch, addLink,

addNode Add node to graph

addPort Generate port mapping for new edge

switches Return all switches

Hosts/nodes/switches/links Return all hosts

isSwitch Return true if node is a switch, return false otherwise

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 )

net = Mininet( topo=SingleSwitchTopo( 3 ) )net.start()CLI( net )net.stop()

Page 16: POSTECH 1/24 CSED702Y: Software Defined Networking James Won-Ki Hong Department of Computer Science and Engineering POSTECH, Korea jwkhong@postech.ac.kr.

POSTECH 16/24CSED702Y: Software Defined Networking

Mininet Tutorial (7/7)

Mininet Application Programming Interface Usage Customized topology

# cat custom.py

LEN_DPID = 16from mininet.topo import Topoclass MyTopo( Topo ):

def name_dpid( self, index ): dpid = '%02d' % ( index ) zeros = '0' * ( LEN_DPID - len( dpid ) ) name = 's%02d' % ( index ) return { 'name':name, 'dpid':zeros + dpid }

def build( self, count=1): hosts = [ self.addHost( 'h%d' % i ) for i in range( 1, count + 1 ) ] s1 = self.addSwitch( **self.name_dpid(1) ) for h in hosts: self.addLink( h, s1 )

topos = { 'mytopo': MyTopo }

# mn --custom custom.py --topo mytopo,3*** Creating network*** Adding controller*** Adding hosts:h1 h2 h3

More examples can be found here:https://github.com/mininet/mininet/tree/master/examples

Page 17: POSTECH 1/24 CSED702Y: Software Defined Networking James Won-Ki Hong Department of Computer Science and Engineering POSTECH, Korea jwkhong@postech.ac.kr.

POSTECH 17/24CSED702Y: Software Defined Networking

Mininet Applications

MiniEdit A GUI application which eases the Mininet topology generation Either save the topology or export as a Mininet python script

Visual Network Description (VND) A GUI tool which allows automate creation of Mininet and Open-

Flow controller scripts

Page 18: POSTECH 1/24 CSED702Y: Software Defined Networking James Won-Ki Hong Department of Computer Science and Engineering POSTECH, Korea jwkhong@postech.ac.kr.

POSTECH 18/24CSED702Y: Software Defined Networking

Two Flow Insertion Methods

Reactive Flow Insertion A non-matched packet reaches an OpenFlow switch, it is sent to the

controller, based on the packet an appropriate flow is inserted

Proactive Flow Insertion Flow can be inserted proactively by the controller in switches before

packet arrive

OpenFlowController

host1 host2switch1 (reactive) switch2 (proactive)

acquireroute

insertflow

SRC DST ACT …SRC DST ACT …

h1 h2 p1

SRC DST ACT …

h1 h2 p1

Page 19: POSTECH 1/24 CSED702Y: Software Defined Networking James Won-Ki Hong Department of Computer Science and Engineering POSTECH, Korea jwkhong@postech.ac.kr.

POSTECH 19/24CSED702Y: Software Defined Networking

DEMO Scenarios

Construct a Customized Topology Using Mininet A topology with two hosts and five switches

Scenario Setup the flow in reactive manner Ping from host1 to host2 in reactive manner Ping from all hosts to the other hosts

host1 host2

switch1

switch2

switch4

Route #1

Route #2

switch3

switch5

1 2

3

1 2 1 2

1 2

1

2

30 0

Page 20: POSTECH 1/24 CSED702Y: Software Defined Networking James Won-Ki Hong Department of Computer Science and Engineering POSTECH, Korea jwkhong@postech.ac.kr.

POSTECH 20/24CSED702Y: Software Defined Networking

Testbed

Floodlight Controller

Java A

pp

Jytho

n A

pp

OVS Switch

OVS Switch

OVS Switch

OVS Switch

Static Flow

Pusher

REST-based

App

Southbound API

Northbound API

OVS Switch

Host

Host

Host

Host

Host

HostHost

Host

Host

Host

mininet

Implement OpenFlow Protocol

Not standardized yet, use proprietary

APIs

Page 21: POSTECH 1/24 CSED702Y: Software Defined Networking James Won-Ki Hong Department of Computer Science and Engineering POSTECH, Korea jwkhong@postech.ac.kr.

POSTECH 21/24CSED702Y: Software Defined Networking

Floodlight Installation

Native Installation from Source Recommended OS: any version of Linux distribution Procedures

• Install pre-requisite software packages

• Download source from github and build the stable version

• Run the floodlight

• Access floodlight dashboard• http://floodlight_ip_address:8080/ui/index.html

$ sudo apt-get install openjdk-7-jdk$ sudo apt-get install ant

# yum install java-1.7.0-openjdk java-1.7.0-openjdk-devel# yum install ant

Ubuntu

EPEL

$ git clone git://github.com/floodlight/floodlight.git $ cd floodlight$ ant

# ./floodlight.sh

Page 22: POSTECH 1/24 CSED702Y: Software Defined Networking James Won-Ki Hong Department of Computer Science and Engineering POSTECH, Korea jwkhong@postech.ac.kr.

POSTECH 22/24CSED702Y: Software Defined Networking

DEMO Execution Procedures

Procedures Start Floodlight controller daemon

Initialize Mininet by specifying custom topology

Initiate a ICMP request from host1

Initiate ICMP requests from all hosts

# $FLOODLIGHT_PATH/floodlight.sh

$ sudo mn --custom ./topo.py --topo mytopo --controller=remote,ip=127.0.0.1,port=6653

mininet> h1 ping h2

mininet> pingall

Page 23: POSTECH 1/24 CSED702Y: Software Defined Networking James Won-Ki Hong Department of Computer Science and Engineering POSTECH, Korea jwkhong@postech.ac.kr.

POSTECH 23/24CSED702Y: Software Defined Networking

Sample Examples using Mininet

At Stanford Pick a paper, reproduce a key result or challenge it

• Wide range of projects include transport protocols, data center topologies• E.g., CoDel, HULL, MPTCP wireless, Outcast, Jellyfish, DCTCP, Incast, Hedera,

Dcell, RED and more…• Total # of projects: 18• # of replicated projects: 16• https://reproducingnetworkresearch.wordpress.com

At MIT Design a transport protocol to achieve high throughput and low de-

lay on cellular links Baseline protocol: Sprout (NSDI 2013) Competition between students, and two student protocols were

comparable with SproutProtocol Design Contests: Anirudh Sivaraman, Keith Winstein, Pauline Varley, Jo˜ao Batalha, Ameesh Goyal, Somak Das, Joshua Ma, and Hari Balakrishnan, CCR July 2014

Page 24: POSTECH 1/24 CSED702Y: Software Defined Networking James Won-Ki Hong Department of Computer Science and Engineering POSTECH, Korea jwkhong@postech.ac.kr.

POSTECH 24/24CSED702Y: Software Defined Networking

Q&A


Recommended