1 / 30

Introduction to NS-2

Introduction to NS-2. Xiaohua Tian Illinois Institute of Technology. What is NS-2 ?. NS is a event driven network simulator that simulates variety of IP networks NS implements Network Protocols : TCP, UDP Traffic behavior : FTP, Telnet, CBR, VBR

navid
Download Presentation

Introduction to NS-2

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to NS-2 Xiaohua Tian Illinois Institute of Technology

  2. What is NS-2 ? • NS is a event driven network simulator that simulates variety of IP networks • NS implements • Network Protocols : TCP, UDP • Traffic behavior : FTP, Telnet, CBR, VBR • Router Queue Management : Drop Tail, RED, CBQ • Routing algorithms : Dijkstra • Adhoc routing, Sensor Networks • Multicasting , MAC layer protocols • Wired, Wireless, Satellite

  3. NS-2 Software Structure • NS simulator is based on 2 languages • C++ • Used to implement the protocols • For example implementation of Mac 802.11 in ~ns/ns-2.30/mac/802_11.[cc,h] Advantage Reduce packet and event processing time • Otcl • Used to configure the topology, the nodes, the channel, to schedule the events Advantage Easy to change model and re-run Flexible for integration

  4. C++ and Otcl Duality • C++ and Otcl Duality • Architectural View of NS

  5. General Simulation Process

  6. Installation (windows environment) • Install cygwin: www.cygwin.com

  7. Cygwin installation

  8. Cygwin installation

  9. Cygwin installation

  10. Cygwin installation

  11. Cygwin installation

  12. Cygwin installation

  13. Cygwin installation

  14. 2. NS-2.30 installation • copy the ns-allinone-2.30.tar.gz (from Blackboard) file in your Cygwin home directory (typically something like C:\cygwin\home\John) • Launch Cygwin, a command line window should appear. Type the following commands: • gzip -d -c ns-allinone-2.30.tar.gz | tar xvf – (or use winrar to unpack the package) • cd ns-allinone-2.30 • ./install

  15. 2. Environment variable config

  16. Environment variable config

  17. Environment variable config

  18. Environment variable config • Path: C:\cygwin\home\username\ns-allinone-2.30\bin; • TCL_LIBRARY: C:\cygwin\home\username\ns-allinone-2.30\tcl8.4.13 • LD_LIBRARY_PATH: C:\cygwin\home\username\ns-allinone-2.30\otcl-1.12

  19. 3. Steps to set up the simulation • Initialize the simulator • Define files for output (tracing) • Set up the topology • Set up the “agents” • Set up the traffic between the nodes • Start the simulation • Analyze the trace files to compute the parameters of interest

  20. Setting Up Variables • Initialize the Simulator set ns_ [new Simulator] • Setup Trace File set tracefile [open simple.tr w] $ns_ trace-all $tracefile • Setup NAM trace file set namfile [open out.nam w] $ns_ namtrace-all $namfile

  21. Set up the topology Create 2 nodes n0 and n1 set n0 [$ns_ node] Set n1 [$ns_ node] Create Duplex-Link between n0 and n1 $ns_ duplex-link $n0 $n1 2Mb 10ms DropTail 10ms Propagation Delay 2Mb of Capacity Bi-directional link n0 n1

  22. Setup traffic flow • Setup a TCP connection Set tcp [new Agent/TCP] $ns_ attach-agent $n0 $tcp Set sink [new Agent/TCPSink] $ns_ attach-agent $n1 $sink $ns_ connect $tcp $sink Setup a FTP over TCP Set ftp [new Application/FTP] $ftp attach-agent $tcp FTP TCP Sink n0 n1

  23. Set Stop Time and Start Simulation $ns_ at 0.1 “$ftp start” $ns_ at 10.0 “$ftp stop” $ns_ at 10.1 “finish” $ns run // Starting simulation // Define a Finish procedure Proc finish {} { global ns_ tracefile namfile $ns_ flush-trace close $tracefile close $namfile exec nam out.nam & // Calling NAM exit 0 }

  24. Running the Script and Using NAM • ns filename.tcl • The simulation will generate the trace file simple.tr • NAM can be run in 2 ways • Inside TCL file “ exec nam out.nam &” • Outside TCL file “ nam out.nam”

  25. NAM Screenshot

  26. Trace Files

  27. Working with Trace Files • To compute Throughput, Jitter, End to End Delay Process trace files with any of these utilities 1) AWK 2) GREP 3) PERL To plot the graph 1) gnuplot 2) xgraph In Tcl : exec xgraph out.tr & Out Tcl : xgraph out.tr

  28. Screenshot of XGRAPH

  29. Conclusion

  30. References • http://www.cygwin.com/ • http://www.isi.edu/nsnam/ns/ns-documentation.html Contains the NS manual detailed documentation of the source code • http://nile.wpi.edu/NS/

More Related