Project

General

Profile

Dynamic Uml Mesh Modeler » History » Version 22

Martin Willi, 18.02.2011 11:34
Added hint about --arch option

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 19 Martin Willi
      args       - additional arguments to pass to guest, such as memory configuration
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 18 Martin Willi
* install libbridge manually: <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 18 Martin Willi
gcc -fPIC -c libbridge_devif.c libbridge_if.c libbridge_init.c libbridge_misc.c
129 18 Martin Willi
ar rcs libbridge.a libbridge_devif.o libbridge_if.o libbridge_init.o libbridge_misc.o
130 18 Martin Willi
ranlib libbridge.a
131 18 Martin Willi
install libbridge.a /usr/local/lib
132 18 Martin Willi
install libbridge.h /usr/local/include
133 10 Martin Willi
</pre>
134 17 Tobias Brunner
135 17 Tobias Brunner
* Build and install strongSwan from Git sources: <pre>
136 17 Tobias Brunner
git clone http://git.strongswan.org/strongswan.git
137 1 Martin Willi
cd strongswan
138 16 Martin Willi
less HACKING
139 1 Martin Willi
./autogen
140 16 Martin Willi
./configure --enable-dumm [other options]
141 1 Martin Willi
make
142 1 Martin Willi
make install
143 1 Martin Willi
</pre>
144 16 Martin Willi
145 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.
146 10 Martin Willi
147 10 Martin Willi
148 16 Martin Willi
h3. Guest master filesystem setup
149 16 Martin Willi
150 17 Tobias Brunner
* create a clean directory and a directory for our master filesystem in it: <pre>
151 16 Martin Willi
mkdir umldir
152 10 Martin Willi
cd umldir
153 10 Martin Willi
mkdir master
154 16 Martin Willi
</pre>
155 17 Tobias Brunner
156 17 Tobias Brunner
* bootstrap a debian sid system into master: <pre>
157 16 Martin Willi
debootstrap sid master http://mirror.switch.ch/ftp/pub/debian/
158 22 Martin Willi
</pre>To build a x86 guest on a x64 host, use the --arch option.
159 17 Tobias Brunner
160 17 Tobias Brunner
* enter chroot <pre>
161 16 Martin Willi
chroot master
162 16 Martin Willi
</pre>
163 17 Tobias Brunner
164 17 Tobias Brunner
* Enable main repository <pre>
165 4 Martin Willi
echo deb http://mirror.switch.ch/ftp/pub/debian sid main contrib > /etc/apt/sources.list
166 16 Martin Willi
aptitude update
167 16 Martin Willi
</pre>
168 17 Tobias Brunner
169 17 Tobias Brunner
* Install proper locales support <pre>
170 1 Martin Willi
aptitude install locales
171 16 Martin Willi
dpkg-reconfigure locales
172 16 Martin Willi
</pre>
173 17 Tobias Brunner
174 20 Martin Willi
* For Ubuntu lucid guests, you'll have to specify the locales before generating them: <pre>
175 20 Martin Willi
echo "en_US.UTF-8 UTF-8" >> /var/lib/locales/supported.d/local
176 20 Martin Willi
</pre>
177 20 Martin Willi
178 17 Tobias Brunner
* Install some packages for strongSwan <pre>
179 16 Martin Willi
aptitude install libgmp3c2 libsqlite3-0 libcurl3 dropbear gdb binutils
180 16 Martin Willi
</pre>
181 17 Tobias Brunner
182 17 Tobias Brunner
* leave chroot <pre>
183 16 Martin Willi
exit
184 16 Martin Willi
</pre>
185 17 Tobias Brunner
186 17 Tobias Brunner
* build a vanilla UML kernel (using "my config": attachment:.config): <pre>
187 10 Martin Willi
wget http://kernel.org/pub/linux/kernel/v2.6/linux-2.6.27.tar.bz2
188 10 Martin Willi
tar jxvf linux-2.6.27.tar.bz2
189 10 Martin Willi
cd linux-2.6.27
190 11 Martin Willi
make mrproper
191 10 Martin Willi
wget -O - http://trac.strongswan.org/browser/trunk/src/dumm/patches/mconsole-exec-2.6.27.patch?format=txt | patch -p1
192 11 Martin Willi
wget http://trac.strongswan.org/attachment/wiki/DynamicUmlMeshModeler/.config?format=raw -O .config
193 14 Martin Willi
ARCH=um make menuconfig
194 16 Martin Willi
ARCH=um make
195 11 Martin Willi
</pre>
196 16 Martin Willi
197 16 Martin Willi
198 16 Martin Willi
h3. Start a network
199 16 Martin Willi
200 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_.
201 17 Tobias Brunner
202 17 Tobias Brunner
* Invoke the graphical client <pre>
203 16 Martin Willi
sudo ipsec dumm
204 10 Martin Willi
</pre>
205 1 Martin Willi
Add guests, select our master filesystem and the compiled kernel. Add a bridges and connect your guests to it.
206 10 Martin Willi
Start your guests and configure them. 
207 1 Martin Willi
208 16 Martin Willi
* Using the _irdumm_ ruby client <pre>
209 17 Tobias Brunner
sudo ipsec irdumm
210 21 Martin Willi
irb> sun = Guest.new("sun", "path/to/linux-2.6.27/linux", "path/to/master/", "mem=64M con1=xterm")
211 1 Martin Willi
irb> sun.start
212 1 Martin Willi
irb> sun.exec("echo sun > /etc/hostname")
213 1 Martin Willi
irb> sun.add("eth0").connect(Bridge.new("br0")).add("192.168.0.1")
214 1 Martin Willi
irb> sun.exec("ifconfig") { |line| puts line }
215 1 Martin Willi
irb> quit
216 16 Martin Willi
</pre>
217 1 Martin Willi
218 16 Martin Willi
219 16 Martin Willi
h2. Installing strongSwan on guests
220 16 Martin Willi
221 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
222 16 Martin Willi
<pre>
223 1 Martin Willi
cd path/to/strongswan/
224 1 Martin Willi
DESTDIR=/full/path/to/master make install
225 16 Martin Willi
</pre>