auto-wifi-cap: Support using existing station list.

This can be an easier way to drive this script from yet another
script and/or use existing stations instead of creating our own.
This commit is contained in:
Ben Greear
2018-07-19 12:50:06 -07:00
parent 179ac78524
commit 1add46c602

View File

@@ -27,7 +27,9 @@ use constant shelf_num => 1;
# Default values for ye ole cmd-line args.
our $use_existing_sta = 0;
our $use_existing_cfg = 0;
our $resource = 1;
our $upstream_resource = -1;
our $quiet = "yes";
our $radio = ""; # wiphy0
our $ssid = "my-ssid";
@@ -54,6 +56,8 @@ our @test_text = ();
our $use_pdu_mix = "false";
our $pdu_percent = "pps";
our @pdu_mix = ();
our $use_stations = "";
our @user_stations = ();
our $multicon = -1;
########################################################################
@@ -64,6 +68,7 @@ our $usage = "$0
[--mgr {host-name | IP}]
[--mgr_port {ip port}]
[--resource {number}]
[--upstream_resource {number}]
[--gui_host {LANforge gui_host (127.0.0.1)}]
[--gui_port {LANforge gui_port (7777)}]
[--radio {name,name2,..}] example: wiphy0,wiphy1
@@ -74,6 +79,7 @@ our $usage = "$0
[--ssid {ssid}]
[--num_sta {num-stations-per-radio}] # For each radio.
[--use_existing_sta ] # Assume stations are already properly created and do not re-create.
[--use_existing_cfg ] # Use existing station config
[--upstream {upstream-port-name (eth1)}]
[--first_ip {first-ip-addr | DHCP}]
[--percent_tcp {percent_tcp for mixed traffic type}]
@@ -83,6 +89,7 @@ our $usage = "$0
[--use_pdu_mix { true | (false) }]
[--pdu_percent { bps | (pps) }]
[--pdu_mix { pdu-size:%, pdu-size:%, ... }]
[--use_station { sta1,sta2, ... }] # Specify which stations to use.
[--test_name { my-test-name}]
[--test_text { 'my-test<br>over the air<br>funky-hardware-x<br>OS z'}]
[--multicon { -1: auto, 0 none, 1 new process, 2+ new process + multiple streams}
@@ -104,6 +111,7 @@ GetOptions
'gui_host=s' => \$::gui_host,
'gui_port=i' => \$::gui_port,
'resource=i' => \$::resource,
'upstream_resource=i' => \$::upstream_resource,
'radio=s' => \$::radio,
'speed_ul=i' => \$::speed_ul,
'ul_ps_rate=i' => \$::ul_ps_rate,
@@ -112,6 +120,7 @@ GetOptions
'ssid=s' => \$::ssid,
'num_sta=i' => \$::num_sta,
'use_existing_sta' => \$::use_existing_sta,
'use_existing_cfg' => \$::use_existing_cfg,
'upstream=s' => \$::upstream,
'first_ip=s' => \$::first_ip,
'percent_tcp=i' => \$::percent_tcp,
@@ -124,6 +133,7 @@ GetOptions
'use_pdu_mix=s' => \$::use_pdu_mix,
'pdu_percent=s' => \$::pdu_percent,
'pdu_mix=s' => \@::pdu_mix,
'use_station=s' => \$::use_stations,
'quiet|q=s' => \$::quiet,
'help' => \$::help,
) || die("$::usage");
@@ -132,6 +142,15 @@ if ($::help) {
print $::usage;
exit(0);
}
if ($use_stations ne "") {
@user_stations = split(",", $use_stations);
}
if ($upstream_resource == -1) {
$upstream_resource = $resource;
}
our $mgr_telnet = new Net::Telnet(Prompt => '/default\@btbits\>\>/',
Timeout => 20);
$::mgr_telnet->open(Host => $lfmgr_host,
@@ -175,16 +194,18 @@ if (!$::use_existing_sta) {
}
}
# Create/Set stations on these radios.
for ($i = 0; $i<@radios; $i++) {
my $r = $radios[$i];
if (!$::use_existing_cfg) {
# Create/Set stations on these radios.
for ($i = 0; $i<@radios; $i++) {
my $r = $radios[$i];
print "Creating/Setting $::num_sta virtual stations on resource $::resource radio: $r\n";
system("./lf_associate_ap.pl --mgr $::lfmgr_host --mgr_port $::lfmgr_port --resource $::resource "
." --action add --radio $r --ssid $::ssid "
." --first_sta sta$first_sta --first_ip $::first_ip "
." --num_stations $::num_sta --admin_down_on_add");
$first_sta += $::num_sta;
print "Creating/Setting $::num_sta virtual stations on resource $::resource radio: $r\n";
system("./lf_associate_ap.pl --mgr $::lfmgr_host --mgr_port $::lfmgr_port --resource $::resource "
." --action add --radio $r --ssid $::ssid "
." --first_sta sta$first_sta --first_ip $::first_ip "
." --num_stations $::num_sta --admin_down_on_add");
$first_sta += $::num_sta;
}
}
my $cwd = cwd();
@@ -194,12 +215,22 @@ my $wifi_cap_fname = "wifi_auto_cap_" . $$ . ".txt";
open(CAP, ">$wifi_cap_fname") or die ("Can't open $wifi_cap_fname for writing.\n");
print CAP "__CFG VERSION 1\n";
print CAP "__CFG SEL_PORT 1 $::resource $::upstream\n";
print CAP "__CFG SEL_PORT 1 $::upstream_resource $::upstream\n";
our @sta_list = ();
for ($i = $starting_sta; $i<$first_sta; $i++) {
print CAP "__CFG SEL_PORT 1 $::resource sta$i\n";
push(@sta_list, "sta$i");
if (@user_stations) {
# Use all existing stations on the specified radio
for ($i = 0; $i<@user_stations; $i++) {
my $sta_name = $user_stations[$i];
print CAP "__CFG SEL_PORT 1 $::resource $sta_name\n";
push(@sta_list, "$sta_name");
}
}
else {
for ($i = $starting_sta; $i<$first_sta; $i++) {
print CAP "__CFG SEL_PORT 1 $::resource sta$i\n";
push(@sta_list, "sta$i");
}
}
print CAP "__CFG STA_INCREMENT $::increment\n";