Home | Hardware | Internet News |Web Hosting |IT Management |Network Storage
LinuxPlanet
Search 
  Power Search | Tips 

 Front Door
 Discussion
 LinuxEngine
 Opinions
 Reports
 Reviews
 Tutorials
 News
 Technology Jobs

 Browse by subject.
Free Newsletter

Linux Planet
Linux Today
More Free Newsletters

Be a Commerce Partner


















internet.com
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

Print this article
Email this article

   LinuxPlanet / Tips



Quick and dirty net sniffing
Analyse tcpdump output with a perl "one liner"

James Andrews
Tuesday, October 26, 1999 02:59:12 PM

run tcpdump -c 5000 >file1

and then analyse the output:
perl -n -e 'next unless(/^\S/ ); @a=split(/\s/); $s{$a[1]}++;
END {@o=sort { $s {$b} <=> $s{$a} }keys %s; for
(@o[0..10]) { print ``$s{$_} $_\n''}}' file1

Do this repeatedly to see what is generating the traffic on your host's interface.

Here is the same thing as a short script:

#!/usr/bin/perl -w
while(<>)
{ next unless(/^\S/);
@a=split(/\s/);
$s{$a[1]}++;
}
@o=sort { $s{$b} <=> $s{$a} }keys %s;
for (@o[0..10]) {
print ``$s{$_} $_\n'';
}

If you want something more sophisticated then the Ethereal package is worth a look.





Linux is a trademark of Linus Torvalds.


internet.com home | search | help! | about us

Jupiter Online Media

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers