Lab Exercise 3 (part A) Introduction to Mininet

Similar documents
Protocols for Data Networks (aka Advanced Computer Networks)

Cloud and Datacenter Networking

Outline. SDN Overview Mininet and Ryu Overview Mininet VM Setup Ryu Setup OpenFlow Protocol and Open vswitch Reference

Mininet Tutorial. Leonardo Richter Bays Gustavo Mio7o Marcelo Caggiani Luizelli Luciano Paschoal Gaspary

A short walk-through of Mininet and POX

Mininet & OpenFlow 24/11/2016

Denial-of-Service (DoS) Attacks in an SDN Environment

ADVANCED COMPUTER NETWORKS Assignment 9: Introduction to OpenFlow

Lab 3: Simple Firewall using OpenFlow

ADVANCED COMPUTER NETWORKS Assignment 9: Introduction to OpenFlow

Module 2 OpenFlow Configuration Lab

The instructions in this document are applicable to personal computers running the following Operating Systems:

Programming Assignment

Experiment Task Design:

OpenFlow Configuration Lab

Lab 1: Introduction to Linux Networking

Spring 2017 Gabriel Kuri

Using echo command in shell script

Project 4: SDNs Due: 11:59 PM, Dec 12, 2018

COM-407: TCP/IP NETWORKING. LAB EXERCISES (TP) 1 INTRODUCTION TO MININET With Solutions

Lab 3a Using the vi editor

Lab 1: Accessing the Linux Operating System Spring 2009

Parallel Programming Pre-Assignment. Setting up the Software Environment

Assignment 2: Getting to know yanc and Mininet

Jackson State University Department of Computer Science CSC / Computer Security Fall 2013 Instructor: Dr. Natarajan Meghanathan

Configuration and Management of Networks

Linux Systems Administration Getting Started with Linux

Mininet/Openflow. Objectives. Network Topology. You will need a Number

Lab I: Using tcpdump and Wireshark

CS155: Computer Security Spring Project #1. Due: Part 1: Thursday, April pm, Part 2: Monday, April pm.

Reliable SDN Network Architecture

Lab 5a Shell Script Lab 4 Using Arithmetic Operators in shell script

The instructions in this document are applicable to personal computers running the following Operating Systems:

An intro to Mininet. TELE4642: Week5

Assignment 1: Build Environment

Static routing lab KTH/CSC. Juniper version. Group Nr. Name 1. Name 2. Name 3. Name 4. Date. Grade. Instructor s Signature

15-110: Principles of Computing, Spring 2018

LAB 0: LINUX COMMAND LINE AND SVN

COMP 3331/9331: Computer Networks & Applications. Programming Assignment 2: Link State Routing

COP4530 Data Structures, Algorithms and Generic Programming Recitation 3 Date: January 20 & 22, 2009

Sharpen Exercise: Using HPC resources and running parallel applications

CMSC 201 Spring 2017 Lab 01 Hello World

Getting Started Guide. Installation and Setup Instructions. For version Copyright 2009 Code 42 Software, Inc. All rights reserved

Configuration and Management of Networks 2014 / 2015

CS Fundamentals of Programming II Fall Very Basic UNIX

State of the Internet The Need for a New Network Software-Defined Networking (SDN) Network Data Plane SDN Data Plane Technology: OpenFlow

Network softwarization Lab session 2: OS Virtualization Networking

/ Cloud Computing. Recitation 5 September 27 th, 2016

Performance Test of Openflow Agent on Openflow Software-Based Mikrotik RB750 Switch

LAN Setup Reflection. Ask yourself some questions: o Does your VM have the correct IP? o Are you able to ping some locations, internal and external?

CS 215 Fundamentals of Programming II Spring 2019 Very Basic UNIX

Some Ubuntu Practice...

Instructions PLEASE READ (notice bold and underlined phrases)

LAB #5 Intro to Linux and Python on ENGR

CS155: Computer Security Spring Project #1

Week - 01 Lecture - 04 Downloading and installing Python

OPENSTACK CLOUD RUNNING IN A VIRTUAL MACHINE. In Preferences, add 3 Host-only Ethernet Adapters with the following IP Addresses:

Software Defined Networks (S.D.N): Experimentation with Mininet Topologies

Lab Zero: A First Experiment Using GENI and Jacks Tool

Post Ubuntu Install Exercises

CMSC 201 Spring 2018 Lab 01 Hello World

CE151 ASSIGNMENT

UoW HPC Quick Start. Information Technology Services University of Wollongong. ( Last updated on October 10, 2011)

CSC209. Software Tools and Systems Programming.

CSE 101 Introduction to Computers Development / Tutorial / Lab Environment Setup

CS Programming Languages Fall Homework #2

CS 361S - Network Security and Privacy Spring Project #2

Introduction. File System. Note. Achtung!

Assignment 1: Communicating with Programs

LAN Setup Reflection

Lab 1 Introduction to UNIX and C

Quick Installation Guide: TC-Python

Computer Security Coursework Exercise CW1 Web Server and Application Security

Lab Assignment 4 for ECE671 Posted: 11/15/16 Due: 11/29/16. Network Address Translation (NAT) on GENI

Computer Systems and Networks. ECPE 170 Jeff Shafer University of the Pacific. Linux Basics

Assignment 5. 2 Assignment: Emulate a Data Center and Manage it via a Cloud Network Controller

HW/Lab 3: SSL/TLS. CS 336/536: Computer Network Security DUE 11am on Nov 10 (Monday)

Test Lab Introduction to the Test Lab Linux Cluster Environment

Lab Two: Simple TCP/IP Implementation on Click Router

Image Sharpening. Practical Introduction to HPC Exercise. Instructions for Cirrus Tier-2 System

Lab Zero: A First Experiment Using GENI and Jacks Tool

Extegrity Exam4 Take Home Exam Guide

Lab STP configuration on Catalyst 1900 Command Line Interface

On successful completion of the course, the students will be able to attain CO: Experiment linked. 2 to 4. 5 to 8. 9 to 12.

COMPUTER NETWORKING LAB EXERCISES (TP) 1 BASIC CONFIGURATION AND TOOLS FOR EVERYBODY:

Session 1: Accessing MUGrid and Command Line Basics

Introduction to Linux for BlueBEAR. January

Contents. Note: pay attention to where you are. Note: Plaintext version. Note: pay attention to where you are... 1 Note: Plaintext version...

The Assignment is divided into preparation, practical part, and documentation.

C152 Laboratory Exercise 1

Exercise 1: Basic Tools

Introduction to Unix - Lab Exercise 0

Intro to OpenFlow Tutorial

Sharpen Exercise: Using HPC resources and running parallel applications

Before jumping into the exercises perhaps we should recall the FlowVisor API calls which can be reached by using the command fvctl as shown below:

SDN-based Defending against ARP Poisoning Attack

Adding Content to Blackboard

CSC 112 Lab 1: Introduction to Unix and C++ Fall 2009

Logging into the Firepower System

Gns3 You Must Use 'manual Mode' To Connect A Link

Transcription:

Lab Exercise 3 (part A) Introduction to Mininet Objectives: Learn the basic commands in Mininet Learn how to create basic network topologies in Mininet Learn Mininet API Marks: This exercise forms the first part of lab exercise 3. The second part (part B) will be part of next week s lab. Both parts together will comprise 15 marks. Only selected exercises will be marked. However, students must submit answers for all exercises. Deadline: Before your scheduled lab next week. So you get one week to work on this lab. For example, if you go to the Monday 12 noon lab, then your submission is due before 12 noon on the following Monday. You can submit as many times as you wish before the deadline. A later submission will override the earlier submission, so make sure you submit the correct file. Do not leave until the last moment to submit, as there may be technical or communications error and you will not have time to rectify it. Late Penalty: Late penalty will be applied as follows: 1 day after deadline: 20% reduction 2 days after deadline: 40% reduction 3 days after deadline: 60% reduction 4 or more days late: NOT accepted Note that the above penalty is applied to your final mark. For example, if you submit your lab work 2 days late and your score on the lab is 8, then your final mark will be 8-3.2 (40% penalty) = 4.8. Submission Instructions: Submit a PDF document lab3a.pdf with answers to all questions for all exercises. Include all supporting documents such as topology files for Questions 5 and 6(*.py). Create a tar archive of all files called lab3a.tar. Submit the archive using give. Click on the submission link at the top of the page. Max file size for submission is 3MB. Original Work Only: You are strongly encouraged to discuss the questions with other students in your lab. However, each student must submit his or her own work. You may refer to the reference material and also conduct your own research to answer the questions. 1

