ns-3 (http://www.nsnam.org) is a discrete-event network simulator for Internet systems, targeted primarily for research and educational use. ns-3 is free software, licensed under the GNU GPLv2 license, and is publicly available for research, development, and use. ns-3 is intended as an eventual replacement for the popular ns-2 simulator. The project has an active developer base and a vibrant community of networking researchers involved with it.
Please note that ns-3 is _not_ an evolution of ns-2, and is a completely new simulator written from scratch. ns-3's source code is written in C++, whereas end users can develop their simulation scripts using C++ or Python. ns-3 works on Linux and Unix variants, OSX and Windows (via Cygwin).
In the following tutorials, we will cover some of the important concepts that underly ns-3, and the basics of writing simulation scripts. Note that there are also a tonne of tutorials at http://www.nsnam.org/tutorials.html.
Version and OS
For the tutorials, we will be using ns-3-dev. We recommend using a GNU/Linux variant or OSX for these tutorials.
(Please see the associated text box of individual spoken tutorials on the website to decide the versions of software and OS to which it is applicable.)
ns-3 allows one to perform network simulations, and thus aid in the testing and validation of network models. Simulations are important because they provide a platform to verify the working of a protocol before a real world implementation of the same can be experimented with.
To run a simulation, a user writes a simulation script in either C++ or Python. The simulation script uses the models that are available and generates PCAP and/or ASCII traces. Users may use their own formats for extraction of data out of a simulation.
Users are expected to be familiar with C++ and be familiar with Computer Networks.
- Prof. M. S. Gaur, Department of Computer Engineering, Malaviya National Institute of Technology, Jaipur, India.
- Lalith Suresh P., Department of Computer Science and Engineering, Instituto Superior Técnico, Lisbon, Portugal.
NS-3 Basic Tutorials
NS-3 Concepts and Installation
This tutorial covers some important concepts of ns-3, and then proceeds to demonstrate an installation of the same.
- Packets: Packet objects are units of information sent and received by applications.
- Nodes: A Node class represents a network element in ns-3. Just like in a real network node, it may _optionally_ have an Ipv4 stack, one or more routing protocols, a mobility model or applications running on top of it.
- Applications: Applications are traffic generators, which generate streams of data as per user defined intervals/bursts. They are highly configurable. A well known kind of application that ns-3 offers is 'ping'.
- NetDevices: NetDevice objects represent real world network interfaces in ns-3. Presently, ns-3 allows users to use Csma, Wifi, Point-to-point, Wimax, Mesh and many more with their simulation nodes.
- Helpers: Helpers, as the name suggests, add an extra layer of abstraction to make it easier for users to write simulation scripts with fewer lines of code.
- Logging: Allows a user to perform classical 'printf' style debugging with ease.
- Tracing: This is ns-3's mechanism to probe and collect information from particular points of the simulation system. This can be from different part's of a node's stack such as the NetDevice, the PHY, or the transport.
- Use Mercurial to clone ns-3-dev.
- Build ns-3.
Basic Simulation Tutorial
This tutorial covers the writing of basic simulation scripts. The following sequence of steps will be involved:
- Creating nodes.
- Adding Csma network devices to the nodes and connecting the devices.
- Setting up an Ipv4 stack on the nodes.
- Setting up applications on the nodes.
- Running the simulation.
- Viewing Trace Files using Wireshark.
NS-3 Advanced Tutorials
These tutorials cover Wifi simulations, routing protocols, mobility models, the PyViz visualiser, the tracing subsystem and the flow monitor.
- Create nodes.
- Add Wifi NetDevices to the nodes. Setup the MAC/PHY properties.
- Setting up an Ipv4 stack on the nodes.
- Setup a routing protocol (we'll use OLSR) on the nodes to perform routing.
- Setup a mobility model for the nodes.
- Setup applications on the nodes.
- Use PyViz to visualise the Wifi simulation.
- Demonstrate the varying of simulation speed.
- Observe a node's routing table and other properties attached to it.
- Make use of the tracing subsystem with the Wifi simulation.
- Use the tracing mechanism to observe a particular node's NetDevice.
ns-3 Flow Monitor
- Setup the flow monitor to monitor flow statistics in the Wifi simulation.