TECH Software Defined Networking Mininet Tutorial James WonKi

  • Slides: 24
Download presentation
TECH Software Defined Networking: Mininet Tutorial James Won-Ki Hong Department of Computer Science and

TECH Software Defined Networking: Mininet Tutorial James Won-Ki Hong Department of Computer Science and Engineering POSTECH, Korea jwkhong@postech. ac. kr CSED 702 Y: Software Defined Networking 1/24

Outline v Introduction § Motivation v Installation v Mininet Tutorial § Command line interface

Outline v Introduction § Motivation v Installation v Mininet Tutorial § Command line interface usage § Application programming interface usage v Demo § Demo scenarios § Demo presentation v Experiences on Mininet TECH CSED 702 Y: Software Defined Networking 2/24

Types of Network Testbeds v Platforms for Network/Systems Teaching TECH Platform Advantages Disadvantages Hardware

Types of Network Testbeds v Platforms for Network/Systems Teaching TECH 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 multiplexing CSED 702 Y: Software Defined Networking 3/24

Hardware based Network Testbed (1/2) v Very Simple Network using Full System Virtualization TECH

Hardware based Network Testbed (1/2) v Very Simple Network using Full System Virtualization TECH h 1 (10. 0. 0. 1) s 1 h 2 (10. 0. 0. 2) CSED 702 Y: Software Defined Networking 4/24

Hardware based Network Testbed (2/2) v Problems § Too much work even for creating

Hardware based Network Testbed (2/2) v Problems § Too much work even for creating such a simple network topology § Not programmable h 1 (10. 0. 0. 1) sudo bash # Create host namespaces ip netns add h 1 ip netns add h 2 # Create switch ovs-vsctl add-br s 1 # Create links ip link add h 1 -eth 0 type veth peer name s 1 -eth 1 ip link add h 2 -eth 0 type veth peer name s 1 -eth 2 ip link show # Move host ports into namespaces ip link set h 1 -eth 0 netns h 1 ip link set h 2 -eth 0 netns h 2 ip netns exec h 1 ip link show ip netns exec h 2 ip link show TECH s 1 h 2 (10. 0. 0. 2) # Connect switch ports to OVS ovs-vsctl add-port s 1 -eth 1 ovs-vsctl add-port s 1 -eth 2 ovs-vsctl show # Set up Open. Flow controller ovs-vsctl set-controller s 1 tcp: 127. 0. 0. 1 ovs-controller ptcp: & ovs-vsctl show # Configure network ip netns exec h 1 ifconfig h 1 -eth 0 10. 1 ip netns exec h 1 ifconfig lo up ip netns exec h 2 ifconfig h 2 -eth 0 10. 2 ip netns exec h 1 ifconfig lo up ifconfig s 1 -eth 1 up ifconfig s 1 -eth 2 up # Test network ip netns exec h 1 ping -c 1 10. 2 CSED 702 Y: Software Defined Networking 5/24

Emulator based Network Testbed v What We Want is TECH § A simple command-line

Emulator based Network Testbed v What We Want is TECH § 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 h 1 (10. 0. 0. 1) s 1 h 2 (10. 0. 0. 2) h 1 = net. add. Host( 'h 1' ) h 2 = net. add. Host( 'h 2' ) s 1 = net. add. Switch( 's 1' ) c 0 = net. add. Controller( 'c 0' ) net. add. Link( h 1, s 1 ) net. add. Link( h 2, s 1 ) net. start() CLI( net ) Topology Generation using Mininet API CSED 702 Y: Software Defined Networking 6/24

Introduction to Mininet v Mininet TECH § A network emulator which creates realistic virtual

Introduction to Mininet v Mininet TECH § 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 Programming 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 v. Switch, Soft. Switch CSED 702 Y: Software Defined Networking 7/24

Mininet Installation (1/2) v Mininet VM Installation § The easiest and most fool-proof way

