LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
Search this Thread
Old 02-05-2013, 06:16 AM   #1
vin.18
LQ Newbie
 
Registered: Feb 2013
Posts: 1

Rep: Reputation: Disabled
request to generate a awk file for NS2 .tr file


hi guys i have a line from my .tr file can anyone write a code in awk script for me so as to calculate total sent packets, total dropped packets, throughput.

s -t 0.023906650 -Hs 9 -Hd -1 -Ni 9 -Nx 270.00 -Ny 500.00 -Nz 0.00 -Ne -1.000000 -Nl AGT -Nw --- -Ma 0 -Md 0 -Ms 0 -Mt 0 -Is 9.0 -Id -1.0 -It PBC -Il 250 -If 0 -Ii 0 -Iv 32

please its a humble request....!
 
Old 02-09-2013, 10:07 AM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950
Please use ***[code][/code]*** tags around your code and data, to preserve the original formatting and to improve readability. Do not use quote tags, bolding, colors, "start/end" lines, or other creative techniques.


I'm not familiar with this input. Which fields are the packet fields you want? Is there just the one line, or do you need to add up multiple entries? What is the exact calculation you need to do, and how exactly do you want the output formatted?

In any case, it should be easy. For a single line calculation, you just need to put the proper field numbers into the arithmetic expression and print out the result. For a multi-line total, you include a variable to store the running totals in, and print out the final value of it at the end of the file.


Here are a few useful awk references:
http://www.grymoire.com/Unix/Awk.html
http://www.gnu.org/software/gawk/man...ode/index.html
http://www.pement.org/awk/awk1line.txt
http://www.catonmat.net/series/awk-one-liners-explained
 
2 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
how to generate nam file after installing leach in ns2.34 rakeshpanchiwala Linux - Software 0 01-13-2013 01:45 PM
[SOLVED] replace matched pattern from 1st file into 2nd file using awk sopier Programming 6 12-13-2011 10:58 AM
[SOLVED] AWK: split the file into multiple file and request for explanation of a known code cristalp Programming 4 11-23-2011 08:29 AM
[SOLVED] generate a .bmap file for mkinitrd from .map file Thom1b Slackware 2 03-26-2010 11:01 AM
awk: fatal:cannot open file for reading (no such file or Directory) in Linux sangati vishwanath Linux - Software 4 07-06-2005 01:59 AM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration