-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun-iperf
executable file
·74 lines (56 loc) · 2.11 KB
/
run-iperf
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/perl -w
use strict;
use LWP::UserAgent;
use HTTP::Request::Common;
my $down_linkfile = $ARGV[ 0 ];
my $up_linkfile = $ARGV[ 1 ];
my $logfile = $ARGV[ 2 ];
my $port = $ARGV[ 3 ];
my $latency = $ARGV[ 4 ];
my $time = $ARGV[ 5 ];
print $time;
my $server = "iperf3 -s -p $port";
if ( not defined $down_linkfile or not defined $up_linkfile) {
die "Usage: $0 DOWN_LINKFILE UP_LINKFILE\n";
}
my $receiver_pid = fork;
if ( $receiver_pid < 0 ) {
die qq{$!};
} elsif ( $receiver_pid == 0 ) {
# child
exec "iperf3 -s -i 0 -p $port" or die qq{$!};
}
chomp( my $prefix = qx{dirname `which mm-link`} );
my $tracedir = $prefix . q{/../share/mahimahi/traces};
# run the sender inside a linkshell and a delayshell
my @command = qw{mm-delay 20 mm-link UPLINK DOWNLINK};
# display livegraphs if we seem to be running under X
#if ( defined $ENV{ 'DISPLAY' } ) {
# push @command, qw{--meter-uplink --meter-uplink-delay};
#}
push @command, qw{--once --uplink-log --downlink-log --uplink-queue=droptail --uplink-queue-args=\"packets=100\" --downlink-queue=droptail --downlink-queue-args=\"packets=100\" -- sh -c};
push @command, "iperf3 -c \$MAHIMAHI_BASE -p $port -t $time -i 0 -R ";
# for the contest, we will send data over Verizon's downlink
# (datagrump sender's uplink)
die unless $command[ 3 ] eq "UPLINK";
# when there's a loop going through each trace, the above line will look like the below:
#print STDERR "Down linkfile: $down_linkfile\n";
$command[ 3 ] = qq{$tracedir/$up_linkfile};
die unless $command[ 1 ] eq "20";
$command[ 1 ] = "$latency";
#print STDERR "Up linkfile: $up_linkfile\n";
die unless $command[ 4 ] eq "DOWNLINK";
$command[ 4 ] = qq{$tracedir/$down_linkfile};
#print STDERR "Up log linkfile: $logfile\n";
die unless $command[ 6 ] eq "--uplink-log";
$command[ 6 ] = qq{--uplink-log=up-$logfile-$latency-$time};
#print STDERR "Down log linkfile: $logfile\n";
die unless $command[ 7 ] eq "--downlink-log";
$command[ 7 ] = qq{--downlink-log=down-$logfile-$latency-$time};
print @command;
system @command;
# kill the receiver
system "killall -s9 iperf3";
print STDERR "\n";
print STDERR qq{ done.\n\n};
print STDERR "\n";