SlideShare a Scribd company logo
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 (20)

WIRELESS TRANSMISSION
WIRELESS TRANSMISSIONWIRELESS TRANSMISSION
WIRELESS TRANSMISSION
junnubabu
 
Leaky Bucket & Tocken Bucket - Traffic shaping
Leaky Bucket & Tocken Bucket - Traffic shapingLeaky Bucket & Tocken Bucket - Traffic shaping
Leaky Bucket & Tocken Bucket - Traffic shaping
Vimal Dewangan
 
Csma protocols
Csma protocolsCsma protocols
Csma protocols
Manal Shah
 
Daa notes 1
Daa notes 1Daa notes 1
Daa notes 1
smruti sarangi
 
Data link control
Data link controlData link control
Data link control
Iffat Anjum
 
Bus Based Multiprocessors v2
Bus Based Multiprocessors v2Bus Based Multiprocessors v2
Bus Based Multiprocessors v2
Mustafa Yumurtacı
 
Interrupt in real time system
Interrupt in real time system Interrupt in real time system
Interrupt in real time system
ali jawad
 
Branch prediction
Branch predictionBranch prediction
Branch prediction
Aneesh Raveendran
 
evolution of mobile networks generations 1G, 2G, 3G, 4G, 5G.pdf
evolution of mobile networks generations 1G, 2G, 3G, 4G, 5G.pdfevolution of mobile networks generations 1G, 2G, 3G, 4G, 5G.pdf
evolution of mobile networks generations 1G, 2G, 3G, 4G, 5G.pdf
AGMPlanning
 
Daa
DaaDaa
Daa
Dhananjay Singh
 
Unit vi (2)
Unit vi (2)Unit vi (2)
Unit vi (2)
Siva Nageswararao
 
Packet sniffers
Packet sniffers Packet sniffers
Packet sniffers
Ravi Teja Reddy
 
Mac protocols
Mac protocolsMac protocols
Mac protocols
juno susi
 
IT8602 Mobile Communication - Unit I Introduction
IT8602 Mobile Communication - Unit I IntroductionIT8602 Mobile Communication - Unit I Introduction
IT8602 Mobile Communication - Unit I Introduction
pkaviya
 
Unit 3 Network Layer PPT
Unit 3 Network Layer PPTUnit 3 Network Layer PPT
Unit 3 Network Layer PPT
KalpanaC14
 
Contention based MAC protocols
Contention based  MAC protocolsContention based  MAC protocols
Contention based MAC protocols
Darwin Nesakumar
 
Flow Control
Flow ControlFlow Control
Flow Control
selvakumar_b1985
 
Networks classification
Networks classificationNetworks classification
Networks classification
Mukesh Chinta
 
Introduction to Garbage Collection
Introduction to Garbage CollectionIntroduction to Garbage Collection
Introduction to Garbage Collection
Artur Mkrtchyan
 
Getweeklyhoursbyuser
GetweeklyhoursbyuserGetweeklyhoursbyuser
Getweeklyhoursbyuser
hasheemm
 
WIRELESS TRANSMISSION
WIRELESS TRANSMISSIONWIRELESS TRANSMISSION
WIRELESS TRANSMISSION
junnubabu
 
Leaky Bucket & Tocken Bucket - Traffic shaping
Leaky Bucket & Tocken Bucket - Traffic shapingLeaky Bucket & Tocken Bucket - Traffic shaping
Leaky Bucket & Tocken Bucket - Traffic shaping
Vimal Dewangan
 
Csma protocols
Csma protocolsCsma protocols
Csma protocols
Manal Shah
 
Data link control
Data link controlData link control
Data link control
Iffat Anjum
 
Interrupt in real time system
Interrupt in real time system Interrupt in real time system
Interrupt in real time system
ali jawad
 
