SlideShare a Scribd company logo
1 of 26
Download to read offline
An Introduction to Network Simulator
AWK, GnuPlot
Dr. Ajit K Nayak
Dept of CSIT, ITER
S‘O’A University, BBSR
Part III
• Introducing AWK
• Introducing gnuPlot
Basics of AWK
• AWK is a scripting language suitable for text processing /
data extraction and report formatting.
• It is interpreted line by line and produces the output in a
required format.
• Input text files are considered to be a set of records
containing different fields, i.e. each line in the file is a record
(row) and each word of a line is considered as a field
(column).
• The default column separator is white space, however other
delimiters such as a comma (,), or a tab space may also be
used.
• First column of the file is accesses using $1, second column
using $2 etc.
NS-2/AN/Intro/ 3
Example-1
• Let us consider a text file (file.txt) with the following content.
Ashok 20-sep-1991 India
Marry 13-oct-1995 Italy
John 15-mar-1990 USA
Karim 25-Feb-1993 Pakistan
• Command Line Execution:
– Issue the following commands in the command prompt.
awk < file.txt ’{print $2}’
or
awk ’{print $2}’ file.txt
• It will display the second field(column) of each line available
in a text file called ’file.txt’.
NS-2/AN/Intro/ 4
General Structure of AWK
BEGIN action(s)
A set of patterns action(s) pair
END action(s)
• All actions with BEGIN pattern are executed once at
the beginning of the execution of the script.
Normally the variable initializations are made in this
section.
• The pattern-action pair between BEGIN and END
pattern are executed for each line of the input file.
• Finally actions with END pattern are executed once
at the end. END section is normally used for
printing the summarized results.
NS-2/AN/Intro/ 5
Example
• Let us consider a text file (file.txt) with the following content.
1001 Ashok 83 73 93
1002 Ram 30 43 67
1003 John 45 69 83
1004 Marry 43 35 59
1005 Samita 20 33 47
1006 Shibani 66 66 76
1007 Sourav 30 25 45
1008 Samyak 71 75 65
1009 Rudra 30 43 67
1010 Laila 85 83 87
NS-2/AN/Intro/ 6
Example-2
• Write AWK script to print All the students having first division
with their average % score of marks
#program to print student names scoring First division
BEGIN {
lines=0;
print "n Students with First Division";
print "=========================";
}
{
lines++;
avg=($3+$4+$5)/3;
if (avg >= 60) {
NS-2/AN/Intro/ 7
printf $2 "t" avg "%n";
}
}
END{
print “=====*=====";
print lines " lines scanned...";
}
Execute with: awk -f myFirstAwk.sh < file.txt
Practice Programs
• Write and execute all example programs
• Write AWK script for the followings
– To print the list of Failed students.
– To print the list of Poor students.
( avg mark < class avg)
Data format: (reg, name m1, m2, m3)
NS-2/AN/Intro/ 8
GNUPlot
• GNUPlot is a software used to plot graphs using
data or functions.
• It is a command driven and suitable for 2D as well
as 3D plots.
• To start, issue the command gnuplot in the
command line, that will a result a prompt like,
gnuplot>
• This is called the gnuplot command line. A plot now
can be created using any of the following two ways.
i) use the plot command in command line, or
ii) create a script file with extension ’<script_file>.p’ then load
the script.
NS-2/AN/Intro/ 9
Plotting
• Plot using a predefined function:
gnuplot > plot sin(x)/x
• Plot using a data file (scheduling.dat)
# Processor requirement for different algorithms
#Tasks Alg1 Alg2 Alg3
70 5 8 10
80 6 10 11
90 7 12 12
100 10 14 15
plot “scheduling.dat" using 1:2 title ’Alg1’ with lines, 
“scheduling.dat" u 1:4 t ’Alg’ w linespoints
NS-2/AN/Intro/ 10
#Task Alg1 Alg2 Alg3
110 10 16 18
120 11 19 22
130 12 25 23
140 13 30 24
150 13 34 26
Customizing plots
#Gnuplot script file: scheduling.p
set autoscale # scale axis automatically
set xtic auto # set xtics automatically
set ytic auto # set ytics automatically
set title "Processor requirement in different Algs"
set xlabel "Processors"
set ylabel "Tasks"
set key 0.01,100 #position of Legend
plot "scheduling.dat" u 1:2 t ’Alg1’ w lines , "scheduling.dat" u
1:3 t ’Alg2’ with linespoints
• To execute this script: gnuplot> load ’schedule.p’
NS-2/AN/Intro/ 11
Histograms
# File name: histo.p;
set grid;
set style data histograms;
set style histogram cluster;
set style fill pattern;
set key left;
plot ’scheduling.dat’ using 2:xtic(1) t “Alg1", 
"" u 3 t "Alg2", "" u 4 t "Alg3";
• The col1 data of the data file(scheduling.dat) is taken to be
the values in the x-axis.
• The values in col_2 - col_4 forms three bars in a cluster.
• Each row of data file is treated as one cluster and numbers of
bars in a cluster is the number of columns considered in the
plot command. NS-2/AN/Intro/ 12
Practice Programs
• Write and execute all example programs
• Consider the data file containing marks of the
students in 3 subjects and plot the following
graphs.
– Draw a line plot containing 3 lines i) regNo vs
mark1, ii) regNo vs mark2, and iii) regNo vs mark3.
– A histogram that contains regNo in x axis and 3
different marks of one student is plotted as 3
clustered bars for each students.
NS-2/AN/Intro/ 13
Output? (twoNode.tr)
+ 1 0 1 cbr 500 ------- 0 0.0 1.0 0 0
- 1 0 1 cbr 500 ------- 0 0.0 1.0 0 0
+ 1.005 0 1 cbr 500 ------- 0 0.0 1.0 1 1
- 1.005 0 1 cbr 500 ------- 0 0.0 1.0 1 1
+ 1.01 0 1 cbr 500 ------- 0 0.0 1.0 2 2
- 1.01 0 1 cbr 500 ------- 0 0.0 1.0 2 2
r 1.014 0 1 cbr 500 ------- 0 0.0 1.0 0 0
+ 1.015 0 1 cbr 500 ------- 0 0.0 1.0 3 3
- 1.015 0 1 cbr 500 ------- 0 0.0 1.0 3 3
r 1.019 0 1 cbr 500 ------- 0 0.0 1.0 1 1
+ 1.02 0 1 cbr 500 ------- 0 0.0 1.0 4 4
- 1.02 0 1 cbr 500 ------- 0 0.0 1.0 4 4
r 1.024 0 1 cbr 500 ------- 0 0.0 1.0 2 2
Explaining Output (I)
• Column 1: events
– +: enqueue
– -: dequeue
– r: receive
– d: drop
• Column 2:
– Time of event
• Column 3 & 4:
– Trace between which two nodes?
Network Performance - I
Average Delay:
• It is the average of total delay incurred due
to all packets.
– For each packet i received, find the delay as
delayi
= arrivalTimePacketi - sendingTimePacketi
– Compute Average delay for n packets as follows
avgDelay = 1..n delayi / n
NS-2/AN/Intro/ 16
Network Performance - II
Network Throughput:
• It is defined as the total number of bytes
received at the destination per sec.
– Add the bytes of all data packets received.
– Divide the total size calculated in above step by
the simulation time.
– To get the values in Mbps multiply final value with
8/1000000.
NS-2/AN/Intro/ 17
AWK Script to find Packet Statistics
#== =packetStat.awk ===
# Run with: awk -f packetStat.awk < trace.tr
BEGIN {
totPktRecvd=0
drop=0
}
{
event = $1
intDest = $4
if (event == "r" && intDest == dest) {
totPktRecvd ++
}
NS-2/AN/Intro/ 18
AWK Script contd.
if (event == "d") {
drop++
}
}
END {
printf("Total Packets Recvd = %g n",totPktRecvd)
printf("Total Packets Dropped = %g n",drop)
}
NS-2/AN/Intro/ 19
AWK Script to compute Avg Delay
#== =avgDelay.awk ===
# Run with: awk -f avgDelay.awk < trace.tr
BEGIN {
for (i in pktSent) {
pktSent[i] = 0
}
for (i in pktRecvd) {
pktRecvd[i] = 0
}
delay = avgDelay = 0
} # begin ends here
NS-2/AN/Intro/ 20
Avg Delay script contd.
{
event = $1
time = $2
intSrc=$3
intDest=$4
src=$9
dest=$10
pktSeq = $12
intSrc = (intSrc".0")
intDest = (intDest".0")
# Store packets send times
if (pktSent[pktSeq] == 0 && event == "+" && intSrc == src) {
pktSent[pktSeq] = time
} NS-2/AN/Intro/ 21
Avg Delay script contd. - I
# Store packets arrival time
if (event == "r" && intDest == dest) {
pktRecvd[pktSeq] = time
}
}
END {
# Compute average delay
for (i in pktRecvd) {
if (pktSent[i] == 0) {
printf("nError %gn",i)
}
delay += pktRecvd[i] - pktSent[i]
num ++
} NS-2/AN/Intro/ 22
Avg Delay script contd. - II
if (num != 0) {
avgDelay = delay / num
} else {
avgDelay = 0
}
printf("Avg Delay = %g msn",avgDelay*1000)
} # program ends here
NS-2/AN/Intro/ 23
Practice Programs
• Write a NS script to implement above program
and generate a trace file (trace.tr)
• Write one AWK script to find packet statistics
and average delay.
• Write one AWK script to find average network
throughput
NS-2/AN/Intro/ 24
Suggested Readings
• The GNU Awk User's Guide
–http://www.gnu.org/software/gawk/
manual/gawk.html
• Official gnuplot documentation
–http://www.gnuplot.info/documentation.html
NS-2/AN/Intro/ 25
Thank You
End of NS2

