Project

General

Profile

Dynamic Uml Mesh Modeler » History » Version 5

Martin Willi, 08.08.2007 17:06

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 1 Martin Willi
''Dumm'' is currently in [source:trunk/src/dumm heavy development] and incomplete. A prototype is running 
10 1 Martin Willi
and a proof of concept has shown that it works.
11 1 Martin Willi
Along with the ''dumm'' library, a console client is developed to interactively set
12 1 Martin Willi
up and reconfigure UML networks. A test framework for strongSwan is planned around 
13 1 Martin Willi
it, and a neat GTK GUI to click together your UML network would be just lovely (someone?).
14 1 Martin Willi
15 1 Martin Willi
== Terminology ==
16 1 Martin Willi
 * Host 
17 1 Martin Willi
   * The machine you are working on, has virtual guests in it. Mostly
18 1 Martin Willi
    runs on bare hardware (unless you do really fancy stuff).
19 1 Martin Willi
 * Guest
20 1 Martin Willi
   * Virtual UML machine running on the host.
21 1 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 innterfaces 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] highly 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 1 Martin Willi
      * [source:trunk/src/libstrongswan libstrongswan]
41 1 Martin Willi
      * [http://tiswww.case.edu/php/chet/readline/rltop.html libreadline]
42 1 Martin Willi
      * libbridge from [http://linux-net.osdl.org/index.php/Bridge bridge-utils]
43 1 Martin Willi
  * Guest:
44 1 Martin Willi
    * Kernel:
45 1 Martin Willi
      * hostfs
46 1 Martin Willi
      * consoles?
47 1 Martin Willi
    * Userland:
48 1 Martin Willi
      * ip (from iproute2)/netlink proxy?
49 1 Martin Willi
50 1 Martin Willi
== Architecture ==
51 1 Martin Willi
52 1 Martin Willi
=== Working set ===
53 1 Martin Willi
Dumm needs a directory to store all its files, guest configurations and other
54 1 Martin Willi
stuff. Inside that working directory, you'll find:
55 1 Martin Willi
56 1 Martin Willi
{{{
57 2 Martin Willi
workingdir/      - root folder containing a set of hosts and scenarios
58 3 Martin Willi
  guests/        - contains all created guests
59 2 Martin Willi
    alice/       - subdirectory for host "alice"
60 2 Martin Willi
      alice/     - UML created folder (named umid) containing UML runtime files
61 2 Martin Willi
      boot.log   - hosts boot console log (con0)
62 2 Martin Willi
      mem        - memory configuration file (contains amount of guest memory in MB)
63 2 Martin Willi
      linux      - symlinked UML kernel this host uses
64 2 Martin Willi
      master/    - symlinked master root file system for this host
65 2 Martin Willi
      diff/      - copy-on-write overlay to master this host uses
66 2 Martin Willi
      union/     - mounted unified filesystem (master + diff + optional scenario)
67 1 Martin Willi
    bob/
68 2 Martin Willi
      ...        - same stuff as in alice
69 2 Martin Willi
  scenarios/     - contains all scenarios
70 1 Martin Willi
    test1/       - a scenario folder
71 3 Martin Willi
      diff/      - copy-on-write overlays for each guest's union folder
72 3 Martin Willi
        alice/   - COW for alice
73 3 Martin Willi
        bob/     - COW for bob
74 3 Martin Willi
      config     - network configuration file
75 1 Martin Willi
}}}
76 1 Martin Willi
77 1 Martin Willi
=== Networking ===
78 1 Martin Willi
Network connectivity is realized through tap devices. When creating a ''eth0''
79 1 Martin Willi
network device on ''alice'', a ''alice-eth0'' tap device appears on the host. These
80 1 Martin Willi
are directly connected, when ''alice'' sends traffic to ''eth0'', it appears on the
81 1 Martin Willi
host at ''alice-eth0''. You can see that as a small network segment (or just a
82 1 Martin Willi
cable), where these interfaces are attached directly.
83 1 Martin Willi
To build larger network segments, linux bridging on the host comes into play.
84 1 Martin Willi
Segments are created by creating a bridge (as with brctl), and then attaching
85 1 Martin Willi
our tap devices to that bridge. Routing can be done on a UML guest, or even on
86 1 Martin Willi
the host.
87 1 Martin Willi
This setup has some advantages over the ''uml_switch'' solution. Bridging works
88 1 Martin Willi
more reliable in the kernel, and as we see every network interface on the host,
89 1 Martin Willi
we can sniff at every interface to get some clue what the guests are doing.
90 1 Martin Willi
91 1 Martin Willi
== Howto ==
92 4 Martin Willi
In this mini-howto, we build and boot a minimalistic debian guest on a ubuntu host.
93 4 Martin Willi
We do everything as root here to simplify things!
94 1 Martin Willi
=== Host setup ===
95 4 Martin Willi
  * install FUSE:
96 4 Martin Willi
{{{
97 4 Martin Willi
aptitude install libfuse-dev
98 4 Martin Willi
}}}
99 4 Martin Willi
  * install libbridge:
100 4 Martin Willi
{{{
101 4 Martin Willi
git clone git://git.kernel.org/pub/scm/linux/kernel/git/shemminger/bridge-utils.git
102 4 Martin Willi
cd bridge-utils
103 4 Martin Willi
autoconf
104 4 Martin Willi
./configure
105 4 Martin Willi
cd libbridge
106 4 Martin Willi
make
107 4 Martin Willi
make install
108 4 Martin Willi
}}}
109 4 Martin Willi
  * Build and install strongSwan from SVN sources.
110 4 Martin Willi
{{{
111 4 Martin Willi
svn co www.strongswan.org/ikev2/trunk strongswan
112 4 Martin Willi
cd strongswan
113 4 Martin Willi
less HACKING
114 4 Martin Willi
./autogen
115 4 Martin Willi
./configure --enable-uml [other options]
116 4 Martin Willi
make
117 4 Martin Willi
make install
118 4 Martin Willi
}}}
119 1 Martin Willi
120 4 Martin Willi
  * Ubuntu kernels almost fit our needs, they have FUSE and TAP device support. However, 
121 4 Martin Willi
    SKAS3 mode is missing. Build your own kernel based on the 
122 4 Martin Willi
    [https://wiki.ubuntu.com/KernelCustomBuild Ubuntu Howto], patched with the
123 4 Martin Willi
    [http://www.user-mode-linux.org/~blaisorblade/patches/skas3-2.6/ SKAS3 patch].
124 4 Martin Willi
125 1 Martin Willi
=== Guest setup ===
126 4 Martin Willi
  * create a clean directory and a directory for our master filesystem in it:
127 4 Martin Willi
{{{
128 4 Martin Willi
mkdir umldir
129 4 Martin Willi
cd umldir
130 4 Martin Willi
mkdir master
131 4 Martin Willi
}}}
132 4 Martin Willi
  * debootstrap a debian etch system into master:
133 4 Martin Willi
{{{
134 4 Martin Willi
debootstrap etch master http://mirror.switch.ch/ftp/pub/debian/
135 4 Martin Willi
echo "proc /proc proc none 0 0" > master/etc/fstab
136 4 Martin Willi
}}}
137 5 Martin Willi
  * build a vanilla UML kernel (using [http://trac.strongswan.org/attachment/wiki/DynamicUmlMeshModeler/.config my config]):
138 4 Martin Willi
{{{
139 4 Martin Willi
wget http://kernel.org/pub/linux/kernel/v2.6/linux-2.6.22.1.tar.bz2
140 4 Martin Willi
tar jxvf linux-2.6.22.1.tar.bz2
141 4 Martin Willi
cd linux-2.6.22.1
142 1 Martin Willi
make mrproper
143 5 Martin Willi
wget http://trac.strongswan.org/attachment/wiki/DynamicUmlMeshModeler/.config?format=raw -O .config
144 4 Martin Willi
ARCH=um make menuconfig
145 4 Martin Willi
ARCH=um make
146 4 Martin Willi
}}}
147 1 Martin Willi
148 1 Martin Willi
=== Sample session ===
149 4 Martin Willi
  * go to our created testing directory and start ''dumm'':
150 4 Martin Willi
{{{
151 4 Martin Willi
cd umldir
152 4 Martin Willi
ipsec dumm
153 4 Martin Willi
}}}
154 4 Martin Willi
  * create and start hosts alice and bob, each with an interface:
155 4 Martin Willi
{{{
156 4 Martin Willi
# guest
157 4 Martin Willi
guest# create
158 4 Martin Willi
guest name: alice
159 4 Martin Willi
kernel image: linux-2.6.22.1/linux
160 4 Martin Willi
master filesystem: master
161 4 Martin Willi
amount of memory in MB: 128
162 4 Martin Willi
guest 'alice' created
163 4 Martin Willi
guest/alice# start
164 4 Martin Willi
guest 'alice' is booting
165 4 Martin Willi
guest/alice# addif
166 4 Martin Willi
interface name: eth0
167 4 Martin Willi
guest/alice# back
168 4 Martin Willi
guest# create
169 4 Martin Willi
guest name: bob
170 4 Martin Willi
kernel image: linux-2.6.22.1/linux
171 4 Martin Willi
master filesystem: master
172 4 Martin Willi
amount of memory in MB: 128
173 4 Martin Willi
guest 'bob' created
174 4 Martin Willi
guest/bob# start
175 4 Martin Willi
guest 'bob' is booting
176 4 Martin Willi
guest/bob# addif
177 4 Martin Willi
interface name: eth0
178 4 Martin Willi
guest/bob# back
179 4 Martin Willi
guest# back
180 4 Martin Willi
#
181 4 Martin Willi
}}}
182 4 Martin Willi
  * create a bridge and attach guests interfaces:
183 4 Martin Willi
{{{
184 4 Martin Willi
# bridge
185 4 Martin Willi
bridge# create
186 4 Martin Willi
bridge name: br0
187 4 Martin Willi
bridge 'br0' created
188 4 Martin Willi
bridge/br0# addif
189 4 Martin Willi
guest name: alice
190 4 Martin Willi
interface name: eth0
191 4 Martin Willi
bridge/br0# addif
192 4 Martin Willi
guest name: bob
193 4 Martin Willi
interface name: eth0
194 4 Martin Willi
bridge/br0# back
195 4 Martin Willi
bridge# back
196 4 Martin Willi
#
197 4 Martin Willi
}}}
198 4 Martin Willi
  * interface manipulation on netlink is not done yet, so do it manually:
199 4 Martin Willi
    * on master:
200 4 Martin Willi
{{{
201 4 Martin Willi
ifconfig alice-eth3 up
202 4 Martin Willi
ifconfig bob-eth3 up
203 4 Martin Willi
ifconfig br3 up
204 4 Martin Willi
}}}
205 4 Martin Willi
    * on alice:
206 4 Martin Willi
{{{
207 4 Martin Willi
ifconfig eth0 up
208 4 Martin Willi
ifconfig eth0 192.168.1.1 netmask 255.255.255.0
209 4 Martin Willi
ping 192.168.1.2
210 4 Martin Willi
}}}
211 4 Martin Willi
    * on bob:
212 4 Martin Willi
{{{
213 4 Martin Willi
ifconfig eth0 up
214 4 Martin Willi
ifconfig eth0 192.168.1.1 netmask 255.255.255.0
215 4 Martin Willi
ping 192.168.1.1
216 4 Martin Willi
}}}