Project

General

Profile

Dynamic Uml Mesh Modeler » History » Version 12

Martin Willi, 18.07.2008 14:42

1 1 Martin Willi
= Dynamic Uml Mesh Modeler =
2 1 Martin Willi
''Dumm'' is a framework to set up a virtual network using user mode linux guests.
3 1 Martin Willi
It cleverly glues together some nice technologies to build networks dynamically.
4 1 Martin Willi
To change the network topology, hosts are not required to reboot, changes apply
5 1 Martin Willi
instantly and configuration can be done on the host (no network connection
6 1 Martin Willi
required to change anything).
7 1 Martin Willi
8 1 Martin Willi
== Status ==
9 11 Martin Willi
''Dumm'' is experimental and [source:trunk/src/dumm in developement]. 
10 11 Martin Willi
Along with the ''dumm'' library, two frontends are currently usable:
11 11 Martin Willi
  * A graphical GTK client
12 11 Martin Willi
  * A console client with Ruby bindings to script scenarios in Ruby
13 1 Martin Willi
14 10 Martin Willi
The graphical client is incomplete. It is missing:
15 10 Martin Willi
  * Removal of added switches
16 1 Martin Willi
  * Disconnecting guests from switches
17 10 Martin Willi
  * Scenario management
18 10 Martin Willi
19 11 Martin Willi
The Ruby console client also misses a surrounding testing infrastructure which
20 11 Martin Willi
will be built with ruby in the near future.
21 10 Martin Willi
22 1 Martin Willi
== Why UML? ==
23 1 Martin Willi
UML is a senior in vitualization technologies, and there is a lot of new
24 1 Martin Willi
hyped stuff about virtualization around. However, UML is lightweight, easy to
25 1 Martin Willi
set up and allows dynamic reconfiguration (e.g. add/remove interfaces at
26 1 Martin Willi
runtime), allows access to the hosts filesystem through hostfs and has some
27 1 Martin Willi
other neat features.
28 1 Martin Willi
Performance is not critical for our needs, and maybe we get hardware
29 1 Martin Willi
virtualization support soon in UML.
30 1 Martin Willi
It is free and fits perfectly.
31 1 Martin Willi
32 1 Martin Willi
== Requirements ==
33 1 Martin Willi
  * Host:
34 1 Martin Willi
    * Kernel:
35 1 Martin Willi
      * A recent 2.6 kernel
36 1 Martin Willi
      * [http://www.user-mode-linux.org/~blaisorblade/patches/skas3-2.6/ SKAS3 patch] recommended
37 1 Martin Willi
      * [http://fuse.sourceforge.net/ FUSE] enabled
38 1 Martin Willi
      * support for TAP devices
39 1 Martin Willi
    * Userland:
40 10 Martin Willi
      * [source:trunk/src/libstrongswan libstrongswan]
41 1 Martin Willi
      * libbridge from [http://linux-net.osdl.org/index.php/Bridge bridge-utils]
42 11 Martin Willi
      * using the GTK client:
43 11 Martin Willi
        * GTK+2 with developement headers
44 11 Martin Willi
        * Gnome !VteTerminal with developement headers
45 11 Martin Willi
      * using the Ruby client:
46 11 Martin Willi
        * Ruby 1.8 with developement headers
47 11 Martin Willi
        * IRB
48 10 Martin Willi
  * Guest:
49 1 Martin Willi
    * Kernel:
50 1 Martin Willi
      * hostfs
51 1 Martin Willi
      * tuntap networking
52 10 Martin Willi
      * mcast networking
53 11 Martin Willi
      * our extended [source:trunk/src/dumm/patches mconsole exec patch]
54 1 Martin Willi
    * Userland:
55 11 Martin Willi
      * ip from iproute2
56 1 Martin Willi
57 1 Martin Willi
== Architecture ==
58 1 Martin Willi
59 1 Martin Willi
=== Working set ===
60 1 Martin Willi
Dumm needs a directory to store all its files, guest configurations and other
61 1 Martin Willi
stuff. Inside that working directory, you'll find:
62 1 Martin Willi
63 2 Martin Willi
{{{
64 1 Martin Willi
workingdir/      - root folder containing a set of hosts and scenarios
65 2 Martin Willi
  guests/        - contains all created guests
66 2 Martin Willi
    alice/       - subdirectory for host "alice"
67 2 Martin Willi
      alice/     - UML created folder (named umid) containing UML runtime files
68 2 Martin Willi
      mem        - memory configuration file (contains amount of guest memory in MB)
69 11 Martin Willi
      pid        - PID file if guest is running, handy to attach gdb to kernel
70 2 Martin Willi
      linux      - symlinked UML kernel this host uses
71 2 Martin Willi
      master/    - symlinked master root file system for this host
72 2 Martin Willi
      diff/      - copy-on-write overlay to master this host uses
73 1 Martin Willi
      union/     - mounted unified filesystem (master + diff + optional scenario)
74 2 Martin Willi
    bob/
75 2 Martin Willi
      ...        - same stuff as in alice
76 11 Martin Willi
  templates/     - contains all scenario templates
77 3 Martin Willi
    test1/       - a scenario folder
78 3 Martin Willi
      diff/      - copy-on-write overlays for each guest's union folder
79 3 Martin Willi
        alice/   - COW for alice
80 3 Martin Willi
        bob/     - COW for bob
81 1 Martin Willi
}}}
82 1 Martin Willi
83 1 Martin Willi
=== Networking ===
84 1 Martin Willi
Network connectivity is realized through tap devices. When creating a ''eth0''
85 1 Martin Willi
network device on ''alice'', a ''alice-eth0'' tap device appears on the host. These
86 1 Martin Willi
are directly connected, when ''alice'' sends traffic to ''eth0'', it appears on the
87 1 Martin Willi
host at ''alice-eth0''. You can see that as a small network segment (or just a
88 1 Martin Willi
cable), where these interfaces are attached directly.
89 1 Martin Willi
To build larger network segments, linux bridging on the host comes into play.
90 1 Martin Willi
Segments are created by creating a bridge (as with brctl), and then attaching
91 1 Martin Willi
our tap devices to that bridge. Routing can be done on a UML guest, or even on
92 1 Martin Willi
the host.
93 1 Martin Willi
This setup has some advantages over the ''uml_switch'' solution. Bridging works
94 1 Martin Willi
more reliable in the kernel, and as we see every network interface on the host,
95 1 Martin Willi
we can sniff at every interface to get some clue what the guests are doing.
96 1 Martin Willi
97 1 Martin Willi
== Howto ==
98 1 Martin Willi
In this mini-howto, we build and boot a minimalistic debian guest on a ubuntu host.
99 4 Martin Willi
We do everything as root here to simplify things!
100 10 Martin Willi
101 1 Martin Willi
=== Host setup ===
102 10 Martin Willi
  * install required packages:
103 7 Tobias Brunner
{{{
104 11 Martin Willi
aptitude install libfuse-dev libgtk2.0-dev libvte-dev ruby1.8-dev irb1.8
105 1 Martin Willi
}}}
106 4 Martin Willi
  * install libbridge:
107 4 Martin Willi
{{{
108 4 Martin Willi
git clone git://git.kernel.org/pub/scm/linux/kernel/git/shemminger/bridge-utils.git
109 4 Martin Willi
cd bridge-utils
110 4 Martin Willi
autoconf
111 4 Martin Willi
./configure
112 1 Martin Willi
cd libbridge
113 1 Martin Willi
make
114 1 Martin Willi
make install
115 8 Tobias Brunner
}}}
116 4 Martin Willi
  * Build and install strongSwan from SVN sources.
117 4 Martin Willi
{{{
118 4 Martin Willi
svn co www.strongswan.org/ikev2/trunk strongswan
119 4 Martin Willi
cd strongswan
120 1 Martin Willi
less HACKING
121 4 Martin Willi
./autogen
122 10 Martin Willi
./configure --enable-dumm [other options]
123 1 Martin Willi
make
124 1 Martin Willi
make install
125 1 Martin Willi
}}}
126 1 Martin Willi
127 1 Martin Willi
  * Ubuntu kernels almost fit our needs, they have FUSE and TAP device support. However, 
128 1 Martin Willi
    SKAS3 mode is missing. Build your own kernel based on the 
129 1 Martin Willi
    [https://wiki.ubuntu.com/KernelCustomBuild Ubuntu Howto], patched with the
130 10 Martin Willi
    [http://www.user-mode-linux.org/~blaisorblade/patches/skas3-2.6/ SKAS3 patch]. SKAS3 is
131 10 Martin Willi
    not required, but guests run much faster with SKAS3 enabled on the host.
132 1 Martin Willi
133 10 Martin Willi
=== Guest master filesystem setup ===
134 1 Martin Willi
  * create a clean directory and a directory for our master filesystem in it:
135 1 Martin Willi
{{{
136 1 Martin Willi
mkdir umldir
137 1 Martin Willi
cd umldir
138 1 Martin Willi
mkdir master
139 1 Martin Willi
}}}
140 10 Martin Willi
  * bootstrap a debian sid system into master:
141 1 Martin Willi
{{{
142 10 Martin Willi
debootstrap sid master http://mirror.switch.ch/ftp/pub/debian/
143 1 Martin Willi
}}}
144 10 Martin Willi
  * enter chroot
145 10 Martin Willi
{{{
146 10 Martin Willi
chroot master
147 10 Martin Willi
}}}
148 10 Martin Willi
  * enable login on tty0
149 10 Martin Willi
{{{
150 10 Martin Willi
echo "0:2345:respawn:/sbin/getty 38400 tty0" >> /etc/inittab
151 10 Martin Willi
echo "tty0" >> /etc/securetty
152 10 Martin Willi
}}}
153 10 Martin Willi
  * Enable main repository
154 10 Martin Willi
{{{
155 10 Martin Willi
echo deb http://mirror.switch.ch/ftp/pub/debian sid main contrib > /etc/apt/sources.list
156 1 Martin Willi
aptitude update
157 1 Martin Willi
}}}
158 1 Martin Willi
  * Install proper locales support
159 10 Martin Willi
{{{
160 1 Martin Willi
aptitude install locales
161 10 Martin Willi
dpkg-reconfigure locales
162 10 Martin Willi
}}}
163 10 Martin Willi
  * Install some packages for strongSwan
164 10 Martin Willi
{{{
165 10 Martin Willi
aptitude install libgmp3c2 libsqlite3-0 libcurl3 dropbear gdb binutils
166 10 Martin Willi
}}}
167 10 Martin Willi
  * leave chroot
168 10 Martin Willi
{{{
169 10 Martin Willi
exit
170 10 Martin Willi
}}}
171 4 Martin Willi
  * build a vanilla UML kernel (using [http://trac.strongswan.org/attachment/wiki/DynamicUmlMeshModeler/.config my config]):
172 4 Martin Willi
{{{
173 11 Martin Willi
wget http://kernel.org/pub/linux/kernel/v2.6/linux-2.6.26.tar.bz2
174 11 Martin Willi
tar jxvf linux-2.6.26.tar.bz2
175 11 Martin Willi
cd linux-2.6.26
176 1 Martin Willi
make mrproper
177 11 Martin Willi
wget -O - http://trac.strongswan.org/browser/trunk/src/dumm/patches/mconsole-exec-2.6.26.patch?format=txt | patch -p1
178 1 Martin Willi
wget http://trac.strongswan.org/attachment/wiki/DynamicUmlMeshModeler/.config?format=raw -O .config
179 1 Martin Willi
ARCH=um make menuconfig
180 1 Martin Willi
ARCH=um make
181 1 Martin Willi
}}}
182 4 Martin Willi
183 4 Martin Willi
=== Start a network ===
184 4 Martin Willi
You'll have to run the tools as root. Make sure you have a DISPLAY set, e.g. by starting it under ''sudo''.
185 4 Martin Willi
  * Invoke the graphical client
186 4 Martin Willi
{{{
187 6 Martin Willi
sudo ipsec dumm
188 6 Martin Willi
}}}
189 10 Martin Willi
Add guests, select our master filesystem and the compiled kernel. Add a bridges and connect your guests to it.
190 10 Martin Willi
Start your guests and configure them. 
191 10 Martin Willi
192 11 Martin Willi
  * Using the ''irdumm'' ruby client
193 10 Martin Willi
{{{
194 11 Martin Willi
sudo ipsec irdumm
195 12 Martin Willi
irb> sun = Guest.new("sun")
196 11 Martin Willi
irb> sun.start
197 11 Martin Willi
irb> sun.exec("echo sun > /etc/hostname")
198 11 Martin Willi
irb> sun.add("eth0").connect(Bridge.new("br0")).add("192.168.0.1")
199 12 Martin Willi
irb> sun.exec("ifconfig") { |line| puts line }
200 11 Martin Willi
irb> quit
201 4 Martin Willi
}}}
202 10 Martin Willi
203 10 Martin Willi
== Installing strongSwan on guests ==
204 10 Martin Willi
As we have full access to the master filesystem on the host, we can build strongSwan on the host and install it to the guests
205 1 Martin Willi
{{{
206 10 Martin Willi
cd path/to/strongswan/
207 10 Martin Willi
DESTDIR=/full/path/to/master make install
208 1 Martin Willi
}}}