More Related Content

What's hot

射頻電子實驗手冊 - [實驗8] 低雜訊放大器模擬
射頻電子實驗手冊 - [實驗8] 低雜訊放大器模擬射頻電子實驗手冊 - [實驗8] 低雜訊放大器模擬
射頻電子實驗手冊 - [實驗8] 低雜訊放大器模擬Simen Li
 
射頻電子 - [第二章] 傳輸線理論
射頻電子 - [第二章] 傳輸線理論射頻電子 - [第二章] 傳輸線理論
射頻電子 - [第二章] 傳輸線理論Simen Li
 
dokumen.tips_ericsson-lte-throughput-troubleshooting-techniques_SUPERRRRRRR.ppt
dokumen.tips_ericsson-lte-throughput-troubleshooting-techniques_SUPERRRRRRR.pptdokumen.tips_ericsson-lte-throughput-troubleshooting-techniques_SUPERRRRRRR.ppt
dokumen.tips_ericsson-lte-throughput-troubleshooting-techniques_SUPERRRRRRR.pptLibaBali
 
Network Design on cisco packet tracer 6.0
Network Design on cisco packet tracer 6.0Network Design on cisco packet tracer 6.0
Network Design on cisco packet tracer 6.0Saurav Pandey
 
4 lte access transport network dimensioning issue 1.02
4 lte access transport network dimensioning issue 1.024 lte access transport network dimensioning issue 1.02
4 lte access transport network dimensioning issue 1.02saeed_sh65
 
RF Module Design - [Chapter 1] From Basics to RF Transceivers
RF Module Design - [Chapter 1] From Basics to RF TransceiversRF Module Design - [Chapter 1] From Basics to RF Transceivers
RF Module Design - [Chapter 1] From Basics to RF TransceiversSimen Li
 
Q & A for 3G Optimization
Q & A for 3G Optimization Q & A for 3G Optimization
Q & A for 3G Optimization l3p15
 
射頻電子實驗手冊 [實驗6] 阻抗匹配模擬
射頻電子實驗手冊 [實驗6] 阻抗匹配模擬射頻電子實驗手冊 [實驗6] 阻抗匹配模擬
射頻電子實驗手冊 [實驗6] 阻抗匹配模擬Simen Li
 
LTE Reviews - PCI Analysis
LTE Reviews - PCI AnalysisLTE Reviews - PCI Analysis
LTE Reviews - PCI Analysispaulo_campolina
 
VCO Simulation with Cadence Spectre
VCO Simulation with Cadence SpectreVCO Simulation with Cadence Spectre
VCO Simulation with Cadence SpectreHoopeer Hoopeer
 
射頻電子 - [第六章] 低雜訊放大器設計
射頻電子 - [第六章] 低雜訊放大器設計射頻電子 - [第六章] 低雜訊放大器設計
射頻電子 - [第六章] 低雜訊放大器設計Simen Li
 
Cs irat degradation due to physical channel failure
Cs irat degradation due to physical channel failureCs irat degradation due to physical channel failure
Cs irat degradation due to physical channel failurefateh-med
 
5.5 inch Amoled (1080x1920) Datasheet
5.5 inch Amoled (1080x1920) Datasheet5.5 inch Amoled (1080x1920) Datasheet
5.5 inch Amoled (1080x1920) DatasheetPanox Display
 
Pci mod3,6,30 analysis and auto optimization
Pci mod3,6,30 analysis and auto optimizationPci mod3,6,30 analysis and auto optimization
Pci mod3,6,30 analysis and auto optimizationShuangquan Lei
 
VLSI Design Final Project - 32 bit ALU
VLSI Design Final Project - 32 bit ALUVLSI Design Final Project - 32 bit ALU
VLSI Design Final Project - 32 bit ALUSachin Kumar Asokan
 
射頻電子 - [第四章] 散射參數網路
射頻電子 - [第四章] 散射參數網路射頻電子 - [第四章] 散射參數網路
射頻電子 - [第四章] 散射參數網路Simen Li
 

What's hot (20)

射頻電子實驗手冊 - [實驗8] 低雜訊放大器模擬
射頻電子實驗手冊 - [實驗8] 低雜訊放大器模擬射頻電子實驗手冊 - [實驗8] 低雜訊放大器模擬
射頻電子實驗手冊 - [實驗8] 低雜訊放大器模擬
 
射頻電子 - [第二章] 傳輸線理論
射頻電子 - [第二章] 傳輸線理論射頻電子 - [第二章] 傳輸線理論
射頻電子 - [第二章] 傳輸線理論
 
Design for Testability
Design for Testability Design for Testability
Design for Testability
 
dokumen.tips_ericsson-lte-throughput-troubleshooting-techniques_SUPERRRRRRR.ppt
dokumen.tips_ericsson-lte-throughput-troubleshooting-techniques_SUPERRRRRRR.pptdokumen.tips_ericsson-lte-throughput-troubleshooting-techniques_SUPERRRRRRR.ppt
dokumen.tips_ericsson-lte-throughput-troubleshooting-techniques_SUPERRRRRRR.ppt
 
Network Design on cisco packet tracer 6.0
Network Design on cisco packet tracer 6.0Network Design on cisco packet tracer 6.0
Network Design on cisco packet tracer 6.0
 
4 lte access transport network dimensioning issue 1.02
4 lte access transport network dimensioning issue 1.024 lte access transport network dimensioning issue 1.02
4 lte access transport network dimensioning issue 1.02
 
RF Module Design - [Chapter 1] From Basics to RF Transceivers
RF Module Design - [Chapter 1] From Basics to RF TransceiversRF Module Design - [Chapter 1] From Basics to RF Transceivers
RF Module Design - [Chapter 1] From Basics to RF Transceivers
 
Q & A for 3G Optimization
Q & A for 3G Optimization Q & A for 3G Optimization
Q & A for 3G Optimization
 
Hspice tut
Hspice tutHspice tut
Hspice tut
 
射頻電子實驗手冊 [實驗6] 阻抗匹配模擬
射頻電子實驗手冊 [實驗6] 阻抗匹配模擬射頻電子實驗手冊 [實驗6] 阻抗匹配模擬
射頻電子實驗手冊 [實驗6] 阻抗匹配模擬
 
LTE Reviews - PCI Analysis
LTE Reviews - PCI AnalysisLTE Reviews - PCI Analysis
LTE Reviews - PCI Analysis
 
VCO Simulation with Cadence Spectre
VCO Simulation with Cadence SpectreVCO Simulation with Cadence Spectre
VCO Simulation with Cadence Spectre
 
射頻電子 - [第六章] 低雜訊放大器設計
射頻電子 - [第六章] 低雜訊放大器設計射頻電子 - [第六章] 低雜訊放大器設計
射頻電子 - [第六章] 低雜訊放大器設計
 
Lec13
Lec13Lec13
Lec13
 
Cs irat degradation due to physical channel failure
Cs irat degradation due to physical channel failureCs irat degradation due to physical channel failure
Cs irat degradation due to physical channel failure
 
Sdcch drop rate
Sdcch  drop  rateSdcch  drop  rate
Sdcch drop rate
 
5.5 inch Amoled (1080x1920) Datasheet
5.5 inch Amoled (1080x1920) Datasheet5.5 inch Amoled (1080x1920) Datasheet
5.5 inch Amoled (1080x1920) Datasheet
 
Pci mod3,6,30 analysis and auto optimization
Pci mod3,6,30 analysis and auto optimizationPci mod3,6,30 analysis and auto optimization
Pci mod3,6,30 analysis and auto optimization
 
VLSI Design Final Project - 32 bit ALU
VLSI Design Final Project - 32 bit ALUVLSI Design Final Project - 32 bit ALU
VLSI Design Final Project - 32 bit ALU
 
射頻電子 - [第四章] 散射參數網路
射頻電子 - [第四章] 散射參數網路射頻電子 - [第四章] 散射參數網路
射頻電子 - [第四章] 散射參數網路
 

Viewers also liked

Introduction to database-Formal Query language and Relational calculus
Introduction to database-Formal Query language and Relational calculusIntroduction to database-Formal Query language and Relational calculus
Introduction to database-Formal Query language and Relational calculusAjit Nayak
 
Computer Fundamentals & Intro to C Programming module i
Computer Fundamentals & Intro to C Programming module iComputer Fundamentals & Intro to C Programming module i
Computer Fundamentals & Intro to C Programming module iAjit Nayak
 
Parallel programming using MPI
Parallel programming using MPIParallel programming using MPI
Parallel programming using MPIAjit Nayak
 
Software Engineering :UML class diagrams
Software Engineering :UML class diagramsSoftware Engineering :UML class diagrams
Software Engineering :UML class diagramsAjit Nayak
 
INNOVATION IS NOT AN OPTION
INNOVATION IS NOT AN OPTIONINNOVATION IS NOT AN OPTION
INNOVATION IS NOT AN OPTIONSebastien Juras
 
Database Programming using SQL
Database Programming using SQLDatabase Programming using SQL
Database Programming using SQLAjit Nayak
 
Uml Omg Fundamental Certification 1
Uml Omg Fundamental Certification 1Uml Omg Fundamental Certification 1
Uml Omg Fundamental Certification 1Ricardo Quintero
 
Things to know to improve your willpower
Things to know to improve your willpowerThings to know to improve your willpower
Things to know to improve your willpowerSebastien Juras
 
Operating Systems Part III-Memory Management
Operating Systems Part III-Memory ManagementOperating Systems Part III-Memory Management
Operating Systems Part III-Memory ManagementAjit Nayak
 
Software Engineering :Behavioral Modelling - II State diagram
Software Engineering :Behavioral Modelling - II State diagramSoftware Engineering :Behavioral Modelling - II State diagram
Software Engineering :Behavioral Modelling - II State diagramAjit Nayak
 
Uml Omg Fundamental Certification 2
Uml Omg Fundamental Certification 2Uml Omg Fundamental Certification 2
Uml Omg Fundamental Certification 2Ricardo Quintero
 
Software Engineering : OOAD using UML
Software Engineering : OOAD using UMLSoftware Engineering : OOAD using UML
Software Engineering : OOAD using UMLAjit Nayak
 
The Bad Guy in your company and how have him under control
The Bad Guy in your company and how have him under controlThe Bad Guy in your company and how have him under control
The Bad Guy in your company and how have him under controlSebastien Juras
 
03 administracion de requisitos
03 administracion de requisitos03 administracion de requisitos
03 administracion de requisitosRicardo Quintero
 
Computer Networks Module III
Computer Networks Module IIIComputer Networks Module III
Computer Networks Module IIIAjit Nayak
 
Software Engineering an Introduction
Software Engineering an IntroductionSoftware Engineering an Introduction
Software Engineering an IntroductionAjit Nayak
 
Six things to know about your brain to become an expert
Six things to know about your brain to become an expertSix things to know about your brain to become an expert
Six things to know about your brain to become an expertSebastien Juras
 
Uml Omg Fundamental Certification 5
Uml Omg Fundamental Certification 5Uml Omg Fundamental Certification 5
Uml Omg Fundamental Certification 5Ricardo Quintero
 

Viewers also liked (20)

Introduction to database-Formal Query language and Relational calculus
Introduction to database-Formal Query language and Relational calculusIntroduction to database-Formal Query language and Relational calculus
Introduction to database-Formal Query language and Relational calculus
 
Computer Fundamentals & Intro to C Programming module i
Computer Fundamentals & Intro to C Programming module iComputer Fundamentals & Intro to C Programming module i
Computer Fundamentals & Intro to C Programming module i
 
Parallel programming using MPI
Parallel programming using MPIParallel programming using MPI
Parallel programming using MPI
 
Software Engineering :UML class diagrams
Software Engineering :UML class diagramsSoftware Engineering :UML class diagrams
Software Engineering :UML class diagrams
 
INNOVATION IS NOT AN OPTION
INNOVATION IS NOT AN OPTIONINNOVATION IS NOT AN OPTION
INNOVATION IS NOT AN OPTION
 
Database Programming using SQL
Database Programming using SQLDatabase Programming using SQL
Database Programming using SQL
 
Uml Omg Fundamental Certification 1
Uml Omg Fundamental Certification 1Uml Omg Fundamental Certification 1
Uml Omg Fundamental Certification 1
 
01 conceptos de diseño
01 conceptos de diseño01 conceptos de diseño
01 conceptos de diseño
 
Things to know to improve your willpower
Things to know to improve your willpowerThings to know to improve your willpower
Things to know to improve your willpower
 
Operating Systems Part III-Memory Management
Operating Systems Part III-Memory ManagementOperating Systems Part III-Memory Management
Operating Systems Part III-Memory Management
 
Software Engineering :Behavioral Modelling - II State diagram
Software Engineering :Behavioral Modelling - II State diagramSoftware Engineering :Behavioral Modelling - II State diagram
Software Engineering :Behavioral Modelling - II State diagram
 
Uml Omg Fundamental Certification 2
Uml Omg Fundamental Certification 2Uml Omg Fundamental Certification 2
Uml Omg Fundamental Certification 2
 
Software Engineering : OOAD using UML
Software Engineering : OOAD using UMLSoftware Engineering : OOAD using UML
Software Engineering : OOAD using UML
 
The Bad Guy in your company and how have him under control
The Bad Guy in your company and how have him under controlThe Bad Guy in your company and how have him under control
The Bad Guy in your company and how have him under control
 
03 administracion de requisitos
03 administracion de requisitos03 administracion de requisitos
03 administracion de requisitos
 
The badguy summary
The badguy   summaryThe badguy   summary
The badguy summary
 
Computer Networks Module III
Computer Networks Module IIIComputer Networks Module III
Computer Networks Module III
 
Software Engineering an Introduction
Software Engineering an IntroductionSoftware Engineering an Introduction
Software Engineering an Introduction
 
Six things to know about your brain to become an expert
Six things to know about your brain to become an expertSix things to know about your brain to become an expert
Six things to know about your brain to become an expert
 
Uml Omg Fundamental Certification 5
Uml Omg Fundamental Certification 5Uml Omg Fundamental Certification 5
Uml Omg Fundamental Certification 5
 

Similar to NS2: AWK and GNUplot - PArt III

pg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLpg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLCommand Prompt., Inc
 
pg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLpg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLMark Wong
 
Ns2: OTCL - PArt II
Ns2: OTCL - PArt IINs2: OTCL - PArt II
Ns2: OTCL - PArt IIAjit Nayak
 
Your tuning arsenal: AWR, ADDM, ASH, Metrics and Advisors
Your tuning arsenal: AWR, ADDM, ASH, Metrics and AdvisorsYour tuning arsenal: AWR, ADDM, ASH, Metrics and Advisors
Your tuning arsenal: AWR, ADDM, ASH, Metrics and AdvisorsJohn Kanagaraj
 
Why you should be using structured logs
Why you should be using structured logsWhy you should be using structured logs
Why you should be using structured logsStefan Krawczyk
 
Oracle Open World Thursday 230 ashmasters
Oracle Open World Thursday 230 ashmastersOracle Open World Thursday 230 ashmasters
Oracle Open World Thursday 230 ashmastersKyle Hailey
 
Ns2: Introduction - Part I
Ns2: Introduction - Part INs2: Introduction - Part I
Ns2: Introduction - Part IAjit Nayak
 
Basic Query Tuning Primer - Pg West 2009
Basic Query Tuning Primer - Pg West 2009Basic Query Tuning Primer - Pg West 2009
Basic Query Tuning Primer - Pg West 2009mattsmiley
 
pg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLpg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLMark Wong
 
Postgres performance for humans
Postgres performance for humansPostgres performance for humans
Postgres performance for humansCraig Kerstiens
 
AWR, ADDM, ASH, Metrics and Advisors.ppt
AWR, ADDM, ASH, Metrics and Advisors.pptAWR, ADDM, ASH, Metrics and Advisors.ppt
AWR, ADDM, ASH, Metrics and Advisors.pptbugzbinny
 
pg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLpg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLCommand Prompt., Inc
 
pg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLpg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLMark Wong
 