Notation: In the examples below, we have used the $ sign to represent Linux commands that should be typed at the shell prompt, mininet> to show Mininet commands that should be typed at Mininet s CLI (command line interface), and # to show Linux commands that are typed at a root shell prompt. In each case, you should only type the name of the command and then press return. The actual prompt may look very different on your computer (e.g. it may contain the computer's hostname, or your username, or the current directory name). The commands that you are supposed to type are in this bold font. Part 1: Basic Commands in Mininet In the first step, we start a simple network topology by running the following command: $ sudo mn The above command creates the default topology in Mininet (known as the minimal topology), which includes one OpenFlow 1 kernel switch connected to two hosts, plus the OpenFlow reference. This topology could also be mentioned on the command line using option --topo=minimal with the mn command. Once you run the above command, all four entities (two hosts, one switch, and one controller) are running in the VM and the Mininet CLI comes up. You can run the help command to see the list of commands in the CLI. In the rest of this section, you will practice the basic commands in Mininet. Display nodes: mininet> nodes For more detailed information about the nodes in the network, use dump. Display topology: mininet> net Simple commands within a node: If the first string typed into the Mininet CLI is a host, switch or controller name, the corresponding command is executed on that node. For example, run the following command on host h1 to show its network interfaces. mininet> h1 ifconfig -a 1 OpenFlow is communication protocol between switches and controllers. We do not need to know the details of the OpenFlow protocol in this course. 2

In the above command, you can replace h1 with s1 to see the details of the switch s interfaces. Also, for a list of processes in a host you can run h1 ps a. Note that a switch is a layer 2 packet switch (also known as a bridge). We will examine switches in details when we study about the link layer. Question 1: Draw the Mininet minimal topology and include the IP and MAC addresses for hosts and the switch. To which switch ports are the hosts and controller connected? Test connectivity between hosts: In order to ping host 1 from host 2, run the following command: mininet> h1 ping c5 h2 Question 2: Examine the ping time for all five tries in the above command. What is the ping time for each try? Question 3: You should see that the ping time for the first try is larger than the next tries. How do you explain this observation? A simple way to test the connectivity of all nodes in the Mininet CLI is to run the pingall command, which does an all-pairs ping. XTerm display To display an xterm for host h1, run the following command. This will be useful to run commands within a host or switch. mininet> xterm h1 Python Interpreter If the first part of a command in Mininet is py, then the CLI interprets the command as a Python command. This helps you to manipulate the network objects, such as hosts, switches, and controllers, using the CLI. Here is an example which displays the IP address of host h1. mininet> py h1.ip() Exit and clean up For exiting from the Mininet CLI, run command exit. It is strongly recommended to clean up after exiting by running command sudo mn c. NOTE: PLEASE REMEMBER TO MOUNT YOUR CSE HOME DIRECTORY IN THE VM AND TO SAVE YOUR WORK IN YOUR HOME DIRECTORY BEFORE QUITING. 3

