References Awk – A Tutorial and Introduction NS by Example nile.wpi.edu/NS/

Slides:



Advertisements
Similar presentations
1 NS-2 Tutorial COMP R2 University of Manitoba March 4, 2009.
Advertisements

Statistical Methods Lynne Stokes Department of Statistical Science Lecture 7: Introduction to SAS Programming Language.
Introduction to Matlab
An Introduction to NS-2 * Gayatri Swamynathan CS 276 TA *some slides are from a presentation by Haobo Yu & Nader Salehi, USC/ISI.
Brief Intro to ns2: The most widely used Network Simulator COMP5416 Advanced Network Technologies Based on: Marc Greis's
Ns-2 Tutorial Exercise (1) Multimedia Networking Group, The Department of Computer Science, UVA Jianping Wang Adopted from Nicolas’s slides Jianping Wang,
Introduction to NS. Information Main website Documentation, mailing list archive, tutorial Location of Source codes –C++ files.
M. Dahshan - TCOM52721 TCOM 5272 Telecomm Lab Dr. Mostafa Dahshan OU-Tulsa 4W 2 nd floor
Questions  RED vs. DropTail  What’s the key difference?  Why RED drops packet randomly?  What’s the major effect if using RED.
Submitters: Stella Pantofel Michael Halperin Igor Berman
TCP Performance: what to measure?  Dynamic Performance  Bottleneck utilization, queue length;  TCP source congestion window,
Introduction to Network Simulator NS-2 Part II
Advanced File Processing
Wireless Networking and Systems CSE 590 ns2 tutorial.
Agenda Sed Utility - Advanced –Using Script-files / Example Awk Utility - Advanced –Using Script-files –Math calculations / Operators / Functions –Floating.
Agenda User Profile File (.profile) –Keyword Shell Variables Linux (Unix) filters –Purpose –Commands: grep, sort, awk cut, tr, wc, spell.
1 Experimental Statistics - week 4 Chapter 8: 1-factor ANOVA models Using SAS.
Descriptive Statistics I: By the end of this class you should be able to: Palm: Section 7.1, 7.2 Program cords and delays in your music programs plot a.
CIS 218 Advanced UNIX1 CIS 218 – Advanced UNIX (g)awk.
Role and Mechanism of Queue Internet Engineering.
Advanced File Processing. 2 Objectives Use the pipe operator to redirect the output of one command to another command Use the grep command to search for.
Network Simulator-2 Sandeep singla 1998A2A7540. NS-2 A discrete event simulator Focused on modeling network protocols –Wired, wireless –TCP,UDP,unicast,multicast.
NetFlow Very useful for traffic analysis Very useful for traffic analysis Standard sampler: Standard sampler: –Cisco Netflow –Juniper Traffic Sampling.
1 Network Simulator Tutorial. 2 Network Simulation * Motivation: Learn fundamentals of evaluating network performance via simulation Overview: fundamentals.
Introduction to Unix – CS 21 Lecture 12. Lecture Overview A few more bash programming tricks The here document Trapping signals in bash cut and tr sed.
Background of Wireless Communication Student Presentations and Projects Wireless Communication Technology Wireless Networking and Mobile IP Wireless Local.
Lecture 24CS311 – Operating Systems 1 1 CS311 – Lecture 24 Outline Final Exam Study Guide Note: These lecture notes are not intended replace your notes.
1 NS Fundamentals. USC INFORMATION SCIENCES INSTITUTE 2 OTcl and C++: The Duality C++ OTcl Pure C++ objects Pure OTcl objects C++/OTcl split objects ns.
1 Introduction to NS-2 r Tutorial overview of NS m Create basic NS simulation r Walk-through a simple example m Model specification m Execution and trace.
The material contained in this document is proprietary to Triniti Corporation (Triniti). This material may not be disclosed, duplicated or otherwise revealed,
16-Dec-15Advanced Programming Spring 2002 sed and awk Henning Schulzrinne Dept. of Computer Science Columbia University.
Use of Mobility models in ns-2 Karthik Dantu Shyam Kapadia.
IP-BASED MOBILITY FOR WIRELESS LANS WITH THE NETWORK SIMULATOR NS Frank Christahl, Andreas Huber, Matthias Rosenschon University of Applied Sciences Giessen-Friedberg.
– Introduction to the Shell 1/21/2016 Introduction to the Shell – Session Introduction to the Shell – Session 3 · Job control · Start,
1 Lecture 10 Introduction to AWK COP 3344 Introduction to UNIX.
ORAFACT Text Processing. ORAFACT Searching Inside Files grep - searches for patterns within files grep [options] [[-e] pattern] filename [...] -n shows.
Network Topology. Network Topology Cont. Sender = 0 and Receiver = 5 Sender = 0 and Receiver = 5 Sender transmits ftp traffic over TCP/IP to receiver.
Groups of cells labeled with letters that go up and down (vertical)
CS 403: Programming Languages Lecture 20 Fall 2003 Department of Computer Science University of Alabama Joel Jones.
Awk- An Advanced Filter by Prof. Shylaja S S Head of the Dept. Dept. of Information Science & Engineering, P.E.S Institute of Technology, Bangalore
1 UNIX Operating Systems II Part 2: Shell Scripting Instructor: Stan Isaacs.
NS-2 Training 12/12/2011. Introduction  NS-2: Network Simulator Generation 2  Latest Release: 2.35 / Nov. 4, 2011 
Spreadsheet I n Concepts & operations. Concepts n Workbook: Excel file n Worksheet: sheet n Row: 1-???? n Column: A - Z, AA - ?? n Cell n Cell address.
CSE 303 Concepts and Tools for Software Development Richard C. Davis UW CSE – 10/9/2006 Lecture 6 – String Processing.
Introduction to Matlab. Outline:  What is Matlab? Matlab Screen Variables, array, matrix, indexing Operators.
MSAA PRESENTS: AN EXCEL TUTORIAL
Arun Vishwanathan Nevis Networks Pvt. Ltd.
Lesson 5-Exploring Utilities
Speaker Dr. Saloua CHETTIBI Lecturer at University of Jijel
Computer Application in Engineering Design
Choe, Hyun Jung (Stella)
Introduction to ns-2: “The” Network Simulator
Chapter 6 Filters.
Jonathan W. Duggins; James Blum NC State University; UNC Wilmington
Shell Script Assignment 1.
Specification-Based Testing and the Category-Partition Method
Basic operations in Matlab
Microsoft Office 2013 Coming to a PC near you!.
Microsoft Excel 2003 Illustrated Complete
What is Bash Shell Scripting?
The Linux Command Line Chapter 6
The ‘grep’ Command Colin Masterson.
Guide To UNIX Using Linux Third Edition
Microsoft Excel 101.
Eviews Tutorial for Labor Economics Lei Lei
Topics Introduction to Value-returning Functions: Generating Random Numbers Writing Your Own Value-Returning Functions The math Module Storing Functions.
Learning Objectives: Creating a new Table Style
A Fair Scheduling Scheme for HCF
Awk.
Introduction to Bash Programming, part 3
Presentation transcript:

References Awk – A Tutorial and Introduction www.grymoire.com/Unix/Awk.html NS by Example nile.wpi.edu/NS/

Trace Analysis Tools

Awk utility Awk is an excellent filtering and reporting utility A pseudo-C interpreter Same C arithmetic Supports associative arrays (array index can be a variable of any type)

Awk – Basic Structure pattern { action } pattern specifies when action is performed Awk is line oriented Default pattern matches every line Two other important patterns BEGIN END M. Dahshan - TCOM5272

Awk – Basic Structure Example on an NS trace file Output + 0.5075 0 1 cbr 210 ------- 0 0.0 1.0 2 2 - 0.5075 0 1 cbr 210 ------- 0 0.0 1.0 2 2 r 0.51112 0 1 cbr 210 ------- 0 0.0 1.0 0 0 BEGIN {print “Time\tSequence Number”} {print $2”\t”$11} END {print “DONE”} Output Time Sequence Number 0.5075 2 0.5075 2 0.51112 0 DONE M. Dahshan - TCOM5272

Calculating Packet Delay BEGIN { # simple awk script to generate end-to-end # packet lifetime statistics # in a form suitable for plotting with xgraph # Lloyd Wood, July 1999. # http://www.ee.surrey.ac.uk/Personal/L.Wood/ns/ highest_packet_id = 0; } M. Dahshan - TCOM5272

Calculating Packet Delay { action = $1; time = $2; node_1 = $3; node_2 = $4; src = $5; flow_id = $8; node_1_address = $9; node_2_address = $10; seq_no = $11; packet_id = $12; M. Dahshan - TCOM5272

Calculating Packet Delay if ( packet_id > highest_packet_id ) highest_packet_id = packet_id; # getting start time is not a problem, provided you're not starting # traffic at 0.0. # could test for sending node_1_address or flow_id here. if ( start_time[packet_id] == 0 ) start_time[packet_id] = time; # only useful for small unicast where packet_id doesn't wrap. # checking receive means avoiding recording drops if ( action != "d" ) { if ( action == "r" ) { # could test for receiving node_2_address or flow_id here. end_time[packet_id] = time; } } else { end_time[packet_id] = -1; M. Dahshan - TCOM5272

Calculating Packet Delay END { for ( packet_id = 0; packet_id <= highest_packet_id; packet_id++ ) { start = start_time[packet_id]; end = end_time[packet_id]; packet_duration = end - start; if ( start < end ) printf("%d %f\n", packet_id , packet_duration); } M. Dahshan - TCOM5272

Calculate Average Delay First, calculate packet delay { #increment number of lines num_lines++; #sum the delay values #column 2 is the packet delay sum_delay=sum_delay+$2; } END {print sum_delay/num_lines} M. Dahshan - TCOM5272

Calculating Dropped Packets BEGIN{dropped=0} { action = $1; if(action=="d") dropped++; } END{print dropped} M. Dahshan - TCOM5272

Calculating Throughput Throughput = total number of bytes received BEGIN{dest=3} { action = $1; node2 = $4; packet_size = $6; if(action=="r" && node2=dest) throughput + = packet_size; } END{throughput} M. Dahshan - TCOM5272

Calculating Jitter Jitter = difference between packet delays First, calculate packet delay M. Dahshan - TCOM5272

Calculating Jitter BEGIN {old_delay=0.0;} { delay = $2; if(old_delay>0) jitter=delay-old_delay; else jitter=0.0; #if(jitter<0) jitter = -jitter; old_delay = delay; print $1 " " jitter; } M. Dahshan - TCOM5272

cat, grep, wc We can simplify processing by doing some pre-filtering using grep We can also do some quick calculations by combining multiple small commands Take the output of a command as an input to the next command (pipes) M. Dahshan - TCOM5272

Print only CBR Traffic grep cbr out.tr r 0.114 1 2 cbr 1000 ------- 2 1.0 3.1 0 0 + 0.114 2 3 cbr 1000 ------- 2 1.0 3.1 0 0 - 0.114 2 3 cbr 1000 ------- 2 1.0 3.1 0 0 + 0.116 1 2 cbr 1000 ------- 2 1.0 3.1 2 2 - 0.116 1 2 cbr 1000 ------- 2 1.0 3.1 2 2 r 0.122 1 2 cbr 1000 ------- 2 1.0 3.1 1 1 M. Dahshan - TCOM5272

Print CBR Traffic From 2 to 3 grep "2 3 cbr" out.tr + 0.114 2 3 cbr 1000 ------- 2 1.0 3.1 0 0 - 0.114 2 3 cbr 1000 ------- 2 1.0 3.1 0 0 + 0.122 2 3 cbr 1000 ------- 2 1.0 3.1 1 1 - 0.122 2 3 cbr 1000 ------- 2 1.0 3.1 1 1 + 0.13 2 3 cbr 1000 ------- 2 1.0 3.1 2 2 - 0.13 2 3 cbr 1000 ------- 2 1.0 3.1 2 2 + 0.138 2 3 cbr 1000 ------- 2 1.0 3.1 3 3 - 0.138 2 3 cbr 1000 ------- 2 1.0 3.1 3 3 r 0.138706 2 3 cbr 1000 ------- 2 1.0 3.1 0 0 + 0.146 2 3 cbr 1000 ------- 2 1.0 3.1 4 4 M. Dahshan - TCOM5272

Print Only Received Packets grep ^r out.tr r 0.114 1 2 cbr 1000 ------- 2 1.0 3.1 0 0 r 0.122 1 2 cbr 1000 ------- 2 1.0 3.1 1 1 r 0.13 1 2 cbr 1000 ------- 2 1.0 3.1 2 2 r 0.138 1 2 cbr 1000 ------- 2 1.0 3.1 3 3 r 0.138706 2 3 cbr 1000 ------- 2 1.0 3.1 0 0 r 0.146 1 2 cbr 1000 ------- 2 1.0 3.1 4 4 r 0.146706 2 3 cbr 1000 ------- 2 1.0 3.1 1 1 r 0.154 1 2 cbr 1000 ------- 2 1.0 3.1 5 5 r 0.154706 2 3 cbr 1000 ------- 2 1.0 3.1 2 2 r 0.162 1 2 cbr 1000 ------- 2 1.0 3.1 6 6 M. Dahshan - TCOM5272

Print CBR Received at Node 3 grep ^r out.tr | grep "2 3 cbr" r 0.138706 2 3 cbr 1000 ------- 2 1.0 3.1 0 0 r 0.146706 2 3 cbr 1000 ------- 2 1.0 3.1 1 1 r 0.154706 2 3 cbr 1000 ------- 2 1.0 3.1 2 2 r 0.162706 2 3 cbr 1000 ------- 2 1.0 3.1 3 3 r 0.170706 2 3 cbr 1000 ------- 2 1.0 3.1 4 4 r 0.178706 2 3 cbr 1000 ------- 2 1.0 3.1 5 5 r 0.186706 2 3 cbr 1000 ------- 2 1.0 3.1 6 6 r 0.194706 2 3 cbr 1000 ------- 2 1.0 3.1 7 7 r 0.202706 2 3 cbr 1000 ------- 2 1.0 3.1 8 8 r 0.210706 2 3 cbr 1000 ------- 2 1.0 3.1 9 9 M. Dahshan - TCOM5272

Calculate Dropped Packets! grep ^d out.tr | wc –l 18 M. Dahshan - TCOM5272

Activities M. Dahshan - TCOM5272

Trace Analysis Example Download the file Trace Analysis Example http://nile.wpi.edu/NS/Example/ns-simple-trace.tcl M. Dahshan - TCOM5272

Activity 1: Calculate Packet Delay Use the provided packet delay script to calculate the delay for CBR traffic only! Save the output to a file cbr_delay.txt Commands: ns ns-simple-trace.tcl grep cbr out.tr | awk -f pkt_delay.awk > cbr_delay.txt M. Dahshan - TCOM5272

Activity 2: Calculate Jitter Use the provided packet jitter script to calculate the delay for CBR traffic Save the output to a file cbr_jitter.txt Commands: awk -f jitter.awk cbr_delay.txt > cbr_jitter.txt M. Dahshan - TCOM5272

Activity 3: Plot Delay and Jitter Use xgraph or gnuplot to plot the delay and jitter for CBR traffic on the same graph For xgraph xgraph cbr_delay.txt cbr_jitter.txt M. Dahshan - TCOM5272

Activity 3: Plot Delay and Jitter Using gnuplot gnuplot gnuplot>set key left top Right noreverse enhanced box gnuplot>set xlabel "Packet ID" gnuplot>set ylabel "Delay and Jitter (sec)" gnuplot>plot “cbr_delay.txt" using 1:2 title “Packet Delay" with lines 1, “cbr_jitter.txt" using 1:2 title “Jitter" with lines 2 M. Dahshan - TCOM5272

Activity 4: Stochastic Fair Queue Edit the ns-sample-trace.tcl script Change the queue type from DropTail to SFQ Save as ns-sample-trace-sfq.tcl Recalculate delay, jitter and plot the results (cbr_delay_sfq.txt, cbr_jitter_sfq.txt) Discuss your findings M. Dahshan - TCOM5272

Activity 4: Random Early Detection Edit the ns-sample-trace.tcl script Change the queue type from DropTail to RED Save as: ns-sample-trace-red.tcl Recalculate delay, jitter and plot the results (cbr_delay_red.txt, cbr_jitter_red.txt) Discuss your findings M. Dahshan - TCOM5272