📄 runonmach.pl
字号:
#!/usr/bin/perl -wuse strict;# exitmy ($name, $other, $when, $sqbool, $rate, $urate, $click_path, $eabool) = @ARGV;chdir "/root/work/tools/";my $now = time();if ($urate != 0) {# run udpgen print $now . " runonmach running udpgen on $name\n"; system("./udpgen -t 60 -r $urate $other >& /tmp/udpgen.out.$name.$sqbool.$rate.$eabool &");} else { print $now . " runonmach not running udpgen on $name\n";}# attempt to run first show stats at $whensleep($when - time() - 1);while (time() < $when) { select(undef, undef, undef, 0.2);}# run show_stats and save it to start.$name.$sqbool.$rate.$eaboolchdir "$click_path/conf/wifi/scripts/";my $start = time();system("./show_stats > /tmp/start.$name.$sqbool.$rate.$eabool");# attempt to run next show stat at when+20sleep 19;while (time() < $when + 20) { select(undef, undef, undef, 0.2);}# run show_stats and save it to end.$name.$sqbool.$rate.$eaboolmy $end = time();system("./show_stats > /tmp/end.$name.$sqbool.$rate.$eabool");# kill udpgen clickif ($urate != 0) { system("killall -INT udpgen");}system("killall click");if ($urate != 0) {# compute total packets recd, num decoded etc. and write to stats.$sqbool.$rate.$eabool file my ($startrecd, $startdups, $startdec, $startdecdups, $startnew, $startdecnew) = (0, 0, 0, 0, 0, 0); open(FH, "</tmp/start.$name.$sqbool.$rate.$eabool") or die "could not open start.$name.$sqbool.$rate.$eabool"; while (<FH>) { chomp; if ($_ =~ /^Nreceived: (\d+); Nduplicates: (\d+); Nnewpkts : (\d+)/) { $startrecd = $1; $startdups = $2; $startnew = $3; } if ($_ =~ /^Ndecoded: (\d+);.* Nduplicates: (\d+); NNewPkts : (\d+)/) { $startdec = $1; $startdecdups = $2; $startdecnew = $3; } } close FH; my ($endrecd, $enddups, $enddec, $enddecdups, $endnew, $enddecnew) = (0, 0, 0, 0); open(FH, "</tmp/end.$name.$sqbool.$rate.$eabool") or die "could not open end.$name.$sqbool.$rate.$eabool"; while (<FH>) { chomp; if ($_ =~ /^Nreceived: (\d+); Nduplicates: (\d+); Nnewpkts : (\d+)/) { $endrecd = $1; $enddups = $2; $endnew = $3; } if ($_ =~ /^Ndecoded: (\d+); Nundecodable: \d+; Nduplicates: (\d+); NNewPkts : (\d+)/) { $enddec = $1; $enddecdups = $2; $enddecnew = $3; } } close FH; #unlink "/tmp/start.$name.$bool.$rate";#unlink "/tmp/end.$name.$bool.$rate"; my $csent = ($endnew - $startnew) + ($enddecnew - $startdecnew); # assume that packets are 1472 bytes long my $tput = $csent * 1472 * 8.0/($end - $start); open(FH, ">/tmp/stats.$name.$sqbool.$rate.$eabool") or die "could not open stats.$name.$sqbool.$rate.$eabool"; print FH "$name Time: $start $end\n"; print FH "$name NumPackets: $startrecd $endrecd $startdups $enddups $startdec $enddec $startdecdups $enddecdups\n"; print FH "$name Rate: $tput\n"; close FH;} exit 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -