Virtual Machines for Programming Assignments
The programming assignments of this course will be done using the Mininet emulator. The recommended way of accessing mininet is through VM images loaded with Mininet, which will provide easy access to the emulator, without the need for installation or setup. You will have two ways to access the VMs prepared for the 2 programming assignments. You can either install VirtualBox on your own computer and import the VM images, or you can access the images through the teaching systems.
VM images on Virtual Box
- VirtualBox: Download and install VirtualBox, a virtualization platform. VirtualBox is available on Linux, Windows, and MacOS, yet it does not support Apple Silicon. Therefore, to the best of our knowledge, if your computer has Apple M chips, you won't be able to import the VM images.
- VM images: Download the VM images for PA1 or PA2.
- Import VMs: On VirtualBox, go to File->Import Appliance and select the .ova file you just downloaded. Follow the steps to create your VM.
- Port Forwarding: To avoid using the VirtualBox VMs interface for working with Mininet, set up port forwarding on your VM instance. With port forwarding, you can expose port 22 inside the VM instance (listened to by the OpenSSH server) in your host machine. To do this, click on your newly imported VM, and click on Settings > Network > Advanced > Port Forwarding. In the new window, add a rule to forward port 22 on the Guest to port 2222 on the Host, with TCP protocol. The IP fields can remain empty.
- Start VM: Power on your VM and wait for the guest OS to boot, until you see the login page.
- Connect to VM: On your host machine, open up a terminal, and connect via SSH to your virtual machine, by running the following command:
The port number is the same as the one chosen in the port forwarding step. If you chose anything other than 2222, you should change this command accordingly.ssh -p 2222 USERNAME@localhost
- Login: The USERNAME in the previous step is "mininet" for Assignment 1's VM, and "csc458" for Assignment 2. The passwords are the same as the username for both of the assignments.
- Mininet Sanity Check: Do a quick check by running the following commands:
sudo mn -c sudo mn --test pingall
- Do the assignment: Continue with the assignment according to the handout.
MiniNet on CDF
If you don't want to (or can't) deploy the VMs on your personal machines, you can use the workstation machines in the Bahen center to create VM for your assignment.- Every registered student (CSC458/CSC2209) will have access to their copy of a MiniNet VM on workstation machines.
- Your Mininet VM runs with 1GB of memory and a private network connecting to the rest of the world.
- All workstation machines should be usable for the assignment.
To use the Mininet VM for CSC458/2209:
Log into one of the CDF teaching lab workstation machines with your teach.cs credentials.
Open a terminal window and run the command
cvm csc458-1
for assignment 1's VM, and run
cvm csc458-2
for assignment 2's VM. If this is the first time you've used the VM, there may be a few seconds of delay. If the VM is loading, ignore any errors you see in the output.
-
A new window will pop up showing the VM console. When it is ready to use, you can log in on the console (not recommended), or via ssh from the same host on which you started the VM (recommended), using
ssh -p PORT USER@localhost
For assignment 1, the PORT is 8021, the USER is mininet, and the password is mininet.
For assignment 2, the PORT is 8022, the USER is csc458, and the password is csc458.
Other Things You Should Know
- VMs (either on the CDF machines or your personal machines) are not a reliable place to keep your ongoing work. Backup your work on a remote version control system (e.g., git), or through other methods, you are comfortable with.
- It is best to close down the VM cleanly before logging off the CDF workstation by doing
sudo poweroff
and waiting for the VM-console window to disappear. If you just log off (or if you kill the process started by the cvm command), the virtual machine will stop abruptly, rather like pulling out the power plug on a real system. Often this will do no harm, but there's some chance you'll end up with a corrupted virtual machine that won't work right anymore, or the changes you made won't persist on the disk. - If you use the VM console window, your keyboard and mouse may get stuck in there. To unstick them, press your keyboard's left-hand CTRL and ALT keys at the same time.
- There is one copy of the Mininet VM associated with your CDF account. You'll get the same one no matter which workstation you log into.
- Do not run the VM more than once at the same time; if you do, you'll likely end up with a scrambled, corrupt virtual disk. There is some simple protection to try to keep you from doing this by accident but it doesn't yet detect if you do it on two different workstations.
- If you end up with a corrupted VM, you can destroy your VM instance and start anew. Type in the command
cvm -DESTROY [VM-NAME]
replacing [VM-NAME] with csc458-1 or csc458-2 for the first and second assignment respectively. Then issue the originalcvm
command to instantiate a new VM.