Difference between revisions of "HOWTO make ns-3 interact with the real world"

From Nsnam
Jump to: navigation, search
(Real Nodes and Simulated Networks)
(Real Nodes and Simulated Networks)
Line 37: Line 37:
 
This is an important use-case for ns-3.  We want to be able to use real applications, but we don't want to have to actually assemble large networks of computers and attempt to control them.  In this mode, we really want to create '''virtual''' nodes and connect them through simulated networks.  A better way to think of this is real applications running on virtual computers, talking over '''simulated''' networks.
 
This is an important use-case for ns-3.  We want to be able to use real applications, but we don't want to have to actually assemble large networks of computers and attempt to control them.  In this mode, we really want to create '''virtual''' nodes and connect them through simulated networks.  A better way to think of this is real applications running on virtual computers, talking over '''simulated''' networks.
  
There are many different virtualization solutions available to work with.  Technically, what we are talking about is platform virtualization.  This space can be further broken down to full virtualization and paravirtualization.  You can think of these as heavyweight and lightweight solutions, respectively.
+
There are many different virtualization solutions available to work with.  Technically, what we are talking about is platform virtualization.  Platform virtualization can be further broken down into full virtualization and paravirtualization.  You can think of these as heavyweight and lightweight solutions, respectively.
  
 
=== Full Virtualization ===
 
=== Full Virtualization ===

Revision as of 05:12, 17 February 2010

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 a simulator. Its primary function is to simulate networks of communicating nodes and the traffic between them. To do this, ns-3 provides its primary abstractions of computing nodes with applications to generate traffic; and net devices and channels to move the traffic.

Often, however, it is desirable to mix and match real and simulated entities. For example, in order to validate a network model, one might create a simulation scenario, run the simulated model and gather statistics. Then one might move to real hardware and run the same scenario. One would then compare the results of the two run to verify that the simulation is indeed a faithful representation of the hardware to some specified degree under specified circumstances. One might also envision a scenario in which a network configuration is prohobitively expensive to create using real hardware. In this case, one might want to simulate a large network, but use real applications to drive the simulation through some virtualization scheme.

There are a number of ways that once could conceive of connecting various real and simulated components. This HOWTO discusses the ns-3 mechanisms for combining these components.

HOWTO make ns-3 interact with the real world

Given the abstractions of computing nodes, and the physical state of real or simulated, one can compose a table of possible configurations:

Networks
Nodes Real Simulated
Real Your Computer and Network ns-3 TAP
Simulated ns-3 EMU ns-3 Native Simulation

To read this table, find the "physicality" (real or simulated) of the networks in a column and the "physicality" of the nodes in a row and find the technology you want to look at the intersection. For example, if you want to use a simulated network and real computing nodes, you are directed to something called "ns-3 TAP." If you want to use simulated nodes and real networks, you are expected to use a technology called "ns-3 EMU." From the perspective of this HOWTO, these are the interesting cases of integrating real and simulated hosts and networks; and these cases are shaded in blue.

Preliminaries

The first step for anyone interested in ns-3 simulations of any kind is to visit The ns-3 Tutorial and work through the entire document. There are lots of answers to common questions there; and you can become a fairly sophisticated ns-3 user just by spending a few hours there.

If you are not up to speed on the material covered in the tutorial, you will most likely not understand the ns-3 scenari given. We will assume some facility with ns-3, so you are encouraged to spend the time with the tutorial. Really. Please.

Simulated Nodes and Simulated Networks

If you are interested in using ns-3 to simulate both nodes and devices, there are dozens of great examples to be found in the ns-3 distributions under the examples directory. Spending some time perusing the examples will be time well spent. Make sure to go through the tutorial first (do you sense a pattern here), and you will find them fairly easy going.

Real Nodes and Simulated Networks

This is an important use-case for ns-3. We want to be able to use real applications, but we don't want to have to actually assemble large networks of computers and attempt to control them. In this mode, we really want to create virtual nodes and connect them through simulated networks. A better way to think of this is real applications running on virtual computers, talking over simulated networks.

There are many different virtualization solutions available to work with. Technically, what we are talking about is platform virtualization. Platform virtualization can be further broken down into full virtualization and paravirtualization. You can think of these as heavyweight and lightweight solutions, respectively.

Full Virtualization

In full virtualization, a virtual machine environment is created that completely simulates some underlying hardware. In this environment, one can make a single system appear to be multiple systems of the same or different types. For example, one could run a virtualization system on Windows that gave the appearance of multiple Windows systems, multiple Linux systems or some mix of these or other environments. One example of a full virtualization system is VMWare. Another is VirtualBox. Full virtualization environments are considered heavyweight systems since every aspect of a target machine must be simulated, and individual virtual machines must be completely isolated from one another.

Paravirtualization

In paravirtualization, a virtual machine environment is created but an underlying machine is not completely simulated. In one form, this requires porting of the guest (virtualized) operating system to a virtualization environment. In another form, the underlying host operating system is used to create the illusion of virtualization of some parts of the underlying host hardware. The second form of paravirtualization is most lightweight and therefore most suitable to running many instances of virtual (simulated) nodes in ns-3. A good example of a paravirtualization system of this kind is Linux Containers. This kind of solution will allow one to create virtual Linux guest systems on a Linux host system, but would not allow one to create virtual Windows systems on a Linux host system.

Mix and Match

The technology to use for virtualization will vary according to your needs. Since ns-3 is primarily a Linux-based system, we concentrate on virutalization systems for Linux. Full virtualization and paravirtualization schemes may be combined to suit individual needs. For example, I have a Windows machine at home. In order to run ns-3 under Linux, I personally use VirtualBox. I run a Fedora 12 virtual machine which supports Linux Containers (lxc). I then use the paravirtualization of the lxc tools to create multiple virtual hosts which I then wire together using ns-3 simulated networks. Although this configuration is not going to win any speed contests, it is a much ligher-weight solution than running multiple fully virtualized Linux systems under VMware, for example; and makes a reasonable development system. If I have the need for speed, I will turn to a server-grade multiple core system running Linux directly, and use paravirtualization there to combine raw power and lightweight virtualization.

ns-3 TapBridge

Fortunately, the same basic mechanism allows ns-3 to work with both virtualization and paravirtualization systems. Since ns-3 is a Linux-based system, we use a Linux mechanism to implement the required functionality. We call this mechanism the ns-3 TAP mecanism. This uses a special net device called a TapBridge; Tap coming from the tun/tap device which is the Linux device driver used to make the connection from ns-3 to the Linux guest operating system, and Bridge since it conceptually extends a Linux (brctl) bridge into ns-3.

HOWTOs

If you decide to go the route of paravirtualization, we have a HOWTO that describes the process of creating virtual machines using Linux Containers: HOWTO Use Linux Containers to set up virtual networks. If you have a Windows machine and you would like to get Fedora 12 running as a fully virtualized system, see HOWTO use VirtualBox to run simulations on Windows machines for a description of how to get Fedora 12 on your system before proceeding with the first HOWTO.

If you decide to go with full virtualization, we have a HOWTO that describes the process of creating virtual machines using VMware: HOWTO use VMware to set up virtual networks (Windows).

Simulated Nodes and Real Networks

This use-case is addressed by the ns-3 EMU device.

Real Nodes and Real Networks

I'm afraid ns-3 isn't going to be able to help you with this one. Maybe you should consider replacing some of those expensive nodes and networks with simulations.


Craigdo 04:58, 17 February 2010 (UTC)