Difference between revisions of "HOWTO use VirtualBox to run simulations on Windows machines"

From Nsnam
Jump to: navigation, search
(HOWTO use VirtualBox to run simulations on Windows machines)
Line 13: Line 13:
 
1.  The first thing you must do is get the VirtualBox binaries.
 
1.  The first thing you must do is get the VirtualBox binaries.
 
     a.  Go to [[http://www.virtualbox.org/wiki/Downloads the VirtualBox downloads page]]
 
     a.  Go to [[http://www.virtualbox.org/wiki/Downloads the VirtualBox downloads page]]
     b.  Download and run the VirtualBox binary for Windows Hosts by clicking on  
+
     b.  Download and run the VirtualBox binary for Windows Hosts by clicking on the x86/amd64 link.  You will get the usual '''File Download - Security Warning''' dialog.  Just click '''Run''' to download and run the about 70 megabyte file.
        the x86/amd64 link.  You will get the usual '''File Download - Security  
+
     c.  After the file downloads, you will get the usual Windows '''Internet Explorer - Security Warning''' dialog.  Just select '''Run'''.
        Warning''' dialog.  Just click '''Run''' to download and run the about  
+
        70 megabyte file.
+
     c.  After the file downloads, you will get the usual Windows '''Internet  
+
        Explorer - Security Warning''' dialog.  Just select '''Run'''.
+
  
 
2.  Step through the '''Sun VirtualBox Setup Wizard'''.
 
2.  Step through the '''Sun VirtualBox Setup Wizard'''.

Revision as of 21:15, 6 November 2009

Main Page - Current Development - Developer FAQ - Tools - Related Projects - Project Ideas - Summer Projects

Installation - Troubleshooting - User FAQ - HOWTOs - Samples - Models - Education - Contributed Code - Papers

ns-3 is primarily a Linux platform and advanced ns-3 features will use Linux specific functions to accomplish their goals. Since Windows is such as widely used platorm, ns-3 does provide a supported solution for running in that environment using a Linux-emulation environment called [Cygwin]. However, Cygwin is not a perfect emulation of any Linux. This means there will be features available on Linux systems that are simply not usable on Windows systems.

Fortnately, a technology called virtualization exists to allow one to share computer hardware between operating systems and allow you use Linux systems essentially as if they were running natively on your hardware. This happens as your Windows is running, so it appears as if Windows and Linux were sharing your hardware.

There are several virtualization schemes currently available. Two of the most popular are VMware (see HOWTO use VMware to set up virtual networks (Windows)) and VirtualBox. We will cover VirtualBox in this HOWTO.

There is extensive documemtation available online for VirtualBox. Look [here] for a starting point. Note that by downloading the VirtualBox code you are implicitly agreeing to [this license].

HOWTO use VirtualBox to run simulations on Windows machines

1. The first thing you must do is get the VirtualBox binaries.

   a.  Go to [the VirtualBox downloads page]
   b.  Download and run the VirtualBox binary for Windows Hosts by clicking on the x86/amd64 link.  You will get the usual File Download - Security Warning dialog.  Just click Run to download and run the about 70 megabyte file.
   c.  After the file downloads, you will get the usual Windows Internet Explorer - Security Warning dialog.  Just select Run.

2. Step through the Sun VirtualBox Setup Wizard.

   a.  Press the Next > button.
   b.  Accept the terms of the license agrreement (if you desire) by clicking
       the corresponding radio button.
   c.  Press the Next > button.
   d.  Review the features that will be installed if you desire.  I just accept
       them as-is.
   e.  Press the Next > button.
   f.  Decide if you want a desktop and quick lanch icon.  If you expect to 
       use ns-3 a lot it is probably worthwhile, but completely up to your 
       preference
   g.  Press the Next > button.

3. Perform the actual installation. Warning: This step will temporarily disconnect you from the Internet.

   a.  Press the Install button to start the installation process.
   b.  You will see a number of dialog boxes (six) complaining that VirtualBox has not 
       passed Windows Logo Testing.  Press Continue Anyway.
   c.  When you see the Sun VirtualBox installation is complete message
       leave the Start Sun VirtualBox after installation radio button
       selected.
   d.  Press the Finish' button.

3. Register with Sun Online. VirtualBox will ask you to register with Sun Online. If you already have a Sun Online account, enter it or just fill out the account creation part of the page and press Register. If the restration process complains about a bad IP address, just create a new account.

4. Download a Linux CD image.

   a.  Decide which version of Linux you are going to use.  If you have no 
       strong preference, I would use the same version that tns-3 does most
       of its testing on.  Look [here
       for the ns-3 wiki.  Follow the [[http://ns-regression.ee.washington.edu:8010/waterfall
       Buildbot Waterfall Display]] link, and notice the list of platforms.
       At the time of this writing, most of them are fc10.  This means Fedora
       Core 10.  Fedora it is; and they are at Fedora 11 as of this writing.
   b.  Go to [The Fedora Project] and then to 
       [Get Fedora] and download a
       CD image.  You will get the usual File Download - Do you want to open
       or save this file? dialog.  Just click Save and tell the system
       where to put the almost 700 megabyte file.

5. Start a new virtual machine

   a.  Go to the Sun VirtualBox window you started in step 3.
   b.  Press the "New" button.  This will start a New Virtual Machine Wizard.
   c.  Press Next > in the wizard.
   d.  Give your new virtual machine a name, say "ns-3-fedora-11.
   e.  In the OS Type box, select Linux as the Operating System and
       Fedora as the Version.
   f.  Press Next > in the wizard.
   g.  Keeping in mind how much physical memory you have in your host machine,
       give the new virtual machine some memory.  This won't be available for 
       your host machine.  I choose 512 MB on my 2 GB Windows machine.
   h.  Press Next > in the wizard.
   i.  Keeping in mind how much hard disk space you have in your host machine
       give teh new virtual machine some memory.  You will need disk for the 
       base OS, the toolchain and at least one ns-3 distribution, which will 
       require about 1.2 gig at the time of this writing.
   j.  Press Next > in the New Virtual Machine Wizard to start the
       Create New Virtual Disk Wizard.
   k.  Press Next > in the Create New Virtual Disk Wizard.
   l.  Leave the Dynamically expanding storage radio button selected and
       press Next > in the Create New Virtual Disk Wizard.
   m.  Select a maximum size for the disk (I use 10 GB) and press Next > 
       in the Create New Virtual Disk Wizard.
   o.  Press Finish in the Create New Virtual Disk Wizard to create
       your disk.
   p.  This takes you back to the New Virtual Machine Wizard which will 
       be giving you a summary of the new virtual machine parameters.  Press 
       Finish in the Create New Virtual Disk Wizard to create
       your new virtual machine.

6. "Insert" your boot CD. In the Sun VirtualBox window, you should now see a virtual machine named "ns-3-fedora-11" in the powered off state on the left side. On the right side, you should see the "Details" tab selected, with the details for "ns-3-fedora-11" displayed.

   a.  Click on the CD/DVD-ROM item.
   b.  Select the Mount CD/DVD Drive check box.
   c.  Select the ISO Image FIle radio button.
   d.  Browse for the ISO Image File.
   e.  Select the "Add" Icon and browse to the ISO image file for Fedora 11
       you saved in step 4.
   f.  Press Select and then OK.

7. Power up the virtual machine and install Fedora 11.

   a.  Select the "Start" icon in the Sun VirtualBox window.  It is shaped like
       a green arrow.
   b.  Read the information dialog about how to get in and out of the virual
       machine window and press OK.
   c.  Read the information dialog about color mode and press OK.
   d.  Click into the new virtual machine window, select Capture and 
       watch Fedora 11 start to install (this will take a while).
   e.  When the login box appears, press "Log In" and then double click the 
       Install to Hard Disk icon.
   f.  Press 'Next to bein the Fedora 11 installation process and copy the
       image to the virtual machine hard drive.  This is going to take somex
       considerable time since you are installing a whole operating system.
       We won't cover how to proceed here in detail since this is not a Fedora
       11 installation guide.  Google is your friend if you have problems.



5. Freshen the Software Distribution

   a.  sudo yum install pkg-config libxml2 libxml2-dev
   d.  sudo yum install gcc g++ make automake autoconf binutils
   e.  sudo yum install openssh-server openssh-client openssl libssl-dev
   f.  sudo yum install python-dev mercurial
   g.  sudo yum install tcpdump gdb emacs
   h.  exit

6. Log in as User (Appliance comes pre-configured with one user)

   a.  log in as user: user, password user
   b.  Change your password (passwd) if you are connected to the real world and 
       like your system intact

7. Get and Test ns-3-dev

   a.  mkdir repos
   b.  cd repos
   c.  hg clone http://code.nsnam.org/ns-3-dev
   d.  cd ns-3-dev
   e.  ./waf configure -d debug
   f.  ./waf
   g.  ./waf --regression

As an old math professor once said, "I feel joy"!

Now it's time for a breather. You have a configured Ubuntu JeOS Virtual Machine and you've built and tested ns-3 on it. Now might be a good time to copy this VM somewhere safe as your base machine. If you want to clone your machine you can use this copy, or if you manage to wedge the VM, you can use the copy as a checkpoint and restore a working copy without going through all the pain we just suffered through.

8. Checkpoint the VM

   a.  log out of the VM (exit);
   b.  Press the red rectangle (stop) button on the VMware Server Console;
   c.  Open My Computer/Virtual Machines
   d.  Copy "ub710jeos" to "ub710jeos checkpoint"

Now it's time to start creating that test network that was the reason we started this process. We'll use the checkpointed VM we just made and copy it to begin.

9. Create new VM with a Private Network

   a.  Copy "c:\Virtual Machines\ub710jeos checkpoint" to another directory in
       the "Virtual Machines" directory and call it "ns-3-test-1"
   b.  Select the File->Open menu option and Browse for the  
       "ns-3-test-1" directory and open the "ub710jeos.vmx" file;
   e.  Select the "Edit virtual machine settings" command on the VMware Server
       Console;
   d.  Click on the "Options" tab;
   e.  Enter "ns-3-test-1" in the "Virtual machine name" text box;
   f.  Click on the "Hardware" tab;
   g.  Click on the "Add" button.  You will launch the "Add Hardware Wizard";
   h.  Click "Next";
   i.  Click "Ethernet Adapter" and then "Next";
   j.  Click the "Host Only:  A private network shared with the host" radio
       button and then "Next";
   k.  Click "OK";
   l.  Select the "Start this virtual machine" command on the VMware Server
       Console;
   m.  You will get a dialog box asking about a new UUID.  Select the "Create"
       radio button and press "OK";
   n.  Ubuntu JeOS will start in a "console window."
   o.  Log in as root (you changed the password, right?)
   p.  Edit (vi) "/etc/network/interfaces" and add the following lines 
       before the similar delcaration of the primary network interface:
           # The private network interface
           auto eth1
           iface eth1 inet dhcp
   q.  Edit (vi) /etc/hosts and replace instances of "ub710jeos" with 
       "ns-3-test-1";
   r.  Edit (vi) /etc/hostname and replace "ub710jeos" with "ns-3-test-1";
   s.  Change the host hame by executing "hostname ns-3-test-1";
   t.  Log out of the VM;
   u.  Press the red square (stop) button on the VMware Server Console to 
       stop the VM.

Now you have one VM with a private network on it. You can repeat step nine as many times as you want, renaming the VMs ns-3-test-2, ns-3-test-3, etc. Go ahead and make a ns-3-test-2 virtual machine just so we can do something interesting.

10. Start Your Virtual Test Network

   a.  Select the "ns-3-test-1" tab on the VMware Server Console;
   b.  Select the "Start this virtual machine" command on the VMware Server
       Console;
   c.  Ubuntu JeOS will start in a "console window";
   d.  You should see an "ns-3-test-1 login" prompt when it comes up;
   e.  Select the "ns-3-test-2" tab on the VMware Server Console;
   f.  Select the "Start this virtual machine" command on the VMware Server
       Console;
   g.  Ubuntu JeOS will start in a "console window."
   h.  You should see an "ns-3-test-2 login" prompt when it comes up;

You can now switch between the running virtual machines by selecting the appropriate tab on the VMware Server Console. Enter a VM by clicking in the console window and exit by pressing <ctrl>+<alt>. Select another tab of a running VM and enter that VM by clicking in the console window.

12. Update /etc/hosts and Check Connectivity

   a.  Log in to "ns-3-test-1" as root;
   b.  Run ifconfig -a and note the IP address of eth1;
   c.  Log in to "ns-3-test-2" as root;
   d.  Run ifconfig -a and note the IP address of eth1;
   e.  Edit (vi) "/etc/hosts" on "ns-3-test-1" and add an appropriate line
       for "ns-3-test-2".  On my machine it is
       "192.168.136.129 ns-3-test-2";
   f.  Edit (vi) "/etc/hosts" on "ns-3-test-2" and add an appropriate line
       for "ns-3-test-1".  On my machine it is
       "192.168.136.128 ns-3-test-1";
   g.  On ns-3-test-1 run "ping ns-3-test-2" to verify;
   h.  On ns-3-test-2 run "ping ns-3-test-1" to verify;

At this point, you probably will want to set up users, shells, aliases, other tools (emacs, ddd, etc) or whatever else you will be needing. For example, I set up a new user to match my user name on all of the other ns-3-related machines I work with, set the shell to bash, copied over my aliases, ssh keys, etc., etc., yadda, yadda.

CAVEATS

   a.  Be careful about carelessly using disk space in these VMs.  We have 
       intentionally limited the size of the backing disk file to 1 GB so we 
       don't consume all of your Windows resources.  This does mean that you 
       will be limited to perhaps one or two full builds of ns-3 with regression
       traces depending on what other stuff you install.  If you run out of 
       disk, you can increase it using VMware tools installed for you in the 
       Windows "Command Prompt."
       i.   Open your "Command Prompt";
       ii.  Change into "C:\Program Files\VMWare\VMware Server;
       iii. There is an executable there named "vmware-vdiskmanager.exe";
       iv.  Find the full path to the disk image file you want to increase;
       v.   Increase the disk size using the following recipe:
            vmware-vdiskmanager -x 16GB "C:\Virtual Machines\ns-3-test-1\ub710jeos.vmdk"

Congratulations, you are now ns-3 emulation ready.

Craigdo 16:17, 6 August 2008 (EDT)