Mininet Installation (1/2) v 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. , Virtual. Box, Qemu, VMware Workstation, VMware Fusion, or KVM) • Import VM image into selected hypervisor v Native Installation from Source TECH § Recommended OS: Ubuntu 11. 10 and later § Procedures • Download source from github $ git clone git: //github. com/mininet • Full installation: Mininet + Open v. Swtich + wireshark + etc. $ mininet/util/install. sh -a • Minimum installation: + Mininet + Open v. Switch $ mininet/util/install. sh -fnv CSED 702 Y: Software Defined Networking 8/24

Mininet Installation (2/2) v Native Installation from Package TECH § Recommended OS: Ubuntu 12.

Mininet Installation (2/2) v Native Installation from Package TECH § Recommended OS: Ubuntu 12. 04 and later § Procedures • Remove all previously installed Mininet and Open v. Switch $ sudo rm -rf /usr/local/bin/mnexec /usr/local/lib/python*/*/*mininet* /usr/local/bin/ovs-* /usr/local/sbin/ovs-* • Install Mininet package according to your Ubuntu version (choose one of them!) $ sudo apt-get install mininet/quantal-backports $ sudo apt-get install mininet/precise-backports Ubuntu 13. 04 Ubuntu 12. 10 Ubuntu 12. 04 • Deactive Openv. Switch controller if it is running $ sudo service openvswitch-controller stop $ sudo update-rc. d openvswitch-controller disable • You can also install additional software from mininet source $ git clone git: //github. com/mininet $ mininet/util/install. sh -fw CSED 702 Y: Software Defined Networking 9/24

Mininet Tutorial (1/7) ECH v Mininet Command Line Interface Usage § Interact with hosts

Mininet Tutorial (1/7) ECH v Mininet Command Line Interface Usage § Interact with hosts and switches • Start a minimal topology $ sudo mn • Start a minimal topology using a remote controller $ sudo mn --controller=remote, ip=[IP_ADDDR], port=[listening port] • Start a custom topology $ sudo mn --custom [topo_script_path] --topo=[topo_name] • Display nodes mininet> nodes • Display links mininet> net • Dump information about all nodes mininet> dump CSED 702 Y: Software Defined Networking 10/24

Mininet Tutorial (2/7) ECH v Mininet Command Line Interface Usage § Interact with hosts

Mininet Tutorial (2/7) ECH v Mininet Command Line Interface Usage § Interact with hosts and switches • Check the IP address of a certain node mininet> h 1 ifconfig -a • Print the process list from a host process mininet> h 1 ps -a § Test connectivity between hosts • Verify the connectivity by pinging from host 0 to host 1 mininet> h 1 ping -c 1 h 2 • Verify the connectivity between all hosts mininet> pingall CSED 702 Y: Software Defined Networking 11/24

Mininet Tutorial (3/7) ECH v Mininet Command Line Interface Usage § Run a regression

Mininet Tutorial (3/7) ECH v Mininet Command Line Interface Usage § Run a regression test • Traffic receive preparation mininet> iperf -s -u -p [port_num] & • Traffic generation from client mininet> iperf -c [IP] -u -t [duration] -b [bandwidth] -p [port_num] & § Link variations $ sudo mn -link tc, bw=[bandwidth], delay=[delay_in_millisecond] § Python Interpreter • Print accessible local variables $ py locals() • Execute a method through invoking mininet API $ py [mininet_name_space]. [method] CSED 702 Y: Software Defined Networking 12/24

Mininet Tutorial (4/7) ECH v Mininet Application Programming Interface Usage § Low-level API: nodes

Mininet Tutorial (4/7) ECH v 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 Node Link Method Description MAC/set. MAC Return/Assign MAC address of a node or specific interface IP/set. IP 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 Create a link to another node, make two new interfaces h 1 = Host( 'h 1' ) h 2 = Host( 'h 2' ) s 1 = OVSSwitch( 's 1', in. Namespace=False ) c 0 = Controller( 'c 0', in. Namespace=False ) Link( h 1, s 1 ) Link( h 2, s 1 ) h 1. set. IP( '10. 1/8' ) h 2. set. IP( '10. 2/8' ) c 0. start() s 1. start( [ c 0 ] ) print h 1. cmd( 'ping -c 1', h 2. IP() ) s 1. stop() c 0. stop() CSED 702 Y: Software Defined Networking 13/24

Mininet Tutorial (5/7) ECH v Mininet Application Programming Interface Usage § Middle-level API: network

Mininet Tutorial (5/7) ECH v Mininet Application Programming Interface Usage § Middle-level API: network object • mininet. Mininet • Network emulation with hosts spawned in network namespaces Class Net Method Description add. Host Add a host to network add. Switch Add a switch to network add. Link two nodes into together add. Controller Add a controller to network get. Node. By. Name 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() h 1 = net. add. Host( 'h 1' ) h 2 = net. add. Host( 'h 2' ) s 1 = net. add. Switch( 's 1' ) c 0 = net. add. Controller( 'c 0' ) net. add. Link( h 1, s 1 ) net. add. Link( h 2, s 1 ) net. start() print h 1. cmd( 'ping -c 1', h 2. IP() ) CLI( net ) net. stop() CSED 702 Y: Software Defined Networking 14/24

Mininet Tutorial (6/7) ECH v Mininet Application Programming Interface Usage § High-level API: topology

Mininet Tutorial (6/7) ECH v Mininet Application Programming Interface Usage § High-level API: topology templates • mininet. topo. Topo • Data center network representation for structured multi-trees Class Topo Method Description Methods similar to net E. g. , add. Host, add. Switch, add. Link, add. Node Add node to graph add. Port Generate port mapping for new edge switches Return all switches Hosts/nodes/switches/links Return all hosts is. Switch Return true if node is a switch, return false otherwise class Single. Switch. Topo( Topo ): "Single Switch Topology" def build( self, count=1): hosts = [ self. add. Host( 'h%d' % i ) for i in range( 1, count + 1 ) ] s 1 = self. add. Switch( 's 1' ) for h in hosts: self. add. Link( h, s 1 ) net = Mininet( topo=Single. Switch. Topo( 3 ) ) net. start() CLI( net ) net. stop() CSED 702 Y: Software Defined Networking 15/24

Mininet Tutorial (7/7) ECH v Mininet Application Programming Interface Usage § Customized topology #

Mininet Tutorial (7/7) ECH v Mininet Application Programming Interface Usage § Customized topology # cat custom. py LEN_DPID = 16 from mininet. topo import Topo class My. Topo( Topo ): def name_dpid( self, index ): dpid = '%02 d' % ( index ) zeros = '0' * ( LEN_DPID - len( dpid ) ) name = 's%02 d' % ( index ) return { 'name': name, 'dpid': zeros + dpid } def build( self, count=1): hosts = [ self. add. Host( 'h%d' % i ) for i in range( 1, count + 1 ) ] s 1 = self. add. Switch( **self. name_dpid(1) ) for h in hosts: self. add. Link( h, s 1 ) topos = { 'mytopo': My. Topo } # mn --custom. py --topo mytopo, 3 *** Creating network *** Adding controller *** Adding hosts: h 1 h 2 h 3 More examples can be found here: https: //github. com/mininet/tree/master/examples CSED 702 Y: Software Defined Networking 16/24

Mininet Applications ECH v Mini. Edit § A GUI application which eases the Mininet

Mininet Applications ECH v Mini. Edit § A GUI application which eases the Mininet topology generation § Either save the topology or export as a Mininet python script v Visual Network Description (VND) § A GUI tool which allows automate creation of Mininet and Open. Flow controller scripts CSED 702 Y: Software Defined Networking 17/24

Two Flow Insertion Methods ECH v Reactive Flow Insertion § A non-matched packet reaches

Two Flow Insertion Methods ECH v Reactive Flow Insertion § A non-matched packet reaches an Open. Flow switch, it is sent to the controller, based on the packet an appropriate flow is inserted v Proactive Flow Insertion § Flow can be inserted proactively by the controller in switches before packet arrive SRC DST ACT h 1 h 2 p 1 Open. Flow Controller … acquire route SRC DST ACT h 1 h 2 p 1 … insert flow host 1 switch 1 (reactive) switch 2 (proactive) CSED 702 Y: Software Defined Networking host 2 18/24

DEMO Scenarios ECH v Construct a Customized Topology Using Mininet § A topology with

DEMO Scenarios ECH v Construct a Customized Topology Using Mininet § A topology with two hosts and five switches v Scenario § Setup the flow in reactive manner § Ping from host 1 to host 2 in reactive manner § Ping from all hosts to the other hosts 1 0 1 2 2 2 1 switch 2 switch 3 3 host 1 Route #1 1 3 2 switch 1 switch 5 1 2 switch 4 0 host 2 Route #2 CSED 702 Y: Software Defined Networking 19/24

Testbed Jython App Java App ECH RESTbased App Static Flow Pusher Not standardized yet,

Testbed Jython App Java App ECH RESTbased App Static Flow Pusher Not standardized yet, use proprietary APIs Northbound API Floodlight Controller Southbound API OVS Switch Host OVS Switch Host Implement Open. Flow Protocol OVS Switch Host mininet CSED 702 Y: Software Defined Networking 20/24

Floodlight Installation ECH v Native Installation from Source § Recommended OS: any version of

Floodlight Installation ECH v Native Installation from Source § Recommended OS: any version of Linux distribution § Procedures • Install pre-requisite software packages $ sudo apt-get install openjdk-7 -jdk $ sudo apt-get install ant # yum install java-1. 7. 0 -openjdk-devel # yum install ant Ubuntu EPEL • Download source from github and build the stable version $ git clone git: //github. com/floodlight. git $ cd floodlight $ ant • Run the floodlight #. /floodlight. sh • Access floodlight dashboard • http: //floodlight_ip_address: 8080/ui/index. html CSED 702 Y: Software Defined Networking 21/24

DEMO Execution Procedures ECH v Procedures § Start Floodlight controller daemon # $FLOODLIGHT_PATH/floodlight. sh

DEMO Execution Procedures ECH v Procedures § Start Floodlight controller daemon # $FLOODLIGHT_PATH/floodlight. sh § Initialize Mininet by specifying custom topology $ sudo mn --custom. /topo. py --topo mytopo --controller=remote, ip=127. 0. 0. 1, port=6653 § Initiate a ICMP request from host 1 mininet> h 1 ping h 2 § Initiate ICMP requests from all hosts mininet> pingall CSED 702 Y: Software Defined Networking 22/24

Sample Examples using Mininet ECH v At Stanford § Pick a paper, reproduce a

Sample Examples using Mininet ECH v At Stanford § Pick a paper, reproduce a key result or challenge it • Wide range of projects include transport protocols, data center topologies • E. g. , Co. Del, HULL, MPTCP wireless, Outcast, Jellyfish, DCTCP, Incast, Hedera, Dcell, RED and more… • Total # of projects: 18 • # of replicated projects: 16 • https: //reproducingnetworkresearch. wordpress. com v At MIT § Design a transport protocol to achieve high throughput and low delay on cellular links § Baseline protocol: Sprout (NSDI 2013) § Competition between students, and two student protocols were comparable with Sprout Protocol Design Contests: Anirudh Sivaraman, Keith Winstein, Pauline Varley, Jo˜ao Batalha, Ameesh Goyal, Somak Das, Joshua Ma, and Hari Balakrishnan, CCR July 2014 CSED 702 Y: Software Defined Networking 23/24

Q&A ECH CSED 702 Y: Software Defined Networking 24/24

Q&A ECH CSED 702 Y: Software Defined Networking 24/24