Part 2: Custom Topologies Mininet supports a simple Python API to create custom network topologies. You can create your custom topology by writing a few lines of Python code. For example, Figure 1 shows a topology with two switches and four hosts. Figure 2 implements the topology using the Mininet Python API. The code consists of a class, named MyFirstTopo which extends the Topo class provided by the API. We suggest that you SSH into your mininet VM so that you can use a GUI text editor such as gedit or emacs (see instructions in the Mininet Introduction document). Save the source code in a file, named myfirsttopo.py in your (mounted) CSE home directory. You can download the source code from here: myfirsttopo.py. Change the working directory to your CSE home directory and type: mininet> sudo mn --custom myfirsttopo.py --topo myfirsttopo Question 4: Draw Figure 1 and label the IP and MAC address for the hosts. Also label the interface names and MAC address of the switch ports that are connected to the hosts. Host 1 (h1) Host 3 (h3) Switch 1 (s1) Switch 2 (s2) Host 2 (h2) Host 4 (h4) Figure 1 A sample network topology (myfirsttopo.py) 1. from mininet.topo import Topo 2. 3. class MyFirstTopo( Topo ): 4. "Simple topology example." 5. def init ( self ): 6. "Create custom topo." 7. # Initialize topology 8. Topo. init ( self ) 9. # Add hosts and switches 10. h1 = self.addhost( 'h1' ) 11. h2 = self.addhost( 'h2' ) 12. h3 = self.addhost( 'h3' ) 13. h4 = self.addhost( 'h4' ) 14. leftswitch = self.addswitch( 's1' ) 15. rightswitch = self.addswitch( 's2' ) 16. # Add links 17. self.addlink( h1, leftswitch ) 18. self.addlink( h2, leftswitch ) 19. self.addlink( leftswitch, rightswitch ) 20. self.addlink( rightswitch, h3 ) 21. self.addlink( rightswitch, h4 ) 22. 23. topos = { 'myfirsttopo': ( lambda: MyFirstTopo() ) } Figure 2 Source code for the custom topology presented in Figure 1. 4

If you want to run a quick test without entering the CLI, you can use option --test in Mininet, as follow: mininet> sudo mn --custom myfirsttopo.py --topo myfirsttopo --test pingall Now assume that we want to accomplish the following: 1. Create the topology shown in Figure 1 2. Start the network 3. Show the detailed connectivity of all nodes in the network 4. Test the connectivity by pinging all nodes We can automate this sequence of operations by writing a Python script. This helps us to automate network experiments. To this end, we extend the previous source code, as shown in Figure 3. Download the source code from here: myfirstexpr.py. 1. #!/usr/bin/python 2. 3. from mininet.topo import Topo 4. from mininet.net import Mininet 5. from mininet.util import dumpnodeconnections 6. from mininet.log import setloglevel 7. 8. class MyFirstTopo( Topo ): 9. "Simple topology example." 10. def init ( self ): 11. "Create custom topo." 12. # Initialize topology 13. Topo. init ( self ) 14. # Add hosts and switches 15. h1 = self.addhost( 'h1' ) 16. h2 = self.addhost( 'h2' ) 17. h3 = self.addhost( 'h3' ) 18. h4 = self.addhost( 'h4' ) 19. leftswitch = self.addswitch( 's1' ) 20. rightswitch = self.addswitch( 's2' ) 21. # Add links 22. self.addlink( h1, leftswitch ) 23. self.addlink( h2, leftswitch ) 24. self.addlink( leftswitch, rightswitch ) 25. self.addlink( rightswitch, h3 ) 26. self.addlink( rightswitch, h4 ) 27. 28. def runexperiment(): 29. "Create and test a simple experiment" 30. topo = MyFirstTopo( ) 31. net = Mininet(topo) 32. net.start() 33. print "Dumping host connections" 34. dumpnodeconnections(net.hosts) 35. print "Testing network connectivity" 36. net.pingall() 37. net.stop() 38. 39. if name == ' main ': 40. # Tell mininet to print useful information 41. setloglevel('info') 42. runexperiment() Figure 3 Source code for an experiment on the custom topology. 5

