Example Simulation using the ns Network Simulator




ns setup This page demonstrates how to create network simulations with ns, using a very simple communication scenario. The ns source code as well as installation instructions can be found at http://www.isi.edu/nsnam/ns/ns-build.html.

The simulated topology consists of four hosts (0, 1, 4, 5) connected to routers (2, 3) over 10MBit/s links. The routers themselves are connected over a slower point-to-point connection with a bandwidth of 1MBit/s. A TCP connection starting at time 2.0s sends packets from host 0 to host 5. At time 4.0s, a UDP connection starts up and takes away some of the available bandwidth. The UDP connection terminates at time 8.0s and TCP reclaims the available bandwidth. The corresponding scenario file is tcp.tcl.
To run the simulations, call "ns tcp.tcl". This produces a packet trace file out.tr and a NAM file out.nam. To see a graph of the throughput of the flows, download the Perl script plot.pl and call "plot.pl out.tr 4 5". The graph is saved under the file name out.ps.

throughput graph

The Network Animator NAM can be used to visualize dynamic behavior of the simulation over time: "nam out.nam".

throughput graph