evolution of mobile networks generations 1G, 2G, 3G, 4G, 5G.pdf
evolution of mobile networks generations 1G, 2G, 3G, 4G, 5G.pdfevolution of mobile networks generations 1G, 2G, 3G, 4G, 5G.pdf
evolution of mobile networks generations 1G, 2G, 3G, 4G, 5G.pdf
AGMPlanning
 
Mac protocols
Mac protocolsMac protocols
Mac protocols
juno susi
 
IT8602 Mobile Communication - Unit I Introduction
IT8602 Mobile Communication - Unit I IntroductionIT8602 Mobile Communication - Unit I Introduction
IT8602 Mobile Communication - Unit I Introduction
pkaviya
 
Unit 3 Network Layer PPT
Unit 3 Network Layer PPTUnit 3 Network Layer PPT
Unit 3 Network Layer PPT
KalpanaC14
 
Contention based MAC protocols
Contention based  MAC protocolsContention based  MAC protocols
Contention based MAC protocols
Darwin Nesakumar
 
Networks classification
Networks classificationNetworks classification
Networks classification
Mukesh Chinta
 
Introduction to Garbage Collection
Introduction to Garbage CollectionIntroduction to Garbage Collection
Introduction to Garbage Collection
Artur Mkrtchyan
 
Getweeklyhoursbyuser
GetweeklyhoursbyuserGetweeklyhoursbyuser
Getweeklyhoursbyuser
hasheemm
 

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
Ajit 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 i
Ajit Nayak
 
Parallel programming using MPI
Parallel programming using MPIParallel programming using MPI
Parallel programming using MPI
Ajit Nayak
 
Software Engineering :UML class diagrams
Software Engineering :UML class diagramsSoftware Engineering :UML class diagrams
Software Engineering :UML class diagrams
Ajit Nayak
 
INNOVATION IS NOT AN OPTION
INNOVATION IS NOT AN OPTIONINNOVATION IS NOT AN OPTION
INNOVATION IS NOT AN OPTION
Sebastien Juras
 
Database Programming using SQL
Database Programming using SQLDatabase Programming using SQL
Database Programming using SQL
Ajit Nayak
 
Uml Omg Fundamental Certification 1
Uml Omg Fundamental Certification 1Uml Omg Fundamental Certification 1
Uml Omg Fundamental Certification 1
Ricardo Quintero
 
01 conceptos de diseño
01 conceptos de diseño01 conceptos de diseño
01 conceptos de diseño
Ricardo 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 willpower
Sebastien Juras
 
Operating Systems Part III-Memory Management
Operating Systems Part III-Memory ManagementOperating Systems Part III-Memory Management
Operating Systems Part III-Memory Management
Ajit 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 diagram
Ajit Nayak
 
Uml Omg Fundamental Certification 2
Uml Omg Fundamental Certification 2Uml Omg Fundamental Certification 2
Uml Omg Fundamental Certification 2
Ricardo Quintero
 
Software Engineering : OOAD using UML
Software Engineering : OOAD using UMLSoftware Engineering : OOAD using UML
Software Engineering : OOAD using UML
Ajit 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 control
Sebastien Juras
 
03 administracion de requisitos
03 administracion de requisitos03 administracion de requisitos
03 administracion de requisitos
Ricardo Quintero
 
The badguy summary
The badguy   summaryThe badguy   summary
The badguy summary
Sebastien Juras
 
Computer Networks Module III
Computer Networks Module IIIComputer Networks Module III
Computer Networks Module III
Ajit Nayak
 
Software Engineering an Introduction
Software Engineering an IntroductionSoftware Engineering an Introduction
Software Engineering an Introduction
Ajit 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 expert
Sebastien Juras
 
Uml Omg Fundamental Certification 5
Uml Omg Fundamental Certification 5Uml Omg Fundamental Certification 5
Uml Omg Fundamental Certification 5
Ricardo Quintero
 
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
Ajit 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 i
Ajit Nayak
 
Parallel programming using MPI
Parallel programming using MPIParallel programming using MPI
Parallel programming using MPI
Ajit Nayak
 
Software Engineering :UML class diagrams
Software Engineering :UML class diagramsSoftware Engineering :UML class diagrams
Software Engineering :UML class diagrams
Ajit Nayak
 
INNOVATION IS NOT AN OPTION
INNOVATION IS NOT AN OPTIONINNOVATION IS NOT AN OPTION
INNOVATION IS NOT AN OPTION
Sebastien Juras
 
Database Programming using SQL
Database Programming using SQLDatabase Programming using SQL
Database Programming using SQL
Ajit Nayak
 
Uml Omg Fundamental Certification 1
Uml Omg Fundamental Certification 1Uml Omg Fundamental Certification 1
Uml Omg Fundamental Certification 1
Ricardo 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 willpower
Sebastien Juras
 
Operating Systems Part III-Memory Management
Operating Systems Part III-Memory ManagementOperating Systems Part III-Memory Management
Operating Systems Part III-Memory Management
Ajit 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 diagram
Ajit Nayak
 
Uml Omg Fundamental Certification 2
Uml Omg Fundamental Certification 2Uml Omg Fundamental Certification 2
Uml Omg Fundamental Certification 2
Ricardo Quintero
 
Software Engineering : OOAD using UML
Software Engineering : OOAD using UMLSoftware Engineering : OOAD using UML
Software Engineering : OOAD using UML
Ajit 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 control
Sebastien Juras
 
03 administracion de requisitos
03 administracion de requisitos03 administracion de requisitos
03 administracion de requisitos
Ricardo Quintero
 
Computer Networks Module III
Computer Networks Module IIIComputer Networks Module III
Computer Networks Module III
Ajit Nayak
 
Software Engineering an Introduction
Software Engineering an IntroductionSoftware Engineering an Introduction
Software Engineering an Introduction
Ajit 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 expert
Sebastien Juras
 
Uml Omg Fundamental Certification 5
Uml Omg Fundamental Certification 5Uml Omg Fundamental Certification 5
Uml Omg Fundamental Certification 5
Ricardo Quintero
 

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

Awk programming
Awk programming Awk programming
Awk programming
Dr.M.Karthika parthasarathy
 
Ns network simulator
Ns network simulatorNs network simulator
Ns network simulator
Dr. Edwin Hernandez
 
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
Mark Wong
 
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
Command Prompt., Inc
 
Ns2: OTCL - PArt II
Ns2: OTCL - PArt IINs2: OTCL - PArt II
Ns2: OTCL - PArt II
Ajit 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 Advisors
John Kanagaraj
 
Sge
SgeSge
Sge
Chris Roeder
 
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
Stefan Krawczyk
 
Oracle Open World Thursday 230 ashmasters
Oracle Open World Thursday 230 ashmastersOracle Open World Thursday 230 ashmasters
Oracle Open World Thursday 230 ashmasters
Kyle Hailey
 
Ns2: Introduction - Part I
Ns2: Introduction - Part INs2: Introduction - Part I
Ns2: Introduction - Part I
Ajit Nayak
 
Basic Query Tuning Primer
Basic Query Tuning PrimerBasic Query Tuning Primer
Basic Query Tuning Primer
Command Prompt., Inc
 
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
mattsmiley
 
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
Mark Wong
 
~Ns2~
~Ns2~~Ns2~
~Ns2~
Bhaseerun nisha
 
Postgres performance for humans
Postgres performance for humansPostgres performance for humans
Postgres performance for humans
Craig Kerstiens
 
Using Libtracecmd to Analyze Your Latency and Performance Troubles
Using Libtracecmd to Analyze Your Latency and Performance TroublesUsing Libtracecmd to Analyze Your Latency and Performance Troubles
Using Libtracecmd to Analyze Your Latency and Performance Troubles
ScyllaDB
 
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
bugzbinny
 
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
Command 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 PostgreSQL
Mark 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 Howto
Mark Wong
 
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
Mark Wong
 
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
Command Prompt., Inc
 
