Top Banner

of 54

IntroNS2

Jan 09, 2016

Download

Documents

Vipan Sharma

ns2
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • Introduction to NS2-Network Simulator-

    -Prepared by Changyong Jung

  • ContentsOverviewHow to InstallOTCL The User LanguageEvent SchedulerPacketSimulation Example

  • OverviewWhat is NS2?- Event driven network simulator - Developed at UC Berkely - Implements network protocols 1) TCP, UPD 2) Traffic source mechanism: FTP, TELNET, Web, CBR and VBR 3) Router Queue management mechanism: Drop Tail, RED, CBQ 4) Routing Algorithm: Dijkstra, and etc 5) Multicasting, Mac layer protocols for LAN

  • OverviewBackground on the ns Simulator - based on two languages( an object-oriented simulator (C++), and OTcl (object-oriented Tcl) interpreter. - has rich library of network and protocol object - Compiled C++ hierarchy gives efficiency in simulation and faster execution times. - With OTcl script provided by user, a network topology is simulated.

  • OverviewNs2 is event simulator where the advance of time depends on the timing of events which are maintained by a scheduler.Event an object in C++ hierarchy. unique ID, Scheduled time, pointer to an objectScheduler maintains ordered data structure with the events to be executed and fires them one by one, invoking the handler of the event.

  • How to Install-Window XP-Go to Website: http://nsnam.isi.edu/nsnam/index.php/Running_Ns_and_Nam_Under_Windows_9x/2000/XP_Using_CygwinRead Requirements and Installation Tips Carefully.Download cygwin.exe from http://www.cygwin.com/Click the cygwin.exe

  • How to InstallCygwin Installation

  • How to Install

  • How to InstallSelect browse for cygwin file( I selected as default)

  • How to InstallLocal package directory (I recommend c:\cygwin).

  • How to InstallSelect to Install all ( I recommend it)You can select install, default, uninstall, install, and reinstall behind the first line all. If you select install, then all sub items will be automatically selected. Otherwise you may lose some items.

  • How to InstallSelect download site

  • How to InstallInstalling

  • How to InstallFinishing Installing

  • How to InstallNS2 InstallationDownload ns-allinone-2.29.2.tar.gz from Website and Save it to the c:/cygwin /usr/localUnpack it: tar xvfz ns-allinone-2.29.2.tar.gzClick on desktop icon cygwin

  • How to Install

  • How to InstallType cd .. to go to the upper folder(cd must be low case. And there is one space between d and .)Type cd .. again.

  • How to Installcd usr, go to folder usrcd local, go to folder local

  • How to InstallFind install.exe

  • How to InstallStart to run the installation ./install

  • How to InstallInstalling

  • How to InstallInstalling

  • How to InstallConfigure system variables and library pathsAfter finishing installing, following window appears

  • How to InstallConfigure system variablesGo to My computer and click view system information

  • How to InstallGo to advanced Tab and Click Environmental variables

  • How to Install

  • How to InstallHighlight path which is system variable box and press the Edit button.

  • How to Install

  • How to InstallAdd the following path separated with ; make sure to not change the existing path.

    /usr/local/ns-allinone-2.29.2/bin/usr/local/ns-allinone-2.29.2/tcl8.4.11/unix/usr/local/ns-allinone-2.29.2/tk8.4.11/unix

  • How to InstallGo to cygwin and type the following contentExport LD_LIBRARY_PATH=/usr/local/ns-allinone-2.29/otcl-1.11Export LD_LIBRARY_PATH=/usr/local/ns-allinone-2.29/libExport TCL_LIBRARY_PATH=/usr/local/ns-allinone-2.29/tcl8.4.11/library

  • How to Install

  • OTcl The User LanguageNS2 is basically an OTcl interpreter with network simulation object librariesVery simple syntax and easy integration with other languages.Characteristics: - fast development - provide graphic interface - compatible with many platforms - flexible for integration - easy to use - free

  • OTcl The User LanguageExample

  • OTcl The User LanguageProc: define a procedure, followed by an procedure name and arguments Set: assign a value to a variable[expr ]: to make the interpreter calculate the value of expression within the bracketTo assign to variable x the value that variable a has, then write set x $a.Put: prints out

  • OTcl The User Language

  • Event SchedulerMain users of an event scheduler are network components that simulate packet-handling delay or that need time

  • Event SchedulerTwo different types of event schedulers - real time: for emulation which allow the simulator to interact with a real network - non-real time: three implementations are available (Heap, List, Calendar). The default is set as Calendar

  • Event SchedulerExample . . . set ns [new Simulator] $ns use-scheduler Heap . . .

    . . . set ns [new Simulator] $ns use-scheduler Heap $ns at 300.5 "complete_sim" . . . proc complete_sim {} { . . . }

  • PacketNS2 packet is composed of a stack of headers and optional dataspace.Packet format is initialized when a Simulator object is created. So, a network object can access any header in the stack of a packet it processes using corresponding offset value.

  • Packet

  • Simple Simulation Implement

  • Simple Simulation Implement

  • Simple Simulation ImplementClick on desktop icon cygwinMake sure to put the exe files under C:\cygwin\usr\localDo the following steps to execute example.

  • Simple Simulation Implement

  • Simple Simulation ImplementHowever you will fail to run the ns-simple.tcl with the displayed notice. This is because you did not open XWin yet

  • Simple Simulation ImplementOpen Xwin from C:\cygwin\usr\X11R6\bin. If everything is fine, you will then get the following figures.

  • Simple Simulation ImplementYet you may get the following warning messages:

  • Simple Simulation ImplementThat means some components missed. You can then copy these files from C:\cygwin\bin to C:\cygwin\usr\X11R6\binAfter you open X11, you may still can not run ns-simple.tcl

  • Simple Simulation ImplementThe following command can solve this issue export DISPLAY=:0.0

  • Simple Simulation Implement

  • Simple Simulation ImplementRun ns-simple.tcl

  • Simple Simulation ImplementDONE !!!

  • Simple Simulation Implement

  • Thank You.