This article describes my first experience with the cloonix open-source network simulator. I installed cloonix on ubuntu 12.04 and tested it by running the demonstration script provided with the cloonix package. The demonstration script sets up a simulated OSPF network and runs HTTP traffic between two virtual computers attached to that network.
The cloonix package provides modified versions of networking tools and virtual machine management tools, so one does not need to install a lot of supporting software. The developers also provide filesystems for Linux distributions such as Debian and Vyatta (a Linux router) that can be used in the simulations. More details about what makes cloonix special are available in the online cloonix documentation.
The procedure to set up and run the demonstration script was partly documented on the cloonix web site, and partly documented in README files in the downloaded cloonix packages. This article pulls together all the information required to successfully install cloonix and run the demonstration script.
NOTE (updated February 26, 2013): The Cloonix development team updates Cloonix every few months and, eventually, they remove links to old releases from their web site. To follow this tutorial, use the latest version of Cloonix found on the Cloonix web site.
Linux host computer required
In previous posts, I discussed running open-source network simulators inside a VirtualBox virtual machine to make installation simple and make the solution “portable”. But, in this case, I am using ubuntu 12.04 Linux running on the host computer. I explain why below.
The prepared cloonix demonstration will not run inside a VirtualBox virtual machine running on my iMac, which runs Mac OS X, because the demonstration uses KVM virtual machines. The KVM hypervisor used by cloonix will not run inside another virtual machine (KVM will run inside another KVM virtual machine, but KVM only runs when Linux is the host operating system). I understand that cloonix supports other types of virtualization that are compatible with running inside a virtual machine, but the prepared demonstration uses KVM.
I performed this demonstration on an Apple iMac (2008) computer running the 64-bit version of ubuntu 12.04 as its operating system. Cloonix must be installed in a 64-bit operating system, so I chose the 64-bit ubuntu installer DVD for Mac when installing ubuntu. (I installed a dual-boot configuration so I can switch between OS X and Linux).
Test the host computer for KVM compatibility.
This demonstration, which was created by the authors of cloonix, uses KVM. Cloonix can also use other virtualization technologies such as UML and LXC, so it is still useful even if your computer does not support KVM. However, if your computer does not support KVM the demonstration described below will not work.
KVM relies on hardware extensions provided by the computer’s microprocessor. These virtualization extension technologies are called VT-x or AMD-V. Most computers sold in the past 5 years support these technologies, but computers that have low-cost microprocessors may not support them. To test your system, execute the following command in a terminal or xterm:
$ egrep -c '(vmx|svm)' /proc/cpuinfo
If the return is 0, the microprocessor on your computer does not support the required virtualization extensions, VT-x or AMD-V, so KVM is not supported on your machine because KVM relies on these hardware technologies.
In my case, on my 2008 Apple iMac computer, this command returns the value, “2”, so I know my iMac will run KVM.
Alternatively, you can run the command:
$ lscpu
and see the entry for “Virtualization”. You will see the value, “VT-X” or “AMD-V” opposite the entry for “Virtualization”, if your computer’s microprocessor supports these technologies.
Install supporting software
We need to install some extra software for cloonix to work in Ubuntu 12.04. Prepare your host Ubuntu 12.04 computer for cloonix by following the instructions listed below.
Remember to update the repository before installing the software listed below. Execute the command:
$ sudo apt-get update
Install other software packages
Install the software packages that cloonix relies upon. Depending on which ubuntu DVD you used to install your system, these may already be installed, but run the following commands to make sure:
$ sudo apt-get install xterm $ sudo apt-get install wireshark $ sudo apt-get install spice-client $ sudo apt-get install spice-client-gtk
Download and install cloonix
Download the pre-compiled cloonix software for the 64-bit ubuntu 12.04 release. If you prefer to compile the software, the cloonix demo documentation also provides instructions to compile cloonix.
Download the following files from the Cloonix web site http://clownix.net. Updates occur often, so check for the latest version. This demo uses cloonix version 19.
- Click on Downloads v19.
- Click on Downloads cloonix_v19.
- Click on cloonix-19.1-precise to download the compiled version of Cloonix for the Ubuntu 12.04 distribution.
- Then go back to the Downloads v19 page and click on Download Guests.
- Click on kvm_wheezy_lab_qcow2 to download the filesystem used in this demonstration.
- Then go back to the Downloads v19 page and click on demo_cloonix_web.
All these files will be saved in your ~/Downloads folder.
Install pre-compiled cloonix
In my case, I created a new folder in my home directory called Network_Simulators. Then, when I unpacked the archive using the Archive Manager application, I saved the extracted contents of the downloaded archive, cloonix-19.1-precise.tar.gz, to my Network_Simulators folder.
Or, if I had used the command line, I would have copied the cloonix-19.1-precise.tar.gz archive file to my ~/Network_Simulators directory and execute the command:
$ tar xvf cloonix-19.1-precise.tar.gz
A new directory, cloonix-19.1-precise, will be created in the ~/Network_Simulators directory.
Reboot the host computer
It may not be necessary to reboot the host computer, but I always like to reboot after installing lots of new software. Ensure that any documents you have open on the host computer are saved. In the Terminal program, execute the command:
$ sudo reboot
Set up KVM
You do not need to install KVM because a version of KVM, modified by the cloonix developers, comes with the cloonix package. The cloonix version of KVM will not conflict with the standard version of KVM, if you had already installed KVM from the ubuntu repository.
To use KVM, you need to activate KVM support in the kernel using the modprobe command. Then, the kernel creates the device, /dev/kvm.
$ sudo modprobe kvm_intel nested=1
If you get a fatal error, run the command: $ sudo dmesg
. If the command output shows kvm: disabled by bios
, then you must enable virtualization in your host computer’s BIOS. The procedure to do this will be different for each computer manufacturer so read the user manual to learn how to access your computer’s BIOS settings. After updating the BIOS and saving the settings, power down your computer and then turn it on again. You need to power down to enable the saved BIOS settings; a restart will not work. Then, run the modprobe command, again.
You need to give all users access to /dev/kvm using the chmod command:
sudo chmod 666 /dev/kvm
The ubuntu documentation provides instructions for creating more restricted permissions, if that is required.
Install the lab demo files
Install the demo KVM filesystem
This demonstration uses a guest filesystem that already has the necessary software installed. This filesystem should be extracted from the kvm_wheezy_lab_qcow2.tar.gz archive in the ~/Downloads folder and extracted to the ~/Network Simulators/cloonix-19.1-precise/bulk directory. Use the Archive Manager program to do this.
Modify the start_demo.sh script
There is a README file in the …/cloonix-19.1-precise/sample_demo_scripts/demo_cloonix_web directory. This README file provides directions on how to modify the demo script to run in the directory you created. The following instructions are derived from that README file.
In the start_demo.sh script, replace the line, BASE=/home/perrier/cloonix_labs
, with the path of your own cloonix directory tree. In my case, I replace it with the line: BASE=/home/blinklet/Network_Simulators/cloonix-19.1-precise
Run the cloonix web demo
Run the demo scripts
Open the Terminal program. Navigate to the demo_cloonix-web directory and run the demo script.
$ cd ~/Network_Simulators/cloonix-19.1-precise/sample_demo_scripts/demo_cloonix_web $ ./start_demo.sh
Now the script is running. New windows will open and you will see the script status output in the terminal window. If everything works correctly, the cloonix script will produce the following output in the Terminal:
CONNECT TO UNIX SERVER: /tmp/cloonix_demo_web/cloonix_unix_sock CONNECTED GRAPH PID: 2277 SENDING SNIFF SNIFF Add snf0 SNIFF conf recpath snf0 -set_conf /tmp/cloonix_snf0.pcap SNIFF Add vlan snf0 4444 SNIFF Add vlan snf0 5555 SNIFF Add vlan snf0 lan_dns SNIFF Topo send ended ALL OK, sending topo Add QEMU_KVM router1 Nb eth: 5 Add vlan lan_dns in eth0 of VM router1 Add vlan 3333 in eth1 of VM router1 Add vlan 1111 in eth2 of VM router1 Add vlan 2222 in eth3 of VM router1 Add QEMU_KVM dns Nb eth: 2 Add vlan lan_dns in eth0 of VM dns Add QEMU_KVM server.cloonix.net Nb eth: 3 Add vlan lan_dns in eth0 of VM server.cloonix.net Add vlan 6666 in eth1 of VM server.cloonix.net Add QEMU_KVM router4 Nb eth: 5 Add vlan lan_dns in eth0 of VM router4 Add vlan 5555 in eth1 of VM router4 Add vlan 6666 in eth2 of VM router4 CPU of host machine high! Add vlan 4444 in eth3 of VM router4 CPU of host machine high! Add QEMU_KVM router3 Nb eth: 4 Add vlan lan_dns in eth0 of VM router3 Add vlan 3333 in eth1 of VM router3 Add vlan 33332 in eth2 of VM router3 Add QEMU_KVM client Nb eth: 3 Add vlan lan_dns in eth0 of VM client Add vlan 1111 in eth1 of VM client Add QEMU_KVM router2 Nb eth: 4 Add vlan lan_dns in eth0 of VM router2 Add vlan 2222 in eth1 of VM router2 Add vlan 4444 in eth2 of VM router2 Add QEMU_KVM router33 Nb eth: 4 Add vlan lan_dns in eth0 of VM router33 Add vlan 33332 in eth1 of VM router33 Add vlan 5555 in eth2 of VM router33 Topo send ended ALL OK
The cloonix graph window will appear. Slowly (at least, it was slow on my iMac), circles that represent the virtual machines started by the demo script will appear on in the graph, in sync with the Terminal window output. Wait for the circles to turn blue.
Error router33
In my case, the demonstration script often encountered an error and stopped. The most common error was that the last VM started by the script, Router33, started but did not connect to the cloonix network.
The relevant messages output to the terminal were:
... CPU of host machine high! ... Add QEMU_KVM router33 Nb eth: 4 Add vlan lan_dns in eth0 of VM router33 Add vlan 33332 in eth1 of VM router33 KO: status -1 Machine router33 does not exist
I stopped and started the script multiple times and was able to recreate this problem most of the time. A few times the script failed earlier, a few other times everything worked correctly, but most of the time Router33 failed to connect. I noticed the warning, “CPU of host machine high!” in the script’s output so I believe this is a race condition issue that may occur on slower machine like my iMac. The Router33 virtual machine does not start fast enough, so when the script — which executes regardless of the status of the virtual machines in the simulated network it creates — tries to add Router33’s ethernet interface to the network, it fails.
I posted a query to the cloonix mailing list about this issue and I quickly received a response from the developers. The developers provided me with an easy workaround to complete the script setup. If you encounter this problem, connect Router33 to the network by using the following cloonix commands while in the /cloonix-19.1-precise/sample_demo_scripts/demo_cloonix_web directory:
./ctrl add_vl2eth router33 eth1 33332 ./ctrl add_vl2eth router33 eth0 lan_dns ./ctrl add_vl2eth router33 eth2 5555
This issue will not affect normal use of the cloonix network simulator, where the user creates new networks of virtual machines using the cloonix graph graphical user interface or the cloonix ctrl command line tool. And, the developers said they would fix the issue in a later release.
Verify operation of simulated network
Now, the simulated network and all the virtual machines are running and we want to try out the features of the cloonix tool.
Double-click on the sniffer, which is the small yellow and green circle in the graph. The green spot should turn red. This indicates that the sniffer process is running and is capturing packets. The sniffer writes the captured packets to a pcap file in the host computer’s /tmp directory: /tmp/cloonix_snf0.pcap.
Double-click on the client VM (the blue circle labeled client in the graph window). This will open up an xterm window on the client VM. The xterm window appears on the host computer’s desktop but it is really running on the client VM.
Start the Iceweasel web browser on the client VM. Iceweasel is the web browser that is installed on the Debian Linux distribution running on the client VM. In the client xterm window, execute the command:
$ iceweasel
A new window will open running the Iceweasel browser. Again, while this window appears on the host desktop, the Iceweasel program is really running on the client VM.
In the Iceweasel browser, enter the URL of the server VM, server.cloonix.net and press return. The browser will now request a web page from the server VM and you should see the web page in the Iceweasel browser. It is a simple text message that just say, “It works!”
This shows that the OSPF routing software converged and that all clients, servers, and routers in the simulated network now have the network topology and can locate each other in the network. It also shows that the host computer (and you, the user) can communicate with each virtual machine in the simulation to run software, modify configurations, and inspect system and network status.
Now, stop the sniffer process and inspect the packet capture (pcap) file. To stop the sniffer, double-click on it again. The small red circle should turn green.
Look at the captured packets
In the Terminal program on the host computer, run the command:
$ wireshark /tmp/cloonix_snf0.pcap
This will start the Wireshark packet analysis program and load the packet capture file, cloonix_snf0.pcap.
Browsing through this file shows the packets captured on the VLANs 5555 and 4444 on the cloonix graph, and also on the hidden VLAN lan_dns. (Cloonix allows network elements to be hidden to simplify the graph; right-click on the graph to select and make hidden elements visible.)
The capture file will show OSPF HELLO messages, DNS lookups, HTTP sessions, etc…
Further experimenting with cloonix
Cloonix provides a command interface, the ctrl command. To see all the functions supported by this command, execute the command:
$ ./ctrl |-------------------------------------------------------------------------| /home/blinklet/Network_Simulators/cloonix-19.1-precise/bin_cloonix/cloonix_cli tux:/tmp/cloonix_demo_web/cloonix_unix_sock |-------------------------------------------------------------------------| | kill : Destroys and kills | add_hweth : Add hweth interface | | -k : Same as above | add_vl2eth : Add vlan to vm eth | | delall : Destroys all objects | add_vl2tux : Add vlan to tux/tap | | set_topo : sends a topology | add_vl2ser : Add vlan to serial | | get_topo : stores a topology | del_vm : Delete machine | | get_ftopo : same plus rootfs | del_tux : Delete tux server | | dump_name : dump the vm names | del_tap : Delete tap | | dump_pid : dump the pids | del_hweth : Delete hweth | | dump_ip : dump the admin ips | del_vl2eth : Del vlan from vm eth | | dump_topo : dump the topo | del_vl2tux : Del vlan from tux | | add_vm_file : Add vm with file | del_vl2ser : Del vlan from serial | | add_vm_blxc : Add vm btrfs lxc | event_print : prints events | | add_vm_tlxc : Add vm targz lxc | event_sys : prints system stats | | add_vm_uml : Add vm uml | event_stat : prints flow stats | | add_vm_qkvm : Add vm qemu kvm | event_hop : dump 1 hop debug | | add_vm_ckvm : Add vm cloonix kvm | cool_cmd : Send cmd to cool | | sav_vm_kvm : Save vm rootfs | promisc : Conf promisc for eth | | add_tux_file: Add tux with file | t2t : tux2tux commands | | add_tux : Add tux server | layout : layout commands | | add_tap : Add tap interface | sniff : sniff commands | |-------------------------------------------------------------------------|
Obviously, there is a lot of functionality, here. Also, the graph program provides point-and-click functions that allow you to add and move virtual machines to the simulated network using the computer mouse.
Shut down the demo
To shut down the demonstration, execute the following command in the Terminal program:
$ cd ~/Network_Simulators/cloonix-19.1-precise/sample_demo_scripts/demo_cloonix_web $ ./clean_demo.sh
Conclusion
I am impressed with cloonix. I found it was easy to install and the prepared demonstration script allowed me to try out a lot of functionality. The developers are actively engaged on the mailing list and are passionate about supporting this software.
Once cloonix it is installed, users can create networks of virtual machines using a graphical user interface and monitor the behavior of those networks using standard Linux network analysis tools. In a classroom environment, an administrator could install and configure cloonix on one or more host computers. Students could run network simulations on these computers from their own user accounts, which would prevent students from accidentally breaking the system because the students do not need access to root.
Cloonix can even run inside a KVM virtual machine by using nested virtualization (which is not supported by other hypervisors like VirtualBox, unfortunately). This would allow several students to use separate instances of cloonix on a powerful host computer, over a network connection.
I think that the kvm installation is not required for cloonix, cloonix recompiles the qemu-kvm it uses, the only necessary commands are:
modprobe kvm-install
chmod 666 /dev/kvm
(or something equivalent to give the user rights to /dev/kvm)
The following installations are (probably) not necessary:
sudo apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils
But it is of no consequences to install those, that way users can try other virtualisations.
Thanks for your comment! I will verify this and update this article to simplify the steps, based on your feedback.
I verified that the standard version of KVM does not need to be installed. I made some changes to the article. Thanks again for your feedback!
Pingback: Compiling Cloonix on Ubuntu 12.04 Live | Open-Source Routing and Network Simulation Blog
Pingback: Install Cloonix on a Knoppix USB flash drive | Open-Source Routing and Network Simulation Blog
In less than 2 weeks, during first 15 days of feb 2013, cloonix will provide a c7200 cisco amongs its machines. This will be done with the help of dynamips binary now updated by gns3, the user will have to find and download a cisco ios (which seems easy now).
In 1 month, cloonix will provide a step-by-step way to put a windows 7 inside cloonix, with spice as desktop it works well… The windows machine will be valid 90 days and the machine itself may or may not be downloadable at cloonix, since we do not know exactly what is permited/tolerated as far as a 90 days test windows machines are concerned…
Hi Vincent,
I see Cloonix v20 has been released. I look forward to trying it out!
Thanks,
Brian
Pingback: Put a cisco in your Linux machine
Sir will cloonix run on windows 7?
Hi Vignesh,
No, cloonix will only run on Linux. You could post a question or request to the cloonix mailing list at: http://clownix.net/mailman/listinfo/cloonix-list_clownix.net
Regards,
Brian
Pingback: Install Cloonix v24 | Open-Source Routing and Network Simulation