200 likes | 474 Views
NS-2 Tutorial. COMP 7810 09R2 University of Manitoba March 4, 2009. Goal and Outline. Goal of this tutorial Lead you to get started using NS-2 Outline Introduction - What’s NS? Steps in Using NS-2 (through examples) Development and Your Project. What’s NS?.
E N D
NS-2 Tutorial COMP 7810 09R2 University of Manitoba March 4, 2009
Goal and Outline • Goal of this tutorial • Lead you to get started using NS-2 • Outline • Introduction - What’s NS? • Steps in Using NS-2 (through examples) • Development and Your Project
What’s NS? • NS is a packet-level simulator • Started with Keshav’s REAL in 1989 • Been revised in Berkeley, then others • Overview • Major engine (network components) written in C++ • User-interface is tcl script
Test it out! • Go to http://www.cs.umanitoba.ca/~yliu/TEACH/NS2/TUTORIAL
NS-2 Simulated Components • Protocols • TCP, UDP, DCCP, SCTP, TFRC, Wi-Fi, etc. • Network model • Nodes, links, topology, channel schedulers, buffer management, etc. • Traffic model • Applications: FTP, CBR, MPEG, etc. • Traffic traces
NS-2 Simulated Components (II) • All implemented by students/researchers like you and me • Each release has a few more contributed components added • Many are still being developed • Well documented steps to use and to add to NS-2
General Steps In Using NS-2 • Obtaining NS-2 (made available for you) • Writing an OTcl script. E.g., “a.tcl” • Run the simulation. Just type “ns a.tcl” • Post-process the trace generated • Plot graphs and include in your papers
Obtaining NS-2 • Available to you here in CS • Linux version 2.33 installed on neram-02 (a networks lab Linux machine) • Each student is given a separate complete copy of NS-2 • Email me if you don’t know how to access yours
Obtaining NS-2 (for your home PC) • Available for both Linux and Windows • For Windows, you need VMware or cygwin • For Linux, install all-in-one package requires only four commands • tar xzvf ns-allinone-2.33.tar.gz • cd ns-allinone-2.33 • ./install • source setup.csh (Note this script was written by our system admin Gilbert, you may need to copy it over and “customize” it a little bit) • You are ready to go
Writing An OTcl Script • Use NS-2, take a look at “ns-simple.tcl”
Writing An OTcl Script (II) • Add to NS-2 • Write a new network layer component • Write a new transport layer protocol • Write a new application • Steps • Writing new components in .cc and .h (often free implementations are available) • Add to existing header files in package • Add to Makefile and re-compile
Add To NS-2 • Step-by-step instructions for a few examples available in “NS by Example” from WPI • On Transport, Application, and Network Layers respectively • Web site • http://nile.wpi.edu/NS/
Run The Simulation • Plug in the trace file names
Run the Simulation to Collect Traces • Entire packet level event trace dump to file
Post-Process the Trace Generated • Through scripting languages such as Perl, awk, (ba)sh (shell scripts) • Or spread sheet such as Excel • See example “ns-simple-trace.tcl” to generate trace “out.tr” • Perl and awk combined to produce “jitter.txt”
Plot the Graphs • Gnuplot, very handy tool to give nice graphs • See example “gp”, a Gnuplot script that I wrote • The generated .ps file can be easily added to LaTeX for paper / report writing
Development • Editor (you need a comfortable way to edit files under Linux) • Vi, Emacs, pico, … what else do people use? • Make • A very simple utility to automate compilation
Your Course Project • Some tools to play with • OTcl, editor, make, perl, gnuplot • nam to avoid (an animator not essential to simulation) • Need to add to NS-2? • Search for existing implementations on the net first • Have fun!