$30
Linux Prelab
This pre-lab is designed to get you comfortable with a Linux environment. These commands can all be run on any Linux machine you have access to. You can SSH to the campus timeshare if you do not have a Linux machine easily available. You can also set up the Mininet VM early (see Lab 1 in this PDF) and use that as a Linux environment. Within the VM, the Terminal application will provide you with a CLI.
Recommended resources for this lab:
http://linux-training.be/index.php?nav=fundamentals http://linuxcommand.org/lc3_writing_shell_scripts.php
Feel free to also use online resources/Google/StackOverflow/etc. to help you find solutions to these questions. If you use an online resource, make sure to give credit. Providing the URL in your answer PDF is adaquete.
Pre-lab Questions:
[5] What command will show you which groups you are a member of?
[5] What does the environmental variable “$?” hold? (Hint: the command ‘echo $?’ will should you this on your screen)
[5] What key combination will suspend a currently running process and place it as a background process?
[5] With what command (and arguments) can you find out your kernel version and the “nodename”? [The output should not include any other information]
[5] What is the difference between the paths “.”, “..”, and “~”? What does the path “/” refer to when not preceded by anything?
[5] What is a pid? Which command would you use to find the “pid” for a running process?
[20] Write a single command that will return every user’s default shell. [You may chain commands using piping and redirects] (Hint: See ‘Chapter 19: filters’ of linux-training.be as well as the man page for the /etc/passwd file: https://linux.die.net/man/5/passwd)
[10] What is the difference between “sudo” and “su root”?
[10] How would you tell your computer to run a program or script on a schedule or set interval on Linux? E.g. Run this program once every 30 minutes.
[30] Write a shell script that only prints the even numbered lines of each file in the current directory. The output should be filename: line for each even numbered line. You do not need to print line numbers.
For example, let’s say I write a script in a file called test.sh. I then create 3 files, as shown in the screenshot below:
My directory now looks like the following:
When I run the script, the output should look like the following.
Lab 1: Installing and Using Mininet
Part 1: Installing Virtualbox
The first thing required for mininet is a Virtual Machine (VM) manager to run our mininet VM. VirtualBox is free and open source and can be downloaded here. You are free to use kvm, vmware, or xen if you are familiar with those hypervisors - however, the TAs will not support them, so you are on your own.
If you are having trouble installing VirtualBox, make sure to consult the VirtualBox manual, Piazza, or the TAs.
It is recommended that you start the lab early in case you encounter any problems setting up either
VirtualBox or Mininet. If you do not have a computer, please contact the TAs and we can work something out.
common Problems Installing VirtualBox:
Did you download the correct version? (32-bit vs 64-bit)
Is your computer really old? It might not be able to be virtualized -- talk to the TA.
cMake sure that virtualization is enabled in your BIOS.
Part 2: Installing Mininet
Once VirtualBox is installed, we can install the mininet VM. For this class, please use the VM available at this link.
Using a GUI:
Once the download is complete, open VirtualBox and select File>Import Appliance… Navigate to the OVA file you downloaded.
When the mininet VM has been successfully imported, start the VM.
You should be presented with a GUI. Helpful tips:Chromium is a web browser. You can use this to go to the class webpage, copy/paste example code from the PDFs.
You can use your Google Drive to copy files to/from the VM.
Part 3: Using Mininet
A walkthrough can be found on the mininet page. First and foremost, here’s some background and information on what is Mininet and why we are using it over the physical lab in BE301A.
What is Mininet? Mininet is a “network in a box” developed at Stanford in 2010. It is software designed to allow large scale networks to be emulated in software on a laptop. Its rise has also been dictated by the use of OpenFlow (which will be the subject of Lab 4 and the Final Project). If you are interested in reading, here is the original Mininet paper.
Why Mininet? Our physical lab is aging from the wear and tear of 11 years of usage (it was donated by Cisco in 2004). Mininet is probably one of the simplest forms of network emulators, is free, is open source, and is widely used by the research community, as well as by universities for teaching computer networks. It allows for more interesting topologies than what can be achieved in the physical lab. Most importantly, it has enabled us to accommodate CE 150/L’s enrollment growth (only five years ago enrollment was around 40 students, while today it is peaking at 100). The physical lab only has 10 workstations, however certain workstations are lacking parts (which either have not been or will be replaced) leaving even fewer usable stations per lab. So in light of the growing student base we are looking towards a solution which scales with the number of students. Almost all students have access to a computer, so instead of buying hundreds of thousands of dollars worth of specialized equipment (e.g., routers, switches), we use general-purpose computers (as a side note: if you don’t have a personal computer please talk to the TAs about using VirtualBox on the lab computers).
How does Mininet Work? Mininet works simply by creating a virtual network on your computer/laptop. It accomplishes this task by creating host namespaces (h1, h2, etc) and connecting them through virtual interfaces. So when we run ping between the linux namespaces h1 and h2, the ping will run from h1’s namespace through a virtual interface pair created for h1 and h2, before it reaches h2. If h1 and h2 are connected through a switch as shown in the python code in the Mininet walkthrough, the ping will transit multiple virtual interface pairs. The switches that we will be using are running OpenVSwitch (OVS). Mininet will connect additional virtual interfaces between each virtual port on the switch with each connected host. The host name space allows each host to see the same file system, but operates as its own process that will run separately from each of the other host processes. The OVS version running on the Ubuntu image supports OpenFlow.
Understanding some mininet commands:
sudo mn: will start mininet
You can use mn -h or type help after you have run mininet net.
We can see that when we launched mininet, it created a mini-network from the output. When we use the net command we can see h1 indicated host 1, it has one network interface eth0 which is connected to the switch on interface eth1. This is shown on the output line: h1 h1-eth0:s1-eth1. There is also host 2 (h2), switch 1 (s1), and controller 0 (c0).
From dump we can also see what IP address have been assigned to h1 and h2. We also are given the pids of each process. Processes in mininet are used for hosts, switches, and controllers. Mininet is composed of processes using Interprocess Communication (IPC) to emulate a network environment. You can review the prelab’s resources and reading to understand more.
Running Mininet as a Python script:
To make custom topologies, it is useful to be able to refine a topology in a script. The following is an example of using a Python script to launch Mininet with a custom topology:
#!/usr/bin/python
from mininet.topo import Topo from mininet.net import Mininet from mininet.cli import CLI
class MyTopology(Topo):
"""
A basic topology
""" def __init__(self):
Topo.__init__(self)
# Set Up Topology Here switch = self.addSwitch('s1') ## Adds a Switch
host1 = self.addHost('h1') ## Adds a Host
self.addLink(host1, switch) ## Add a link
if __name__ == '__main__':
"""
If this script is run as an executable (by chmod +x), this is what it will do
""" topo = MyTopology() ## Creates the topology net = Mininet( topo=topo ) ## Loads the topology net.start() ## Starts Mininet
# Commands here will run on the simulated topology
CLI(net)
net.stop() ## Stops Mininet
You should use this as a skeleton for getting started on the lab. On the Mininet site, The API Reference will be an excellent resource for figuring out how to run pings or open the command prompt in between the net.start() and net.stop() lines.
In Mininet change the default configuration to have 4 hosts connected to a switch.
[30 pts] Save a screenshot of dump and pingall Explain what is being shown in the screenshot.
[10 pts] Run the iperf command as well, and screenshot the output, how fast is the connect?
Run wireshark, and using the display filter, filter for “of”. Note: When you run wireshark you should do so as “sudo wireshark”. When you choose an interface to capture on, you should select “any”.[20 pts] Run ping from a host to any other host using hX ping -c 5 hY. How many of_packet_in messages show up? Take a screenshot of your results.
[20 pts] What is the source and destination IP addresses for these entries? Find another packet that matches the “of” filter with the OpenFlow typefield set to OFPT_PACKET_OUT. What is the source and destination IP address for this entry? Take screenshots showing your results.
[20 pts] Replace the display filter for “of” to “icmp && not of”. Run pingall again, how many entries are generated in wireshark? What types of icmp entries show up? Take a screenshot of your results.