0% found this document useful (0 votes)
27 views5 pages

WCN LAB NS-2 Procedure

Uploaded by

Abdul Khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views5 pages

WCN LAB NS-2 Procedure

Uploaded by

Abdul Khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

©Developed by Ayaskanta Mishra

Assistant Professor (II)


Faculty In
In-charge
charge Wireless Communication & Networking Lab

PROCEDURE FOR NS
NS-2
2 EXPERIMENTS (EXP.1 & 2)
Procedure:

STEP 1. Open >Terminal

STEP 2. Terminal

Page 1 of 5
©Developed by Ayaskanta Mishra
Assistant Professor (II)
Faculty In
In-charge
charge Wireless Communication & Networking Lab

• Home Directory: (path: /home/wcn)


• NOTE: Working folder is always home directory i.e /home/wcn ( default directory in
Ubuntu)
• All our ns2 code ie. .tcl files must be created in /home/wcn
• 3 types of Files are used in NS2
• .tcl – script file NS2 code ( which has to be writen in gedit)
• .nam – Network Animator File ( Which has be seen in nam)
• .tr– trace file ( which has to be seen in tracegraph202)

in Terminal (type and execute following):


Write the .tcl script using gedit:
(Take example from n3.pdf and ns_by_example.pdfto to write your ns code based on
the problem defination given in Experiment 1 and 2)

SYNTAX: $ gedit <filename.tcl><ENTER>


e.g: $ gedit expt1.tcl <ENTER>
(Write your code in gedit after writing <SAVE><CLOSE>gedit window)

Compile NS code (.tcl) file:

SYNTAX: $ ns <filename.tcl><ENTER>
e.g: $ ns expt1.tcl <ENTER>

The above procedure will create two output files


1. expt1.nam – Network Animator File
2. expt1.tr – Trace file

Execute NAM (e.g expt1.nam):

SYNTAX: $ nam <filename.nam><ENTER>


e.g. $ nam expt1.nam <ENTER>
NOTE: <ENTER>means press enter key

• The Animation can be controlled by PLAY, STOP, FORWARD, BACKBUTTONS


BACK
• Speed can be controlled using the STEP- slider

Page 2 of 5
©Developed by Ayaskanta Mishra
Assistant Professor (II)
Faculty In
In-charge
charge Wireless Communication & Networking Lab

Execute trace-file
file (.tr) software required: tracegraph202:
In Terminal execute following:

STEP-1:
1: Go to tracegraph202 directory by change directory command (cd)

SYNTAX:
cd / <ENTER>
cd home/wcn/tracegraph202/bin/glnx86 <ENTER>

STEP-2:
2: export library PATH

SYNTAX: (write below in one single linewithout any ENTER)


export
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/wcn/tracegraph202/bin/glnx8
6/

STEP-3: 3: Execute tracegraph ( it will open tracegraph202 window)


SYNTAX:
./trgraph

Steps to open and view your trace


trace-file
file after tracegraph 2.02 Window is open(.tr):
• In Trace graph 2.02 Window Naviagte to File >Open a trace file
• Choose a file to open >Selection
• SYNTAX: /home/wcn/<tracefile_name.tr><OPEN>
e.g. Selection/home/wcn/expt1.tr
/home/wcn/expt1.tr <OPEN>
• After the trace-file
file opens go to Current >“Select the node where you want to see
parameters like throughput”
• Go to Graph-Window
Window and plot 2D and 3D plots as required ( plot 2D plots first
then execute 3D plot at last)
NOTE: once you plot a 3D plot you have to close trgraph2.02 and restart the ./trgraph
from terminal window.

Page 3 of 5
©Developed by Ayaskanta Mishra
Assistant Professor (II)
Faculty In
In-charge
charge Wireless Communication & Networking Lab

Experiment-3
Simulation and invertigation of impact of Contention Window size on the
performance of IEEE 802.11 MAC Protocol(NS
Protocol(NS-2)
2)
Procedure:
STEP-1:Put thecwsim.tclscript
script in /home/wcnfolder
STEP-2: Open >Terminal
STEP-3: 3: After opening Terminal Execute following in Terminal Window
$ cd / <ENTER>
$ cd home/wcn
$ gedit cwsim.tcl
STEP-4: In geditwindow thecwsim.tcl
cwsim.tcl code will open
Go to line number 112 and 113 change the Contention Window Size (CW)
2,7,15,31,63,127 for populating the table given in manual.
$val(mac) set CWMin_ 2
$val(mac) set CWMax_ 2
6 set of experiment has to be perform to populate the table.
Each time you change the CW_Min and CW_Max value once you have to run the
script in terminal as follws:

STEP-5: Open >Terminal


$ ns cwsim.tcl -rlen
rlen 3 ( 3 x 3 = 9 nodes)
Number of Packet Sent:
$ grep AGT cwsim.tr | grep ^s | grep cbr | wc -l
Number of Packet Received:
$ grep AGT cwsim.tr | grep ^r| grep cbr | wc -l
Packet Delivery Ratio (PDR)
= Number of Packet Received / Number of Packet Sent

Go to STEP-44 and change the value CW_Min and CW_Max 7 then 15 then 31 so on upto
127. For each change in script, you have to excute the cwsim.
cwsim.tcl
tcl in terminal as given in
STEP-5.

Repeatative execution of STEP


STEP-4 and STEP-55 will give to data to populate the table given
in manual.
CW (3 x 3 =9 nodes) (4 x 4 = 16 nodes) (5 x 5 = 25 nodes)
Size
Packet Packet PDR Packet Packet PDR Packet Packet PDR
Sent (S) Received =R/S Sent (S) Received =R/S Sent (S) Received =R/S
(R) (R) (R)
2
7
15
31
63
127

Page 4 of 5
©Developed by Ayaskanta Mishra
Assistant Professor (II)
Faculty In
In-charge
charge Wireless Communication & Networking Lab

Throughput Calculation:

Throughput (bits/ sec.) = 512 x 8 x Number of Packet Received (R)


Simulation Time ( 25 Sec.)

Comparation
omparation PDR for 3 x 3 ; 4 x 4 ;5 x 5 node matrix and finding the optimum
Contention Window Size (CW) by plotting graph using xx-graph

Create 3 files 3x3, 4x4, 5x5using


using gedit and store the value of calculated PDR vs. CW_Size
like below:

In terminal:
STEP-1: $ gedit 3x3 <ENTER>
In gedit write following in two columns as shown below and save and close.
Example:
2 0.00134
7 0.03415
15 0.07889
31 0.04515
63 0.03678
127 0.01234

STEP-2: Repeat STEP-11 to create above mentioned 3 files with the


thePDRin
in above table.

STEP-3: After creating all 3 files 3x3, 4x4 and 5x5 PDR vs.CW files plot the x-graph
x by
follwing command in terminal window:

$ xgraph 3x3 4x4 5x5 <ENTER>

Save the graph and comment upon the optimum Contention Winow Size.

Page 5 of 5

You might also like