VNUML User Manual
|
|
Contents | |
1. VNUML Simulation Philosophy 1.1. Types of Tags 2. VNUML Parser Usage 2.1. Building a Simulation Scenario 2.2. Starting and Stopping a Simulation 2.3. Releasing a Simulation Scenario 2.4. Purging a Simulation Scenario 2.5. Common Switches 2.6. Host Interfaces and Virtual Bridges 2.7. Direct login to UMLs 2.8. Working Directory 2.9. Start and Stop Temporal Command Files 2.10. Concurrent Simulation Scenarios 2.11. External Connections and VLAN support 2.12. How to release a Scenario when -d fails 3. Building a Customized Kerne1 4. Filesystem Requirements 5. Installing Software in UML filesystems |
|
1. VNUML Simulation Philosophy | |
This section introduces some basic concepts which are important to know in order to use VNUML tool to design, build and run tests over simulated scenarios. A typical working cycle using VNUML is made up of the following phases:
The typical life cycle with VNUML will consist on executing step 1 to create the scenario, executing steps 2 and 3 to start and stop the simulation processes as many times as desired or needed, and finally executing step 4 in order to release the scenario. This approach makes VNUML a flexible tool, allowing to perform several simulations over the same scenario, without having to start and stop it each time (which, as it was mentioned before, is a costly task in terms of CPU and time). Even in some cases, steps 2 and 3 could not be executed, for example, when the user prefers to interact directly with the virtual machines, instead of defining the commands in VNUML language and using vnumlparser.pl to manage them. Each execution of step 2 followed by step 3 is named a simulation cycle of the scenario. In a similar way, we name the scenario life cycle to the period of time between the execution of steps 1 and 4. Therefore, each life cycle will include zero or more simulation cycles. The following figure represents graphically the different states and the transitions between them. Note that ending a life cycle does not destroy the filesystem that are used by the virtual machines (in the same way that the filesystem of a actual machine is not erased whenever the machine is powered down). Note also that in steps 2 and 3, vnumparser.pl does not perform any interpretation of the simulation tags (see Types of Tags later in this document). It just executes the commands defined in the VNUML file by the user as they are. The user is therefore responsible for the correctness of that commands. On the contrary, all tags used when building or releasing the scenario are checked by the parser before execution. Several simulation scenarios can be executed simultaneously in the same host, as long as certain rules are followed (see Concurrent Simulation Scenarios for more details). Concurrent simulations can be executed isolated or even sharing connections among them and the host. 1.1. Types of TagsThere are three types of tags in a VNUML file:
Tags <version>, <simulation_name>, <ip_offset> and <shell> can be considered either topology or simulation tags, due to the fact that they are used in all modes. VNUML source file can be edited between simulations, but only to modify simulation tags (that is: <filetree>, <start> and <stop> tags). In this way, the simulation behaviour and objectives can be changed between simulation cycles. However, do no edit other tags because it can lead to unpredictible and erroneous behaviours. |
|
2. VNUML Parser Usage | |
This section describes in detail vnumlparser.pl usage options. Basically, the parser is a Perl script that it is called from a shell command-line (it is recommened to put vnumlparser.pl file within console command path). If you call the parser without arguments you get the following brief (but uselful) description of its modes and options: Usage: vnumlparser.pl -t VNUML_file [-o prefix] [-m mount_point] [-c vnuml_dir] [-T tmp_dir] [-k] [-i] [-S scan_mode ] [-w delay] [-B] [-v] [-g] vnumlparser.pl -s VNUML_file [-T tmp_dir] [-M vm_list] [-k] [-i] [-S scan_mode ] [-B] [-v] [-g] vnumlparser.pl -p VNUML_file [-T tmp_dir] [-M vm_list] [-k] [-i] [-S scan_mode ] [-B] [-v] [-g] vnumlparser.pl -r VNUML_file [-T tmp_dir] [-M vm_list] [-k] [-i] [-S scan_mode ] [-B] [-v] [-g] vnumlparser.pl -d VNUML_file [-c vnuml_dir] [-F] [-T tmp_dir] [-k] [-i] [-S scan_mode ] [-B] [-v] [-g] vnumlparser.pl -V Mode: -t VNUML_file, build topology (using VNUML_file) as source -s VNUML_file, start simulation (using VNUML_file) as source -p VNUML_file, stop simulation (using VNUML_file as source) -r VNUML_file, restart simulation (using VNUML_file as source) -d VNUML_file, destroy current simulation (using VNUML_file as source) -V, show program version and exits. Options: -k, skips XML validation in VNUML_file (warning: it is not recommended) -o prefix, dump UML boot messages output to files (using given prefix in pathname) -m mount_point, use mount_point as mount point to configure UML filesystem (default is /mnt/uml) -c vnuml_dir, vnumlparser.pl working directory (default is /var/vnuml) -F, force stopping of UMLs (warning: UML filesystems may be corrupted) -S scan_mode, the way UML readiness is scanned (default is 0, socket style) -w delay, waits delay seconds between UMLs booting (defult is wait no time) -B, blocking mode -i, interactive execution (in combination with -v mode) -v, verbose mode on -g, debug mode on (overrides verbose) -T tmp_dir, temporal files directory (default is /tmp) -M vm_list, start/stop/restart simulation in vm_list UMLs (a list of names separated by ,) Since version 1.3.1: new mode (purge mode, -P) and a new optional switch (-e) for the building topology mode (-t). Usage: vnumlpaser.pl -t VNUML_file [-o prefix] [-m mount_point] [-c vnuml_dir] [-T tmp_dir] [-k] [-i] [-S scan_mode ] [-w delay] [-B] [-e screen_file] [-v] [-g] ... vnuml -P VNUML_file [-T tmp_file] [-k] [-i] [-v] [-g] Mode: ... -P VNUML_file, purge simulation (WARNING: it will remove UML cowed filesystems!) Options: ... -e screen_file, make screen configuration file for pts devices The parser can be invoked using one of the following four diferent modes: build topology (-t mode), start simulation (-s), stop simulation (-p) or destroy simulation (-d). There is an aditional mode, the restart mode (-r), that is a combination of -s and -p executed in sequence. Besides, there is a pseudo-mode, -V, that shows program version and exits. The following sections describe each of these modes in detail. You must be root user to execute vnumlparser.pl (except in debug execution mode, with -g switch). Since version 1.3.1: there is an additional mode: purge mode (-P mode). Since version 1.3.0, vnumlparser.pl supports SKAS mode. 2.1. Building a Simulation ScenarioTo build a simulation scenario use switch -t. If the escenario (or another scenario with the same <simulation_name>) is already running, the parser exits inmediatelly. During the scenario start-up process, several virtual interfaces and bridges are created in the host for the management of virtual machines (they are basically managed by sending commands through a ssh session from the host). This interfaces and bridges exists while the scenario is running, and are destroyed when the release scenario mode (-d) is called. Note that building a simulation scenario can last long, because the UML booting process of each virtual machine is a slow process. The exact duration will heavily depend on the number of virtual machines, the root file system and the physical resources of the host. The following optional switches can be used when invoking vnumlparser using mode -t:
Since version 1.3.1: new optional switch:
2.2. Starting and Stopping SimulationsTo start a simulation over and already running scenario use switch -s; to stop it use switch -p; and to restart it (that is, to stop it and inmediately start it again), use switch -r. Both starting and stopping modes are very similar (-r mode is just a concatenation of both) so they will described together. Basically, the main diference between them is that in start simulation mode vnumlparser.pl executes commands defined with <start> tags, while in stop simulation mode <stop> tagged commands are executed. Before executing start or stop commands, <filetree> tag can be used to copy files or directories from the host file system to the virtual machines ones, or viceversa. This tag is very useful to copy the configuration files needed by the applications to be started in each virtual machine. To use these modes the scenario must have been already started using -t mode. Moreover, UMLs have to be ready to receive commands (management interfaces up and sshd daemon listening in all UMLs). The parser check this, exiting without doing anything if the check fails. The order in which <start> or <stop> commands appear in the VNUML file is the order in which they are executed in the UML or host. As the parser uses SSH to execute commands inside the UMLs, the use of <ssh_key> tag is highly recomended, in order to avoid having to type the password for each SSH access. Due to some problems of the 'ssh' command, vnumlparser.pl may block when executing the UML commands backgrounded with '&'. In this case, press Ctrl+C to unblock it and continue the command execution. Anyway, the blocking can be avoided redirecting input and output of the backgrounded process to /dev/null. For example: nohup /usr/bin/hello </dev/null >/dev/null 2>&1 & (See http://www.slac.stanford.edu/comp/unix/ssh.html for a detailed description of the ssh problem). Note that '>', '<' and '&' characters are forbidden in a XML file, so you need to escape them. For example, to include the previous command inside a <start> tag, you should write: <start type="verbatim">nohup /usr/bin/hello </dev/null >/dev/null 2>&1 &</start> An alternative to avoid having to escape special characters is to store the commands in a file and use the parameter type="file" inside the start or stop tag. Commands included in files do not need to be escaped. The following optional switch can be used when invoking vnumlparser using modes -s, -p or -r:
2.3. Releasing an ScenarioTo release a simulation scenario use switch -d. This mode terminates the scenario lifecycle, by halting all virtual machines and destroying virtual interfaces and bridges created during the start-up mode (-t switch). After a sucessful -d mode, the scenario has to be rebuilt using -t mode. Note that destroying a scenario does not destroy the filesystems of the UMLs. To use -d mode, the scenario must have been already started and all UMLs have to be ready to receive commands (management interface up and sshd daemon listening in all UMLs). The parser checks that, exiting without doing anything if the check fails. As the parser uses SSH to execute the halt command inside each UML, the use of <ssh_key> tag is highly recomended, in order to avoid having to type the password for each UML. Note that releasing a simulation scenario can take a long time, because the UML halting process of each virtual machine is a slow process. The exact duration will heavily depend on the number of virtual machines, the root file system and the physical resources of the host. The following optional switches can be used when invoking vnumlparser using mode -d:
2.4. Purging an ScenarioOnly since version 1.3.1. The main purpose of this mode (-P switch) is to automate deleting actions when a -d mode fails releasing a simulation. When switch -P is used, copied and cowed filesystem in the simulacion directorio are permanently deleted. So, use purge mode carefully! While purging a scenario the following actions are performed:
Warning: steps 2 and 3 produces the killing of all UML processes, not only those in the purged simulation. So, when you are purging a simulation, take care of cleanly terminate (-d mode) all the others simultations (if any) previously. 2.5. Common SwitchesThe following optional switches are common to all vnumlparser.pl execution modes:
2.6. Host Interfaces and Virtual BridgesWhen building a scenario with -t switch, a set of virtual interfaces are created in the host enviroment. The 'ifconfig' command will show you all of them (in additon to any other interface that the host would have). There are three kinds of interfaces managed by vnumlparser.pl:
As mentioned, virtual network connectivity is achived trough the use of virtual bridges configured in the host enviroment. The command 'brctl show' executed in the host will show what bridges exists (one for each virtual network defined with <net>) and what UML interfaces are connected to each bridge (virtual network). 2.7. Direct login to UMLsBy default, virtual machines does not have console access, the only way to login is using SSH through the managament interface. This behaviour can be overriden using <con0> tag. Specifing xterm in a graphical enviroment or a tty, the UML outputs a login prompt to the specified device. When specifing a pts, the number of pseudoterminal can be found using uml_mconsole on the UML. For example, if the simulation name is 'tutorial' and the virtual machine name where pts have been used is 'uml2' uml_mconsole /var/vnuml/tutorial/uml2/mconsole config con0 returns the pseudoterminal filename. This value can be used with screen command to get a console to the UML. For example, if the pseudoterminal would be /dev/pts/6: screen /dev/pts/6 Since version 1.3.1: using -e switch while building the scenario (-t mode) the parser can get the pts devices of the UMLs automactly and put it in a file (whose name is given as the argument of -e switch) that could be use as -c argument of the screen(1) command. 2.8. Working DirectoryThe default vnumlparser.pl working directory is /var/vnuml; this value can be changed using -c switch. The parser stores the following files in the working directory:
Since version 1.3.2-4: the default
working directory can be changed with 2.9. Start and Stop Temporal Command FilesDuring start and stop simulation modes (-s and -p switches), the commands specified with <start> and <stop> (either verbatim or readed from a file) are printed to a script file in the host enviroment (by default to /tmp directory, althought this can be overriden with -T). These files have a header like that: #!/bin/bash # UML start commands file generated by vnumlparser.pl 1.3.0 at Thu Jul 31 00:07:53 CEST 2003 (commands) The first line is the shell that executes this script (the value of the optional <shell> tag, by default /bin/bash). The name of this file is vnuml.name.mode, where name is the name of the virtual machine where the file will run and mode is "start" or "stop", depending of the parser execution mode. These files are installed in the virtual machines (through 'scp' command; therefore previous copies of script files -with the same name- are overriden) in the /root directory and then executed (through 'ssh'). So, /root in the UML filesystem contains the scripts executed during last start and stop simulation modes (it can be useful for debugging purposes). Note that these files are also generated when no <start> or <stop> have been defined for the virtual machine. However, in this case the files are empty (they only contain headers). 2.10. Concurrent Simulation ScenariosVNUML allows to run several concurrent simulations, each one described in a separated VNUML source file. However, to avoid interference between simulations, the following rules have to be followed:
Versions 1.3.0 and before do not perform special checking about whether the above restrictions are being acomplished or not. So, it is under user's responsability. Not following these rules can lead to unpredectible and erroneous behaviours. Note that, to avoid race conditions, no more than one instance of vnumlparser.pl can be execute at the same time. To guarantee this, a global lock file (LOCK in the VNUML working directory) is used. The first action of vnumlparser.pl is to check the existence of this file: if exitst vnumlparser.pl exits doing nothing. In the other case, the file is created. When finishing, vnumlparser.pl removes the LOCK as last action. If a crash occurs while vnumlparser.pl is in execution (for example, an accidental power down in the host) this file may not be removed. In this case, you have to manually remove it. 2.11. External Connections and VLAN supportAs mentioned before, VNUML creates virtual networks to implement the networks defined with <net> tags. These networks allow virtual machines to interchange traffic among them and can optionally be connected to the physical network interfaces of the host (using external attribute). In this way, virtual machines can gain access to external networks. Besides, external interfaces can be physical interfaces (eth0, eth1, etc) or subinterfaces based on VLANs (vlan attribute must be used in this case). If the interface used in a <net> with a external attribute has some configuration (IP address, networks mask and gateway), it will be lost when building the scenario (-t mode). Therefore, if you want to preserve it, you have to use <ipv4> and <route> tags within <hostif> and <host> (note that the configuration is not for the ethX interface, but for the associated bridge; anyway, from a functional point of view, there is no difference). When releasing the scenario (-d mode), the configuration is also lost. If you want vnumlparser.pl to restore it, use <physicalif> tag. Note that if any TCP session (for example, a SSH session) is established in the host through an external interface that VNUML parser will configure, it may get broken. In such cases, just reconnect after a few moments. Anyway, be careful: a wrong configuration of VNUML can lead to lost of network connectivity to the host from the external networks (very important if you log in your host throught network instead logging in through a keyboard console). 2.12. How to release a scenario when -d failsDue to several possible problems, releasing a scenario using -d mode can fail. This situation can be identified by the fact that vnumlparser.pl waits forever to UML halting while Linux processes remains in the user processes space. To kill the parser process you can find useful the following command: 'kill $(pidof /usr/bin/perl)' (be careful: this kills all Perl processes!). Note that the UML processes are mapped to the actual host kernel user space (in a one-by-one basis if SKAS is not being used). You can get a list of the UML processes at any moment using: ps axw | grep linux | cut -c 1-100 NOTE: 'grep linux' in the commands before assumes that your kernel name is 'linux' or linux-compossed (like 'linux-2.4.22um12'). If you are using other name in the <kernel> tag, you have to use the appropiated grep expression. vnumlparser.pl hanging in -d mode could be caused by a misconfiguration of sshd daemon inside UML or in the management interface. The following procedure deals with this situation (use it only as a last resort, it can lead to UML filesystem corruption):
Since version 1.3.1: purge mode automates the procedure described above. |
|
3. Building a Customized Kernel | |
Sooner or later, you will want to build your own customized UML kernel to use in VNUML simulations. This section explains how to do it.
Kernel modules can also be compiled and used. Read about it in the UML Project webpage. |
|
4. Filesystem Requirements | |
Each UML needs a root filesystem to boot (maybe a conventional or COWed copy of a master one). You are strongly encouraged to preserve a master filesystem that will never be used to boot UMLs. UMLs should always boot from copies of this master filesystem (actual copies or COWed copies). Filesystem used with VNUML have to fullfill some requeriments:
Such filesystem acomplishing all requeriments can be built from scratch (see UML web for details) or by modifying one of the available filesystem in the UML Project web site. Anyway, the easiest option to start using VNUML is to download the filesystem used for the tutorial. Filesystem files can be mounted as loopback devices (be careful not to mount filesystems in use by any UML; the risk of corrupting the file filesystem is very high in that case). For example: mount -o loop root_fs_tutorial /mnt It is not a requeriment of vnumlparser.pl itself, but it is important to note that the files needed to support <start> and <stop> operation must be in the filesystem. For example, if you have in your VNUML source file <start type="verbatim">/usr/bin/testprogram</start> it is obvious that the /usr/bin/testprogram executable file must be in the UML filesystem when starting the simulation (remember that you can copy files using <filetree> tag). |
|
5. Installing Software in UML Filesystems | |
To install new software (programs) into a UML filesystem, you can use two procedures:
|
|
|