HOWTO make ns-3 interact with the real world
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.
- 1 HOWTO make ns-3 interact with the real world
- 2 Simulated Nodes and Simulated Networks
- 3 Real Nodes and Simulated Networks
- 4 Simulated Nodes and Real Networks
- 5 Real Nodes and Real Networks
HOWTO make ns-3 interact with the real world
Given the abstractions of computing nodes and networks; and the physical state of real or simulated, one can compose a table of possible configurations:
|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 gray.
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.
In full virtualization, a virtual machine environment is created that completely simulates some underlying hardware and OS environment. Using this technology, 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.
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. Examples of paravirtualization systems of this kind are Linux Containers and OpenVZ. 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, a full virtualization system. I run a virtual machine running the Fedora 12 OS 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.
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.
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
While this is perhaps not as often used as the ns-3 TAP case, using simulated nodes along with real networks can also be important when validating models. In general, one needs to have some assurance that a model has some connection to some reality -- that a model is an accurate representation of a real system. In other words, if you are going to use a simulation model to try and predict how some real system is going to behave, you must have some reason to believe your results -- i.e., that you can trust that an inference made from the model translates into a correct prediction for the real system.
Every model has a target system that it is attempting to simulate to some level of detail and accuracy. The process of getting the model behavior to agree with the target system behavior is called model validation. The process used to validate a model is conceptually quite simple. One compares the behavior of the model to the behavior of the target system, and makes adjustments to the model to improve the correlation. Being able to use ns-3 applications to drive both simulated networks and real networks makes these comparisons easier.
It may also be the case that one has a simulated application one is using to drive ns-3 scenari. The perspective above could be inverted and the real network could be used to validate the simulated applictation by allowing it to connect with real clients or servers, for example.
In either situation, the use cases are addressed by the ns-3 EMU net device. EMU is from network emulation. Network emulation is a term that refers to the ability to allow the simulator to inject traffic into a live network and vice versa.
Often the "live network" is a testbed facility of some kind. The ORBIT testbed is perhaps the best known of these facilities. It is a large two-dimensional grid of 400 802.11 radio nodes which can be dynamically interconnected into specified topologies. The idea is to have a controlled environment that helps gain reproducibility. We have several HOWTOs discussing how to integrate ns-3 and ORBIT:
- HOWTO use ns-3 scripts to drive real hardware (experimental)
- HOWTO use ns-3 directly on the ORBIT testbed hardware
- HOWTO use ns-3 in the ORBIT testbed environment
Signal Propagation Emulation Integration
Another approach is to use real network cards along with a wireless signal propagation emulator. This allows for even more reproducible results than on a testbed with the advantage of not requiring a space the size of a hockey rink. One example of this approach is the CMU Wireless Emulator. This system uses a wireless network emulator that accurately emulates wireless signal propagation. The emulator takes in the signals generated by wireless network cards and subjects them to the same effects that occur in the real world (e.g. attenuation, multi-path fading, etc.). It then feeds the combined signals back into the wireless cards. We have one HOWTO describing how this system is integrated with ns-3.
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 05:55, 17 February 2010 (UTC)