This document discusses the NS-2 network simulator. It provides background on NS-2, describing how it was developed beginning in 1989 and is now developed collaboratively. It also summarizes the key components of NS-2, including that it uses Tcl and C++, with Tcl used for scripts and C++ used for the backend logic. Finally, it provides a brief example of creating a simple network topology using NS-2.
Download as PPTX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
47 views
Computer Networks Project Based Lab
This document discusses the NS-2 network simulator. It provides background on NS-2, describing how it was developed beginning in 1989 and is now developed collaboratively. It also summarizes the key components of NS-2, including that it uses Tcl and C++, with Tcl used for scripts and C++ used for the backend logic. Finally, it provides a brief example of creating a simple network topology using NS-2.
BACKGROUND TO NS2 NS began development in 1989 as a variant of REAL network simulator. By 1995, ns had gained support from DARPA, the VINT project at LBL, Xerox PARC, UCB and USC/ISI. Ns is now developed in collaboration between number of different researchers and institution, including SAMAN (supported by DARPA), CONSER (through the NSF), and ICIR (former ACIRI). Long-running contributions have also come from Sun Microsystems and the UCB Daedelus and Carnegie Mellon Monarch projects, cited by the ns homepage for wireless code additions. Ns is based on two languages, an object oriented simulator written in C++ and an Otcl interpreter, used to execute users command scripts. Ns has a rich library network and protocol objects. There are two class hierarchies: the compiled c++ hierarchy and the interpreted Otcl one, with one to one correspondence between them. ns (from network simulator) is a name for series of discrete event network simulators, specifically ns- 1, ns-2 and ns-3. All of them are discrete-event network simulator, primarily used in research and teaching. ns-3 is free software, publicly available under the GNU GPLv2 license for research, development, and use.
The goal of the ns-3 project is to create an open simulation environment for networking research that will be preferred inside the research community. It should be aligned with the simulation needs of modern networking research. It should encourage community contribution, peer review, and validation of the software. Since the process of creation of a network simulator that contains a sufficient number of high-quality validated, tested and actively maintained models requires a lot of work, ns-3 project spreads this workload over a large community of users and developers.
Ns-2 contains the following components: Tcl: Creating Layouts. C++: for back end logic NAM (Network Animator): to see results or simulation environment. Otcl: Network Protocols design TclCL: linking C++ and Tcl code. X- graph: For analysis (optional).
NS2 ARCHITECHTURE
As shown in the simplified users view of figure below. NS is an Object-oriented Tcl (OTCl) script interpreter that has a simulation event scheduler and network component object libraries and network set-up (plumbing) module libraries.
What Languages are used with NS-2? Split -Language programming is used. Scripting Language(Tcl Tool Command Language and pronounced tickle) System Programming Language (C/C++) Ns is a Tcl interpreter to run Tcl Scripts. By using C++ / OTcl, the network simulator is completely object oriented.
NS2 INSTALLATION DESCRIPTION 2.35 Here we are going to describe how a ns2 can be installed in an ubuntu environment. In order to do that these are the requirements:- i)Hardware requirements:- A system with dual core processor 1.9ghz, minimum 512 Mb of ram, 20 gb of Hard disk space
*Internet should be connected ii)Software requirements:- Pre installed ubuntu version 12.04 Lts(later), Ns-allinone- 2.35 software INSTALLATION PROCEDURE Step 1: - For ns2 installation we need to install four packages they are
1)sudo apt-get install build-essential next we want to enter a password of the ubuntu after entering the password the process of installing the package completed 2) sudo apt-get install libx11-dev by entering this we can install second package 3)sudo apt-get install libxt-dev by this we can complete the installation of third package 4)sudo apt-get install lidxum-dev by this fourth package is completed Step 2: -
i) Extract the ns-allinone-2.35 and keep it on desktop ii) Next open terminal and type the following command iii) cd Desktop/ns-allinone-2.35 and press enter iv) now type ./install v) The installation process starts and continuous for a while and then continue the the procedure vi) By typing cd nam-1.15 and press enter-This command is used for the installation of the essential software packages for the animation display vii) Now type sudo make install viii) After completing this type cd - ix) Now type xgraph-12.2 -This command is for the sake of graphical display x) And enter sudo make install xi) after that if the software is successfully installed xii) Now we have to enter the command ns if percentage (%) symbol is appeared is installation is completed.
NAM (NETWORK ANIMATOR)
NAM provides a visual interpretation of the network topology created. The application was developed as part of the VINT project. Its features are as follows. Fig displays the NAM application and its components.
Provides a visual interpretation of the network created Can be executed directly from a Tcl script Controls include play, stop ff ,rw, pause, a display speed controller and a packet monitor facility. Presents information such as throughput, number packets on each link. Provides a drag and drop interface for creating topologies. NAM is a Tcl/TK based animation tool for viewing network simulation traces and real world packet trace data. The design theory behind nam was to create an animator that is able to read large animation data sets and be extensible enough so that it could be used indifferent network visualization situations. Under this constraint nam was designed to read simple animation event commands from a large trace file. In order to handle large animation data sets a minimum amount of information is kept in memory. . Event commands are kept in the file and reread from the file whenever necessary. The first step to use nam is to produce the trace file. The trace file contains topology information, e.g.nodes. Links, as well as packet traces. Usually, the trace file is generated by ns. During an ns simulation, user can produce topology configurations, layout information, and packet traces using tracing events in ns. CREATING A SIMPLE TOPOLOGY Source code: set ns [new Simulator]
$ns color 0 blue $ns color 1 red $ns color 2 white
set n0 [$ns node] set n1 [$ns node] set n2 [$ns node] set n3 [$ns node]
set f [open out.tr w] $ns trace-all $f set nf [open out.nam w] $ns namtrace-all $nf