54
Introduction to NS2 -Network Simulator-

Introduction to NS2 - Cont

Embed Size (px)

Citation preview

Page 1: Introduction to NS2 - Cont

Introduction to NS2-Network Simulator-

Page 2: Introduction to NS2 - Cont

Contents

OverviewHow to InstallOTCL – The User LanguageEvent SchedulerPacketSimulation Example

Page 3: Introduction to NS2 - Cont

Overview

What is NS2?

- Event driven network simulator

- Developed at UC Berkely

- Implements network protocols 1) TCP, UDP

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

Page 4: Introduction to NS2 - Cont

Overview

Background 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.

Page 5: Introduction to NS2 - Cont

Overview

Ns2 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.

Page 6: Introduction to NS2 - Cont

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_Cygwin

Read “Requirements and Installation Tips” Carefully.

Download cygwin.exe from http://www.cygwin.com/

Click the “cygwin.exe”

Page 7: Introduction to NS2 - Cont

How to Install

Cygwin Installation

Page 8: Introduction to NS2 - Cont

How to Install

Page 9: Introduction to NS2 - Cont

How to Install

Select browse for “cygwin” file( I selected as “default”)

Page 10: Introduction to NS2 - Cont

How to Install

Local package directory (I recommend c:\cygwin).

Page 11: Introduction to NS2 - Cont

How to Install

Select 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.

Page 12: Introduction to NS2 - Cont

How to Install

Select download site

Page 13: Introduction to NS2 - Cont

How to Install

Installing

Page 14: Introduction to NS2 - Cont

How to Install

Finishing Installing

Page 15: Introduction to NS2 - Cont

How to Install

NS2 InstallationDownload ns-allinone-2.29.2.tar.gz from

Website and Save it to the c:/cygwin /usr/local

Unpack it: tar xvfz ns-allinone-2.29.2.tar.gz

Click on desktop icon “cygwin”

Page 16: Introduction to NS2 - Cont

How to Install

Page 17: Introduction to NS2 - Cont

How to Install

Type “cd ..” to go to the upper folder(“cd” must be low case. And there is one space between “d” and “.”)

Type “cd ..” again.

Page 18: Introduction to NS2 - Cont

How to Install

“cd usr”, go to folder “usr” “cd local”, go to folder “local”

Page 19: Introduction to NS2 - Cont

How to Install

Find “install.exe”

Page 20: Introduction to NS2 - Cont

How to Install

Start to run the installation “./install”

Page 21: Introduction to NS2 - Cont

How to Install

Installing

Page 22: Introduction to NS2 - Cont

How to Install

Installing

Page 23: Introduction to NS2 - Cont

How to Install

Configure system variables and library paths After finishing installing, following window appears

Page 24: Introduction to NS2 - Cont

How to Install

Configure system variables Go to “My computer” and click “view system information”

Page 25: Introduction to NS2 - Cont

How to Install

Go to “advanced” Tab and Click “Environmental variables”

Page 26: Introduction to NS2 - Cont

How to Install

Page 27: Introduction to NS2 - Cont

How to Install

Highlight “path” which is “system variable” box and press the “Edit” button.

Page 28: Introduction to NS2 - Cont

How to Install

Page 29: Introduction to NS2 - Cont

How to Install

Add 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

Page 30: Introduction to NS2 - Cont

How to Install

Go to cygwin and type the following content

Export LD_LIBRARY_PATH=/usr/local/ns-allinone-2.29/otcl-1.11

Export LD_LIBRARY_PATH=/usr/local/ns-allinone-2.29/lib

Export TCL_LIBRARY_PATH=/usr/local/ns-allinone-2.29/tcl8.4.11/library

Page 31: Introduction to NS2 - Cont

How to Install

Page 32: Introduction to NS2 - Cont

OTcl – The User Language

NS2 is basically an OTcl interpreter with network simulation object libraries

Very 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

Page 33: Introduction to NS2 - Cont

OTcl – The User Language

Example

Page 34: Introduction to NS2 - Cont

OTcl – The User Language

Proc: 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

Page 35: Introduction to NS2 - Cont

OTcl – The User Language

Page 36: Introduction to NS2 - Cont

Event Scheduler

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

Page 37: Introduction to NS2 - Cont

Event Scheduler

Two 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

Page 38: Introduction to NS2 - Cont

Event Scheduler

Example . . .

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 {} {. . .}

Page 39: Introduction to NS2 - Cont

Packet

NS2 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.

Page 40: Introduction to NS2 - Cont

Packet

Page 41: Introduction to NS2 - Cont

Simple Simulation Implement

Page 42: Introduction to NS2 - Cont

Simple Simulation Implement

Page 43: Introduction to NS2 - Cont

Simple Simulation Implement

Click on desktop icon “cygwin”Make sure to put the exe files under

C:\cygwin\usr\localDo the following steps to execute

example.

Page 44: Introduction to NS2 - Cont

Simple Simulation Implement

Page 45: Introduction to NS2 - Cont

Simple Simulation Implement

However you will fail to run the “ns-simple.tcl” with the displayed notice. This is because you did not open “XWin” yet

Page 46: Introduction to NS2 - Cont

Simple Simulation Implement

Open “Xwin” from “C:\cygwin\usr\X11R6\bin”. If everything is fine, you will then get the following figures.

Page 47: Introduction to NS2 - Cont

Simple Simulation Implement

Yet you may get the following warning messages:

Page 48: Introduction to NS2 - Cont

Simple Simulation Implement

That means some components missed. You can then copy these files from “C:\cygwin\bin” to “C:\cygwin\usr\X11R6\bin”

After you open X11, you may still can not run “ns-simple.tcl”

Page 49: Introduction to NS2 - Cont

Simple Simulation Implement

The following command can solve this issue

export DISPLAY=:0.0

Page 50: Introduction to NS2 - Cont

Simple Simulation Implement

Page 51: Introduction to NS2 - Cont

Simple Simulation Implement

Run “ns-simple.tcl”

Page 52: Introduction to NS2 - Cont

Simple Simulation Implement

DONE !!!

Page 53: Introduction to NS2 - Cont

Simple Simulation Implement

Page 54: Introduction to NS2 - Cont

Thank You….