LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 04-15-2013, 06:49 AM   #1
ines8989
Member
 
Registered: Mar 2013
Posts: 62

Rep: Reputation: Disabled
Result of awk script


Hi i have tested script for delay.awk to analyse a tcp trace file and i obtain this result

2 0.090344 0.045172

I want to trace the graph of delay for my tcp trace file with this code awk but i did'nt inderstand this result please help me : This is my script awk :

------------------------------------------
BEGIN {highest_packet_id = 0;}
{
action = $1;
time = $2;
node =$3;
type = $5;
packet_id =$6;
if (packet_id > highest_packet_id)
highest_packet_id = packet_id;
if (action == "+"){
if (type == "tcp"){
send_time[packet_id] = time;}
#else {send_time[packet_id] = 0;}
}
else if (action == "r"){
if (type == "tcp"){
rcv_time[packet_id] = time;
}
#else{rcv_time[packet_id] = 0;}
}
}
END {packet_no = 0; total_delay = 0;
for (packet_id = 0; packet_id <=highest_packet_id; packet_id++){
if ((send_time[packet_id]!=0) && (rcv_time[packet_id]!=0)){
start = send_time[packet_id];
end = rcv_time[packet_id];
packet_duration = end-start;}
else
packet_duration = -1;
if (packet_duration > 0)
{packet_no++;
total_delay = total_delay + packet_duration; }
}
printf("%d %f %f\n", packet_no, total_delay, total_delay/packet_no);
}

Thanks for you
 
Old 04-15-2013, 07:23 AM   #2
Snark1994
Senior Member
 
Registered: Sep 2010
Distribution: Debian
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
What did you expect it to print? I suspect you want to move the 'printf' line above the brace preceding it (i.e. change

Code:
        if (packet_duration > 0) {
             packet_no++;
             total_delay = total_delay + packet_duration;
        }
    }
    printf("%d %f %f\n", packet_no, total_delay, total_delay/packet_no);
}
to

Code:
        if (packet_duration > 0) {
             packet_no++;
             total_delay = total_delay + packet_duration;
        }
        printf("%d %f %f\n", packet_no, total_delay, total_delay/packet_no);
    }
}


Also, use [CODE][/CODE] tags around your code to make it more legible.

Last edited by Snark1994; 04-15-2013 at 07:26 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Pass Command Result to Awk BarataPT Programming 7 04-15-2011 09:23 AM
awk - gensub first result webhope Programming 3 05-27-2010 05:52 AM
Specific result of awk script jeesun Programming 3 01-24-2010 05:42 AM
using awk on a awk result jpgauvin Programming 1 12-15-2008 03:57 AM
cannot export result from awk into a variable in a bash script Emmanuel_uk Linux - Newbie 4 03-07-2005 01:54 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 04:41 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration