Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

tcp traffic analysis linux command line mb per second

#!/usr/bin/perl
# traffic analysis script using tcpdump
use strict;
use warnings;
use Time::HiRes;

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

STDOUT->autoflush(1);

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
", (localtime())[2,1,0],$bps;
       $start_time = [Time::HiRes::gettimeofday()];
       $bytes_this_interval = 0;
    }
  }
}
Comment

tcp traffic analysis linux command line mb per second

#!/usr/bin/perl
# traffic analysis script using tcpdump
use strict;
use warnings;
use Time::HiRes;

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

STDOUT->autoflush(1);

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
", (localtime())[2,1,0],$bps;
       $start_time = [Time::HiRes::gettimeofday()];
       $bytes_this_interval = 0;
    }
  }
}
Comment

PREVIOUS NEXT
Code Example
Shell :: github shows two icons on commit 
Shell :: FATAL module ucvideo not found 
Shell :: python-swiftclient 3.5.0 uninstall ubuntu 
Shell :: getssl 
Php :: default time zone india php 
Php :: magento 2 create admin user 
Php :: laravel artisan clear cache 
Php :: php start session if not started 
Php :: mage log magento 2 
Php :: laravel order by random 
Php :: wp cron disable 
Php :: php number padding 
Php :: smarty assign var 
Php :: check if user is on mobile php 
Php :: the $request argument is type-hinted with the non-existent class or interface: "AppControllerRequest". 
Php :: laravel 8 password confirmation validation 
Php :: wordpress check user against user roles 
Php :: laravel change post request before save 
Php :: check if includes numbers php 
Php :: php if url contains 
Php :: array to string separated by comma php 
Php :: macos install php 7.4 
Php :: php mysql timestamp format 
Php :: laravel carbon time format AM PM 
Php :: php extract time from datetime 
Php :: install zip php extension 
Php :: pi() in php 
Php :: laravel module create controller 
Php :: add 7 days to date php 
Php :: create and download text file in php 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =