Plug and Play Clownix Network

Vincent Perrier

2008-05

This mini-doc describes main points of the Plug-and-Play Clownix Network


Table of Contents
1. Introduction
2. Root_fs
3. Linux
4. Uml Clownix Switch
5. Ctrl
6. Cloonix_graph

1. Introduction

The goal of this open source package is similar or associated to what is being done at the following links: As you see, clownix is not alone in trying to provide a portable network based on User Mode Linux or UML. As far as I can see, it is the best solution that makes user application virtual networks possible. The usual way to simulate a lan in the networks above, up to now was to one of the 2 solutions: Clownix switch daemon can serve and switch any number of UML machines and taps and that can modify the network topologie upon simple commands.
          network monitoring      topology modification
                     \              /
                      \    tap     /
                       \    |     /
  UML -------------\    \   |    /     /--------------   UML
UML -------------  clownix-switch-daemon ---------------   UML 
  UML -------------/        |          \--------------   UML
                            |
                           tap

The uml clownix network solution is not only a switching daemon, as many of the above solutions, it contains its own file-system, a kernel and a kind of wraper to hide the use of the UML command line. This makes things easy for the user. That is why it is now called Plug-and-Play Network.


working dir (/tmp/clownix) ----------------\
                                            \
host ctrl network IP (1.1.1.1)-----------\   \
                                       clownix-switch ---> Virtual-Machine 
dir with linux and root_fs (./bulk)------/    /
                                             /
rsa keys (id_rsa.pub id_rsa)----------------/
	

I hope you will try it and enjoy its simplicity.


2. Root_fs

Without a doubt, the heaviest actor in a virtual machine is its file-system, it is growing with every version I do.
The list of packages to make the root_fs used is in the linux_from_scratch.tar.gz package that can be downloaded. (In the README part).

Each machine believes it has its own root_fs. As the one provided is 4 giga, you may think that if each machine wants its own copy of the file system, a big network is impossible, UML provides a solution:
It is called the COW, (copy on write), it permits an UML machine to save only the differences between its file system and an untouched reference.
The reference is 4 gigas, but only 1.5 giga is software, the rest is empty space, just as any hard disk has empty space.

All the stuff you import in a virtual machine is destroyed at when the virtual machine is stopped except when --root_fs is used at switch daemon startup. In this case, everything you write in the virtual machine will be stored in the reference root_fs.
Note: in this mode, the switch does not open the control socket, and only a single machine can be launched.

You can find other file systems on the web, but the one provided has an init file customised for the clownix network start at /etc/rc.d/rc3.d/S19clownix:

  if [ -e /dev/ubdb ]; then
    mkdir /mnt/clownix_config_fs
    mount /dev/ubdb /mnt/clownix_config_fs
    cd /mnt/clownix_config_fs
    chmod +x ./config_cmd
    ./config_cmd
    cd -
    umount /mnt/clownix_config_fs
  fi

This file is called at virtual machine startup, "ubdb=path_to_config_fs" is added at the linux uml process start, the path_to_config_fs is transmitted as a secondary hard disc (the primary ubda is the root fs).
This secondary hard disk given as parameter contains the name of the virtual machine and its system ip number.
It is a way to customize the machines without impact on the main reference ubda root file system.
This hack permits also to transmit the rsa authorisation files to use ssh and scp without passwords.

If you need the kernel headers in your compile, particularly if you want to compile a module, do not forget to do "make ARCH=um" instead of make so as to pull the right header files from the virtual machine’s kernel headers.


3. Linux

This is Jeff Dike’s work, if you make the vanilla linux kernel found at kernel.org with the following command: make ARCH=um, then instead of a normal kernel, you get a user software called linux.
Here is a typical parameter list used in a clownix net:
mem=512M
uml_dir=${TMP}/$name umid=umid
ubda=${TMP}/$name/cow,$ROOTFS
ubdb=${TMP}/$name/config/config_fs
eth0=daemon,02:00:00:01:00:00,unix,${TMP}/$name/sig/eth0

Do not get scared by the 512 mega, the memory is used only if necessary, sometime I run only one machine and I do not want any limits to its ram consumption for big compilations.
uml_dir is used to store stuff like the pid of the main process running the virtual machine, the daemon switch uses the machine pids for monitoring an kill.
ubda gives the path to the cow directory where the virtual machine will write the diffs with the reference root_fs. ubda also gives the path to the reference root_fs.
ubdb gives the path to the place where customisation info specific to a virtual machine is stored.
for every interface, the line ethx... is given, this says to use the socket associated to file ${TMP}/$name/sig/ethx and gives the mac address for this interface.
mac addresses follow a rule, it if function of machine number vm and interface number eth:
MAC= 02:00:vm/100:vm%100:00:eth
eth0 of machines in the clownix network are for management use, so the ip number also follows a simple rule:
ip is same network as HostAdmin with netmask=255.0.0.0
IP=X.Y.vm/100.vm%100



5. Uml Clownix Switch

./uml_clownix_switch <port> <num_tap> <ip_admin> <work_dir> <bulk_dir> <rsa_public> <rsa_private> --option

--option has to end the cmd line and can be --net_name, --no_screen or --root_fs
where net_name is just any ascii name that will be put as title of screen term,
no_screen means that the screen software will not be used and you will end up with xterms everywhere, which is annoying.
root_fs tells the daemon switch that you want a single machine and want to write for real on the root_fs file system.


6. Ctrl

try ./ctrl then try all possible options.


7. Cloonix

As this soft needs graphviz libraries, you have to get into one of the virtual machines to run it, try cloonix_graph
This software subscribes to any modification of the daemon switch topology and reacts to it by requesting the new config and drawing it.
If you click on a linux machine, a message is sent to the daemon and the daemon launches an xterm with an ssh to the requested machine.
If you have the cisco ios c7200-advipservicesk9-mz.124-9.T.bin, the dynamips binary and you click on the cisco machine, a message is sent to the daemon and the daemon launches a telnet and sends the password "clownix" with expect so as to have access to the enabled cisco.
graphviz is an impressive piece of open source software, I had no time to understand and use it properly.


8. Source Code

The sources for the clownix part of the whole tool should be found in /usr/src of the virtual machine.