Ns2: OTCL - PArt II
Ns2: OTCL - PArt IINs2: OTCL - PArt II
Ns2: OTCL - PArt II
Ajit 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 Advisors
John 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 logs
Stefan Krawczyk
 
Oracle Open World Thursday 230 ashmasters
Oracle Open World Thursday 230 ashmastersOracle Open World Thursday 230 ashmasters
Oracle Open World Thursday 230 ashmasters
Kyle Hailey
 
Ns2: Introduction - Part I
Ns2: Introduction - Part INs2: Introduction - Part I
Ns2: Introduction - Part I
Ajit 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 2009
mattsmiley
 
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
Mark Wong
 
Postgres performance for humans
Postgres performance for humansPostgres performance for humans
Postgres performance for humans
Craig Kerstiens
 
Using Libtracecmd to Analyze Your Latency and Performance Troubles
Using Libtracecmd to Analyze Your Latency and Performance TroublesUsing Libtracecmd to Analyze Your Latency and Performance Troubles
Using Libtracecmd to Analyze Your Latency and Performance Troubles
ScyllaDB
 
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
bugzbinny
 
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
Command 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 PostgreSQL
Mark 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 Howto
Mark Wong
 

More from Ajit Nayak (16)

Software Engineering : Software testing
Software Engineering : Software testingSoftware Engineering : Software testing
Software Engineering : Software testing
Ajit 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 & Specification
Ajit Nayak
 
Software Engineering : Process Models
Software Engineering : Process ModelsSoftware Engineering : Process Models
Software Engineering : Process Models
Ajit Nayak
 
Socket programming using C
Socket programming using CSocket programming using C
Socket programming using C
Ajit Nayak
 
Object Oriented Analysis Design using UML
Object Oriented Analysis Design using UMLObject Oriented Analysis Design using UML
Object Oriented Analysis Design using UML
Ajit Nayak
 
Operating Systems Part I-Basics
Operating Systems Part I-BasicsOperating Systems Part I-Basics
Operating Systems Part I-Basics
Ajit 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 & Deadlock
Ajit 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 Recovery
Ajit Nayak
 
Introduction to database-Normalisation
Introduction to database-NormalisationIntroduction to database-Normalisation
Introduction to database-Normalisation
Ajit Nayak
 
Introduction to database-ER Model
Introduction to database-ER ModelIntroduction to database-ER Model
Introduction to database-ER Model
Ajit Nayak
 
Computer Networks Module II
Computer Networks Module IIComputer Networks Module II
Computer Networks Module II
Ajit Nayak
 
Computer Networks Module I
Computer Networks Module IComputer Networks Module I
Computer Networks Module I
Ajit 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 III
Ajit 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 I
Ajit 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 II
Ajit Nayak
 
Software Engineering : Software testing
Software Engineering : Software testingSoftware Engineering : Software testing
Software Engineering : Software testing
Ajit 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 & Specification
Ajit Nayak
 
Software Engineering : Process Models
Software Engineering : Process ModelsSoftware Engineering : Process Models
Software Engineering : Process Models
Ajit Nayak
 
Socket programming using C
Socket programming using CSocket programming using C
Socket programming using C
Ajit Nayak
 
Object Oriented Analysis Design using UML
Object Oriented Analysis Design using UMLObject Oriented Analysis Design using UML
Object Oriented Analysis Design using UML
Ajit Nayak
 
Operating Systems Part I-Basics
Operating Systems Part I-BasicsOperating Systems Part I-Basics
Operating Systems Part I-Basics
Ajit 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 & Deadlock
Ajit 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 Recovery
Ajit Nayak
 
Introduction to database-Normalisation
Introduction to database-NormalisationIntroduction to database-Normalisation
Introduction to database-Normalisation
Ajit Nayak
 
Introduction to database-ER Model
Introduction to database-ER ModelIntroduction to database-ER Model
Introduction to database-ER Model
Ajit Nayak
 
Computer Networks Module II
Computer Networks Module IIComputer Networks Module II
Computer Networks Module II
Ajit Nayak
 
Computer Networks Module I
Computer Networks Module IComputer Networks Module I
Computer Networks Module I
Ajit 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 III
Ajit 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 I
Ajit 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 II
Ajit Nayak
 

Recently uploaded (20)

All about the Snail Power Catalog Product 2025
All about the Snail Power Catalog  Product 2025All about the Snail Power Catalog  Product 2025
All about the Snail Power Catalog Product 2025
kstgroupvn
 
world subdivision.pdf...................
world subdivision.pdf...................world subdivision.pdf...................
world subdivision.pdf...................
bmmederos12
 
Introduction of Structural Audit and Health Montoring.pptx
Introduction of Structural Audit and Health Montoring.pptxIntroduction of Structural Audit and Health Montoring.pptx
Introduction of Structural Audit and Health Montoring.pptx
gunjalsachin
 
MODULE 4 BUILDING PLANNING AND DESIGN SY BTECH HVAC SYSTEM IN BUILDING
MODULE 4 BUILDING PLANNING AND DESIGN SY BTECH HVAC SYSTEM IN BUILDINGMODULE 4 BUILDING PLANNING AND DESIGN SY BTECH HVAC SYSTEM IN BUILDING
MODULE 4 BUILDING PLANNING AND DESIGN SY BTECH HVAC SYSTEM IN BUILDING
Dr. BASWESHWAR JIRWANKAR
 
BEC602- Module 3-2-Notes.pdf.Vlsi design and testing notes
BEC602- Module 3-2-Notes.pdf.Vlsi design and testing notesBEC602- Module 3-2-Notes.pdf.Vlsi design and testing notes
BEC602- Module 3-2-Notes.pdf.Vlsi design and testing notes
VarshithaP6
 
UNIT-5-PPT Computer Control Power of Power System
UNIT-5-PPT Computer Control Power of Power SystemUNIT-5-PPT Computer Control Power of Power System
UNIT-5-PPT Computer Control Power of Power System
Sridhar191373
 
Structural Health and Factors affecting.pptx
Structural Health and Factors affecting.pptxStructural Health and Factors affecting.pptx
Structural Health and Factors affecting.pptx
gunjalsachin
 
하이플럭스 락피팅 카달로그 2025 (Lok Fitting Catalog 2025)
하이플럭스 락피팅 카달로그 2025 (Lok Fitting Catalog 2025)하이플럭스 락피팅 카달로그 2025 (Lok Fitting Catalog 2025)
하이플럭스 락피팅 카달로그 2025 (Lok Fitting Catalog 2025)
하이플럭스 / HIFLUX Co., Ltd.
 
Better Builder Magazine, Issue 53 / Spring 2025
Better Builder Magazine, Issue 53 / Spring 2025Better Builder Magazine, Issue 53 / Spring 2025
Better Builder Magazine, Issue 53 / Spring 2025
Better Builder Magazine
 
Forensic Science – Digital Forensics – Digital Evidence – The Digital Forensi...
Forensic Science – Digital Forensics – Digital Evidence – The Digital Forensi...Forensic Science – Digital Forensics – Digital Evidence – The Digital Forensi...
Forensic Science – Digital Forensics – Digital Evidence – The Digital Forensi...
ManiMaran230751
 
Application Security and Secure Software Development Lifecycle
Application  Security and Secure Software Development LifecycleApplication  Security and Secure Software Development Lifecycle
Application Security and Secure Software Development Lifecycle
DrKavithaP1
 
PPT on Grid resilience against Natural disasters.pptx
PPT on Grid resilience against Natural disasters.pptxPPT on Grid resilience against Natural disasters.pptx
PPT on Grid resilience against Natural disasters.pptx
manesumit66
 
UNIT-1-PPT-Introduction about Power System Operation and Control
UNIT-1-PPT-Introduction about Power System Operation and ControlUNIT-1-PPT-Introduction about Power System Operation and Control
UNIT-1-PPT-Introduction about Power System Operation and Control
Sridhar191373
 
[HIFLUX] Lok Fitting&Valve Catalog 2025 (Eng)
[HIFLUX] Lok Fitting&Valve Catalog 2025 (Eng)[HIFLUX] Lok Fitting&Valve Catalog 2025 (Eng)
[HIFLUX] Lok Fitting&Valve Catalog 2025 (Eng)
하이플럭스 / HIFLUX Co., Ltd.
 
ISO 4548-9 Oil Filter Anti Drain Catalogue.pdf
ISO 4548-9 Oil Filter Anti Drain Catalogue.pdfISO 4548-9 Oil Filter Anti Drain Catalogue.pdf
ISO 4548-9 Oil Filter Anti Drain Catalogue.pdf
FILTRATION ENGINEERING & CUNSULTANT
 
9aeb2aae-3b85-47a5-9776-154883bbae57.pdf
9aeb2aae-3b85-47a5-9776-154883bbae57.pdf9aeb2aae-3b85-47a5-9776-154883bbae57.pdf
9aeb2aae-3b85-47a5-9776-154883bbae57.pdf
RishabhGupta578788
 
Silent-Aire Quality Orientation - OFCI_GC - EVAP Unit REV2.pdf
Silent-Aire Quality Orientation - OFCI_GC - EVAP Unit REV2.pdfSilent-Aire Quality Orientation - OFCI_GC - EVAP Unit REV2.pdf
Silent-Aire Quality Orientation - OFCI_GC - EVAP Unit REV2.pdf
EfrainGarrilloRuiz1
 
Kevin Corke Spouse Revealed A Deep Dive Into His Private Life.pdf
Kevin Corke Spouse Revealed A Deep Dive Into His Private Life.pdfKevin Corke Spouse Revealed A Deep Dive Into His Private Life.pdf
Kevin Corke Spouse Revealed A Deep Dive Into His Private Life.pdf
Medicoz Clinic
 
Fresh concrete Workability Measurement
Fresh concrete  Workability  MeasurementFresh concrete  Workability  Measurement
Fresh concrete Workability Measurement
SasiVarman5
 
Proposed EPA Municipal Waste Combustor Rule
Proposed EPA Municipal Waste Combustor RuleProposed EPA Municipal Waste Combustor Rule
Proposed EPA Municipal Waste Combustor Rule
AlvaroLinero2
 
All about the Snail Power Catalog Product 2025
All about the Snail Power Catalog  Product 2025All about the Snail Power Catalog  Product 2025
All about the Snail Power Catalog Product 2025
kstgroupvn
 
world subdivision.pdf...................
world subdivision.pdf...................world subdivision.pdf...................
world subdivision.pdf...................
bmmederos12
 
Introduction of Structural Audit and Health Montoring.pptx
Introduction of Structural Audit and Health Montoring.pptxIntroduction of Structural Audit and Health Montoring.pptx
Introduction of Structural Audit and Health Montoring.pptx
gunjalsachin
 
MODULE 4 BUILDING PLANNING AND DESIGN SY BTECH HVAC SYSTEM IN BUILDING
MODULE 4 BUILDING PLANNING AND DESIGN SY BTECH HVAC SYSTEM IN BUILDINGMODULE 4 BUILDING PLANNING AND DESIGN SY BTECH HVAC SYSTEM IN BUILDING
MODULE 4 BUILDING PLANNING AND DESIGN SY BTECH HVAC SYSTEM IN BUILDING
Dr. BASWESHWAR JIRWANKAR
 
BEC602- Module 3-2-Notes.pdf.Vlsi design and testing notes
BEC602- Module 3-2-Notes.pdf.Vlsi design and testing notesBEC602- Module 3-2-Notes.pdf.Vlsi design and testing notes
BEC602- Module 3-2-Notes.pdf.Vlsi design and testing notes
VarshithaP6
 
UNIT-5-PPT Computer Control Power of Power System
UNIT-5-PPT Computer Control Power of Power SystemUNIT-5-PPT Computer Control Power of Power System
UNIT-5-PPT Computer Control Power of Power System
Sridhar191373
 
Structural Health and Factors affecting.pptx
Structural Health and Factors affecting.pptxStructural Health and Factors affecting.pptx
Structural Health and Factors affecting.pptx
gunjalsachin
 
하이플럭스 락피팅 카달로그 2025 (Lok Fitting Catalog 2025)
하이플럭스 락피팅 카달로그 2025 (Lok Fitting Catalog 2025)하이플럭스 락피팅 카달로그 2025 (Lok Fitting Catalog 2025)
하이플럭스 락피팅 카달로그 2025 (Lok Fitting Catalog 2025)
하이플럭스 / HIFLUX Co., Ltd.
 
Better Builder Magazine, Issue 53 / Spring 2025
Better Builder Magazine, Issue 53 / Spring 2025Better Builder Magazine, Issue 53 / Spring 2025
Better Builder Magazine, Issue 53 / Spring 2025
Better Builder Magazine
 
Forensic Science – Digital Forensics – Digital Evidence – The Digital Forensi...
Forensic Science – Digital Forensics – Digital Evidence – The Digital Forensi...Forensic Science – Digital Forensics – Digital Evidence – The Digital Forensi...
Forensic Science – Digital Forensics – Digital Evidence – The Digital Forensi...
ManiMaran230751
 
Application Security and Secure Software Development Lifecycle
Application  Security and Secure Software Development LifecycleApplication  Security and Secure Software Development Lifecycle
Application Security and Secure Software Development Lifecycle
DrKavithaP1
 
PPT on Grid resilience against Natural disasters.pptx
PPT on Grid resilience against Natural disasters.pptxPPT on Grid resilience against Natural disasters.pptx
PPT on Grid resilience against Natural disasters.pptx
manesumit66
 
UNIT-1-PPT-Introduction about Power System Operation and Control
UNIT-1-PPT-Introduction about Power System Operation and ControlUNIT-1-PPT-Introduction about Power System Operation and Control
UNIT-1-PPT-Introduction about Power System Operation and Control
Sridhar191373
 
9aeb2aae-3b85-47a5-9776-154883bbae57.pdf
9aeb2aae-3b85-47a5-9776-154883bbae57.pdf9aeb2aae-3b85-47a5-9776-154883bbae57.pdf
9aeb2aae-3b85-47a5-9776-154883bbae57.pdf
RishabhGupta578788
 
Silent-Aire Quality Orientation - OFCI_GC - EVAP Unit REV2.pdf
Silent-Aire Quality Orientation - OFCI_GC - EVAP Unit REV2.pdfSilent-Aire Quality Orientation - OFCI_GC - EVAP Unit REV2.pdf
Silent-Aire Quality Orientation - OFCI_GC - EVAP Unit REV2.pdf
EfrainGarrilloRuiz1
 
Kevin Corke Spouse Revealed A Deep Dive Into His Private Life.pdf
Kevin Corke Spouse Revealed A Deep Dive Into His Private Life.pdfKevin Corke Spouse Revealed A Deep Dive Into His Private Life.pdf
Kevin Corke Spouse Revealed A Deep Dive Into His Private Life.pdf
Medicoz Clinic
 
Fresh concrete Workability Measurement
Fresh concrete  Workability  MeasurementFresh concrete  Workability  Measurement
Fresh concrete Workability Measurement
SasiVarman5
 
Proposed EPA Municipal Waste Combustor Rule
Proposed EPA Municipal Waste Combustor RuleProposed EPA Municipal Waste Combustor Rule
Proposed EPA Municipal Waste Combustor Rule
AlvaroLinero2
 

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