diff --git a/wifi_diag/wifi_pcap_diag.pl b/wifi_diag/wifi_pcap_diag.pl index 1bf6616e..4d6505e8 100755 --- a/wifi_diag/wifi_pcap_diag.pl +++ b/wifi_diag/wifi_pcap_diag.pl @@ -66,7 +66,7 @@ my $ampdu_pkt_count_total_rx = 0; my $wmm_info = ""; my $dut = ""; -my $report_prefix = "wifi-diag-"; +our $report_prefix = "wifi-diag-"; my $non_dut_frames = 0; my $show_help = 0; my $gen_report = 0; @@ -91,7 +91,7 @@ GetOptions ( 'help|h' => \$show_help, 'dut=s' => \$dut, - 'report_prefix=s' => \$report_prefix, + 'report_prefix=s' => \$::report_prefix, 'gen_report' => \$gen_report, ) || (print STDERR $usage && exit(1)); @@ -100,14 +100,15 @@ if ($show_help) { print $usage; exit 0 } - -my $glb_ba_tx_fname = $report_prefix . "glb-ba-tx-rpt.txt"; -my $glb_ba_rx_fname = $report_prefix . "glb-ba-rx-rpt.txt"; -my $glb_mcs_ps_fname = $report_prefix . "glb-mcs-ps-rpt.txt"; -my $glb_mcs_tx_fname = $report_prefix . "glb-mcs-tx-rpt.txt"; -my $glb_mcs_rx_fname = $report_prefix . "glb-mcs-rx-rpt.txt"; -my $glb_rtx_tx_fname = $report_prefix . "glb-rtx-tx-rpt.txt"; -my $glb_rtx_rx_fname = $report_prefix . "glb-rtx-rx-rpt.txt"; +$::report_prefix .= "/" + if ($report_prefix !~ m{/$}); +my $glb_ba_tx_fname = $::report_prefix . "glb-ba-tx-rpt.txt"; +my $glb_ba_rx_fname = $::report_prefix . "glb-ba-rx-rpt.txt"; +my $glb_mcs_ps_fname = $::report_prefix . "glb-mcs-ps-rpt.txt"; +my $glb_mcs_tx_fname = $::report_prefix . "glb-mcs-tx-rpt.txt"; +my $glb_mcs_rx_fname = $::report_prefix . "glb-mcs-rx-rpt.txt"; +my $glb_rtx_tx_fname = $::report_prefix . "glb-rtx-tx-rpt.txt"; +my $glb_rtx_rx_fname = $::report_prefix . "glb-rtx-rx-rpt.txt"; if ($gen_report) { $report_html .= genGlobalReports(); @@ -218,55 +219,35 @@ sub saveHtmlReport { WiFi Diag Report -

WiFi Diag Report.

+

WiFi Diag Report

); @@ -275,7 +256,8 @@ h1, h2 { $html .= " \n"; - my $tmp = "$report_prefix/index.html"; + my $tmp = "$::report_prefix/index.html"; + $tmp =~ s{//}{/}g; open(my $IDX, ">", $tmp) or die("Can't open $tmp for writing: $!\n"); print $IDX $html; close $IDX; @@ -289,22 +271,23 @@ sub genTimeGnuplot { my $cols = shift; my $graph_data = shift; - my $text ="# auto-generated gnuplot script -#!/usr/bin/gnuplot + my $text =qq(#!/usr/bin/gnuplot +# auto-generated gnuplot script reset set terminal png set xdata time -set timefmt \"\%s\" -set format x \"\%M:\%S\" +set timefmt '\%s' +set format x '\%M:\%S' -set xlabel \"Date\" -set ylabel \"$ylabel\" +set xlabel "Date" +set ylabel '$ylabel' -set title \"$title\" +set title '$title' set key below set grid -plot \"$graph_data\" using $cols title \"$title\"\n"; +plot '$graph_data' using $cols title '$title' +); return $text; } @@ -318,8 +301,10 @@ sub doTimeGraph { my $html = ""; my $text = genTimeGnuplot($ylabel, $title, $cols, $data_file); - my $png_fname = "$report_prefix$out_file"; + my $png_fname = "$::report_prefix/$out_file"; + $png_fname =~ s{//}{/}g; my $tmp = $report_prefix . "_gnuplot_tmp_script.txt"; + $tmp =~ s{//}{/}g; open(my $GP, ">", $tmp) or die("Can't open $tmp for writing: $!\n"); print $GP $text; close $GP; @@ -327,7 +312,7 @@ sub doTimeGraph { print "cmd: $cmd\n"; system($cmd); - $html .= "\"$title\"
\n"; + $html .= qq($title
\n); return $html; } @@ -374,50 +359,50 @@ sub htmlMcsHistogram { $html .= "WMM Info from DUT Beacon

\n$wmm_info
"; } - $html .= "TX Encoding rate histogram.\n + $html .= "

TX Encoding rate histogram.

\n "; foreach my $name (sort {$a <=> $b} keys %glb_mcs_tx_hash) { - $html .= sprintf("\n", $name, $glb_mcs_tx_hash{$name}, ($glb_mcs_tx_hash{$name} * 100.0) / $tx_pkts); + $html .= sprintf(qq(\n), $name, $glb_mcs_tx_hash{$name}, ($glb_mcs_tx_hash{$name} * 100.0) / $tx_pkts); } $html .= "
Rate MbpsPacketsPercentage
%s%s%f
%s%s%f

\n"; - $html .= "RX Encoding rate histogram.\n + $html .= "

RX Encoding rate histogram

\n "; foreach my $name (sort {$a <=> $b} keys %glb_mcs_rx_hash) { - $html .= sprintf("\n", $name, $glb_mcs_rx_hash{$name}, ($glb_mcs_rx_hash{$name} * 100.0) / $rx_pkts); + $html .= sprintf(qq(\n), $name, $glb_mcs_rx_hash{$name}, ($glb_mcs_rx_hash{$name} * 100.0) / $rx_pkts); } - $html .= "
Rate MbpsPacketsPercentage
%s%s%f
%s%s%f

\n"; + $html .= "\n"; - $html .= "TX Packet Type histogram.\n + $html .= "

TX Packet Type histogram

\n "; foreach my $name (sort keys %glb_pkt_type_tx_hash) { - $html .= sprintf("\n", $name, $glb_pkt_type_tx_hash{$name}, ($glb_pkt_type_tx_hash{$name} * 100.0) / $tx_pkts); + $html .= sprintf(qq(\n), $name, $glb_pkt_type_tx_hash{$name}, ($glb_pkt_type_tx_hash{$name} * 100.0) / $tx_pkts); } - $html .= "
TypePacketsPercentage
%s%s%f
%s%s%f

\n"; + $html .= "\n"; - $html .= "RX Packet Type histogram.\n + $html .= "

RX Packet Type histogram

\n "; foreach my $name (sort keys %glb_pkt_type_rx_hash) { - $html .= sprintf("\n", $name, $glb_pkt_type_rx_hash{$name}, ($glb_pkt_type_rx_hash{$name} * 100.0) / $rx_pkts); + $html .= sprintf(qq(\n), $name, $glb_pkt_type_rx_hash{$name}, ($glb_pkt_type_rx_hash{$name} * 100.0) / $rx_pkts); } $html .= "
TypePacketsPercentage
%s%s%f
%s%s%f

\n"; if ($ampdu_chain_tx_count) { - $html .= "TX AMPDU chain count histogram, average: " . $ampdu_pkt_count_total_tx / $ampdu_chain_tx_count . "\n"; + $html .= "

TX AMPDU chain count histogram

Average: " . $ampdu_pkt_count_total_tx / $ampdu_chain_tx_count . "\n"; $html .= ""; foreach my $name (sort {$a <=> $b} keys %glb_ampdu_pkt_count_tx_hash) { - $html .= sprintf("\n", $name, $glb_ampdu_pkt_count_tx_hash{$name}, ($glb_ampdu_pkt_count_tx_hash{$name} * 100.0) / $ampdu_chain_tx_count); + $html .= sprintf(qq(\n), $name, $glb_ampdu_pkt_count_tx_hash{$name}, ($glb_ampdu_pkt_count_tx_hash{$name} * 100.0) / $ampdu_chain_tx_count); } - $html .= "
Chain CountPacketsPercentage
%s%s%f
%s%s%f

\n"; + $html .= "\n"; } if ($ampdu_chain_rx_count) { - $html .= "RX AMPDU chain count histogram, average: " . $ampdu_pkt_count_total_rx / $ampdu_chain_rx_count . "\n"; + $html .= "

RX AMPDU chain count histogram

Average: " . $ampdu_pkt_count_total_rx / $ampdu_chain_rx_count . "\n"; $html .= ""; foreach my $name (sort {$a <=> $b} keys %glb_ampdu_pkt_count_rx_hash) { - $html .= sprintf("\n", $name, $glb_ampdu_pkt_count_rx_hash{$name}, ($glb_ampdu_pkt_count_rx_hash{$name} * 100.0) / $ampdu_chain_rx_count); + $html .= sprintf(qq(\n), $name, $glb_ampdu_pkt_count_rx_hash{$name}, ($glb_ampdu_pkt_count_rx_hash{$name} * 100.0) / $ampdu_chain_rx_count); } - $html .= "
Chain CountPacketsPercentage
%s%s%f
%s%s%f

\n"; + $html .= "\n"; } return $html;