-
Notifications
You must be signed in to change notification settings - Fork 0
/
testnetwork.pl
52 lines (31 loc) · 855 Bytes
/
testnetwork.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
####### WRITTEN BY : YADU MATHUR ########################
####### CAPTURE NETWORK TRAFFIC And get in MBPS ##############
#MIT License
#Copyright (c) 2019 Yadu Mathur
#!/usr/bin/perl
use strict;
use warnings;
#using Hires
use Time::HiRes;
#use sockets
use IO::Socket::INET;
### SET UP THE TIME LIMIT
my $time_check = 5.0; # seconds
my $bytestostart = 0;
my $start_time = [Time::HiRes::gettimeofday()];
#Flushed
STDOUT->autoflush(1);
while (<>) {
if (/ length (\d+):/) {
$bytestostart += $1;
my $passedseconds = Time::HiRes::tv_interval($start_time);
if ($passedseconds > $time_check) {
my $bips = $bytestostart / $passedseconds;
my $mbps = $bips / 1024;
#compute
printf "%10d %10.2f\n", (time()),$mbps;
$start_time = [Time::HiRes::gettimeofday()];
$bytestostart = 0;
}
}
}