Example-basic

From VNUML-WIKI
Jump to: navigation, search

VNUML Basic Example

Authors:
Fermín Galán (galan at dit.upm.es)
David Fernández (david at dit.upm.es)
version 1.8, October 3rd, 2007


Scenario

The following example builds the basic topology shown in the figures. We provide an IPv4 version and an IPv6 version. The IPv6 version is slightly different; it uses the eth0 host interface as external connection for UML3.

Note that the /tmp/uml1-conf directory must exists in the host machine in order for the <filetree> tag to work in UML1 (for example, you can create it with 'mkdir /tmp/uml1-conf' and create and empty file inside with 'touch /tmp/uml1-conf/foobar.conf' to test). In addition, the <exec> tags are intented to test the command execution mode (more information in the User Manual). For example, use 'vnumlparser.pl -x start@basic.xml -v' to run the commands with seq="start" (in addition, the content of /root/uml1-conf directory will be copied to the virtual machine uml1) and 'vnumlparser.pl -x stop@basic.xml -v' to run the commands with seq="stop".

Before running the IPv6 version you have to edit the specification and change the IP data inside the <host> section to reflect your settings (in this example, 10.1.1.200/24 is the address/mask of the host and 10.1.1.1 the ip address of the router).

In both examples xterm consoles are disabled, so you have to access virtual machines using ssh from the host, for example:

 host> slogin uml1

Basic IPv4
Figure 1: Basic IPv4 scenario


Basic IPv6

Figure 2: Basic IPv6 scenario


VNUML Description (IPv4)


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE vnuml SYSTEM "/usr/share/xml/vnuml/vnuml.dtd" [
  <!ENTITY VNUMLDIR "/usr/share/vnuml/">
  <!ENTITY BASEDIR  "/usr/share/vnuml/examples/basic/">
  <!ENTITY REDIR  "</dev/null >/dev/null 2>&1 &">
]>
<vnuml>

   <global>
      <version>1.8</version>
      <simulation_name>basic</simulation_name>
      <ssh_key>/root/.ssh/identity.pub</ssh_key>
      <automac offset="0"/>
      <vm_mgmt type="private" network="192.168.0.0" mask="24" offset="100">
         <host_mapping/>
      </vm_mgmt>
      <vm_defaults>
         <filesystem type="cow">&VNUMLDIR;filesystems/root_fs_tutorial</filesystem>
         <kernel>&VNUMLDIR;kernels/linux</kernel>
         <shell>/bin/sh</shell>         
      </vm_defaults>
   </global>

   <net name="Net0" mode="uml_switch"/>
   <net name="Net1" mode="uml_switch"/>
   <net name="Net2" mode="uml_switch"/>
   <net name="Net3" mode="virtual_bridge"/>

   <vm name="uml1">
      <mem>50M</mem>
      <if id="1" net="Net0">
         <ipv4>10.0.0.1</ipv4>
      </if>
      <route type="ipv4" gw="10.0.0.3">default</route>
      <filetree root="/" seq="start">/tmp/uml1-conf</filetree>
      <exec seq="start" type="verbatim">ls</exec>
      <exec seq="start" type="verbatim">pwd</exec>
      <exec seq="start" type="verbatim">touch /root/example.start</exec>
      <exec seq="stop" type="verbatim">rm /root/example.start</exec>
      <exec seq="stop" type="verbatim">touch /root/example.stop</exec>
   </vm>

   <vm name="uml2">
      <if id="1" net="Net0">
         <ipv4>10.0.0.2</ipv4>
      </if>
      <route type="ipv4" gw="10.0.0.3">default</route>
   </vm>

   <vm name="uml3">
      <if id="1" net="Net0">
         <ipv4>10.0.0.3</ipv4>
      </if>
      <if id="2" net="Net1">
         <ipv4>10.0.1.1</ipv4>
      </if>
      <if id="3" net="Net3">
         <ipv4>10.0.3.1</ipv4>
      </if>
      <route type="ipv4" gw="10.0.1.2">10.0.2.0/24</route>
      <route type="ipv4" gw="10.0.3.2">default</route>
      <forwarding type="ip"/>
   </vm>

   <vm name="uml4">
      <if id="1" net="Net1">
         <ipv4>10.0.1.2</ipv4>
      </if>
      <if id="2" net="Net2">
         <ipv4>10.0.2.1</ipv4>
      </if>
      <route type="ipv4" gw="10.0.1.1">default</route>
      <forwarding type="ip"/>
   </vm>

   <vm name="uml5">
      <if id="1" net="Net2">
         <ipv4 mask="255.255.255.0">10.0.2.2</ipv4>
      </if>
      <route type="ipv4" gw="10.0.2.1">default</route>
   </vm>

   <host>
      <hostif net="Net3">
         <ipv4>10.0.3.2</ipv4>
      </hostif>
      <route type="ipv4" gw="10.0.3.1">10.0.0.0/16</route>
   </host>

</vnuml>

VNUML Description (IPv6)


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE vnuml SYSTEM "/usr/share/xml/vnuml/vnuml.dtd"
[
  <!ENTITY VNUMLDIR "/usr/share/vnuml/">
  <!ENTITY BASEDIR  "/usr/share/vnuml/examples/basic/">
  <!ENTITY REDIR  "</dev/null >/dev/null 2>&1 &">
]>

<vnuml>

   <global>
      <version>1.8</version>
      <simulation_name>basic</simulation_name>
      <ssh_key>/root/.ssh/identity.pub</ssh_key>
      <automac offset="0"/>
      <vm_mgmt type="private" network="192.168.0.0" mask="24" offset="0">
         <host_mapping/>
      </vm_mgmt>
      <vm_defaults>
         <filesystem type="cow">&VNUMLDIR;filesystems/root_fs_tutorial</filesystem>
         <kernel>&VNUMLDIR;kernels/linux</kernel>
         <shell>/bin/sh</shell>
      </vm_defaults>
   </global>

   <net name="Net0" mode="uml_switch" />
   <net name="Net1" mode="uml_switch" />
   <net name="Net2" mode="uml_switch" />
   <net name="Net3" mode="virtual_bridge" external="eth0" />

   <vm name="uml1">
      <mem>50M</mem>
      <if id="1" net="Net0">
         <ipv6>2001:db8:0::1/64</ipv6>
      </if>
      <route type="ipv6" gw="2001:db8:0::3">2000::/3</route>
      <filetree root="/" seq="start">/tmp/uml1-conf</filetree>
      <exec seq="start" type="verbatim">ls</exec>
      <exec seq="start" type="verbatim">pwd</exec>
      <exec seq="start" type="verbatim">touch /root/example.start</exec>
      <exec seq="stop" type="verbatim">rm /root/example.start</exec>
      <exec seq="stop" type="verbatim">touch /root/example.stop</exec>
   </vm>

   <vm name="uml2">  
      <if id="1" net="Net0">
         <ipv6>2001:db8:0::2/64</ipv6>
      </if>
      <route type="ipv6" gw="2001:db8:0::3">2000::/3</route>
   </vm>

   <vm name="uml3">   
      <if id="1" net="Net0">
         <ipv6>2001:db8:0::3/64</ipv6>
      </if>
      <if id="2" net="Net1">
         <ipv6>2001:db8:1::3/64</ipv6>
      </if>
      <if id="3" net="Net3">
         <ipv6>2001:db8:3::3/64</ipv6>
      </if>
      <route type="ipv6" gw="2001:db8:1::4">2001:db8:2::/64</route>
      <route type="ipv6" gw="2001:db8:3::254">2000::/3</route>
      <forwarding type="ipv6"/>
      <exec seq="start" type="verbatim">touch filesample</exec>
   </vm>

   <vm name="uml4">   
      <if id="1" net="Net1">
         <ipv6>2001:db8:1::4/64</ipv6>
      </if>
      <if id="2" net="Net2">
         <ipv6>2001:db8:2::4/64</ipv6>
      </if>
      <route type="ipv6" gw="2001:db8:1::3">2000::/3</route>
      <forwarding type="ipv6"/>
   </vm>

   <vm name="uml5">
      <if id="1" net="Net2">
         <ipv6>2001:db8:2::5/64</ipv6>
      </if>
      <route type="ipv6" gw="2001:db8:2::4">2000::/3</route>
   </vm>

   <host>
      <hostif net="Net3">
         <ipv4 mask="255.255.255.0">10.1.1.200</ipv4>
         <ipv6>2001:db8:3::254/64</ipv6>
      </hostif>
      <physicalif name="eth0" type="ipv4" ip="10.1.1.200" mask="255.255.255.0" gw="10.1.1.1"/>
      <route type="ipv4" gw="10.1.1.1">default</route>
      <route type="ipv6" gw="2001:db8:3::3">2001:db8::/32</route>
   </host>
</vnuml>

Download

Old Releases

  • 1.3 (note that in this version the example was named "Tutorial" instead of "Basic").
  • 1.6
  • 1.7