Now download the source code and save it in a file named myfirstexpr.py and run the following command: mininet> sudo python myfirstexpr.py Remember to clean up (sudo mn c) and also to save your work in your CSE home directory before moving forward. Part 3: Mininet Python Classes The Mininet Python API consists of a number of Python classes, such as Topo, Mininet, Host, Switch, Link and their subclasses. The API is built at three primary levels which provide different level of abstractions for customising the network topologies. Here is a brief description of the levels: Low-level API: This API includes the base node and link classes such as Host, Switch and Link. You can directly instantiate some objects from these classes to create a network. Mid-level API: This API consists of the Mininet class which provides a number of methods, such as addhost(), addswitch(), and addlink(), for creating a network. High-level API: This API consists of the Topo class, which provides the ability to create reusable, parameterised topology templates. These templates can be passed to the mn command (via the --custom option as in Part 2 above) and used from the command line. Figure 2 and Figure 3 are two examples that show how to use the high-level API. As you can see, the high-level API provides an object-oriented framework by presenting the Topo class. Figure 4 shows how to use the low-level API for creating the custom topology presented in Figure 1. Download the source code from here: myfirsttopo_lowlevel.py. Observe that, with the low-level API we create all the objects and connect the topology manually. You can test this code by typing the following: mininet> sudo python myfirsttopo_lowlevel.py You can find the detailed documentation of all classes provided in the Mininet Python API in http://mininet.org/api/annotated.html. 6

1. #!/usr/bin/python 2. 3. from mininet.node import Host,OVSSwitch,Controller 4. from mininet.link import Link 5. 6. h1 = Host( 'h1' ) 7. h2 = Host( 'h2' ) 8. h3 = Host( 'h3' ) 9. h4 = Host( 'h4' ) 10. s1 = OVSSwitch( 's1', innamespace=false ) 11. s2 = OVSSwitch( 's2', innamespace=false ) 12. c0 = Controller( 'c0', innamespace=false ) 13. Link( h1, s1 ) 14. Link( h2, s1 ) 15. Link( h3, s2 ) 16. Link( h4, s2 ) 17. Link( s1, s2 ) 18. h1.setip( '10.0.0.1/24' ) 19. h2.setip( '10.0.0.2/24' ) 20. h3.setip( '10.0.0.3/24' ) 21. h4.setip( '10.0.0.4/24' ) 22. c0.start() 23. s1.start( [ c0 ] ) 24. s2.start( [ c0 ] ) 25. print h1.ip 26. print h2.ip 27. print h3.ip 28. print h4.ip 29. print 'Pinging...' 30. print h1.cmd( 'ping -c3 ', h2.ip() ) 31. print h1.cmd( 'ping -c3 ', h3.ip() ) 32. s1.stop() 33. s2.stop() 34. c0.stop() Figure 4 Source code for the topology presented in Figure 1 using low-level API. Remember to clean up (sudo mn c) and also to save your work in your CSE home directory before moving forward. Part 4: Simple Tree Topology Many data centres use a tree-like network topology. End-hosts (i.e. servers) connect to top-of-rack switches, called edge switches and form the leaves of the tree; one or more core switches form the root of the tree; and one or more aggregation switches form the intermediate nodes of the tree. In a simple tree topology, there is only one core switch connected to n aggregation switches; each aggregation switch is connected to n edge switches; each edges switches is connected to n hosts (servers). Figure 5 shows a simple tree topology where n =2. 7

Figure 5 Simple-tree topology with n = 2. Question 5: Write a Python program to use the high-level API and create a simple-tree data centre topology. You must follow the naming system as shown in Figure 6. The program gets the value of n as an input. You must organise all the source code in a single source file, name it simpletree_highlevel.py, and include this file in the submission archive. Question 6: Repeat the previous question but now use the low-level API. You must organise all the source code in a single source file, name it simpletree_lowlevel.py, and include this file in the submission archive. Question 7: Use your program (either high-level or low-level) to create a simple-tree with n = 2, as shown in Figure 5. Check the connectivity of all nodes in the network and write your observations. Now stop the core switch using command switch c1 stop, check the connectivity of all hosts and report your observations. How do you explain your findings? Write up your answer in the report. Part 5: Useful Resources Introduction to Mininet: https://github.com/mininet/mininet/wiki/introduction-to-mininet Mininet Walkthrough: http://mininet.org/walkthrough/ Mininet Python API Reference Manual: http://mininet.org/api/annotated.html 8