mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-10-28 17:32:35 +00:00
Support modifying IP/DHCP in wlanpro and other helper scripts.
Fix setting fixed vs IP in lf_associate as well.
This commit is contained in:
@@ -587,7 +587,7 @@ sub fmt_port_cmd {
|
||||
$ist_flags |= 0x4 if($ip ne "NA");
|
||||
$ist_flags |= 0x8 if($::netmask ne "NA");
|
||||
$ist_flags |= 0x20 if($mac_addr ne "NA");
|
||||
$ist_flags |= 0x4000 if($use_dhcp); # what does 'including client-id' mean?
|
||||
$ist_flags |= 0x4000; # Always interested in DHCP, we either set it to DHCP or IP
|
||||
$ist_flags |= 0x800000; # port up
|
||||
|
||||
my $gateway = "0.0.0.0";
|
||||
|
||||
@@ -76,6 +76,10 @@ my $cli_cmd = "";
|
||||
my $log_file = "";
|
||||
my $NOT_FOUND = "-not found-";
|
||||
my $stats_from_file = "";
|
||||
my $ip = "NA"; # DHCP or IP address
|
||||
my $netmask = "NA"; # Netmask, only changed when 'IP' is set.
|
||||
my $gw = "NA"; # Gateway, only changed when 'IP' is set.
|
||||
|
||||
|
||||
########################################################################
|
||||
# Nothing to configure below here, most likely.
|
||||
@@ -110,6 +114,9 @@ my $usage = "$0 --port_name {name | number}
|
||||
[--eap_identity {value|[BLANK]}]
|
||||
[--eap_passwd {value|[BLANK]}]
|
||||
[--log_file {value}] # disabled by default
|
||||
[--ip { DHCP | IPv4 Address }]
|
||||
[--netmask { network mask, only modified if IP is specified as well.]
|
||||
[--gw { network gateway, only modified if IP is specified as well.]
|
||||
[--help|-h ] # show help
|
||||
|
||||
Examples:
|
||||
@@ -119,6 +126,8 @@ Examples:
|
||||
./lf_portmod.pl --manager 192.168.1.101 --cli_cmd \"scan 1 1 sta0\"
|
||||
./lf_portmod.pl --manager 192.168.1.101 --card 1 --port_name eth2 --cmd reset
|
||||
./lf_portmod.pl --manager 192.168.1.101 --card 1 --port_name eth2 --set_ifstate down
|
||||
./lf_portmod.pl --manager 192.168.1.101 --card 1 --port_name eth2 --ip DHCP
|
||||
./lf_portmod.pl --manager 192.168.1.101 --card 1 --port_name eth2 --ip 10.1.1.1 --netmask 255.255.0.0 --gw 10.1.1.254
|
||||
./lf_portmod.pl --manager 192.168.1.101 --card 1 --port_name sta0 --wifi_mode 2 --set_speed \"1 Mbps /b\" \\
|
||||
--ssid fast-ap --passwd \"secret passwd\" --ap DEFAULT
|
||||
./lf_portmod.pl --load my_db
|
||||
@@ -185,6 +194,9 @@ GetOptions
|
||||
'port_stats=s{1,}' => \@port_stats,
|
||||
'eap_identity|i=s' => \$eap_identity,
|
||||
'eap_passwd|p=s' => \$eap_passwd,
|
||||
'ip=s' => \$ip,
|
||||
'netmask=s' => \$netmask,
|
||||
'gw=s' => \$gw,
|
||||
'log_file|l=s' => \$log_file,
|
||||
'log_cli=s{0,1}' => \$log_cli,
|
||||
'wifi_mode=i' => \$wifi_mode,
|
||||
@@ -303,6 +315,43 @@ sub fmt_port_up_down {
|
||||
return $cmd;
|
||||
}
|
||||
|
||||
sub fmt_port_ip {
|
||||
my ($resource, $port_id, $ip, $mask, $gw) = @_;
|
||||
|
||||
my $set_ip = "NA";
|
||||
my $set_mask = "NA";
|
||||
my $set_gw = "NA";
|
||||
|
||||
my $ist_flags = 0;
|
||||
$ist_flags |= 0x4000; # interested in dhcp
|
||||
|
||||
# Specify the interest flags so LANforge knows which flag bits to pay attention to.
|
||||
my $cur_flags = 0;
|
||||
if ($ip eq "DHCP") {
|
||||
$cur_flags |= 0x80000000;
|
||||
}
|
||||
else {
|
||||
$set_ip = $ip;
|
||||
$set_mask = $mask;
|
||||
$set_gw = $gw;
|
||||
|
||||
if ($set_ip ne "NA") {
|
||||
$ist_flags |= (1<<2); # interested in IP
|
||||
}
|
||||
if ($set_mask ne "NA") {
|
||||
$ist_flags |= (1<<3); # interested in netmask
|
||||
}
|
||||
if ($set_gw ne "NA") {
|
||||
$ist_flags |= (1<<4); # interested in gateway
|
||||
}
|
||||
}
|
||||
|
||||
my $cmd = $::utils->fmt_cmd("set_port", 1, $resource, $port_id, "$set_ip",
|
||||
"$set_mask", "$set_gw", "NA", "$cur_flags",
|
||||
"NA", "NA", "NA", "NA", "$ist_flags");
|
||||
return $cmd;
|
||||
}
|
||||
|
||||
sub fmt_wifi_extra {
|
||||
my ($resource, $port_id, $eap_id, $eap_passwd) = @_;
|
||||
my $cmd = $::utils->fmt_cmd("set_wifi_extra", 1, $resource, $port_id,
|
||||
@@ -473,6 +522,11 @@ if ($eap_identity ne "NA" || $eap_passwd ne "NA") {
|
||||
$utils->doCmd($cli_cmd);
|
||||
}
|
||||
|
||||
if ($ip ne "NA") {
|
||||
my $cli_cmd = fmt_port_ip( $card, $port_name, $ip, $netmask, $gw);
|
||||
$utils->doCmd($cli_cmd);
|
||||
}
|
||||
|
||||
if ($cmd eq "reset") {
|
||||
my $pn_int = -1;
|
||||
if ($port_name =~ /^\d+$/ ) {
|
||||
|
||||
@@ -17,7 +17,7 @@ SCRIPTDIR="/home/lanforge/scripts"
|
||||
|
||||
function usage() {
|
||||
echo "$0:
|
||||
--create_sta --name <name> --radio <wiphyX> --security <open|wpa2> --ssid <ssid> --passphrase <wpa2 pass>
|
||||
--create_sta --name <name> --radio <wiphyX> --security <open|wpa2> --ssid <ssid> --passphrase <wpa2 pass> --ip <DHCP | IP-address>
|
||||
--delete_sta --name <name>
|
||||
--show_port --name <name>
|
||||
--list_ports
|
||||
@@ -38,7 +38,8 @@ function usage() {
|
||||
|
||||
Examples:
|
||||
$0 --list_ports --mgr 192.168.1.102 --resource 2
|
||||
$0 --create_sta --resource 2 --name sta100 --radio wiphy0 --security wpa2 --ssid jedtest --passphrase jedtest1
|
||||
$0 --create_sta --resource 2 --name sta100 --radio wiphy0 --security wpa2 --ssid jedtest --passphrase jedtest1 --ip DHCP
|
||||
$0 --create_sta --resource 2 --name sta100 --radio wiphy0 --security wpa2 --ssid jedtest --passphrase jedtest1 --ip 10.1.1.10 --netmask 255.255.255.0
|
||||
$0 --delete_sta --resource 2 --name sta100
|
||||
$0 --up --name sta100
|
||||
$0 --create_cx --name tcp10 --sta sta100 --port eth1 --tcp --bps 1000000
|
||||
@@ -51,7 +52,7 @@ Examples:
|
||||
}
|
||||
## M A I N
|
||||
OPTS="`getopt -o hm:r:n:ud -l help,mgr:,resource:,quiet:,\
|
||||
create_sta,delete_sta,ip:,radio:,name:,ssid:,passphrase:,security:,\
|
||||
create_sta,delete_sta,ip:,radio:,name:,ssid:,passphrase:,security:,ip:,netmask:,\
|
||||
list_ports,list_cx,list_l4,\
|
||||
show_port,endp_vals:,poll_endp,log_cli:,\
|
||||
create_cx,port:,sta:,tcp,udp,bps:,\
|
||||
@@ -66,6 +67,7 @@ fi
|
||||
eval set -- "$OPTS"
|
||||
|
||||
# defualts
|
||||
netmask="255.255.0.0"
|
||||
resource="1"
|
||||
mgr="localhost"
|
||||
action="list"
|
||||
@@ -148,6 +150,12 @@ while true; do
|
||||
--sta)
|
||||
sta="$2"
|
||||
shift 2;;
|
||||
--ip)
|
||||
ip="$2"
|
||||
shift 2;;
|
||||
--netmask)
|
||||
netmask="$2"
|
||||
shift 2;;
|
||||
--port)
|
||||
port="$2"
|
||||
shift 2;;
|
||||
@@ -289,10 +297,9 @@ case "$action" in
|
||||
[ -z "$ssid" ] && usage && echo "No SSID specified." && exit 1
|
||||
[ -z "$security" ] && usage && echo "No WiFi security specified." && exit 1
|
||||
[ -z "$radio" ] && usage && echo "No radio specified." && exit 1
|
||||
[ "$ip" != "DHCP" ] && echo "$0 --ip option only supports DHCP, use lf_portmod.pl or lf_associate_ap.pl to do advanced station creation" && exit 1
|
||||
do_associate --action add \
|
||||
--radio "$radio" --security "$security" --ssid "$ssid" --passphrase "$passphrase" \
|
||||
--first_sta "$name" --first_ip "$ip" --num_stations 1
|
||||
--first_sta "$name" --first_ip "$ip" --netmask "$netmask" --num_stations 1
|
||||
;;
|
||||
|
||||
delete_sta)
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
use strict;
|
||||
use Getopt::Long;
|
||||
use Socket;
|
||||
|
||||
my $pld_size = 500;
|
||||
my $ssid = "wlanpro";
|
||||
@@ -66,6 +67,9 @@ my $wct_duration_sec = 20; # Duration for each iteration
|
||||
my $one_way_test_time = 30;
|
||||
my $bi_test_time = 30;
|
||||
my $interferer_cx = "inteferer_cx";
|
||||
my $ip = "DHCP";
|
||||
my $netmask = "255.255.0.0";
|
||||
my $ipn = 0;
|
||||
|
||||
my $usage = "$0
|
||||
[--pld_size { bytes } ]
|
||||
@@ -91,6 +95,8 @@ my $usage = "$0
|
||||
[--gui_host {LANforge gui_host (127.0.0.1): Must be same as where this script runs.}]
|
||||
[--gui_port {LANforge gui_port (7777): Start your GUI with -cli-port 7777}]
|
||||
[--interferer_cx { name of existing LANforge interferer-cx that we should start for the interference test }]
|
||||
[--ip { DHCP | starting IP address. Default is to use DHCP. }]
|
||||
[--netmask { Ignored if using DHCP, otherwise something like 255.255.255.0. Default is $netmask. }]
|
||||
|
||||
NOTE: The total speed will be multiplied by 1.0 for 3x3 and mixed tests, 0.75 for 2x2 testing,
|
||||
and 0.5 for 1x1 testing. This should still attempt near theoretical throughput without
|
||||
@@ -103,9 +109,14 @@ configured. By default, the intereferer CX name will be 'interferer_cx'.
|
||||
|
||||
Example command:
|
||||
|
||||
# Run test case 5, assumes test case 0 (setup) has already been run.
|
||||
./wlanpro_test.pl --ssid mu-mimo-5G --passphrase hello123 --resource 2 --upstream_resource 1 \
|
||||
--upstream_port eth4 --manager 192.168.100.182 --gui_port 7777 --interferer_cx inter_r3_w0 --testcase 5
|
||||
|
||||
# Run all test cases with Fixed IP addresses (instead of DHCP)
|
||||
./wlanpro_test.pl --ssid mu-mimo-5G --passphrase hello123 --resource 2 --upstream_resource 1 --upstream_port eth4 --manager 192.168.100.182 --gui_host 192.168.100.149 --gui_port 7777 --interferer_cx inter_r3_w0 --testcase -1 --ip 5.5.5.1 --netmask 255.255.255.0
|
||||
|
||||
|
||||
Interesting bugs:
|
||||
|
||||
While testing with a netgear r7800, I noticed that the RX encoding rate received from the AP
|
||||
@@ -149,6 +160,8 @@ GetOptions (
|
||||
'gui_host=s' => \$gui_host,
|
||||
'gui_port=i' => \$gui_port,
|
||||
'interferer_cx=s' => \$interferer_cx,
|
||||
'ip=s' => \$ip,
|
||||
'netmask=s' => \$netmask,
|
||||
) || (print($usage) && exit(1));
|
||||
|
||||
if ($log_name eq "") {
|
||||
@@ -167,6 +180,10 @@ my $brief_log = "$log_prefix";
|
||||
my $summary_text = "$log_prefix";
|
||||
my $mini_summary_text = "$log_prefix";
|
||||
|
||||
if ($ip ne "DHCP") {
|
||||
$ipn = ip2ipn($ip);
|
||||
}
|
||||
|
||||
# Initial setup for test cases, create 40 stations
|
||||
my @cxs = ();
|
||||
my @stations = ();
|
||||
@@ -203,6 +220,10 @@ for ($i = 0; $i<@cx_dump; $i++) {
|
||||
$cmd = "./lf_firemod.pl --mgr $manager --action do_cmd --cmd \"set_cx_state default_tm $interferer_cx STOPPED\"";
|
||||
do_cmd($cmd);
|
||||
|
||||
# Set upstream port to DHCP or fixed IP as requested.
|
||||
$cmd = "./lf_portmod.pl --quiet $quiet --manager $manager --card $upstream_resource --port_name $upstream_port --ip $ip --netmask $netmask";
|
||||
do_cmd($cmd);
|
||||
|
||||
# Set radios to 3x3 mode.
|
||||
if ($testcase == -1 || $testcase == 0) {
|
||||
for ($i = 0; $i<$radio_count; $i++) {
|
||||
@@ -220,7 +241,8 @@ if ($radio_4a =~ /\S+(\d+)/) {
|
||||
my $radio = $radio_4a;
|
||||
$sta_on_4a++;
|
||||
if ($testcase == -1 || $testcase == 0 || $testcase == 6) {
|
||||
$cmd = "./lf_vue_mod.sh --mgr $manager --create_sta --resource $resource --name $sta_name --radio $radio --security $security --ssid $ssid --passphrase $psk";
|
||||
my $_ip = incr_ip();
|
||||
$cmd = "./lf_vue_mod.sh --mgr $manager --create_sta --resource $resource --name $sta_name --radio $radio --security $security --ssid $ssid --passphrase $psk --ip $_ip --netmask $netmask";
|
||||
do_cmd($cmd);
|
||||
|
||||
# Set to maximum mode. The stations might have been
|
||||
@@ -244,7 +266,8 @@ for ($i = 0; $i < $sta_max; $i++) {
|
||||
@stations = (@stations, $sta_name);
|
||||
|
||||
if ($testcase == -1 || $testcase == 0) {
|
||||
$cmd = "./lf_vue_mod.sh --mgr $manager --create_sta --resource $resource --name $sta_name --radio $radio --security $security --ssid $ssid --passphrase $psk";
|
||||
my $_ip = incr_ip();
|
||||
$cmd = "./lf_vue_mod.sh --mgr $manager --create_sta --resource $resource --name $sta_name --radio $radio --security $security --ssid $ssid --passphrase $psk --ip $_ip --netmask $netmask";
|
||||
do_cmd($cmd);
|
||||
|
||||
# Set to maximum mode. The stations might have been
|
||||
@@ -283,7 +306,8 @@ while ($sta_on_4a < $wct_sta_max) {
|
||||
$sta_on_4a++;
|
||||
|
||||
if ($testcase == -1 || $testcase == 0 || $testcase == 6) {
|
||||
$cmd = "./lf_vue_mod.sh --mgr $manager --create_sta --resource $resource --name $sta_name --radio $radio --security $security --ssid $ssid --passphrase $psk";
|
||||
my $_ip = incr_ip();
|
||||
$cmd = "./lf_vue_mod.sh --mgr $manager --create_sta --resource $resource --name $sta_name --radio $radio --security $security --ssid $ssid --passphrase $psk --ip $_ip --netmask $netmask";
|
||||
do_cmd($cmd);
|
||||
|
||||
# Set to maximum mode. The stations might have been
|
||||
@@ -972,5 +996,22 @@ sub uniq {
|
||||
grep !$seen{$_}++, @_;
|
||||
}
|
||||
|
||||
sub incr_ip {
|
||||
if ($ip eq "DHCP") {
|
||||
return "DHCP";
|
||||
}
|
||||
$ipn++;
|
||||
return ipn2ip($ipn);
|
||||
}
|
||||
|
||||
sub ip2ipn {
|
||||
return unpack 'N', inet_aton(shift);
|
||||
}
|
||||
|
||||
sub ipn2ip {
|
||||
return inet_ntoa( pack 'N', shift );
|
||||
}
|
||||
|
||||
|
||||
my @array = qw(one two three two three);
|
||||
my @filtered = uniq(@array);
|
||||
|
||||
Reference in New Issue
Block a user