LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices



Reply
 
Search this Thread
Old 04-26-2013, 05:55 PM   #1
markotitel
Member
 
Registered: Feb 2009
Location: Titel - Serbia
Posts: 166

Rep: Reputation: 18
Measure incoming multicast unicast bandwidth


Hi I wanted to make a script which will measure $Subject.

Command like this
Code:
 tcpdump -n "broadcast or multicast"
has the right output.

how can I parse it in a terms of bandwidth.
 
Old 04-28-2013, 06:58 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,725
Blog Entries: 54

Rep: Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970
tcpstat or ratesniff?
 
Old 04-28-2013, 01:56 PM   #3
markotitel
Member
 
Registered: Feb 2009
Location: Titel - Serbia
Posts: 166

Original Poster
Rep: Reputation: 18
Hi thanks for reply actually here is what I came up with the help of google.

Quote:
tcpdump -tnn -i eth1 -f multicast | sort | uniq -c | awk '{print $3,"> "$5,$1*$NF/2*8/1024 " Kbps"}' | awk '$1 > 10' & sleep 2s && pkill -HUP -f tcpdump
The output is what I wanted like this
Quote:
[root@titel ~]# > 0.00390625 Kbps
192.168.15.179.12345 > 224.0.248.237.12345: 23.4375 Kbps
192.168.15.179.15223 > 224.3.248.237.15223: 193.359 Kbps

[1]+ Done tcpdump -tnn -i eth1 -f multicast | sort | uniq -c | awk '{print $3,"> "$5,$1*$NF/2*8/1024 " Kbps"}' | awk '$1 > 10'
But I need to hit enter to actually exit to prompt. Where am I wrong here.
 
Old 04-28-2013, 04:18 PM   #4
markotitel
Member
 
Registered: Feb 2009
Location: Titel - Serbia
Posts: 166

Original Poster
Rep: Reputation: 18
Hi I came with really dirty bash script that does the job.

here it is
Quote:
#!/bin/bash

time=$1

tcpdump -tnn -i eth1 -f multicast > out &


sleep $time
pkill -TERM -f tcpdump

cat out | sort | uniq -c | awk -v time=${time} '{print $3,"> "$5,$1*$NF/time*8/1024 "Kbps"}'

rm out
I have a question, how to write a script for a program that outputs data until we break it (like tcpdump) and do commands like the one in my script.
 
Old 04-28-2013, 08:14 PM   #5
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,725
Blog Entries: 54

Rep: Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970Reputation: 2970
Well you shouldn't kill the process until you're done. Apart from the 'sort|uniq' a file to tail, a loop, a FIFO or piping it through something else like netbps.pl (can't remember where I got it from):
Code:
#!/usr/bin/perl
use strict;
use warnings;
use Time::HiRes;

my $reporting_interval = 10.0; # seconds
my $bytes_this_interval = 0;
my $start_time = [Time::HiRes::gettimeofday()];

while (<>) {
  if (/ length (\d+):/) {
    $bytes_this_interval += $1;
    my $elapsed_seconds = Time::HiRes::tv_interval($start_time);
    if ($elapsed_seconds > $reporting_interval) {
       my $bps = $bytes_this_interval / $elapsed_seconds;
       printf "%02d:%02d:%02d %10.2f Bps\n", (localtime())[2,1,0],$bps;
       $start_time = [Time::HiRes::gettimeofday()];
       $bytes_this_interval = 0;
    }
  }
}
should all work.
 
1 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
howto: measure and report net bandwidth use SaintDanBert Linux - Networking 2 02-07-2011 12:25 PM
pppd, wvdial, ip-down script | monthly bandwidth measure number-g Linux - Networking 1 05-02-2009 07:08 PM
Is there a way to measure QLA bandwidth at the host? markseger Linux - General 0 06-10-2008 06:44 AM
How to measure bandwidth usage on an IP-VPN setup using MRTG? depam Linux - Hardware 2 02-20-2007 10:38 AM
Unicast - Multicast Ebouffon Linux - Networking 1 11-08-2002 09:56 AM


All times are GMT -5. The time now is 06:52 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration