LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-09-2015, 08:08 AM   #1
Aabha
Member
 
Registered: Aug 2014
Posts: 40

Rep: Reputation: Disabled
Ack script


Dear sir
Although at no of places many types awk files are available, but i am requesting you please give me awk script for packet loss and total throughput for my attached .tr file.I want to calculate throughput between node 4 and 0
There is a problem in attachment so please have a look some sample lines of tr file ....

+ 11.959147 0 1 AM_Data 40 -------- 0 1.0.0.0 0.0.2.0 0 98 2348
- 11.959147 0 1 AM_Data 40 -------- 0 1.0.0.0 0.0.2.0 0 98 2348
+ 11.959161 0 1 AM_Data 40 -------- 0 1.0.0.0 0.0.2.0 0 98 2349
- 11.959161 0 1 AM_Data 40 -------- 0 1.0.0.0 0.0.2.0 0 98 2349
+ 11.959181 0 1 AM_Data 40 -------- 0 1.0.0.0 0.0.2.0 0 98 2350
- 11.959181 0 1 AM_Data 40 -------- 0 1.0.0.0 0.0.2.0 0 98 2350
+ 11.959192 0 1 AM_Data 40 -------- 0 1.0.0.0 0.0.2.0 0 98 2351
- 11.959192 0 1 AM_Data 40 -------- 0 1.0.0.0 0.0.2.0 0 98 2351
s -t 11.962223523 -Hs 10 -Hd -2 -Ni 10 -Nx 1100.00 -Ny 1000.00 -Nz 0.00 -Ne -1.000000 -Nl MAC -Nw --- -Ma 0 -Md 0 -Ms 0 -Mt 0
s -t 11.962312412 -Hs 10 -Hd -2 -Ni 10 -Nx 1100.00 -Ny 1000.00 -Nz 0.00 -Ne -1.000000 -Nl MAC -Nw --- -Ma 0 -Md 0 -Ms 0 -Mt 0
s -t 11.966223523 -Hs 10 -Hd -2 -Ni 10 -Nx 1100.00 -Ny 1000.00 -Nz 0.00 -Ne -1.000000 -Nl MAC -Nw --- -Ma 0 -Md 0 -Ms 0 -Mt 0
s -t 11.966312412 -Hs 10 -Hd -2 -Ni 10 -Nx 1100.00 -Ny 1000.00 -Nz 0.00 -Ne -1.000000 -Nl MAC -Nw --- -Ma 0 -Md 0 -Ms 0 -Mt 0
s -t 11.970223523 -Hs 10 -Hd -2 -Ni 10 -Nx 1100.00 -Ny 1000.00 -Nz 0.00 -Ne -1.000000 -Nl MAC -Nw --- -Ma 0 -Md 0 -Ms 0 -Mt 0
s -t 11.970312412 -Hs 10 -Hd -2 -Ni 10 -Nx 1100.00 -Ny 1000.00 -Nz 0.00 -Ne -1.000000 -Nl MAC -Nw --- -Ma 0 -Md 0 -Ms 0 -Mt 0
r 11.97401 0 1 AM_Data 40 -------- 0 1.0.0.0 0.0.2.0 0 97 2328
r 11.974026 0 1 AM_Data 40 -------- 0 1.0.0.0 0.0.2.0 0 97 2329
r 11.97403 0 1 AM_Data 40 -------- 0 1.0.0.0 0.0.2.0 0 97 2330
r 11.97403 0 1 AM_Data 40 -------- 0 1.0.0.0 0.0.2.0 0 97 2331
r 11.974038 0 1 AM_Data 40 -------- 0 1.0.0.0 0.0.2.0 0 98 2332
r 11.974046 0 1 AM_Data 40 -------- 0 1.0.0.0 0.0.2.0 0 98 2333
r 11.974051 0 1 AM_Data 40 -------- 0 1.0.0.0 0.0.2.0 0 98 2334
r 11.97406 0 1 AM_Data 40 -------- 0 1.0.0.0 0.0.2.0 0 98 2335
r 11.974065 0 1 AM_Data 40 -------- 0 1.0.0.0 0.0.2.0 0 98 2336
r 11.974077 0 1 AM_Data 40 -------- 0 1.0.0.0 0.0.2.0 0 98 2337
 
Old 09-09-2015, 08:12 AM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192
Nobody will give you anything without you showing an attempt.
 
Old 09-10-2015, 12:22 AM   #3
Aabha
Member
 
Registered: Aug 2014
Posts: 40

Original Poster
Rep: Reputation: Disabled
Dear sir
I had tried with no of script but not getting satisfactory output. With some script output is available but not mapped with trace file, with some script there is no output even manually i checked the codes. Please find the attached copy of script i have used....
regards
There is still some problem in attachment ....how can i share script i have used.
 
Old 09-10-2015, 12:56 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Just post the script, inside CODE tags see https://www.linuxquestions.org/quest...do=bbcode#code
 
Old 09-10-2015, 03:53 AM   #5
Aabha
Member
 
Registered: Aug 2014
Posts: 40

Original Poster
Rep: Reputation: Disabled
this is one of the script i have used

PHP Code:
BEGIN {
bytes_recvd 0;
throughput 0;
interval 1;
current_time_instance 0;
 
nxt_time_instance current_time_instance interval;
}
  {
action = $1;
time = $2;
from = $3;
to = $4;
type = $5;
pkt_size = $6;
flow_id = $8;
#src = $9;
#dst = $10;
sequence_n0 = $11;
pkt_id = $12;

if (
time nxt_time_instance)
  {
  if (
action == "r")
  {
  
bytes_recvd bytes_recvd pkt_size;
  }
  }
else {
current_time_instance nxt_time_instance;
nxt_time_instance += interval;
throughput bytes_recvd ;
printf("%d %dn\n",current_time_instancethroughput);
}

 
Old 09-10-2015, 07:28 AM   #6
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
@Aabha, please have a look at the <thr> scripts in "awk-and-perl_scripts_12.2014.tar.gz"
https://drive.google.com/file/d/0B7S...ew?usp=sharing
... One of the scripts may be usable for your particular ns2 trace file.
avg_throughput.awk
avg_throughput-zigbee.awk
avg_thr_wirelss.awk
chainThroughput.pl
e2ethroughput.awk
flow-thr.awk
genthroughput.awk
instantThroughput.awk
instantThroughputStll.awk
Lianghui-throughput.pl
myflowcalcall_throu.awk
thr_drop_delay.awk
thr-one.pl
Throughput2007.awk
throughput-8.pl
throughput-9.pl
throughput_newtrace.awk
throughput.pl
thruput.awk
updown-link-thr.pl
wireless-thr.awk
.... If no success, you can read the files to get ideas for your awk code.

CODE Tags : [code]code text[/code] .
Please do not use PHP code tags, awk code is not php code.


-
 
Old 09-10-2015, 07:37 AM   #7
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
@Aabha : About `Attacments' :

All text files must have suffix .txt to be attached to an LQ post.

A (small) trace file can be attached as out.tr.txt : Please do not omit the .tr !

Larger files.tr(.txt) can be uploaded to 'Google Docs'.
Will be readable on-line with suffix .tr.txt .

-
 
Old 09-10-2015, 11:32 AM   #8
Aabha
Member
 
Registered: Aug 2014
Posts: 40

Original Poster
Rep: Reputation: Disabled
Dear sir
Thank you for your prompt reply and guidance...

Regards
 
Old 09-10-2015, 12:40 PM   #9
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192
So hopefully one of the other scripts mentioned will help, but I thought I would shed some light on the one you were using.
After taking out any cruft which is not being used your script looks like:
Code:
#!/usr/bin/awk -f

BEGIN { 
  bytes_recvd = 0; 
  throughput = 0; 
  interval = 1; 
  current_time_instance = 0; 
  nxt_time_instance = current_time_instance + interval; 
} 
{ 
  action = $1;
  time = $2; 
  pkt_size = $6; 

  if (time < nxt_time_instance) 
  { 
    if (action == "r") 
    { 
      bytes_recvd = bytes_recvd + pkt_size; 
    } 
  } 
  else
  { 
    current_time_instance = nxt_time_instance; 
    nxt_time_instance += interval; 
    throughput = bytes_recvd ; 
    printf("d %dn\n",current_time_instance, throughput); 
  }
}
Essentially time is greater than nxt_time_instance for the first 11 rows and hence your output is:
Code:
1 0n
2 0n
3 0n
4 0n
5 0n
6 0n
7 0n
8 0n
9 0n
10 0n
11 0n
After this it is greater than nxt_time_instance and hence the bytes_recvd is later added up but will never be displayed as the script has no way to get back into
the 'else' part of the script where the printf statement is generating output.

Hope that helps
 
1 members found this post helpful.
Old 09-11-2015, 01:06 AM   #10
Aabha
Member
 
Registered: Aug 2014
Posts: 40

Original Poster
Rep: Reputation: Disabled
Thanks....
 
  


Reply

Tags
awk-ns2, ns2



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
expanding my tc script to include prioritizing for TCP syn/ack/etc. psycroptic Linux - Networking 6 10-07-2013 06:19 PM
ack retransmission jackandking Linux - Networking 5 07-05-2007 06:04 AM
ACK! what is my problem? zmaster Linux - Software 2 06-21-2005 05:33 PM
ack, im a noob no_order Slackware 2 07-06-2003 09:54 PM
Ack, Help! meddleRPI Linux - General 2 05-23-2003 10:32 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:18 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