Project

General

Profile

Dynamic Uml Mesh Modeler » History » Version 17

Tobias Brunner, 05.05.2009 19:24
trac conversion errors fixed

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