1 Mininet and Ryu
2 Outline SDN Overview Mininet and Ryu Overview Mininet VM Setup Ryu Setup OpenFlow Protocol and Open vswitch Reference
3 SDN Overview Decoupling of control and data planes Directly Programmable network Logically centralizing network intelligence Horizontal-integrated
4 SDN Overview Under SDN Architecture, Ryu Framework belongs to the control layer, and help developers to communicate between the controller and Open vswitch. Ryu Framework Source: https://www.sdxcentral.com/sdn/d efinitions/inside-sdn-architecture/ Mininet and Open vswitch
5 Mininet and Ryu Overview VirtualBox VM Ryu App Ryu OpenvSwitch Mininet Xming Server
6 Mininet A network emulator that create virtual network that can run SDN applications. Includes a CLI, for debugging or running network-wide tests. Supports arbitrary custom topologies, and includes a basic set of parametrized topologies. Provides a straightforward and extensible Python API for network creation and experimentation.
7 What is Network Emulator
8 Ryu Overview Ryu can help developers to communicate between the controller and Open vswitch by using OpenFlow protocol. <OpenFlow> <OpenFlow> Open vswitch Open vswitch
9 Mininet VM Setup
10 Mininet VM Setup Download the Mininet VM from our server: (link) Or the following webpage: https://github.com/mininet/mininet/wiki/mininet-vm- Images Install Xming server on the Windows. (link) Download putty.exe from the following webpage: https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
11 Mininet VM Setup Go to File and click Import Appliance to import.ovf file
12 Mininet VM Setup Choose Mininet-VM and use NAT setting at interface 1
13 Mininet VM Setup Use VirtualBox Host-Only Ethernet Adapter setting at Interface 2 to make sure we can use SSH to connect the virtual machine
14 Mininet VM Setup (Optional) Go to File and click Host Network Manager and Enable DHCP server of VirtualBox Host-Only Ethernet Adapter setting to make sure we can use SSH to connect the virtual machine
15 Mininet VM Setup Start the VM login with user/password: mininet/mininet $ sudo ifconfig => Find the IP address used for SSH
16 Mininet VM Setup Need Reconfiguration After Reboot $ sudo ifconfig eth1 up => Enable eth1. $ sudo dhclient eth1 => Give eth1 an ip address.
17 SSH to the VM Open Xming Server Use Putty and enable forwarding to access the VM The IP address should be 192.168.56.xxx.
18 SSH to the VM Enable the X11 forwarding.
19 SSH to the VM Login with user/password: mininet/mininet SSH to the VM
20 Mininet
21 Mininet mn Linux Commands This command needs super user privilege. Basic CLI Command Line sudo mn exit sudo mn -c Description Start a minimal topology Exit mininet Exit and free the resource
22 Mininet mn Linux Commands -h, --help Show the help message. --controller Define what controller to use. --topo Tell mininet what topology I want to use. --custom Read custom topology and node parameters from.py file -x, --xterm Spawn an xterm window for all the nodes inside the network. --mac The mininet will assign static MAC address for each host.
23 Mininet CLI Commands Display Mininet CLI commands mininet> help Display nodes mininet> nodes Display links mininet> net Dump information about all nodes mininet> dump
24 Mininet CLI Commands Xterm display mininet> xterm h1 Ping between all hosts mininet> pingall <node> <command> Ex1: mininet> h1 ifconfig Ex2: mininet> h1 ping h2
25 Xming and Mininet CLI $ sudo mn --topo single,3 mininet> xterm h1
26 Mininet Create Custom Topology Use python script to create custom mininet topology. Use vim or a text editor to write the python file. Some useful function addhost( <host name> ) - add host addswitch( <switch name> ) - add switch addlink( <node1>, <node2> ) - add link
27 Mininet Create Custom Topology Example Topology leftswitch rightswitch lefthost righthost
28 Mininet Create Custom Topology Setup part Create Topology part Important part, name your topology
29 Mininet Create Custom Topology Save the topology file at a location. Use the custom flag and topo flag to tell mininet what topology you want to use. $ sudo mn --custom /mytopology.py --topo=mytopo -- controller=remote(,ip=[host address],port=6633) Default option setting. You can neglect them.
30 Ryu
31 How to Install Ryu $ sudo apt-get update $ sudo apt-get install python-pip python-dev -y $ sudo apt-get install python-eventlet python-routes python-webob pythonparamiko y $ sudo pip install ryu $ sudo pip install --upgrade six
32 Ryu L2 Learning Switch Application The Source Code of the Application: https://github.com/osrg/ryu/blob/master/ryu/app/simple_switch_13.py Another tutorial will be published on the course website.
33 Run The Program Run the Mininet Topology $ sudo mn --topo single,3 --mac --switch ovsk,protocols=openflow13 --controller remote Run the Ryu Application (Login VM with another putty window.) $ ryu-manager --verbose ryu.app.simple_switch_13
34 Result Format: switch_id, src_mac, dst_mac, in_port test mininet Ryu
Open vswitch and 35 OpenFlow
36 Open vswitch Open vswitch is a production quality, virtual switch Open vswitch can operate both as a soft switch running within the hypervisor, and as the control stack for switching silicon. It has been ported to multiple virtualization platforms and switching chipsets.
37 Open vswitch Show Interfaces mininet@mininet-vm:~$sudo ovs-vsctl show Set Controller on the specific Open vswitch mininet@mininet-vm:~$sudo ovs-vsctl set-controller <Bridge name> tcp:1.2.3.4:6633 Set OpenFlow version that the specific Open vswitch can support mininet@mininet-vm:~$sudo ovs-vsctl set bridge <Bridge name> protocols=openflow13 Clear the setting of OpenFlow version on the specific Open vswitch mininet@mininet-vm:~$sudo ovs-vsctl clear bridge <Bridge name> protocols Query the flow rules on the specific Open vswitch mininet@mininet-vm:~$sudo ovs-ofctl dump-flows <Bridge name> -O OpenFlow13
38 Result Open vswitch s1 Flow Table(7 rules): Top 6 rules: host to host 1 rule: to the controller test mininet
39 OpenFlow OpenFlow is a communications protocol that gives access to the forwarding plane of a network switch or router over the network. The OpenFlow protocol is layered on top of the Transmission Control Protocol (TCP), and prescribes the use of Transport Layer Security (TLS). Controllers should listen on TCP port 6653 for switches that want to set up a connection. Earlier versions of the OpenFlow protocol unofficially used port 6633.
40 OpenFlow Message PacketIn The PacketIn message is a way for the switch to send a captured packet to the controller. There are two reasons why this might happen; there could be an explicit action as a result of a match asking for this behavior, or from a miss in the match tables FeatureRes The FeatureRes is the switch's reply to the controller enumerating its abilities. FlowMod One of the main messages, it allows the controller to modify the state of an OpenFlow switch. PacketOut The controller has the ability to inject packets into the data plane of a particular switch. it does this with the PacketOut message, which can either carry a raw packet to inject into the switch, or indicate a local buffer on the switch containing a raw packet to release.
41 Reference Mininet Walkthrough (link) OpenvSwitch Commands (link) OpenFlow Messages (link) Ryu Book (link) simple_monitor_13.py : (link)