PostgreSQL Portland Performance Practice Project - Database Test 2 Howto
PostgreSQL Portland Performance Practice Project - Database Test 2 HowtoPostgreSQL Portland Performance Practice Project - Database Test 2 Howto
PostgreSQL Portland Performance Practice Project - Database Test 2 HowtoMark Wong
 
spark stream - kafka - the right way
spark stream - kafka - the right way spark stream - kafka - the right way
spark stream - kafka - the right way Dori Waldman
 

Similar to NS2: AWK and GNUplot - PArt III (20)

Awk programming
Awk programming Awk programming
Awk programming
 
Ns network simulator
Ns network simulatorNs network simulator
Ns network simulator
 
pg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLpg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQL
 
pg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLpg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQL
 
Ns2: OTCL - PArt II
Ns2: OTCL - PArt IINs2: OTCL - PArt II
Ns2: OTCL - PArt II
 
Your tuning arsenal: AWR, ADDM, ASH, Metrics and Advisors
Your tuning arsenal: AWR, ADDM, ASH, Metrics and AdvisorsYour tuning arsenal: AWR, ADDM, ASH, Metrics and Advisors
Your tuning arsenal: AWR, ADDM, ASH, Metrics and Advisors
 
Sge
SgeSge
Sge
 
Why you should be using structured logs
Why you should be using structured logsWhy you should be using structured logs
Why you should be using structured logs
 
Oracle Open World Thursday 230 ashmasters
Oracle Open World Thursday 230 ashmastersOracle Open World Thursday 230 ashmasters
Oracle Open World Thursday 230 ashmasters
 
Ns2: Introduction - Part I
Ns2: Introduction - Part INs2: Introduction - Part I
Ns2: Introduction - Part I
 
Basic Query Tuning Primer
Basic Query Tuning PrimerBasic Query Tuning Primer
Basic Query Tuning Primer
 
Basic Query Tuning Primer - Pg West 2009
Basic Query Tuning Primer - Pg West 2009Basic Query Tuning Primer - Pg West 2009
Basic Query Tuning Primer - Pg West 2009
 
pg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLpg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQL
 
~Ns2~
~Ns2~~Ns2~
~Ns2~
 
Postgres performance for humans
Postgres performance for humansPostgres performance for humans
Postgres performance for humans
 
AWR, ADDM, ASH, Metrics and Advisors.ppt
AWR, ADDM, ASH, Metrics and Advisors.pptAWR, ADDM, ASH, Metrics and Advisors.ppt
AWR, ADDM, ASH, Metrics and Advisors.ppt
 
pg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLpg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQL
 
pg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQLpg_proctab: Accessing System Stats in PostgreSQL
pg_proctab: Accessing System Stats in PostgreSQL
 
PostgreSQL Portland Performance Practice Project - Database Test 2 Howto
PostgreSQL Portland Performance Practice Project - Database Test 2 HowtoPostgreSQL Portland Performance Practice Project - Database Test 2 Howto
PostgreSQL Portland Performance Practice Project - Database Test 2 Howto
 
spark stream - kafka - the right way
spark stream - kafka - the right way spark stream - kafka - the right way
spark stream - kafka - the right way
 

More from Ajit Nayak

Software Engineering : Software testing
Software Engineering : Software testingSoftware Engineering : Software testing
Software Engineering : Software testingAjit Nayak
 
Software Engineering :Behavioral Modelling - I Sequence diagram
Software Engineering :Behavioral Modelling - I Sequence diagram Software Engineering :Behavioral Modelling - I Sequence diagram
Software Engineering :Behavioral Modelling - I Sequence diagram Ajit Nayak
 
Software Engineering : Requirement Analysis & Specification
Software Engineering : Requirement Analysis & SpecificationSoftware Engineering : Requirement Analysis & Specification
Software Engineering : Requirement Analysis & SpecificationAjit Nayak
 
Software Engineering : Process Models
Software Engineering : Process ModelsSoftware Engineering : Process Models
Software Engineering : Process ModelsAjit Nayak
 
Socket programming using C
Socket programming using CSocket programming using C
Socket programming using CAjit Nayak
 
Object Oriented Analysis Design using UML
Object Oriented Analysis Design using UMLObject Oriented Analysis Design using UML
Object Oriented Analysis Design using UMLAjit Nayak
 
Operating Systems Part I-Basics
Operating Systems Part I-BasicsOperating Systems Part I-Basics
Operating Systems Part I-BasicsAjit Nayak
 
Operating Systems Part II-Process Scheduling, Synchronisation & Deadlock
Operating Systems Part II-Process Scheduling, Synchronisation & DeadlockOperating Systems Part II-Process Scheduling, Synchronisation & Deadlock
Operating Systems Part II-Process Scheduling, Synchronisation & DeadlockAjit Nayak
 
Introduction to database-Transaction Concurrency and Recovery
Introduction to database-Transaction Concurrency and RecoveryIntroduction to database-Transaction Concurrency and Recovery
Introduction to database-Transaction Concurrency and RecoveryAjit Nayak
 
Introduction to database-Normalisation
Introduction to database-NormalisationIntroduction to database-Normalisation
Introduction to database-NormalisationAjit Nayak
 
Introduction to database-ER Model
Introduction to database-ER ModelIntroduction to database-ER Model
Introduction to database-ER ModelAjit Nayak
 
Computer Networks Module II
Computer Networks Module IIComputer Networks Module II
Computer Networks Module IIAjit Nayak
 
Computer Networks Module I
Computer Networks Module IComputer Networks Module I
Computer Networks Module IAjit Nayak
 
Object Oriented Programming using C++ Part III
Object Oriented Programming using C++ Part IIIObject Oriented Programming using C++ Part III
Object Oriented Programming using C++ Part IIIAjit Nayak
 
Object Oriented Programming using C++ Part I
Object Oriented Programming using C++ Part IObject Oriented Programming using C++ Part I
Object Oriented Programming using C++ Part IAjit Nayak
 
Object Oriented Programming using C++ Part II
Object Oriented Programming using C++ Part IIObject Oriented Programming using C++ Part II
Object Oriented Programming using C++ Part IIAjit Nayak
 

More from Ajit Nayak (16)

Software Engineering : Software testing
Software Engineering : Software testingSoftware Engineering : Software testing
Software Engineering : Software testing
 
Software Engineering :Behavioral Modelling - I Sequence diagram
Software Engineering :Behavioral Modelling - I Sequence diagram Software Engineering :Behavioral Modelling - I Sequence diagram
Software Engineering :Behavioral Modelling - I Sequence diagram
 
Software Engineering : Requirement Analysis & Specification
Software Engineering : Requirement Analysis & SpecificationSoftware Engineering : Requirement Analysis & Specification
Software Engineering : Requirement Analysis & Specification
 
Software Engineering : Process Models
Software Engineering : Process ModelsSoftware Engineering : Process Models
Software Engineering : Process Models
 
Socket programming using C
Socket programming using CSocket programming using C
Socket programming using C
 
Object Oriented Analysis Design using UML
Object Oriented Analysis Design using UMLObject Oriented Analysis Design using UML
Object Oriented Analysis Design using UML
 
Operating Systems Part I-Basics
Operating Systems Part I-BasicsOperating Systems Part I-Basics
Operating Systems Part I-Basics
 
Operating Systems Part II-Process Scheduling, Synchronisation & Deadlock
Operating Systems Part II-Process Scheduling, Synchronisation & DeadlockOperating Systems Part II-Process Scheduling, Synchronisation & Deadlock
Operating Systems Part II-Process Scheduling, Synchronisation & Deadlock
 
Introduction to database-Transaction Concurrency and Recovery
Introduction to database-Transaction Concurrency and RecoveryIntroduction to database-Transaction Concurrency and Recovery
Introduction to database-Transaction Concurrency and Recovery
 
Introduction to database-Normalisation
Introduction to database-NormalisationIntroduction to database-Normalisation
Introduction to database-Normalisation
 
Introduction to database-ER Model
Introduction to database-ER ModelIntroduction to database-ER Model
Introduction to database-ER Model
 
Computer Networks Module II
Computer Networks Module IIComputer Networks Module II
Computer Networks Module II
 
Computer Networks Module I
Computer Networks Module IComputer Networks Module I
Computer Networks Module I
 
Object Oriented Programming using C++ Part III
Object Oriented Programming using C++ Part IIIObject Oriented Programming using C++ Part III
Object Oriented Programming using C++ Part III
 
Object Oriented Programming using C++ Part I
Object Oriented Programming using C++ Part IObject Oriented Programming using C++ Part I
Object Oriented Programming using C++ Part I
 
Object Oriented Programming using C++ Part II
Object Oriented Programming using C++ Part IIObject Oriented Programming using C++ Part II
Object Oriented Programming using C++ Part II
 

Recently uploaded

Main Memory Management in Operating System
Main Memory Management in Operating SystemMain Memory Management in Operating System
Main Memory Management in Operating SystemRashmi Bhat
 
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书rnrncn29
 
Novel 3D-Printed Soft Linear and Bending Actuators
Novel 3D-Printed Soft Linear and Bending ActuatorsNovel 3D-Printed Soft Linear and Bending Actuators
Novel 3D-Printed Soft Linear and Bending ActuatorsResearcher Researcher
 
Virtual memory management in Operating System
Virtual memory management in Operating SystemVirtual memory management in Operating System
Virtual memory management in Operating SystemRashmi Bhat
 
US Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionUS Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionMebane Rash
 
Katarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School CourseKatarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School Coursebim.edu.pl
 
70 POWER PLANT IAE V2500 technical training
70 POWER PLANT IAE V2500 technical training70 POWER PLANT IAE V2500 technical training
70 POWER PLANT IAE V2500 technical trainingGladiatorsKasper
 
A brief look at visionOS - How to develop app on Apple's Vision Pro
A brief look at visionOS - How to develop app on Apple's Vision ProA brief look at visionOS - How to develop app on Apple's Vision Pro
A brief look at visionOS - How to develop app on Apple's Vision ProRay Yuan Liu
 
Javier_Fernandez_CARS_workshop_presentation.pptx
Javier_Fernandez_CARS_workshop_presentation.pptxJavier_Fernandez_CARS_workshop_presentation.pptx
Javier_Fernandez_CARS_workshop_presentation.pptxJavier Fernández Muñoz
 
Python Programming for basic beginners.pptx
Python Programming for basic beginners.pptxPython Programming for basic beginners.pptx
Python Programming for basic beginners.pptxmohitesoham12
 
Forming section troubleshooting checklist for improving wire life (1).ppt
Forming section troubleshooting checklist for improving wire life (1).pptForming section troubleshooting checklist for improving wire life (1).ppt
Forming section troubleshooting checklist for improving wire life (1).pptNoman khan
 
Turn leadership mistakes into a better future.pptx
Turn leadership mistakes into a better future.pptxTurn leadership mistakes into a better future.pptx
Turn leadership mistakes into a better future.pptxStephen Sitton
 
Input Output Management in Operating System
Input Output Management in Operating SystemInput Output Management in Operating System
Input Output Management in Operating SystemRashmi Bhat
 
Module-1-(Building Acoustics) Noise Control (Unit-3). pdf
Module-1-(Building Acoustics) Noise Control (Unit-3). pdfModule-1-(Building Acoustics) Noise Control (Unit-3). pdf
Module-1-(Building Acoustics) Noise Control (Unit-3). pdfManish Kumar
 
SOFTWARE ESTIMATION COCOMO AND FP CALCULATION
SOFTWARE ESTIMATION COCOMO AND FP CALCULATIONSOFTWARE ESTIMATION COCOMO AND FP CALCULATION
SOFTWARE ESTIMATION COCOMO AND FP CALCULATIONSneha Padhiar
 
multiple access in wireless communication
multiple access in wireless communicationmultiple access in wireless communication
multiple access in wireless communicationpanditadesh123
 
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...Stork Webinar | APM Transformational planning, Tool Selection & Performance T...
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...Stork
 
Robotics Group 10 (Control Schemes) cse.pdf
Robotics Group 10  (Control Schemes) cse.pdfRobotics Group 10  (Control Schemes) cse.pdf
Robotics Group 10 (Control Schemes) cse.pdfsahilsajad201
 
Secure Key Crypto - Tech Paper JET Tech Labs
Secure Key Crypto - Tech Paper JET Tech LabsSecure Key Crypto - Tech Paper JET Tech Labs
Secure Key Crypto - Tech Paper JET Tech Labsamber724300
 
Cost estimation approach: FP to COCOMO scenario based question
Cost estimation approach: FP to COCOMO scenario based questionCost estimation approach: FP to COCOMO scenario based question
Cost estimation approach: FP to COCOMO scenario based questionSneha Padhiar
 

Recently uploaded (20)

Main Memory Management in Operating System
Main Memory Management in Operating SystemMain Memory Management in Operating System
Main Memory Management in Operating System
 
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
 
Novel 3D-Printed Soft Linear and Bending Actuators
Novel 3D-Printed Soft Linear and Bending ActuatorsNovel 3D-Printed Soft Linear and Bending Actuators
Novel 3D-Printed Soft Linear and Bending Actuators
 
Virtual memory management in Operating System
Virtual memory management in Operating SystemVirtual memory management in Operating System
Virtual memory management in Operating System
 
US Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionUS Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of Action
 
Katarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School CourseKatarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School Course
 
70 POWER PLANT IAE V2500 technical training
70 POWER PLANT IAE V2500 technical training70 POWER PLANT IAE V2500 technical training
70 POWER PLANT IAE V2500 technical training
 
A brief look at visionOS - How to develop app on Apple's Vision Pro
A brief look at visionOS - How to develop app on Apple's Vision ProA brief look at visionOS - How to develop app on Apple's Vision Pro
A brief look at visionOS - How to develop app on Apple's Vision Pro
 
Javier_Fernandez_CARS_workshop_presentation.pptx
Javier_Fernandez_CARS_workshop_presentation.pptxJavier_Fernandez_CARS_workshop_presentation.pptx
Javier_Fernandez_CARS_workshop_presentation.pptx
 
Python Programming for basic beginners.pptx
Python Programming for basic beginners.pptxPython Programming for basic beginners.pptx
Python Programming for basic beginners.pptx
 
Forming section troubleshooting checklist for improving wire life (1).ppt
Forming section troubleshooting checklist for improving wire life (1).pptForming section troubleshooting checklist for improving wire life (1).ppt
Forming section troubleshooting checklist for improving wire life (1).ppt
 
Turn leadership mistakes into a better future.pptx
Turn leadership mistakes into a better future.pptxTurn leadership mistakes into a better future.pptx
Turn leadership mistakes into a better future.pptx
 
Input Output Management in Operating System
Input Output Management in Operating SystemInput Output Management in Operating System
Input Output Management in Operating System
 
Module-1-(Building Acoustics) Noise Control (Unit-3). pdf
Module-1-(Building Acoustics) Noise Control (Unit-3). pdfModule-1-(Building Acoustics) Noise Control (Unit-3). pdf
Module-1-(Building Acoustics) Noise Control (Unit-3). pdf
 
SOFTWARE ESTIMATION COCOMO AND FP CALCULATION
SOFTWARE ESTIMATION COCOMO AND FP CALCULATIONSOFTWARE ESTIMATION COCOMO AND FP CALCULATION
SOFTWARE ESTIMATION COCOMO AND FP CALCULATION
 
multiple access in wireless communication
multiple access in wireless communicationmultiple access in wireless communication
multiple access in wireless communication
 
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...Stork Webinar | APM Transformational planning, Tool Selection & Performance T...
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...
 
Robotics Group 10 (Control Schemes) cse.pdf
Robotics Group 10  (Control Schemes) cse.pdfRobotics Group 10  (Control Schemes) cse.pdf
Robotics Group 10 (Control Schemes) cse.pdf
 
Secure Key Crypto - Tech Paper JET Tech Labs
Secure Key Crypto - Tech Paper JET Tech LabsSecure Key Crypto - Tech Paper JET Tech Labs
Secure Key Crypto - Tech Paper JET Tech Labs
 
Cost estimation approach: FP to COCOMO scenario based question
Cost estimation approach: FP to COCOMO scenario based questionCost estimation approach: FP to COCOMO scenario based question
Cost estimation approach: FP to COCOMO scenario based question
 

NS2: AWK and GNUplot - PArt III

  • 1. An Introduction to Network Simulator AWK, GnuPlot Dr. Ajit K Nayak Dept of CSIT, ITER S‘O’A University, BBSR
  • 2. Part III • Introducing AWK • Introducing gnuPlot
  • 3. Basics of AWK • AWK is a scripting language suitable for text processing / data extraction and report formatting. • It is interpreted line by line and produces the output in a required format. • Input text files are considered to be a set of records containing different fields, i.e. each line in the file is a record (row) and each word of a line is considered as a field (column). • The default column separator is white space, however other delimiters such as a comma (,), or a tab space may also be used. • First column of the file is accesses using $1, second column using $2 etc. NS-2/AN/Intro/ 3
  • 4. Example-1 • Let us consider a text file (file.txt) with the following content. Ashok 20-sep-1991 India Marry 13-oct-1995 Italy John 15-mar-1990 USA Karim 25-Feb-1993 Pakistan • Command Line Execution: – Issue the following commands in the command prompt. awk < file.txt ’{print $2}’ or awk ’{print $2}’ file.txt • It will display the second field(column) of each line available in a text file called ’file.txt’. NS-2/AN/Intro/ 4
  • 5. General Structure of AWK BEGIN action(s) A set of patterns action(s) pair END action(s) • All actions with BEGIN pattern are executed once at the beginning of the execution of the script. Normally the variable initializations are made in this section. • The pattern-action pair between BEGIN and END pattern are executed for each line of the input file. • Finally actions with END pattern are executed once at the end. END section is normally used for printing the summarized results. NS-2/AN/Intro/ 5
  • 6. Example • Let us consider a text file (file.txt) with the following content. 1001 Ashok 83 73 93 1002 Ram 30 43 67 1003 John 45 69 83 1004 Marry 43 35 59 1005 Samita 20 33 47 1006 Shibani 66 66 76 1007 Sourav 30 25 45 1008 Samyak 71 75 65 1009 Rudra 30 43 67 1010 Laila 85 83 87 NS-2/AN/Intro/ 6
  • 7. Example-2 • Write AWK script to print All the students having first division with their average % score of marks #program to print student names scoring First division BEGIN { lines=0; print "n Students with First Division"; print "========================="; } { lines++; avg=($3+$4+$5)/3; if (avg >= 60) { NS-2/AN/Intro/ 7 printf $2 "t" avg "%n"; } } END{ print “=====*====="; print lines " lines scanned..."; } Execute with: awk -f myFirstAwk.sh < file.txt
  • 8. Practice Programs • Write and execute all example programs • Write AWK script for the followings – To print the list of Failed students. – To print the list of Poor students. ( avg mark < class avg) Data format: (reg, name m1, m2, m3) NS-2/AN/Intro/ 8
  • 9. GNUPlot • GNUPlot is a software used to plot graphs using data or functions. • It is a command driven and suitable for 2D as well as 3D plots. • To start, issue the command gnuplot in the command line, that will a result a prompt like, gnuplot> • This is called the gnuplot command line. A plot now can be created using any of the following two ways. i) use the plot command in command line, or ii) create a script file with extension ’<script_file>.p’ then load the script. NS-2/AN/Intro/ 9
  • 10. Plotting • Plot using a predefined function: gnuplot > plot sin(x)/x • Plot using a data file (scheduling.dat) # Processor requirement for different algorithms #Tasks Alg1 Alg2 Alg3 70 5 8 10 80 6 10 11 90 7 12 12 100 10 14 15 plot “scheduling.dat" using 1:2 title ’Alg1’ with lines, “scheduling.dat" u 1:4 t ’Alg’ w linespoints NS-2/AN/Intro/ 10 #Task Alg1 Alg2 Alg3 110 10 16 18 120 11 19 22 130 12 25 23 140 13 30 24 150 13 34 26
  • 11. Customizing plots #Gnuplot script file: scheduling.p set autoscale # scale axis automatically set xtic auto # set xtics automatically set ytic auto # set ytics automatically set title "Processor requirement in different Algs" set xlabel "Processors" set ylabel "Tasks" set key 0.01,100 #position of Legend plot "scheduling.dat" u 1:2 t ’Alg1’ w lines , "scheduling.dat" u 1:3 t ’Alg2’ with linespoints • To execute this script: gnuplot> load ’schedule.p’ NS-2/AN/Intro/ 11
  • 12. Histograms # File name: histo.p; set grid; set style data histograms; set style histogram cluster; set style fill pattern; set key left; plot ’scheduling.dat’ using 2:xtic(1) t “Alg1", "" u 3 t "Alg2", "" u 4 t "Alg3"; • The col1 data of the data file(scheduling.dat) is taken to be the values in the x-axis. • The values in col_2 - col_4 forms three bars in a cluster. • Each row of data file is treated as one cluster and numbers of bars in a cluster is the number of columns considered in the plot command. NS-2/AN/Intro/ 12
  • 13. Practice Programs • Write and execute all example programs • Consider the data file containing marks of the students in 3 subjects and plot the following graphs. – Draw a line plot containing 3 lines i) regNo vs mark1, ii) regNo vs mark2, and iii) regNo vs mark3. – A histogram that contains regNo in x axis and 3 different marks of one student is plotted as 3 clustered bars for each students. NS-2/AN/Intro/ 13
  • 14. Output? (twoNode.tr) + 1 0 1 cbr 500 ------- 0 0.0 1.0 0 0 - 1 0 1 cbr 500 ------- 0 0.0 1.0 0 0 + 1.005 0 1 cbr 500 ------- 0 0.0 1.0 1 1 - 1.005 0 1 cbr 500 ------- 0 0.0 1.0 1 1 + 1.01 0 1 cbr 500 ------- 0 0.0 1.0 2 2 - 1.01 0 1 cbr 500 ------- 0 0.0 1.0 2 2 r 1.014 0 1 cbr 500 ------- 0 0.0 1.0 0 0 + 1.015 0 1 cbr 500 ------- 0 0.0 1.0 3 3 - 1.015 0 1 cbr 500 ------- 0 0.0 1.0 3 3 r 1.019 0 1 cbr 500 ------- 0 0.0 1.0 1 1 + 1.02 0 1 cbr 500 ------- 0 0.0 1.0 4 4 - 1.02 0 1 cbr 500 ------- 0 0.0 1.0 4 4 r 1.024 0 1 cbr 500 ------- 0 0.0 1.0 2 2
  • 15. Explaining Output (I) • Column 1: events – +: enqueue – -: dequeue – r: receive – d: drop • Column 2: – Time of event • Column 3 & 4: – Trace between which two nodes?
  • 16. Network Performance - I Average Delay: • It is the average of total delay incurred due to all packets. – For each packet i received, find the delay as delayi = arrivalTimePacketi - sendingTimePacketi – Compute Average delay for n packets as follows avgDelay = 1..n delayi / n NS-2/AN/Intro/ 16
  • 17. Network Performance - II Network Throughput: • It is defined as the total number of bytes received at the destination per sec. – Add the bytes of all data packets received. – Divide the total size calculated in above step by the simulation time. – To get the values in Mbps multiply final value with 8/1000000. NS-2/AN/Intro/ 17
  • 18. AWK Script to find Packet Statistics #== =packetStat.awk === # Run with: awk -f packetStat.awk < trace.tr BEGIN { totPktRecvd=0 drop=0 } { event = $1 intDest = $4 if (event == "r" && intDest == dest) { totPktRecvd ++ } NS-2/AN/Intro/ 18
  • 19. AWK Script contd. if (event == "d") { drop++ } } END { printf("Total Packets Recvd = %g n",totPktRecvd) printf("Total Packets Dropped = %g n",drop) } NS-2/AN/Intro/ 19
  • 20. AWK Script to compute Avg Delay #== =avgDelay.awk === # Run with: awk -f avgDelay.awk < trace.tr BEGIN { for (i in pktSent) { pktSent[i] = 0 } for (i in pktRecvd) { pktRecvd[i] = 0 } delay = avgDelay = 0 } # begin ends here NS-2/AN/Intro/ 20
  • 21. Avg Delay script contd. { event = $1 time = $2 intSrc=$3 intDest=$4 src=$9 dest=$10 pktSeq = $12 intSrc = (intSrc".0") intDest = (intDest".0") # Store packets send times if (pktSent[pktSeq] == 0 && event == "+" && intSrc == src) { pktSent[pktSeq] = time } NS-2/AN/Intro/ 21
  • 22. Avg Delay script contd. - I # Store packets arrival time if (event == "r" && intDest == dest) { pktRecvd[pktSeq] = time } } END { # Compute average delay for (i in pktRecvd) { if (pktSent[i] == 0) { printf("nError %gn",i) } delay += pktRecvd[i] - pktSent[i] num ++ } NS-2/AN/Intro/ 22
  • 23. Avg Delay script contd. - II if (num != 0) { avgDelay = delay / num } else { avgDelay = 0 } printf("Avg Delay = %g msn",avgDelay*1000) } # program ends here NS-2/AN/Intro/ 23
  • 24. Practice Programs • Write a NS script to implement above program and generate a trace file (trace.tr) • Write one AWK script to find packet statistics and average delay. • Write one AWK script to find average network throughput NS-2/AN/Intro/ 24
  • 25. Suggested Readings • The GNU Awk User's Guide –http://www.gnu.org/software/gawk/ manual/gawk.html • Official gnuplot documentation –http://www.gnuplot.info/documentation.html NS-2/AN/Intro/ 25