diff --git a/cisco_ap_ctl.py b/cisco_ap_ctl.py new file mode 100644 index 00000000..cf8f16e6 --- /dev/null +++ b/cisco_ap_ctl.py @@ -0,0 +1,193 @@ +#!/usr/bin/python3 +''' +LANforge 192.168.100.178 +Controller at 192.168.100.112 admin/Cisco123 +Controller is 192.1.0.10 +AP is on serial port /dev/ttyUSB1 9600 8 n 1 + +make sure pexpect is installed: +$ sudo yum install python3-pexpect + +You might need to install pexpect-serial using pip: +$ pip3 install pexpect-serial + +./cisco_ap_ctl.py +''' + + +import sys +if sys.version_info[0] != 3: + print("This script requires Python 3") + exit() + +import re +import logging +import time +from time import sleep +import pprint +import telnetlib +import argparse +import pexpect + +default_host = "localhost" +default_ports = { + "serial": None, + "ssh": 22, + "telnet": 23 +} +NL = "\n" +CR = "\r\n" +Q = '"' +A = "'" +FORMAT = '%(asctime)s %(name)s %(levelname)s: %(message)s' +band = "a" +logfile = "stdout" + +# regex101.com , +# this will be in the tx_power script +# ^\s+1\s+6\s+\S+\s+\S+\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+) + +def usage(): + print("$0 used connect to Cisco AP:") + print("-a|--ap: AP to act upon") + print("-d|--dest: destination host") + print("-o|--port: destination port") + print("-u|--user: AP login name") + print("-p|--pass: AP password") + print("-s|--scheme (serial|telnet|ssh): connect to controller via serial, ssh or telnet") + print("--tty Serial port for accessing AP") + print("-l|--log file: log messages here") + print("-b|--band: a (5Ghz) or b (2.4Ghz) or abgn for dual-band 2.4Ghz AP") + print("-z|--action: action") + print("-h|--help") + +# see https://stackoverflow.com/a/13306095/11014343 +class FileAdapter(object): + def __init__(self, logger): + self.logger = logger + def write(self, data): + # NOTE: data can be a partial line, multiple lines + data = data.strip() # ignore leading/trailing whitespace + if data: # non-blank + self.logger.info(data) + def flush(self): + pass # leave it to logging to flush properly + +def main(): + + global logfile + + parser = argparse.ArgumentParser(description="Cisco AP Control Script") + parser.add_argument("-a", "--prompt", type=str, help="ap prompt") + parser.add_argument("-d", "--dest", type=str, help="address of the AP 172.19.27.55") + parser.add_argument("-o", "--port", type=int, help="control port on the AP, 2008") + parser.add_argument("-u", "--user", type=str, help="credential login/username, admin") + parser.add_argument("-p", "--passwd", type=str, help="credential password Wnbulab@123") + parser.add_argument("-s", "--scheme", type=str, choices=["serial", "ssh", "telnet"], help="Connect via serial, ssh or telnet") + parser.add_argument("-t", "--tty", type=str, help="tty serial device for connecting to AP") + parser.add_argument("-l", "--log", type=str, help="logfile for messages, stdout means output to console") + parser.add_argument("-z", "--action", type=str, help="action, current action is powercfg") + + args = None + try: + args = parser.parse_args() + host = args.dest + scheme = args.scheme + port = (default_ports[scheme], args.port)[args.port != None] + user = args.user + passwd = args.passwd + if (args.log != None): + logfile = args.log + filehandler = None + except Exception as e: + logging.exception(e) + usage() + exit(2) + console_handler = logging.StreamHandler() + formatter = logging.Formatter(FORMAT) + logg = logging.getLogger(__name__) + logg.setLevel(logging.DEBUG) + file_handler = None + if (logfile is not None): + if (logfile != "stdout"): + file_handler = logging.FileHandler(logfile, "w") + file_handler.setLevel(logging.DEBUG) + file_handler.setFormatter(formatter) + logg.addHandler(file_handler) + logging.basicConfig(format=FORMAT, handlers=[file_handler]) + else: + # stdout logging + logging.basicConfig(format=FORMAT, handlers=[console_handler]) + egg = None # think "eggpect" + ser = None + try: + if (scheme == "serial"): + #eggspect = pexpect.fdpexpect.fdspan(telcon, logfile=sys.stdout.buffer) + import serial + from pexpect_serial import SerialSpawn + ser = serial.Serial(args.tty, 9600, timeout=5) + print("Created serial connection on %s, open: %s"%(args.tty, ser.is_open)) + egg = SerialSpawn(ser) + egg.logfile = FileAdapter(logg) + time.sleep(1) + elif (scheme == "ssh"): + if (port is None): + port = 22 + cmd = "ssh -p%d %s@%s"%(port, user, host) + logg.info("Spawn: "+cmd+NL) + egg = pexpect.spawn(cmd) + #egg.logfile_read = sys.stdout.buffer + egg.logfile = FileAdapter(logg) + i = egg.expect(["password:", "continue connecting (yes/no)?"], timeout=3) + time.sleep(0.1) + if i == 1: + egg.sendline('yes') + egg.expect('password:') + sleep(0.1) + egg.sendline(args.passwd) + elif (scheme == "telnet"): + if (port is None): + port = 23 + cmd = "telnet {} {}".format(host, port) + logg.info("Spawn: "+cmd+NL) + egg = pexpect.spawn(cmd) + egg.logfile = FileAdapter(logg) + # Will login below as needed. + else: + usage() + exit(1) + except Exception as e: + logging.exception(e) + + ap_prompt = "{}>".format(args.prompt) + ap_hash = "{}#".format(args.prompt) + egg.sendline() + + egg.sendline() + time.sleep(0.1) + egg.expect('Username:', timeout=3) + time.sleep(0.1) + egg.sendline(args.user) + time.sleep(0.1) + egg.expect('Password:') + egg.sendline(args.passwd) + egg.expect(ap_prompt) + egg.sendline("en") + egg.expect("Password:") + egg.sendline(args.passwd) + egg.expect("#") + egg.sendline('show controllers dot11Radio 1 powercfg | g T1') + egg.expect("--More--") + egg.sendcontrol('c') + egg.expect("#",timeout=5) + egg.sendline("exit") + egg.excect(">",timeout=5) + egg.sendline("exit") + + # ctlr.execute(cn_cmd) +if __name__ == '__main__': + main() + +#### +#### +#### diff --git a/cisco_wifi_ctl.py b/cisco_wifi_ctl.py index 58c09c37..25393d6a 100755 --- a/cisco_wifi_ctl.py +++ b/cisco_wifi_ctl.py @@ -349,7 +349,7 @@ def main(): found_escape = False if j == 5: - logg.info("9800 timed out looking for CCP,CCP_EN,User:,Password:,CCP_CONFIG loop_count {} i {} j {} before {} after {}".format(CCP,CCP_EN,CCP_CONFIG,loop_count,i,j,egg.before,egg.after)) + logg.info("9800 timed out looking for CCP :{},CCP_EN: {},CCP_CONFIG: {} loop_count {} i {} j {} before {} after {}".format(CCP,CCP_EN,CCP_CONFIG,loop_count,i,j,egg.before,egg.after)) logg.info("9800 Closing the connection and try to re-establish loop_count {} i {} j {}".format(loop_count,i,j)) egg.close(force = True) sleep(1) @@ -567,9 +567,9 @@ def main(): if i == 0: logg.info("9800 found Escape character is '^] i:{} before: {} after: {}".format(i,egg.before,egg.after)) - #egg.sendline(CR) + egg.sendline(CR) # 1/18/2021 - may need a bit more logic found_escape = True - sleep(0.1) + sleep(0.2) j = egg.expect_exact([CCP,CCP_EN,"User:","Password:",CCP_CONFIG,pexpect.TIMEOUT],timeout=3) sleep(0.1) if j == 0: @@ -1108,13 +1108,16 @@ def main(): else: command = "show ap channel %s"%(args.ap) + if (args.action == "no_wlan_wireless_tag_policy" and (args.wlan is None)): + raise Exception("wlan is required") if (args.action == "no_wlan_wireless_tag_policy"): logg.info("send wireless tag policy no wlan") + logg.info("send wireless tag policy no wlan , for wlan {}".format(args.wlan)) egg.sendline("config t") sleep(0.1) i = egg.expect_exact(["(config)#",pexpect.TIMEOUT],timeout=2) if i == 0: - for command in ["wireless tag policy default-policy-tag","no wlan open-wlan policy default-policy-profile"]: + for command in ["wireless tag policy default-policy-tag","no wlan {} policy default-policy-profile".format(args.wlan)]: egg.sendline(command) sleep(1) j = egg.expect_exact([CCP_POLICY_TAG,pexpect.TIMEOUT],timeout=2) @@ -1187,13 +1190,8 @@ def main(): logg.info("did not get the (config)# prompt") if (args.action == "show_wlan_summary"): - egg.sendline("show wlan summary") - sleep(0.1) - i = egg.expect([CCP_EN,pexpect.TIMEOUT],timeout=2) - if i == 0: - logg.info("show wlan summary sent") - if i == 1: - logg.info("show wlan summary timed out") + print("command show wlan summary ") + command = "show wlan summary" if (args.action == "create_wlan" and ((args.wlanID is None) or (args.wlan is None))): raise Exception("wlan and wlanID is required an") @@ -1205,14 +1203,27 @@ def main(): i = egg.expect_exact(["(config)#",pexpect.TIMEOUT],timeout=2) if i == 0: logg.info("elevated to (config)#") - command = "wlan %s %s %s"%(args.wlan, args.wlanID, args.wlan) + command = "wlan %s %s %s"%(args.wlan, args.wlanID, args.wlan) # should the last one be ssid not wlan logg.info("open network command {}".format(command)) egg.sendline(command) sleep(0.4) j = egg.expect_exact([CCP_CONFIG_WLAN,pexpect.TIMEOUT],timeout=2) if j == 0: - for command in ["shutdown","no security ft","no security wpa","no security wpa wpa2","no security wpa wpa2 ciphers aes", - "no security wpa akm dot1x","no shutdown"]: + # previous commands for command in ["shutdown","no security ft","no security wpa","no security wpa wpa2","no security wpa wpa2 ciphers aes", + # "no security wpa akm dot1x","no shutdown"]: + + # 1/14/2021 - Cisco suggestion + # We are basically disabling all the possible security parameters for Authentication + for command in [ + "no security ft", + "no security ft adaptive", + "no security wpa", + "no security wpa wpa2", + "no security wpa wpa1", + "no security wpa wpa2 ciphers aes" + "no security dot1x authentication-list", + "no security wpa akm dot1x", + "no shutdown"]: egg.sendline(command) sleep(1) k = egg.expect_exact([CCP_CONFIG_WLAN,pexpect.TIMEOUT],timeout=2) diff --git a/lf_cisco_power.py b/lf_cisco_power.py index 5d66f05e..1a0dfdfe 100755 --- a/lf_cisco_power.py +++ b/lf_cisco_power.py @@ -220,6 +220,8 @@ def usage(): print('-e','--email', "--email user== passwd== to== smtp== port== 465 (SSL)") print('-ccp','--prompt', "--prompt controller prompt default WLC") print('--beacon_dbm_diff', "--beacon_dbm_diff is the delta that is allowed between the controller tx and the beacon measured") + print('--show_lf_portmod'," show the output of lf_portmod after traffic to verify RSSI values measured by lanforge") + print("-h|--help") @@ -285,13 +287,13 @@ def main(): parser.add_argument("--pf_a4_dropoff", type=str, help="Allow one chain to use lower tx-power and still pass when doing 4x4. Default is 3") parser.add_argument("--wait_forever", action='store_true', help="Wait forever for station to associate, may aid debugging if STA cannot associate properly") parser.add_argument("--adjust_nf", action='store_true', help="Adjust RSSI based on noise-floor. ath10k without the use-real-noise-floor fix needs this option") - parser.add_argument("--wlan", type=str, help="--wlan 9800, wlan identifier default wlan-open",required=True) + parser.add_argument("--wlan", type=str, help="--wlan 9800, wlan identifier, this must match the -ssid",required=True) parser.add_argument("--wlanID", type=str, help="--wlanID 9800 , defaults to 1",default="1",required=True) parser.add_argument("--series", type=str, help="--series 9800 or 3504, defaults to 9800",default="9800") parser.add_argument("--slot", type=str, help="--slot 1 , 9800 AP slot defaults to 1",default="1") parser.add_argument("--create_station", type=str, help="create LANforge station at the beginning of the test") parser.add_argument("--radio", type=str, help="radio to create LANforge station on at the beginning of the test") - parser.add_argument("--ssid", type=str, help="ssid",required=True) + parser.add_argument("--ssid", type=str, help="ssid, this must patch the wlan",required=True) parser.add_argument("--ssidpw", type=str, help="ssidpw",required=True) parser.add_argument("--security", type=str, help="security",required=True) parser.add_argument("--cleanup", action='store_true',help="--cleanup , Clean up stations after test completes ") @@ -302,6 +304,9 @@ def main(): parser.add_argument('-e','--email', action='append', nargs=1, type=str, help="--email user== passwd== to== smtp== port== 465 (SSL)") parser.add_argument('-ccp','--prompt', type=str,help="controller prompt",required=True) parser.add_argument('--beacon_dbm_diff', type=str,help="--beacon_dbm_diff is the delta that is allowed between the controller tx and the beacon measured",default="7") + parser.add_argument('--show_lf_portmod', action='store_true',help="--show_lf_portmod, show the output of lf_portmod after traffic to verify RSSI values measured by lanforge") + parser.add_argument('-ap','--ap', action='append', nargs=1, type=str, help="--ap ap_scheme== ap_prompt== ap_ip== ap_port== ap_user== ap_pw==") + #current_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + "{:.3f}".format(time.time() - (math.floor(time.time())))[1:] #print(current_time) @@ -343,7 +348,12 @@ def main(): # capture the controller output , thus won't got to stdout some output always present cap_ctl_out = False else: - cap_ctl_out = True + cap_ctl_out = True + if (args.wlan != args.ssid): + print("####### ERROR ################################") + print("wlan: {} must equial the station ssid: {}".format(args.wlan,args.ssid)) + print("####### ERROR ################################") + exit(1) # note: there would always be an args.outfile due to the default current_time = time.strftime("%m_%d_%Y_%H_%M_%S", time.localtime()) outfile = "{}_{}.txt".format(args.outfile,current_time) @@ -355,6 +365,20 @@ def main(): if args.log: outfile_log = "{}_{}_output_log.log".format(args.outfile,current_time) print("output file log: {}".format(outfile_log)) + + ap_dict = [] + if args.ap_info: + ap_info = args.ap_info + for _ap_info in ap_info: + print("ap_info {}".format(_ap_info)) + ap_keys = ['ap_scheme','ap_prompt','ap_ip','ap_port','ap_user','ap_pw'] + ap_dict = dict(map(lambda x: x.split('=='), str(_ap_info).replace('[','').replace(']','').replace("'","").split())) + for key in ap_keys: + if key not in ap_dict: + print("missing ap config, for the {}, all these need to be set {} ".format(key,ap_keys)) + exit(1) + print("ap_dict: {}".format(ap_dict)) + email_dicts = [] if args.email: emails = args.email @@ -397,6 +421,8 @@ def main(): logging.basicConfig(format=FORMAT, handlers=[console_handler]) #logg.addHandler(logging.StreamHandler()) # allows to logging to file and stderr + if bool(ap_dict): + logg.info("ap_dict {}".format(ap_dict)) if bool(email_dicts): logg.info("email_dicts {}".format(email_dicts)) @@ -519,6 +545,8 @@ def main(): col = 0 row = 0 worksheet.write(row, col, 'Regulatory\nDomain', dblue_bold); col += 1 + worksheet.set_column(col, col, 10) # Set width + worksheet.write(row, col, 'Controller\nChannel', dblue_bold); col += 1 worksheet.write(row, col, 'AP\nChannel', dblue_bold); col += 1 worksheet.write(row, col, 'NSS', dblue_bold); col += 1 worksheet.set_column(col, col, 10) # Set width @@ -631,7 +659,13 @@ def main(): pss = advanced.stdout.decode('utf-8', 'ignore'); logg.info(pss) except subprocess.CalledProcessError as process_error: - logg.info("Controller unable to commicate to AP or unable to communicate to controller error code {} output {}".format(process_error.returncode, process_error.output)) + logg.info("####################################################################################################") + logg.info("# CHECK IF CONTROLLER HAS TELNET CONNECTION ALREADY ACTIVE") + logg.info("####################################################################################################") + + logg.info("####################################################################################################") + logg.info("# Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}".format(process_error.returncode, process_error.output)) + logg.info("####################################################################################################") exit_test(workbook) try: @@ -663,7 +697,8 @@ def main(): continue # the summaries are different between the 9800 series controller and the 3504 series # if the output changes then the following pattern/regular expression parcing needs to be changed - # this site may help: https://regex101.com/ + # this site may help: https://regex101.com/ + # when using https://regex101.com/ for tool beginning of string begins with ^ if (searchap): if args.series == "9800": pat = "%s\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+(\S+)"%(args.ap) @@ -844,6 +879,20 @@ def main(): logg.info("Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}".format(process_error.returncode, process_error.output)) exit_test(workbook) + if (bw != "NA"): + try: + logg.info("9800/3504 cisco_wifi_ctl.py: bandwidth 20 prior to setting channel, some channels only support 20") + ctl_output = subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band, + "--action", "bandwidth", "--value", "20", "--series" , args.series,"--port", args.port,"--prompt",args.prompt],capture_output=cap_ctl_out, check=True) + if cap_ctl_out: + pss = ctl_output.stdout.decode('utf-8', 'ignore') + logg.info(pss) + + except subprocess.CalledProcessError as process_error: + logg.info("Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}".format(process_error.returncode, process_error.output)) + exit_test(workbook) + + # NSS is set on the station earlier... if (ch != "NA"): logg.info("9800/3504 test_parameters set channel: {}".format(ch)) @@ -878,7 +927,49 @@ def main(): if wlan_created: logg.info("wlan already present, no need to create wlan {} wlanID {} port {}".format(args.wlan, args.wlanID, args.port)) pass - else: + else: + # Verify that a wlan does not exist on wlanID + # delete the wlan if already exists + try: + logg.info("9800 cisco_wifi_ctl.py: show_wlan_summary") + wlan_info = subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band, + "--action", "show_wlan_summary","--series" , args.series,"--port", args.port,"--prompt",args.prompt], capture_output=True, check=True) + pss = wlan_info.stdout.decode('utf-8', 'ignore') + logg.info(pss) + except subprocess.CalledProcessError as process_error: + logg.info("Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}".format(process_error.returncode, process_error.output)) + exit_test(workbook) + + # "number of WLANs:\s+(\S+)" + search_wlan = False + for line in pss.splitlines(): + logg.info(line) + if (line.startswith("---------")): + search_wlan = True + continue + if (search_wlan): + pat = "{}\s+(\S+)\s+(\S+)".format(args.wlanID) + m = re.search(pat, line) + if (m != None): + cc_wlan = m.group(1) + cc_wlan_ssid = m.group(2) + # wlanID is in use + logg.info("###############################################################################") + logg.info("Need to remove wlan: {} wlanID: {} wlan ssid: {}".format(cc_wlan, args.wlanID, cc_wlan_ssid)) + logg.info("###############################################################################") + try: + logg.info("9800 cisco_wifi_ctl.py: delete_wlan, wlan present at start of test: wlan: {} wlanID: {} wlan_ssid: {}".format(cc_wlan, args.wlanID, cc_wlan_ssid)) + ctl_output = subprocess.run(["./cisco_wifi_ctl.py", "--scheme", scheme, "-d", args.dest, "-u", args.user, "-p", args.passwd, "-a", args.ap, "--band", band, + "--action", "delete_wlan","--series",args.series, "--wlan", args.wlan, "--wlanID", args.wlanID,"--port",args.port,"--prompt",args.prompt], capture_output=cap_ctl_out, check=True) + if cap_ctl_out: + pss = ctl_output.stdout.decode('utf-8', 'ignore') + logg.info(pss) + + except subprocess.CalledProcessError as process_error: + logg.info("Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}".format(process_error.returncode, process_error.output)) + exit_test(workbook) + + # Create wlan wlan_created = True logg.info("create wlan {} wlanID {} port {}".format(args.wlan, args.wlanID, args.port)) try: @@ -1179,7 +1270,7 @@ def main(): subprocess.run(["./lf_firemod.pl", "--manager", lfmgr, "--resource", lfresource, "--action", "do_cmd", "--cmd", "set_cx_state all c-udp-power RUNNING"], capture_output=True, check=True) - # Wait 10 more seconds + # Wait configured number of seconds more seconds logg.info("Waiting {} seconds to let traffic run for a bit, Channel {} NSS {} BW {} TX-Power {}".format(args.duration,ch, n, bw, tx)) time.sleep(int(args.duration)) @@ -1194,8 +1285,10 @@ def main(): port_stats = subprocess.run(["./lf_portmod.pl", "--manager", lfmgr, "--card", lfresource, "--port_name", lfstation, "--cli_cmd", "probe_port 1 %s %s"%(lfresource, lfstation)],capture_output=True, check=True) pss = port_stats.stdout.decode('utf-8', 'ignore') - logg.info("./lf_portmod.pl --manager {} --card {} --port_name {} --cli_cmd probe_port 1 {} {}".format(lfmgr, lfresource, lfstation,lfresource,lfstation)) - logg.info(pss) + # for debug: print the output of lf_portmod.pl and the command used + if (args.show_lf_portmod): + logg.info("./lf_portmod.pl --manager {} --card {} --port_name {} --cli_cmd probe_port 1 {} {}".format(lfmgr, lfresource, lfstation,lfresource,lfstation)) + logg.info(pss) foundit = False for line in pss.splitlines(): @@ -1339,7 +1432,7 @@ def main(): pi = int(pathloss) ag = int(antenna_gain) calc_dbm_beacon = int(beacon_sig) + pi + rssi_adj + ag - logg.info("calc_dbm_beacon".format(calc_dbm_beacon)) + logg.info("calc_dbm_beacon {}".format(calc_dbm_beacon)) logg.info("sig: %s"%sig) calc_dbm = int(sig) + pi + rssi_adj + ag @@ -1471,7 +1564,76 @@ def main(): failed_low += 1 least = min(least, diff_a4) - if ((least < (-pfrange - pf_a4_dropoff)) or (failed_low >= 1)): + failed_low_treshold = 1 + # + # + # If the ap dictionary is set the read the AP to see the number + # of spatial streams used. For tx power 1 the AP may determine to use + # fewer spatial streams + # + # + P1 = None + T1 = None + P2 = None + T2 = None + P3 = None + T3 = None + P4 = None + T4 = None + N_ANT = None + DAA_Pwr = None + DAA_N_TX = None + DAA_Total_pwr = None + if(bool(ap_dict)): + logg.info("Read AP ap_scheme: {} ap_ip: {} ap_port: {} ap_user: {} ap_pw: {}".format(ap_dict['ap_scheme'],ap_dict['ap_ip'],ap_dict["ap_port"], + ap_dict['ap_user'],ap_dict['ap_pw'])) + try: + logg.info("cisco_ap_ctl.py: no_logging_console") + ap_info= subprocess.run(["./cisco_ap_ctl.py", "--scheme", ap_dict['ap_scheme'], "--prompt", ap_dict['ap_prompt'],"--dest", ap_dict['ap_ip'], "--port", ap_dict["ap_port"], + "-user", ap_dict['ap_user'], "-passwd", ap_dict['ap_pw'],"--action", "powercfg"],capture_output=True, check=True) + pss = ap_info.stdout.decode('utf-8', 'ignore'); + logg.info(pss) + except subprocess.CalledProcessError as process_error: + logg.info("####################################################################################################") + logg.info("# CHECK IF AP HAS TELNET CONNECTION ALREADY ACTIVE") + logg.info("####################################################################################################") + + logg.info("####################################################################################################") + logg.info("# Unable to commicate to AP or unable to communicate to controller error code: {} output {}".format(process_error.returncode, process_error.output)) + logg.info("####################################################################################################") + #exit_test(workbook) + exit(1) + + for line in pss.splitlines(): + logg.info("ap {}".format(line)) + m = re.search('^\s+1\s+6\s+\S+\s+\S+\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)') + if (m != None): + P1 = m.group(1) + T1 = m.group(2) + P2 = m.group(3) + T2 = m.group(4) + P3 = m.group(5) + T3 = m.group(6) + P4 = m.group(7) + T4 = m.group(8) + N_ANT = m.group(9) + DAA_Pwr = m.group(10) + DAA_N_TX = m.group(11) + DAA_Total_pwr = m.group(12) + print("P1: {} T1: {} P2: {} T2: {} P3: {} T3: {} P4: {} T4: {} N_ANT: {} DAA_Pwr: {} DAA_N_TX: {} DAA_Total_pwr: {}" + .format(P1,T1,P2,T2,P3,T3,P4,T4,N_ANT,DAA_Pwr,DAA_N_TX,DAA_Total_pwr)) + + else: + logg.info("AP Check regular expression!!!") + exit(1) + + + + # + # The controller may adjust the number of spatial streams to allow for the + # best power values + # + if ((least < (-pfrange - pf_a4_dropoff)) or (failed_low >= failed_low_treshold)): pf = 0 if (diff_a1 > pfrange): @@ -1513,6 +1675,7 @@ def main(): col = 0 worksheet.write(row, col, myrd, center_blue); col += 1 + worksheet.write(row, col, cc_ch, center_blue); col += 1 worksheet.write(row, col, _ch, center_blue); col += 1 worksheet.write(row, col, _nss, center_blue); col += 1 worksheet.write(row, col, cc_bw, center_blue); col += 1 diff --git a/py-json/create_wanlink.py b/py-json/create_wanlink.py index 3e1f00e8..74d0d9cc 100755 --- a/py-json/create_wanlink.py +++ b/py-json/create_wanlink.py @@ -30,6 +30,9 @@ def main(): num_wanlinks = -1 # see if there are old wanlinks to remove lf_r = LFRequest.LFRequest(base_url+"/wl/list") + + port_a ="rd0a" + port_b ="rd1a" try: json_response = lf_r.getAsJson() LFUtils.debug_printer.pprint(json_response) @@ -69,7 +72,7 @@ def main(): 'alias': 'wl_eg1-A', 'shelf': 1, 'resource': '1', - 'port': 'eth3', + 'port': port_a, 'latency': '75', 'max_rate': '128000', 'description': 'cookbook-example' @@ -83,7 +86,7 @@ def main(): 'alias': 'wl_eg1-B', 'shelf': 1, 'resource': '1', - 'port': 'eth5', + 'port': port_b, 'latency': '95', 'max_rate': '256000', 'description': 'cookbook-example' diff --git a/py-json/create_sta.py b/py-json/old-examples/create_sta.py similarity index 100% rename from py-json/create_sta.py rename to py-json/old-examples/create_sta.py diff --git a/py-json/generic_cx.py b/py-json/old-examples/generic_cx.py similarity index 96% rename from py-json/generic_cx.py rename to py-json/old-examples/generic_cx.py index de0e77b1..1db36b8b 100755 --- a/py-json/generic_cx.py +++ b/py-json/old-examples/generic_cx.py @@ -1,4 +1,7 @@ #!/usr/bin/env python3 +""" +This script is out-dated, please see py-scripts/test_ipv4_variable_time.py +""" import sys import pprint from pprint import pprint diff --git a/py-json/test_l4.py b/py-json/old-examples/test_l4.py similarity index 100% rename from py-json/test_l4.py rename to py-json/old-examples/test_l4.py diff --git a/py-json/wct-example.py b/py-json/old-examples/wct-example.py similarity index 97% rename from py-json/wct-example.py rename to py-json/old-examples/wct-example.py index 59e03302..0d1e1410 100755 --- a/py-json/wct-example.py +++ b/py-json/old-examples/wct-example.py @@ -2,7 +2,8 @@ ''' # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - -# Example of how to operate a WCT instance using cli-socket - +# Example of how to operate a WCT instance using cli-socket. - +# This script is out-dated. Please refer to py-scripts/run_cv_scenario.py - # - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - make sure pexpect is installed: @@ -156,4 +157,4 @@ if __name__ == '__main__': #### #### -#### \ No newline at end of file +#### diff --git a/py-json/realm.py b/py-json/realm.py index 9bae7241..b555d6e8 100755 --- a/py-json/realm.py +++ b/py-json/realm.py @@ -822,14 +822,21 @@ class Realm(LFCliBase): def new_test_group_profile(self): return TestGroupProfile(self.lfclient_host, self.lfclient_port, local_realm=self, debug_=self.debug) +<<<<<<< HEAD class BaseProfile(LFCliBase): def __init__(self, local_realm): self.parent_realm = local_realm +======= +class BaseProfile(LFCliBase): + def __init__(self,local_realm): + self.parent_realm=local_realm +>>>>>>> e9a071eff8cfb397f9534ea865f8450e43078cee self.halt_on_error = False self.exit_on_error = False def json_get(self, target): +<<<<<<< HEAD return self.parent_realm.json_get(target) def json_post(self, req_url, data, debug_=False, suppress_related_commands_=None): @@ -868,6 +875,10 @@ class BaseProfile(LFCliBase): def wait_until_cxs_appear(self, target, debug=False): return self.parent_realm.wait_until_cxs_appear(target, debug=False) +======= + self.debug_ = False + return self.parent_realm.json_get(self,target) +>>>>>>> e9a071eff8cfb397f9534ea865f8450e43078cee class MULTICASTProfile(LFCliBase): def __init__(self, lfclient_host, lfclient_port, local_realm, @@ -1044,6 +1055,7 @@ class MULTICASTProfile(LFCliBase): pprint.pprint(self) +<<<<<<< HEAD class L3CXProfile(BaseProfile): def __init__(self, lfclient_host, @@ -1061,6 +1073,16 @@ class L3CXProfile(BaseProfile): name_prefix_="Unset", number_template_="00000", debug_=False): +======= + +class L3CXProfile(BaseProfile): + def __init__(self, lfclient_host, lfclient_port, local_realm, + side_a_min_bps=None, side_b_min_bps=None, + side_a_max_bps=0, side_b_max_bps=0, + side_a_min_pdu=-1, side_b_min_pdu=-1, + side_a_max_pdu=0, side_b_max_pdu=0, + report_timer_=3000, name_prefix_="Unset", number_template_="00000", debug_=False): +>>>>>>> e9a071eff8cfb397f9534ea865f8450e43078cee """ :param lfclient_host: :param lfclient_port: @@ -1137,13 +1159,21 @@ class L3CXProfile(BaseProfile): monitor_interval=1, col_names=None, created_cx=None, +<<<<<<< HEAD monitor=True, +======= + show=True, +>>>>>>> e9a071eff8cfb397f9534ea865f8450e43078cee report_file=None, output_format=None, script_name=None, arguments=None): try: +<<<<<<< HEAD duration_sec = self.parse_time(duration_sec).seconds +======= + duration_sec=self.local_realm.parse_time(duration_sec).seconds +>>>>>>> e9a071eff8cfb397f9534ea865f8450e43078cee except: if (duration_sec is None) or (duration_sec <= 1): raise ValueError("L3CXProfile::monitor wants duration_sec > 1 second") @@ -1164,6 +1194,7 @@ class L3CXProfile(BaseProfile): else: output_format = report_file.split('.')[-1] +<<<<<<< HEAD # Step 1, column names if fields = None: pass @@ -1171,6 +1202,12 @@ class L3CXProfile(BaseProfile): fields = ",".join(col_names) print(fields) # Step 2, monitor columns +======= + #Step 1, column names + fields=",".join(col_names) + print(fields) + #Step 2, monitor columns +>>>>>>> e9a071eff8cfb397f9534ea865f8450e43078cee start_time = datetime.datetime.now() end_time = start_time + datetime.timedelta(seconds=duration_sec) print(end_time) @@ -1179,6 +1216,7 @@ class L3CXProfile(BaseProfile): passes = 0 expected_passes = 0 old_cx_rx_values = self.__get_rx_values() +<<<<<<< HEAD timestamps = [] # for x in range(0,int(round(iterations,0))): if col_names = None: @@ -1188,6 +1226,12 @@ class L3CXProfile(BaseProfile): response = self.json_get("/endp/all") else: response = self.json_get("/endp/%s?fields=%s" % (created_cx, fields)) +======= + timestamps=[] + #for x in range(0,int(round(iterations,0))): + while datetime.datetime.now() < end_time: + response = self.json_get("/endp/%s?fields=%s" % (created_cx, fields)) +>>>>>>> e9a071eff8cfb397f9534ea865f8450e43078cee if "endpoint" not in response: print(response) raise ValueError("no endpoint?") @@ -1213,8 +1257,15 @@ class L3CXProfile(BaseProfile): time.sleep(monitor_interval) print(value_map) +<<<<<<< HEAD # step 3 organize data endpoints = list() +======= + #if passes == expected_passes: + #self._pass("PASS: All tests passed") + #step 3 organize data + endpoints=list() +>>>>>>> e9a071eff8cfb397f9534ea865f8450e43078cee for endpoint in value_map.values(): endpoints.append(endpoint['endpoint']) endpoints2 = [] @@ -1226,11 +1277,19 @@ class L3CXProfile(BaseProfile): itertools.chain.from_iterable(itertools.repeat(x, len(created_cx.split(','))) for x in timestamps)) for point in range(0, len(endpoints2)): endpoints2[point].insert(0, timestamps2[point]) +<<<<<<< HEAD # step 4 save and close header_row = col_names header_row.insert(0, 'Timestamp') print(header_row) if output_format.lower() in ['excel', 'xlsx'] or report_file.split('.')[-1] == 'xlsx': +======= + #step 4 save and close + header_row=col_names + print(header_row) + header_row.insert(0,'Timestamp') + if output_format.lower() in ['excel','xlsx'] or report_file.split('.')[-1] == 'xlsx': +>>>>>>> e9a071eff8cfb397f9534ea865f8450e43078cee report_fh = open(report_file, "w+") workbook = xlsxwriter.Workbook(report_file) worksheet = workbook.add_worksheet() @@ -1286,9 +1345,15 @@ class L3CXProfile(BaseProfile): def refresh_cx(self): for cx_name in self.created_cx.keys(): +<<<<<<< HEAD self.json_post("/cli-json/show_cxe", { "test_mgr": "ALL", "cross_connect": cx_name +======= + self.local_realm.json_post("/cli-json/show_cxe", { + "test_mgr": "ALL", + "cross_connect": cx_name +>>>>>>> e9a071eff8cfb397f9534ea865f8450e43078cee }, debug_=self.debug) print(".", end='') @@ -1296,8 +1361,13 @@ class L3CXProfile(BaseProfile): print("Starting CXs...") for cx_name in self.created_cx.keys(): if self.debug: +<<<<<<< HEAD print("cx-name: %s" % (cx_name)) self.json_post("/cli-json/set_cx_state", { +======= + print("cx-name: %s"%(cx_name)) + self.local_realm.json_post("/cli-json/set_cx_state", { +>>>>>>> e9a071eff8cfb397f9534ea865f8450e43078cee "test_mgr": "default_tm", "cx_name": cx_name, "cx_state": "RUNNING" @@ -3498,7 +3568,7 @@ class StationProfile: # First, request remove on the list. for port_eid in desired_stations: self.local_realm.rm_port(port_eid, check_exists=True, debug_=debug_) - + time.sleep(delay) # And now see if they are gone LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, port_list=desired_stations) diff --git a/py-json/wlan_test.py b/py-json/wlan_theoretical_sta.py similarity index 85% rename from py-json/wlan_test.py rename to py-json/wlan_theoretical_sta.py index 10506e67..33da6451 100644 --- a/py-json/wlan_test.py +++ b/py-json/wlan_theoretical_sta.py @@ -1,5 +1,10 @@ ''' +Candela Technologies Inc. +Info : Standard Script for WLAN Capaity Calculator +Date : +Author : Anjali Rahamatkar + This Script has three classes : 1. abg11_calculator : It will take all the user input of 802.11a/b/g station,calculate Intermediate values and Theoretical values. 2. n11_calculator : It will take all the user input of 802.11n station,calculate Intermediate values and Theoretical values. @@ -15,7 +20,8 @@ import json # Class to take all user input (802.11a/b/g Standard) -class abg11_calculator: + +class abg11_calculator(): def __init__(self, Traffic_Type, PHY_Bit_Rate, Encryption, QoS, MAC_Frame_802_11, Basic_Rate_Set, Preamble, slot_name, Codec_Type, RTS_CTS_Handshake, CTS_to_self): @@ -31,9 +37,77 @@ class abg11_calculator: self.RTS_CTS_Handshake = RTS_CTS_Handshake self.CTS_to_self = CTS_to_self + + + # This function is for calculate intermediate values and Theoretical values - def input_parameter(self): + @staticmethod + def create_argparse(prog=None, formatter_class=None, epilog=None, description=None): + if (prog is not None) or (formatter_class is not None) or (epilog is not None) or (description is not None): + ap = argparse.ArgumentParser(prog=prog, + formatter_class=formatter_class, + allow_abbrev=True, + epilog=epilog, + description=description) + else: + ap = argparse.ArgumentParser() + + # Station : 11abg + + ap.add_argument("-sta", "--station", help="Enter Station Name : [11abg,11n,11ac](by Default 11abg)") + ap.add_argument("-t", "--traffic", help="Enter the Traffic Type : [Data,Voice](by Default Data)") + ap.add_argument("-p", "--phy", + help="Enter the PHY Bit Rate of Data Flow : [1, 2, 5.5, 11, 6, 9, 12, 18, 24, 36, 48, 54](by Default 54)") + ap.add_argument("-e", "--encryption", + help="Enter the Encryption : [None, WEP , TKIP, CCMP](by Default None)") + ap.add_argument("-q", "--qos", help="Enter the QoS = : [No, Yes](by Default [No for 11abg] and [Yes for 11n])") + ap.add_argument("-m", "--mac", + help="Enter the 802.11 MAC Frame : [Any Value](by Default [106 for 11abg] and [1538 for 11n])") + ap.add_argument("-b", "--basic", nargs='+', + help="Enter the Basic Rate Set : [1,2, 5.5, 11, 6, 9, 12, 18, 24, 36, 48, 54]" + " (by Default [1 2 5.5 11 6 12] for 11abg, [6 12 24] for 11n/11ac])") + ap.add_argument("-pre", "--preamble", help="Enter Preamble value : [ Short, Long, N/A](by Default Short)") + ap.add_argument("-s", "--slot", help="Enter the Slot Time : [Short, Long, N/A](by Default Short)") + ap.add_argument("-co", "--codec", help="Enter the Codec Type (Voice Traffic): {[ G.711 , G.723 , G.729]" + "by Default G.723 for 11abg, G.711 for 11n} and" + "{['Mixed','Greenfield'] by Default Mixed for 11ac}") + ap.add_argument("-r", "--rts", help="Enter the RTS/CTS Handshake : [No, Yes](by Default No)") + ap.add_argument("-c", "--cts", help="Enter the CTS-to-self (protection) : [No, Yes](by Default No)") + + # Station : 11n and 11ac + + ap.add_argument("-d", "--data", + help="Enter the Data/Voice MCS Index : ['0','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']by Default 7") + ap.add_argument("-ch", "--channel", + help="Enter the Channel Bandwidth = : ['20','40'] by Default 40 for 11n and " + "['20','40','80'] by Default 80 for 11ac") + ap.add_argument("-gu", "--guard", help="Enter the Guard Interval = : ['400','800'] (by Default 400)") + ap.add_argument("-high", "--highest", + help="Enter the Highest Basic MCS = : ['0','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'](by Default 1)") + ap.add_argument("-pl", "--plcp", + help="Enter the PLCP Configuration = : ['Mixed','Greenfield'] (by Default Mixed) for 11n") + ap.add_argument("-ip", "--ip", + help="Enter the IP Packets per A-MSDU = : ['0','1','2','3','4','5','6','7','8','9'," + "'10','11','12','13','14','15','16','17','18','19','20'] (by Default 0)") + ap.add_argument("-mc", "--mc", + help="Enter the MAC Frames per A-MPDU = : ['0','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'](by Default [42 for 11n] and [64 for 11ac])") + ap.add_argument("-cw", "--cwin", + help="Enter the CWmin (leave alone for default) = : [Any Value] (by Default 15)") + ap.add_argument("-spa", "--spatial", help="Enter the Spatial Streams = [1,2,3,4] (by Default 4)") + ap.add_argument("-rc", "--rtscts", help="Enter the RTS/CTS Handshake and CTS-to-self " + " = ['No','Yes'] (by Default No for 11ac)") + return ap + + def calculate(self): PHY_Bit_Rate_float = float(self.PHY_Bit_Rate) PHY_Bit_Rate_int = int(PHY_Bit_Rate_float) @@ -419,7 +493,7 @@ class abg11_calculator: Client_5 = Ttxframe_data + SIFS_value + Ttxframe + DIFS_value + RTS_CTS_Handshake_Overhead + CTS_to_self_Handshake + MeanBackoff_value / 20 Client_6 = Ttxframe_data + SIFS_value + Ttxframe + DIFS_value + RTS_CTS_Handshake_Overhead + CTS_to_self_Handshake + MeanBackoff_value / 50 Client_7 = Ttxframe_data + SIFS_value + Ttxframe + DIFS_value + RTS_CTS_Handshake_Overhead + CTS_to_self_Handshake + MeanBackoff_value / 100 - Client_1_new = format(Client_1, '.2f') + self.Client_1_new = format(Client_1, '.2f') Client_2_new = format(Client_2, '.4f') Client_3_new = format(Client_3, '.4f') Client_4_new = format(Client_4, '.4f') @@ -430,7 +504,7 @@ class abg11_calculator: # Max Frame Rate Max_Frame_Rate_C1 = 1000000 / Client_1 - Max_Frame_Rate_C1_round = round(Max_Frame_Rate_C1) + self.Max_Frame_Rate_C1_round = round(Max_Frame_Rate_C1) Max_Frame_Rate_C2 = 1000000 / Client_2 Max_Frame_Rate_C2_round = round(Max_Frame_Rate_C2) Max_Frame_Rate_C3 = 1000000 / Client_3 @@ -447,7 +521,7 @@ class abg11_calculator: # Max. Offered Load (802.11) Max_Offered_Load_C1 = Max_Frame_Rate_C1 * Nbits_value / 1000000 - Max_Offered_Load_C1_new = format(Max_Offered_Load_C1, '.3f') + self.Max_Offered_Load_C1_new = format(Max_Offered_Load_C1, '.3f') Max_Offered_Load_C2 = Max_Frame_Rate_C2 * Nbits_value / 1000000 Max_Offered_Load_C2_new = format(Max_Offered_Load_C2, '.3f') Max_Offered_Load_C3 = Max_Frame_Rate_C3 * Nbits_value / 1000000 @@ -464,7 +538,7 @@ class abg11_calculator: # Offered Load Per 802.11 Client Offered_Load_Per_Client1 = Max_Offered_Load_C1 / 1 - Offered_Load_Per_Client1_new = format(Offered_Load_Per_Client1, '.3f') + self.Offered_Load_Per_Client1_new = format(Offered_Load_Per_Client1, '.3f') Offered_Load_Per_Client2 = Max_Offered_Load_C2 / 2 Offered_Load_Per_Client2_new = format(Offered_Load_Per_Client2, '.3f') Offered_Load_Per_Client3 = Max_Offered_Load_C3 / 5 @@ -481,7 +555,7 @@ class abg11_calculator: # Offered Load (802.3 Side) Offered_Load_C1 = Max_Frame_Rate_C1 * Ethernet_MAC_Frame_int * 8 / 1000000 - Offered_Load_C1_new = format(Offered_Load_C1, '.3f') + self.Offered_Load_C1_new = format(Offered_Load_C1, '.3f') Offered_Load_C2 = Max_Frame_Rate_C2 * Ethernet_MAC_Frame_int * 8 / 1000000 Offered_Load_C2_new = format(Offered_Load_C2, '.3f') Offered_Load_C3 = Max_Frame_Rate_C3 * Ethernet_MAC_Frame_int * 8 / 1000000 @@ -499,7 +573,7 @@ class abg11_calculator: if ip == 1: IP_Throughput_C1 = Max_Frame_Rate_C1 * ip_packet * 8 / 1000000 - IP_Throughput_C1_new = format(IP_Throughput_C1, '.3f') + self.IP_Throughput_C1_new = format(IP_Throughput_C1, '.3f') IP_Throughput_C2 = Max_Frame_Rate_C2 * ip_packet * 8 / 1000000 IP_Throughput_C2_new = format(IP_Throughput_C2, '.3f') IP_Throughput_C3 = Max_Frame_Rate_C3 * ip_packet * 8 / 1000000 @@ -513,7 +587,7 @@ class abg11_calculator: IP_Throughput_C7 = Max_Frame_Rate_C7 * ip_packet * 8 / 1000000 IP_Throughput_C7_new = format(IP_Throughput_C7, '.3f') else: - IP_Throughput_C1_new = "N/A" + self.IP_Throughput_C1_new = "N/A" IP_Throughput_C2_new = "N/A" IP_Throughput_C3_new = "N/A" IP_Throughput_C4_new = "N/A" @@ -521,102 +595,104 @@ class abg11_calculator: IP_Throughput_C6_new = "N/A" IP_Throughput_C7_new = "N/A" - print("\n" + "******************Station : 11abgCalculator*****************************" + "\n") - print("Theoretical Maximum Offered Load" + "\n") - print("1 Client:") - All_theoretical_output = {'Packet Interval(usec)': Client_1_new, 'Max Frame Rate(fps)': Max_Frame_Rate_C1_round, - 'Max. Offered Load (802.11)(Mb/s)': Max_Offered_Load_C1_new, - 'Offered Load Per 802.11 Client(Mb/s)': Offered_Load_Per_Client1_new, - 'Offered Load (802.3 Side)(Mb/s)': Offered_Load_C1_new, - 'IP Throughput (802.11 -> 802.3)(Mb/s)': IP_Throughput_C1_new} - print(json.dumps(All_theoretical_output, indent=4)) + Voice_Call = Max_Frame_Rate_C1 / Codec_Frame_rate Voice_Call_value = round(Voice_Call) if "Data" in self.Traffic_Type: - Maximum_Theoretical_R_value = "N/A" + self.Maximum_Theoretical_R_value = "N/A" else: if "G.711" in self.Codec_Type: - Maximum_Theoretical_R_value = 85.9 + self.Maximum_Theoretical_R_value = 85.9 else: if "G.723" in self.Codec_Type: - Maximum_Theoretical_R_value = 72.9 + self.Maximum_Theoretical_R_value = 72.9 else: if "G.729" in self.Codec_Type: - Maximum_Theoretical_R_value = 81.7 + self.Maximum_Theoretical_R_value = 81.7 else: - Maximum_Theoretical_R_value = 93.2 + self.Maximum_Theoretical_R_value = 93.2 if "Data" in self.Traffic_Type: - Estimated_MOS_Score = "N/A" - Maximum_Bidirectional = "N/A" + self.Estimated_MOS_Score = "N/A" + self.Maximum_Bidirectional_Voice_Calls = "N/A" else: if (Voice_Call_value <= 1): - Maximum_Bidirectional_Voice_Calls = Max_Frame_Rate_C1_round / Codec_Frame_rate + Maximum_Bidirectional_Voice_Calls1 = self.Max_Frame_Rate_C1_round / Codec_Frame_rate elif (Voice_Call_value <= 2): - Maximum_Bidirectional_Voice_Calls = Max_Frame_Rate_C2_round / Codec_Frame_rate + Maximum_Bidirectional_Voice_Calls1 = Max_Frame_Rate_C2_round / Codec_Frame_rate elif (Voice_Call_value <= 5): - Maximum_Bidirectional_Voice_Calls = Max_Frame_Rate_C3_round / Codec_Frame_rate + Maximum_Bidirectional_Voice_Calls1 = Max_Frame_Rate_C3_round / Codec_Frame_rate elif (Voice_Call_value <= 10): - Maximum_Bidirectional_Voice_Calls = Max_Frame_Rate_C4_round / Codec_Frame_rate + Maximum_Bidirectional_Voice_Calls1 = Max_Frame_Rate_C4_round / Codec_Frame_rate elif (Voice_Call_value <= 20): - Maximum_Bidirectional_Voice_Calls = Max_Frame_Rate_C5_round / Codec_Frame_rate + Maximum_Bidirectional_Voice_Calls1 = Max_Frame_Rate_C5_round / Codec_Frame_rate elif (Voice_Call_value <= 50): - Maximum_Bidirectional_Voice_Calls = Max_Frame_Rate_C6_round / Codec_Frame_rate + Maximum_Bidirectional_Voice_Calls1 = Max_Frame_Rate_C6_round / Codec_Frame_rate else: - Maximum_Bidirectional_Voice_Calls = Max_Frame_Rate_C7_round / Codec_Frame_rate - Maximum_Bidirectional = round(Maximum_Bidirectional_Voice_Calls, 2) - if Maximum_Theoretical_R_value < 0: - Estimated_MOS_Score = 1 + Maximum_Bidirectional_Voice_Calls1 = Max_Frame_Rate_C7_round / Codec_Frame_rate + self.Maximum_Bidirectional_Voice_Calls = round(Maximum_Bidirectional_Voice_Calls1, 2) + if self.Maximum_Theoretical_R_value < 0: + self.Estimated_MOS_Score = 1 else: - if Maximum_Theoretical_R_value > 100: - Estimated_MOS_Score = 4.5 + if self.Maximum_Theoretical_R_value > 100: + self.Estimated_MOS_Score = 4.5 else: - Estimated_MOS_Score_1 = 1 + 0.035 * Maximum_Theoretical_R_value + Maximum_Theoretical_R_value * ( - Maximum_Theoretical_R_value - 60) * ( - 100 - Maximum_Theoretical_R_value) * 7 * 0.000001 - Estimated_MOS_Score = round(Estimated_MOS_Score_1, 2) + Estimated_MOS_Score_1 = 1 + 0.035 * self.Maximum_Theoretical_R_value + self.Maximum_Theoretical_R_value * ( + self.Maximum_Theoretical_R_value - 60) * ( + 100 - self.Maximum_Theoretical_R_value) * 7 * 0.000001 + self.Estimated_MOS_Score = round(Estimated_MOS_Score_1, 2) + + + + def get_result(self): + + print("\n" + "******************Station : 11abgCalculator*****************************" + "\n") + print("Theoretical Maximum Offered Load" + "\n") + print("1 Client:") + All_theoretical_output = {'Packet Interval(usec)': self.Client_1_new, 'Max Frame Rate(fps)': self.Max_Frame_Rate_C1_round, + 'Max. Offered Load (802.11)(Mb/s)': self.Max_Offered_Load_C1_new, + 'Offered Load Per 802.11 Client(Mb/s)': self.Offered_Load_Per_Client1_new, + 'Offered Load (802.3 Side)(Mb/s)': self.Offered_Load_C1_new, + 'IP Throughput (802.11 -> 802.3)(Mb/s)': self.IP_Throughput_C1_new} + print(json.dumps(All_theoretical_output, indent=4)) print("\n" + "Theroretical Voice Call Capacity" + "\n") - All_theoretical_voice = {'Maximum Theoretical R-value': Maximum_Theoretical_R_value, - 'Estimated MOS Score': Estimated_MOS_Score, - 'Maximum Bidirectional Voice Calls(calls)': Maximum_Bidirectional} + All_theoretical_voice = {'Maximum Theoretical R-value': self.Maximum_Theoretical_R_value, + 'Estimated MOS Score': self.Estimated_MOS_Score, + 'Maximum Bidirectional Voice Calls(calls)': self.Maximum_Bidirectional_Voice_Calls} print(json.dumps(All_theoretical_voice, indent=4)) ##Class to take all user input (802.11n Standard) -class n11_calculator(): +class n11_calculator(abg11_calculator): def __init__(self, Traffic_Type, Data_Voice_MCS, Channel_Bandwidth, Guard_Interval_value, Highest_Basic_str, Encryption, QoS, IP_Packets_MSDU_str, MAC_Frames_per_A_MPDU_str, BSS_Basic_Rate, MAC_MPDU_Size_Data_Traffic, - Codec_Type_Voice_Traffic, PLCP, CWmin, RTS_CTS_Handshake, CTS_to_self_protection): - self.Traffic_Type = Traffic_Type + Codec_Type, PLCP, CWmin, RTS_CTS_Handshake, CTS_to_self,PHY_Bit_Rate=None,MAC_Frame_802_11=None,Basic_Rate_Set=None,Preamble=None,slot_name=None): + super().__init__(Traffic_Type, PHY_Bit_Rate, Encryption, QoS, MAC_Frame_802_11, Basic_Rate_Set, Preamble, + slot_name, Codec_Type, RTS_CTS_Handshake, CTS_to_self) self.Data_Voice_MCS = Data_Voice_MCS self.Channel_Bandwidth = Channel_Bandwidth self.Guard_Interval_value = Guard_Interval_value self.Highest_Basic_str = Highest_Basic_str - self.Encryption = Encryption - self.QoS = QoS self.IP_Packets_MSDU_str = IP_Packets_MSDU_str self.MAC_Frames_per_A_MPDU_str = MAC_Frames_per_A_MPDU_str self.BSS_Basic_Rate = BSS_Basic_Rate self.MAC_MPDU_Size_Data_Traffic = MAC_MPDU_Size_Data_Traffic - self.Codec_Type_Voice_Traffic = Codec_Type_Voice_Traffic self.PLCP = PLCP self.CWmin = CWmin - self.RTS_CTS_Handshake = RTS_CTS_Handshake - self.CTS_to_self_protection = CTS_to_self_protection + # This function is for calculate intermediate values and Theoretical values - def input_parameter(self): - + def calculate(self): global HT_data_temp global temp_value SIFS = 16.00 @@ -773,17 +849,17 @@ class n11_calculator(): Encrypt_Hdr = 16 # c36 Codec IP Packet Size - if "G.711" in self.Codec_Type_Voice_Traffic: + if "G.711" in self.Codec_Type: Codec_IP_Packet_Size = 200 Codec_Frame_Rate = 100 else: - if "G.723" in self.Codec_Type_Voice_Traffic: + if "G.723" in self.Codec_Type: Codec_IP_Packet_Size = 60 Codec_Frame_Rate = 67 else: - if "G.729" in self.Codec_Type_Voice_Traffic: + if "G.729" in self.Codec_Type: Codec_IP_Packet_Size = 60 Codec_Frame_Rate = 100 @@ -1096,7 +1172,7 @@ class n11_calculator(): CTS_to_self_Handshake_Overhead = 0 else: - if "Yes" in self.CTS_to_self_protection: + if "Yes" in self.CTS_to_self: if "20" in self.Channel_Bandwidth: CTS_to_self_Handshake_Overhead = 20 + 4 * int((22 + 14 * 8 + 24 * 4 - 1) / (24 * 4)) + SIFS @@ -1112,7 +1188,7 @@ class n11_calculator(): MAC_PPDU_Interval_1 = RTS_CTS_Handshake_Overhead + CTS_to_self_Handshake_Overhead + Ttxframe + Ack_Response_Overhead + BlockAck_Response_Overhead + DIFS + ( MeanBackoff / 1) - Client_1_new = format(MAC_PPDU_Interval_1, '.2f') + self.Client_1_new = format(MAC_PPDU_Interval_1, '.2f') MAC_PPDU_Interval_2 = RTS_CTS_Handshake_Overhead + CTS_to_self_Handshake_Overhead + Ttxframe + Ack_Response_Overhead + BlockAck_Response_Overhead + DIFS + ( MeanBackoff / 2) Client_2_new = format(MAC_PPDU_Interval_2, '.2f') @@ -1135,7 +1211,7 @@ class n11_calculator(): # Max PPDU Rate Max_PPDU_Rate_1 = 1000000 / MAC_PPDU_Interval_1 - Client_8_new = format(Max_PPDU_Rate_1, '.2f') + self.Client_8_new = format(Max_PPDU_Rate_1, '.2f') Max_PPDU_Rate_2 = 1000000 / MAC_PPDU_Interval_2 Client_9_new = format(Max_PPDU_Rate_2, '.2f') Max_PPDU_Rate_3 = 1000000 / MAC_PPDU_Interval_3 @@ -1167,7 +1243,7 @@ class n11_calculator(): Max_MAC_MPDU_Rate_6 = Max_PPDU_Rate_6 Max_MAC_MPDU_Rate_7 = Max_PPDU_Rate_7 - Client_15_new = round(Max_MAC_MPDU_Rate_1) + self.Client_15_new = round(Max_MAC_MPDU_Rate_1) Client_16_new = round(Max_MAC_MPDU_Rate_2) Client_17_new = round(Max_MAC_MPDU_Rate_3) Client_18_new = round(Max_MAC_MPDU_Rate_4) @@ -1195,7 +1271,7 @@ class n11_calculator(): Max_MAC_MSDU_Rate_6 = Max_MAC_MPDU_Rate_6 Max_MAC_MSDU_Rate_7 = Max_MAC_MPDU_Rate_7 - Client_22_new = round(Max_MAC_MSDU_Rate_1) + self.Client_22_new = round(Max_MAC_MSDU_Rate_1) Client_23_new = round(Max_MAC_MSDU_Rate_2) Client_24_new = round(Max_MAC_MSDU_Rate_3) Client_25_new = round(Max_MAC_MSDU_Rate_4) @@ -1212,7 +1288,7 @@ class n11_calculator(): Max_802_11_MAC_Frame_Data_Rate_6 = Max_MAC_MPDU_Rate_6 * MAC_MPDU_Size * 8 / 1000000 Max_802_11_MAC_Frame_Data_Rate_7 = Max_MAC_MPDU_Rate_7 * MAC_MPDU_Size * 8 / 1000000 - Client_29_new = format(Max_802_11_MAC_Frame_Data_Rate_1, '.3f') + self.Client_29_new = format(Max_802_11_MAC_Frame_Data_Rate_1, '.3f') Client_30_new = format(Max_802_11_MAC_Frame_Data_Rate_2, '.3f') Client_31_new = format(Max_802_11_MAC_Frame_Data_Rate_3, '.3f') Client_32_new = format(Max_802_11_MAC_Frame_Data_Rate_4, '.3f') @@ -1230,7 +1306,7 @@ class n11_calculator(): Max_802_11_MAC_Payload_Goodput_6 = MSDU * 8 * Max_MAC_MSDU_Rate_6 / 1000000 Max_802_11_MAC_Payload_Goodput_7 = MSDU * 8 * Max_MAC_MSDU_Rate_7 / 1000000 - Client_36_new = format(Max_802_11_MAC_Payload_Goodput_1, '.3f') + self.Client_36_new = format(Max_802_11_MAC_Payload_Goodput_1, '.3f') Client_37_new = format(Max_802_11_MAC_Payload_Goodput_2, '.3f') Client_38_new = format(Max_802_11_MAC_Payload_Goodput_3, '.3f') Client_39_new = format(Max_802_11_MAC_Payload_Goodput_4, '.3f') @@ -1248,7 +1324,7 @@ class n11_calculator(): MAC_Goodput_Per_802_11_Client_6 = Max_802_11_MAC_Payload_Goodput_6 / 50 MAC_Goodput_Per_802_11_Client_7 = Max_802_11_MAC_Payload_Goodput_7 / 100 - Client_43_new = format(MAC_Goodput_Per_802_11_Client_1, '.3f') + self.Client_43_new = format(MAC_Goodput_Per_802_11_Client_1, '.3f') Client_44_new = format(MAC_Goodput_Per_802_11_Client_2, '.3f') Client_45_new = format(MAC_Goodput_Per_802_11_Client_3, '.3f') Client_46_new = format(MAC_Goodput_Per_802_11_Client_4, '.3f') @@ -1268,7 +1344,7 @@ class n11_calculator(): Offered_Load_8023_Side_5 = Max_MAC_MSDU_Rate_5 * Ethernet_value * 8 / 1000000 Offered_Load_8023_Side_6 = Max_MAC_MSDU_Rate_6 * Ethernet_value * 8 / 1000000 Offered_Load_8023_Side_7 = Max_MAC_MSDU_Rate_7 * Ethernet_value * 8 / 1000000 - Client_50_new = format(Offered_Load_8023_Side_1, '.3f') + self.Client_50_new = format(Offered_Load_8023_Side_1, '.3f') Client_51_new = format(Offered_Load_8023_Side_2, '.3f') Client_52_new = format(Offered_Load_8023_Side_3, '.3f') Client_53_new = format(Offered_Load_8023_Side_4, '.3f') @@ -1277,7 +1353,7 @@ class n11_calculator(): Client_56_new = format(Offered_Load_8023_Side_7, '.3f') else: - Client_50_new = "N/A" + self.Client_50_new = "N/A" Client_51_new = "N/A" Client_52_new = "N/A" Client_53_new = "N/A" @@ -1294,7 +1370,7 @@ class n11_calculator(): IP_Goodput_802_11_8023_5 = Max_MAC_MSDU_Rate_5 * ip_1 * 8 / 1000000 IP_Goodput_802_11_8023_6 = Max_MAC_MSDU_Rate_6 * ip_1 * 8 / 1000000 IP_Goodput_802_11_8023_7 = Max_MAC_MSDU_Rate_7 * ip_1 * 8 / 1000000 - Client_57_new = format(IP_Goodput_802_11_8023_1, '.3f') + self.Client_57_new = format(IP_Goodput_802_11_8023_1, '.3f') Client_58_new = format(IP_Goodput_802_11_8023_2, '.3f') Client_59_new = format(IP_Goodput_802_11_8023_3, '.3f') Client_60_new = format(IP_Goodput_802_11_8023_4, '.3f') @@ -1303,7 +1379,7 @@ class n11_calculator(): Client_63_new = format(IP_Goodput_802_11_8023_7, '.3f') else: - Client_57_new = "N/A" + self.Client_57_new = "N/A" Client_58_new = "N/A" Client_59_new = "N/A" Client_60_new = "N/A" @@ -1315,31 +1391,31 @@ class n11_calculator(): # c53 if "Data" in self.Traffic_Type: - Maximum_Theoretical_R_value = "N/A" - Estimated_MOS_Score = "N/A" + self.Maximum_Theoretical_R_value = "N/A" + self.Estimated_MOS_Score = "N/A" else: - if "G.711" in self.Codec_Type_Voice_Traffic: - Maximum_Theoretical_R_value = 85.9 + if "G.711" in self.Codec_Type: + self.Maximum_Theoretical_R_value = 85.9 else: - if "G.723" in self.Codec_Type_Voice_Traffic: - Maximum_Theoretical_R_value = 72.9 + if "G.723" in self.Codec_Type: + self.Maximum_Theoretical_R_value = 72.9 else: - if "G.729" in self.Codec_Type_Voice_Traffic: - Maximum_Theoretical_R_value = 81.7 + if "G.729" in self.Codec_Type: + self.Maximum_Theoretical_R_value = 81.7 else: - Maximum_Theoretical_R_value = 93.2 + self.Maximum_Theoretical_R_value = 93.2 - if Maximum_Theoretical_R_value < 0: - Estimated_MOS_Score = 1 + if self.Maximum_Theoretical_R_value < 0: + self.Estimated_MOS_Score = 1 else: - if Maximum_Theoretical_R_value > 100: - Estimated_MOS_Score = 4.5 + if self.Maximum_Theoretical_R_value > 100: + self.Estimated_MOS_Score = 4.5 else: - Estimated_MOS_Score_1 = ( - 1 + 0.035 * Maximum_Theoretical_R_value + Maximum_Theoretical_R_value * ( - Maximum_Theoretical_R_value - 60) * ( - 100 - Maximum_Theoretical_R_value) * 7 * 0.000001) - Estimated_MOS_Score = format(Estimated_MOS_Score_1, '.2f') + self.Estimated_MOS_Score_1 = ( + 1 + 0.035 * self.Maximum_Theoretical_R_value + self.Maximum_Theoretical_R_value * ( + self.Maximum_Theoretical_R_value - 60) * ( + 100 - self.Maximum_Theoretical_R_value) * 7 * 0.000001) + self.Estimated_MOS_Score = format(self.Estimated_MOS_Score_1, '.2f') # Voice_Call_Range try: @@ -1376,58 +1452,57 @@ class n11_calculator(): pass if "Data" in self.Traffic_Type: - Maximum_Bidirectional_Voice_Calls = "N/A" + self.Maximum_Bidirectional_Voice_Calls = "N/A" else: - Maximum_Bidirectional_Voice_Calls = round(Maximum_Bidirectional, 2) + self.Maximum_Bidirectional_Voice_Calls = round(Maximum_Bidirectional, 2) + + + + def get_result(self): print("\n" + "******************Station : 11nCalculator*****************************" + "\n") print("Theoretical Maximum Offered Load" + "\n") print("1 Client:") - All_theoretical_output = {'MAC PPDU Interval(usec)': Client_1_new, 'Max PPDU Rate(fps)': Client_8_new, - 'Max MAC MPDU Rate': Client_15_new, - 'Max MAC MSDU Rate': Client_22_new, - 'Max. 802.11 MAC Frame Data Rate(Mb/s)': Client_29_new, - 'Max. 802.11 MAC Payload Goodput(Mb/s)': Client_36_new, - 'MAC Goodput Per 802.11 Client(Mb/s)': Client_43_new, - 'Offered Load (802.3 Side)(Mb/s)': Client_50_new, - 'IP Goodput (802.11 -> 802.3)(Mb/s)': Client_57_new} + All_theoretical_output = {'MAC PPDU Interval(usec)': self.Client_1_new, + 'Max PPDU Rate(fps)': self.Client_8_new, + 'Max MAC MPDU Rate': self.Client_15_new, + 'Max MAC MSDU Rate': self.Client_22_new, + 'Max. 802.11 MAC Frame Data Rate(Mb/s)': self.Client_29_new, + 'Max. 802.11 MAC Payload Goodput(Mb/s)': self.Client_36_new, + 'MAC Goodput Per 802.11 Client(Mb/s)': self.Client_43_new, + 'Offered Load (802.3 Side)(Mb/s)': self.Client_50_new, + 'IP Goodput (802.11 -> 802.3)(Mb/s)': self.Client_57_new} print(json.dumps(All_theoretical_output, indent=4)) print("\n" + "Theroretical Voice Call Capacity" + "\n") - All_theoretical_voice = {'Maximum Theoretical R-value': Maximum_Theoretical_R_value, - 'Estimated MOS Score': Estimated_MOS_Score, - 'Maximum Bidirectional Voice Calls(calls)': Maximum_Bidirectional_Voice_Calls} + All_theoretical_voice = {'Maximum Theoretical R-value': self.Maximum_Theoretical_R_value, + 'Estimated MOS Score': self.Estimated_MOS_Score, + 'Maximum Bidirectional Voice Calls(calls)': self.Maximum_Bidirectional_Voice_Calls} print(json.dumps(All_theoretical_voice, indent=4)) ##Class to take all user input (802.11ac Standard) -class ac11_calculator(): +class ac11_calculator(n11_calculator): + + def __init__(self, Traffic_Type, Data_Voice_MCS, spatial, Channel_Bandwidth, Guard_Interval_value, - Highest_Basic_str, Encryption, QoS, + Highest_Basic_str, Encryption, QoS,IP_Packets_MSDU_str, MAC_Frames_per_A_MPDU_str, BSS_Basic_Rate, MAC_MPDU_Size_Data_Traffic, + Codec_Type, CWmin, RTS_CTS,PLCP = None,RTS_CTS_Handshake=None,CTS_to_self=None): + super().__init__(Traffic_Type, Data_Voice_MCS, Channel_Bandwidth, Guard_Interval_value, Highest_Basic_str, + Encryption, QoS, IP_Packets_MSDU_str, MAC_Frames_per_A_MPDU_str, BSS_Basic_Rate, MAC_MPDU_Size_Data_Traffic, - Codec_Type_Voice_Traffic, CWmin, RTS_CTS): - self.Traffic_Type = Traffic_Type - self.Data_Voice_MCS = Data_Voice_MCS - self.Channel_Bandwidth = Channel_Bandwidth - self.Guard_Interval_value = Guard_Interval_value - self.Highest_Basic_str = Highest_Basic_str - self.Encryption = Encryption - self.QoS = QoS - self.IP_Packets_MSDU_str = IP_Packets_MSDU_str - self.MAC_Frames_per_A_MPDU_str = MAC_Frames_per_A_MPDU_str - self.BSS_Basic_Rate = BSS_Basic_Rate - self.MAC_MPDU_Size_Data_Traffic = MAC_MPDU_Size_Data_Traffic - self.Codec_Type_Voice_Traffic = Codec_Type_Voice_Traffic - self.CWmin = CWmin - self.RTS_CTS = RTS_CTS + Codec_Type, PLCP, CWmin, RTS_CTS_Handshake, CTS_to_self) + self.spatial = spatial + self.RTS_CTS = RTS_CTS + # This function is for calculate intermediate values and Theoretical values - def input_parameter(self): + def calculate(self): SIFS = 16.00 DIFS = 34.00 @@ -1572,16 +1647,16 @@ class ac11_calculator(): MeanBackoff = CWmin_leave_alone_for_default * Slot_Time / 2 IP_Packets_MSDU = int(self.IP_Packets_MSDU_str) - if "Mixed" in self.Codec_Type_Voice_Traffic: + if "Mixed" in self.Codec_Type: plcp = 1 - elif "Greenfield" in self.Codec_Type_Voice_Traffic: + elif "Greenfield" in self.Codec_Type: plcp = 2 RTS_CTS_Handshake = 1 if "No" in self.RTS_CTS: - CTS_to_self_protection = 1 + CTS_to_self = 1 elif "Yes" in self.RTS_CTS: - CTS_to_self_protection = 2 + CTS_to_self = 2 # g24 QoS Hdr @@ -1836,7 +1911,7 @@ class ac11_calculator(): if RTS_CTS_Handshake == 2: CTS_to_self_Handshake_Overhead = 0 else: - if CTS_to_self_protection == 2: + if CTS_to_self == 2: if "20" in self.Channel_Bandwidth: CTS_to_self_Handshake_Overhead = 20 + 4 * int((22 + 14 * 8 + 24 * 4 - 1) / (24 * 4)) + SIFS else: @@ -1869,7 +1944,7 @@ class ac11_calculator(): MAC_PPDU_Interval_1 = RTS_CTS_Handshake_Overhead + CTS_to_self_Handshake_Overhead + Ttxframe + Ack_Response_Overhead + BlockAck_Response_Overhead + DIFS + ( MeanBackoff / 1) - Client_1_new = format(MAC_PPDU_Interval_1, '.2f') + self.Client_1_new = format(MAC_PPDU_Interval_1, '.2f') MAC_PPDU_Interval_2 = RTS_CTS_Handshake_Overhead + CTS_to_self_Handshake_Overhead + Ttxframe + Ack_Response_Overhead + BlockAck_Response_Overhead + DIFS + ( MeanBackoff / 2) Client_2_new = format(MAC_PPDU_Interval_2, '.2f') @@ -1894,7 +1969,7 @@ class ac11_calculator(): # Max PPDU Rate Max_PPDU_Rate_1 = 1000000 / MAC_PPDU_Interval_1 - Client_8_new = format(Max_PPDU_Rate_1, '.2f') + self.Client_8_new = format(Max_PPDU_Rate_1, '.2f') Max_PPDU_Rate_2 = 1000000 / MAC_PPDU_Interval_2 Client_9_new = format(Max_PPDU_Rate_2, '.2f') Max_PPDU_Rate_3 = 1000000 / MAC_PPDU_Interval_3 @@ -1927,7 +2002,7 @@ class ac11_calculator(): Max_MAC_MPDU_Rate_6 = Max_PPDU_Rate_6 Max_MAC_MPDU_Rate_7 = Max_PPDU_Rate_7 - Client_15_new = round(Max_MAC_MPDU_Rate_1) + self.Client_15_new = round(Max_MAC_MPDU_Rate_1) Client_16_new = round(Max_MAC_MPDU_Rate_2) Client_17_new = round(Max_MAC_MPDU_Rate_3) Client_18_new = round(Max_MAC_MPDU_Rate_4) @@ -1955,7 +2030,7 @@ class ac11_calculator(): Max_MAC_MSDU_Rate_6 = Max_MAC_MPDU_Rate_6 Max_MAC_MSDU_Rate_7 = Max_MAC_MPDU_Rate_7 - Client_22_new = round(Max_MAC_MSDU_Rate_1) + self.Client_22_new = round(Max_MAC_MSDU_Rate_1) Client_23_new = round(Max_MAC_MSDU_Rate_2) Client_24_new = round(Max_MAC_MSDU_Rate_3) Client_25_new = round(Max_MAC_MSDU_Rate_4) @@ -1973,7 +2048,7 @@ class ac11_calculator(): Max_802_11_MAC_Frame_Data_Rate_6 = Max_MAC_MPDU_Rate_6 * MAC_MPDU_Size * 8 / 1000000 Max_802_11_MAC_Frame_Data_Rate_7 = Max_MAC_MPDU_Rate_7 * MAC_MPDU_Size * 8 / 1000000 - Client_29_new = format(Max_802_11_MAC_Frame_Data_Rate_1, '.3f') + self.Client_29_new = format(Max_802_11_MAC_Frame_Data_Rate_1, '.3f') Client_30_new = format(Max_802_11_MAC_Frame_Data_Rate_2, '.3f') Client_31_new = format(Max_802_11_MAC_Frame_Data_Rate_3, '.3f') Client_32_new = format(Max_802_11_MAC_Frame_Data_Rate_4, '.3f') @@ -1991,7 +2066,7 @@ class ac11_calculator(): Max_802_11_MAC_Payload_Goodput_6 = MSDU * 8 * Max_MAC_MSDU_Rate_6 / 1000000 Max_802_11_MAC_Payload_Goodput_7 = MSDU * 8 * Max_MAC_MSDU_Rate_7 / 1000000 - Client_36_new = format(Max_802_11_MAC_Payload_Goodput_1, '.3f') + self.Client_36_new = format(Max_802_11_MAC_Payload_Goodput_1, '.3f') Client_37_new = format(Max_802_11_MAC_Payload_Goodput_2, '.3f') Client_38_new = format(Max_802_11_MAC_Payload_Goodput_3, '.3f') Client_39_new = format(Max_802_11_MAC_Payload_Goodput_4, '.3f') @@ -2009,7 +2084,7 @@ class ac11_calculator(): MAC_Goodput_Per_802_11_Client_6 = Max_802_11_MAC_Payload_Goodput_6 / 50 MAC_Goodput_Per_802_11_Client_7 = Max_802_11_MAC_Payload_Goodput_7 / 100 - Client_43_new = format(MAC_Goodput_Per_802_11_Client_1, '.3f') + self.Client_43_new = format(MAC_Goodput_Per_802_11_Client_1, '.3f') Client_44_new = format(MAC_Goodput_Per_802_11_Client_2, '.3f') Client_45_new = format(MAC_Goodput_Per_802_11_Client_3, '.3f') Client_46_new = format(MAC_Goodput_Per_802_11_Client_4, '.3f') @@ -2028,7 +2103,7 @@ class ac11_calculator(): Offered_Load_8023_Side_5 = Max_MAC_MSDU_Rate_5 * Ethernet_value * 8 / 1000000 Offered_Load_8023_Side_6 = Max_MAC_MSDU_Rate_6 * Ethernet_value * 8 / 1000000 Offered_Load_8023_Side_7 = Max_MAC_MSDU_Rate_7 * Ethernet_value * 8 / 1000000 - Client_50_new = format(Offered_Load_8023_Side_1, '.3f') + self.Client_50_new = format(Offered_Load_8023_Side_1, '.3f') Client_51_new = format(Offered_Load_8023_Side_2, '.3f') Client_52_new = format(Offered_Load_8023_Side_3, '.3f') Client_53_new = format(Offered_Load_8023_Side_4, '.3f') @@ -2037,7 +2112,7 @@ class ac11_calculator(): Client_56_new = format(Offered_Load_8023_Side_7, '.3f') else: - Client_50_new = "N/A" + self.Client_50_new = "N/A" Client_51_new = "N/A" Client_52_new = "N/A" Client_53_new = "N/A" @@ -2054,7 +2129,7 @@ class ac11_calculator(): IP_Goodput_802_11_8023_5 = Max_MAC_MSDU_Rate_5 * ip_1 * 8 / 1000000 IP_Goodput_802_11_8023_6 = Max_MAC_MSDU_Rate_6 * ip_1 * 8 / 1000000 IP_Goodput_802_11_8023_7 = Max_MAC_MSDU_Rate_7 * ip_1 * 8 / 1000000 - Client_57_new = format(IP_Goodput_802_11_8023_1, '.3f') + self.Client_57_new = format(IP_Goodput_802_11_8023_1, '.3f') Client_58_new = format(IP_Goodput_802_11_8023_2, '.3f') Client_59_new = format(IP_Goodput_802_11_8023_3, '.3f') Client_60_new = format(IP_Goodput_802_11_8023_4, '.3f') @@ -2063,7 +2138,7 @@ class ac11_calculator(): Client_63_new = format(IP_Goodput_802_11_8023_7, '.3f') else: - Client_57_new = "N/A" + self.Client_57_new = "N/A" Client_58_new = "N/A" Client_59_new = "N/A" Client_60_new = "N/A" @@ -2074,20 +2149,20 @@ class ac11_calculator(): # Theoretical Voice Call Capacity if "Data" in self.Traffic_Type: - Maximum_Theoretical_R_value = "N/A" - Estimated_MOS_Score = "N/A" + self.Maximum_Theoretical_R_value = "N/A" + self.Estimated_MOS_Score = "N/A" else: - Maximum_Theoretical_R_value = 85.9 - if Maximum_Theoretical_R_value < 0: - Estimated_MOS_Score = 1 + self.Maximum_Theoretical_R_value = 85.9 + if self.Maximum_Theoretical_R_value < 0: + self.Estimated_MOS_Score = 1 else: - if Maximum_Theoretical_R_value > 100: - Estimated_MOS_Score = 4.5 + if self.Maximum_Theoretical_R_value > 100: + self.Estimated_MOS_Score = 4.5 else: - Estimated_MOS_Score_1 = (1 + 0.035 * Maximum_Theoretical_R_value + Maximum_Theoretical_R_value * ( - Maximum_Theoretical_R_value - 60) * (100 - Maximum_Theoretical_R_value) * 7 * 0.000001) - Estimated_MOS_Score = format(Estimated_MOS_Score_1, '.2f') + Estimated_MOS_Score_1 = (1 + 0.035 * self.Maximum_Theoretical_R_value + self.Maximum_Theoretical_R_value * ( + self.Maximum_Theoretical_R_value - 60) * (100 - self.Maximum_Theoretical_R_value) * 7 * 0.000001) + self.Estimated_MOS_Score = format(Estimated_MOS_Score_1, '.2f') # Voice_Call_Range @@ -2126,26 +2201,29 @@ class ac11_calculator(): pass if "Data" in self.Traffic_Type: - Maximum_Bidirectional_Voice_Calls = "N/A" + self.Maximum_Bidirectional_Voice_Calls = "N/A" else: - Maximum_Bidirectional_Voice_Calls = round(Maximum_Bidirectional, 2) + self.Maximum_Bidirectional_Voice_Calls = round(Maximum_Bidirectional, 2) + + + def get_result(self): print("\n" + "******************Station : 11ac Calculator*****************************" + "\n") print("Theoretical Maximum Offered Load" + "\n") print("1 Client:") - All_theoretical_output = {'MAC PPDU Interval(usec)': Client_1_new, 'Max PPDU Rate(fps)': Client_8_new, - 'Max MAC MPDU Rate': Client_15_new, - 'Max MAC MSDU Rate': Client_22_new, - 'Max. 802.11 MAC Frame Data Rate(Mb/s)': Client_29_new, - 'Max. 802.11 MAC Payload Goodput(Mb/s)': Client_36_new, - 'MAC Goodput Per 802.11 Client(Mb/s)': Client_43_new, - 'Offered Load (802.3 Side)(Mb/s)': Client_50_new, - 'IP Goodput (802.11 -> 802.3)(Mb/s)': Client_57_new} + All_theoretical_output = {'MAC PPDU Interval(usec)': self.Client_1_new, 'Max PPDU Rate(fps)': self.Client_8_new, + 'Max MAC MPDU Rate': self.Client_15_new, + 'Max MAC MSDU Rate': self.Client_22_new, + 'Max. 802.11 MAC Frame Data Rate(Mb/s)': self.Client_29_new, + 'Max. 802.11 MAC Payload Goodput(Mb/s)': self.Client_36_new, + 'MAC Goodput Per 802.11 Client(Mb/s)': self.Client_43_new, + 'Offered Load (802.3 Side)(Mb/s)': self.Client_50_new, + 'IP Goodput (802.11 -> 802.3)(Mb/s)': self.Client_57_new} print(json.dumps(All_theoretical_output, indent=4)) print("\n" + "Theroretical Voice Call Capacity" + "\n") - All_theoretical_voice = {'Maximum Theoretical R-value': Maximum_Theoretical_R_value, - 'Estimated MOS Score': Estimated_MOS_Score, - 'Maximum Bidirectional Voice Calls(calls)': Maximum_Bidirectional_Voice_Calls} - print(json.dumps(All_theoretical_voice, indent=4)) + All_theoretical_voice = {'Maximum Theoretical R-value': self.Maximum_Theoretical_R_value, + 'Estimated MOS Score': self.Estimated_MOS_Score, + 'Maximum Bidirectional Voice Calls(calls)': self.Maximum_Bidirectional_Voice_Calls} + print(json.dumps(All_theoretical_voice, indent=4)) \ No newline at end of file diff --git a/py-json/ws-sta-monitor.py b/py-json/ws-sta-monitor.py index de72ca3d..e5a9a5eb 100755 --- a/py-json/ws-sta-monitor.py +++ b/py-json/ws-sta-monitor.py @@ -16,6 +16,7 @@ if sys.version_info[0] != 3: import argparse import json import logging +import pprint import traceback import time from time import sleep @@ -25,11 +26,7 @@ try: import thread except ImportError: import _thread as thread -import pprint -import LANforge -from LANforge import LFRequest from LANforge import LFUtils -from LANforge.LFUtils import NA cre={ "phy": re.compile(r'^(1\.\d+):\s+(\S+)\s+\(phy', re.I), @@ -69,29 +66,46 @@ rebank = { "ifname" : re.compile("IFNAME=(\S+)") } websock = None +host = "localhost" +base_url = None +port = 8081 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +def usage(): + print("""Example: __file__ --host 192.168.1.101 --port 8081\n""") + + def main(): global websock - host = "localhost" - base_url = "ws://%s:8081"%host - resource_id = 1 # typically you're using resource 1 in stand alone realm + # global host + # global base_url + # resource_id = 1 # typically you're using resource 1 in stand alone realm parser = argparse.ArgumentParser(description="test creating a station") - parser.add_argument("-m", "--host", type=str, help="json host to connect to") + parser.add_argument("-m", "--host", type=str, help="websocket host to connect to") + parser.add_argument("-p", "--port", type=str, help="websoket port") - args = None + host = "unset" + base_url = "unset" try: - args = parser.parse_args() - if (args.host is not None): - host = args.host, - baseurl = base_url = "ws://%s:8081"%host + args = parser.parse_args() + if (args.host is None): + host = "localhost" + elif (type(args) is tuple) or (type(args) is list): + host = args.host[0] + else: + host = args.host + + base_url = "ws://%s:%s" % (host, port) + except Exception as e: - logging.exception(e) - usage() - exit(2) + print("Exception: "+e) + logging.exception(e) + usage() + exit(2) # open websocket + # print("Main: base_url: %s, host:%s, port:%s" % (base_url, host, port)) websock = start_websocket(base_url, websock) @@ -125,16 +139,16 @@ def sock_filter(wsock, text): if (test in message["details"]): return; except KeyError: - print ("Message lacks key 'details'") + print("Message lacks key 'details'") try: if ("wifi-event" in message.keys()): for test in ignore: - #print (" is ",test, " in ", message["wifi-event"]) + # print (" is ",test, " in ", message["wifi-event"]) if (test in message["wifi-event"]): return; except KeyError: - print("Message lacks key 'wifi-event'" ) + print("Message lacks key 'wifi-event'") if (("time" in message.keys()) and ("timestamp" in message.keys())): return @@ -150,27 +164,28 @@ def sock_filter(wsock, text): station_name = match_result.group(1) if (message["is_alert"]): - print ("alert: ", message["details"]) - #LFUtils.debug_printer.pprint(message) + print("alert: ", message["details"]) + # LFUtils.debug_printer.pprint(message) return else: - #LFUtils.debug_printer.pprint(message) + # LFUtils.debug_printer.pprint(message) if (" IP change from " in message["details"]): if (" to 0.0.0.0" in messsage["details"]): - print ("e: %s.%s lost IP address",[resource,station_name]) + print("e: %s.%s lost IP address", [resource, station_name]) else: - print ("e: %s.%s gained IP address",[resource,station_name]) + print("e: %s.%s gained IP address", [resource, station_name]) if ("Link DOWN" in message["details"]): - return # duplicates alert + return # duplicates alert - print ("event: ", message["details"]) + print("event: ", message["details"]) return if ("wifi-event" in message.keys()): if ("CTRL-EVENT-CONNECTED" in message["wifi-event"]): # redunant return - if (("CTRL-EVENT-CONNECTED - Connection to " in message["wifi-event"]) and (" complete" in message["wifi-event"])): + if (("CTRL-EVENT-CONNECTED - Connection to " in message["wifi-event"]) and ( + " complete" in message["wifi-event"])): return; if ((": assoc " in message["wifi-event"]) and ("status: 0: Successful" in message["wifi-event"])): return @@ -178,61 +193,61 @@ def sock_filter(wsock, text): try: match_result = cre["phy"].match(message["wifi-event"]) if (match_result is not None): - #LFUtils.debug_printer.pprint(match_result) - #LFUtils.debug_printer.pprint(match_result.groups()) + # LFUtils.debug_printer.pprint(match_result) + # LFUtils.debug_printer.pprint(match_result.groups()) resource = match_result.group(1) station_name = match_result.group(2) else: match_result = cre["ifname"].match(message["wifi-event"]) - #LFUtils.debug_printer.pprint(match_result) - #LFUtils.debug_printer.pprint(match_result.groups()) + # LFUtils.debug_printer.pprint(match_result) + # LFUtils.debug_printer.pprint(match_result.groups()) if (match_result is not None): resource = match_result.group(1) station_name = match_result.group(2) else: - print ("Is there some other combination??? :", message["wifi-event"]) + print("Is there some other combination??? :", message["wifi-event"]) station_name = 'no-sta' resource_name = 'no-resource' - print ("bleh!") + print("bleh!") except Exception as ex2: - print ("No regex match:") + print("No regex match:") print(repr(ex2)) traceback.print_exc() sleep(1) - #print ("Determined station name: as %s.%s"%(resource, station_name)) + # print ("Determined station name: as %s.%s"%(resource, station_name)) if ((": auth ") and ("status: 0: Successful" in message["wifi-event"])): match_result = cre["auth"].match(message["wifi-event"]) if (match_result and match_result.groups()): bssid = match_result.group(1) - print ("station %s.%s auth with %s"%(resource,station_name,bssid)) + print("station %s.%s auth with %s" % (resource, station_name, bssid)) return else: - print ("station %s.%s auth with ??"%(resource,station_name)) + print("station %s.%s auth with ??" % (resource, station_name)) LFUtils.debug_printer.pprint(match_result) if ("Associated with " in message["wifi-event"]): match_result = cre["associated"].match(message["wifi-event"]) if (match_result and match_result.groups()): bssid = match_result.group(1) - print ("station %s.%s assocated with %s"%(resource,station_name,bssid)) + print("station %s.%s assocated with %s" % (resource, station_name, bssid)) return else: - print ("station %s.%s assocated with ??"%(resource,station_name)) + print("station %s.%s assocated with ??" % (resource, station_name)) LFUtils.debug_printer.pprint(match_result) if (" - Connection to " in message["wifi-event"]): match_result = cre["connected"].match(message["wifi-event"]) if (match_result and match_result.groups()): bssid = match_result.group(1) - print ("station %s.%s connected to %s"%(resource,station_name,bssid)) + print("station %s.%s connected to %s" % (resource, station_name, bssid)) return else: - print ("station %s.%s connected to ??"%(resource,station_name)) + print("station %s.%s connected to ??" % (resource, station_name)) LFUtils.debug_printer.pprint(match_result) if ("disconnected" in message["wifi-event"]): - print ("Station %s.%s down"%(resource,station_name)) + print("Station %s.%s down" % (resource, station_name)) return if ("Trying to associate with " in message["wifi-event"]): @@ -240,10 +255,10 @@ def sock_filter(wsock, text): if (match_result and match_result.groups()): bssid = match_result.group(1) - print ("station %s.%s associating with %s"%(resource,station_name,bssid)) + print("station %s.%s associating with %s" % (resource, station_name, bssid)) return else: - print ("station %s.%s associating with ??"%(resource,station_name)) + print("station %s.%s associating with ??" % (resource, station_name)) LFUtils.debug_printer.pprint(match_result) if ("Trying to authenticate" in message["wifi-event"]): @@ -251,10 +266,10 @@ def sock_filter(wsock, text): if (match_result and match_result.groups()): bssid = match_result.group(1) - print ("station %s.%s authenticating with %s"%(resource,station_name,bssid)) + print("station %s.%s authenticating with %s" % (resource, station_name, bssid)) return else: - print ("station %s.%s authenticating with ??"%(resource,station_name)) + print("station %s.%s authenticating with ??" % (resource, station_name)) LFUtils.debug_printer.pprint(match_result) if ("Authenticated" in message["wifi-event"]): @@ -262,67 +277,70 @@ def sock_filter(wsock, text): LFUtils.debug_printer.pprint(match_result) if (match_result and match_result.groups()): bssid = match_result.group(1) - print ("station %s.%s authenticated with %s"%(resource,station_name,bssid)) + print("station %s.%s authenticated with %s" % (resource, station_name, bssid)) else: - print ("station %s.%s authenticated with ??"%(resource,station_name)) + print("station %s.%s authenticated with ??" % (resource, station_name)) - print ("w: ", message["wifi-event"]) + print("w: ", message["wifi-event"]) else: - print ("\nUnhandled: ") + print("\nUnhandled: ") LFUtils.debug_printer.pprint(message) except KeyError as kerr: - print ("# ----- Bad Key: ----- ----- ----- ----- ----- ----- ----- ----- ----- -----") - print ("input: ",text) - print (repr(kerr)) + print("# ----- Bad Key: ----- ----- ----- ----- ----- ----- ----- ----- ----- -----") + print("input: ", text) + print(repr(kerr)) traceback.print_exc() - print ("# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----") + print("# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----") sleep(1) return except json.JSONDecodeError as derr: - print ("# ----- Decode err: ----- ----- ----- ----- ----- ----- ----- ----- ----- -----") - print ("input: ",text) - print (repr(derr)) + print("# ----- Decode err: ----- ----- ----- ----- ----- ----- ----- ----- ----- -----") + print("input: ", text) + print(repr(derr)) traceback.print_exc() - print ("# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----") + print("# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----") sleep(1) return except Exception as ex: - print ("# ----- Exception: ----- ----- ----- ----- ----- ----- ----- ----- ----- -----") + print("# ----- Exception: ----- ----- ----- ----- ----- ----- ----- ----- ----- -----") print(repr(ex)) - print ("input: ",text) + print("input: ", text) LFUtils.debug_printer.pprint(message) traceback.print_exc() - print ("# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----") + print("# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----") sleep(1) return # ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- def m_error(wsock, err): - print ("# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----\n") + print("# ----- Error: ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----\n") LFUtils.debug_printer.pprint(err) - print ("# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----\n") + print("# ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----\n") + # ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- def m_open(wsock): def run(*args): time.sleep(0.1) - #ping = json.loads(); + # ping = json.loads(); wsock.send('{"text":"ping"}') + thread.start_new_thread(run, ()) - print ("started websocket client") + print("Connected...") + # ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- def m_close(wsock): LFUtils.debug_printer.pprint(wsock) + # ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- def start_websocket(uri, websock): - #websocket.enableTrace(True) websock = websocket.WebSocketApp(uri, - on_message = sock_filter, - on_error = m_error, - on_close = m_close) + on_message=sock_filter, + on_error=m_error, + on_close=m_close) websock.on_open = m_open websock.run_forever() return websock diff --git a/py-scripts/example_open_connection.py b/py-scripts/example_open_connection.py deleted file mode 100755 index 4d5308f5..00000000 --- a/py-scripts/example_open_connection.py +++ /dev/null @@ -1,109 +0,0 @@ -#!/usr/bin/env python3 - -import sys -import os -if sys.version_info[0] != 3: - print("This script requires Python 3") - exit(1) - -if 'py-json' not in sys.path: - sys.path.append(os.path.join(os.path.abspath('..'), 'py-json')) -import LANforge -from LANforge.lfcli_base import LFCliBase -from LANforge import LFUtils -import realm -import argparse -import time -import pprint - - -class IPv4Test(LFCliBase): - def __init__(self, ssid, security, password, sta_list=None, number_template="00000", host="localhost", port=8080, radio ="wiphy0",_debug_on=False, - _exit_on_error=False, - _exit_on_fail=False): - super().__init__(host, port, _debug=_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail) - self.host = host - self.port = port - self.ssid = ssid - self.security = security - self.password = password - self.sta_list = sta_list - self.timeout = 120 - self.radio=radio - self.number_template = number_template - self.debug = _debug_on - self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port) - self.station_profile = self.local_realm.new_station_profile() - - self.station_profile.lfclient_url = self.lfclient_url - self.station_profile.ssid = self.ssid - self.station_profile.ssid_pass = self.password, - self.station_profile.security = self.security - self.station_profile.number_template_ = self.number_template - self.station_profile.mode = 0 - - def build(self): - # Build stations - self.station_profile.use_security(self.security, self.ssid, self.password) - self.station_profile.set_number_template(self.number_template) - print("Creating stations") - self.station_profile.set_command_flag("add_sta", "create_admin_down", 1) - self.station_profile.set_command_param("set_port", "report_timer", 1500) - self.station_profile.set_command_flag("set_port", "rpt_timer", 1) - self.station_profile.create(radio=self.radio, sta_names_=self.sta_list, debug=self.debug) - self.station_profile.admin_up() - if self.local_realm.wait_for_ip(station_list=self.sta_list, debug=self.debug, timeout_sec=30): - self._pass("Station build finished") - self.exit_success() - else: - self._fail("Stations not able to acquire IP. Please check network input.") - self.exit_fail() - - - def cleanup(self, sta_list): - self.station_profile.cleanup(sta_list) - LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, port_list=sta_list, - debug=self.debug) - -def main(): - - parser = LFCliBase.create_basic_argparse( - prog='example_open_connection.py', - # formatter_class=argparse.RawDescriptionHelpFormatter, - formatter_class=argparse.RawTextHelpFormatter, - epilog='''\ - Example code that creates a specified amount of stations on a specified SSID using Open security. - ''', - - description='''\ - example_open_connection.py - -------------------- - - Generic command example: - python3 ./example_open_connection.py - --mgr localhost - --mgr_port 8080 - --num_stations 3 - --radio wiphy1 - --ssid netgear-open - --passwd [BLANK] - --debug - ''') - - args = parser.parse_args() - num_sta = 2 - if (args.num_stations is not None) and (int(args.num_stations) > 0): - num_sta = int(args.num_stations) - - station_list = LFUtils.portNameSeries(prefix_="sta", - start_id_=0, - end_id_=num_sta-1, - padding_number_=10000) - ip_test = IPv4Test(host=args.mgr, port=args.mgr_port, ssid=args.ssid, password=args.passwd, - security="open", radio=args.radio, sta_list=station_list) - ip_test.cleanup(station_list) - ip_test.timeout = 60 - ip_test.build() - -if __name__ == "__main__": - main() diff --git a/py-scripts/example_wep_connection.py b/py-scripts/example_wep_connection.py deleted file mode 100755 index 9eaaf607..00000000 --- a/py-scripts/example_wep_connection.py +++ /dev/null @@ -1,109 +0,0 @@ -#!/usr/bin/env python3 - -import sys -import os -if sys.version_info[0] != 3: - print("This script requires Python 3") - exit(1) - -if 'py-json' not in sys.path: - sys.path.append(os.path.join(os.path.abspath('..'), 'py-json')) -import LANforge -from LANforge.lfcli_base import LFCliBase -from LANforge import LFUtils -import realm -import argparse -import time -import pprint - - -class IPv4Test(LFCliBase): - def __init__(self, ssid, security, password, sta_list=None, number_template="00000", radio = "wiphy0",_debug_on=False, host="locahost", port=8080, - _exit_on_error=False, - _exit_on_fail=False): - super().__init__(host, port, _debug=_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail) - self.host = host - self.port = port - self.radio = radio - self.ssid = ssid - self.security = security - self.password = password - self.sta_list = sta_list - self.timeout = 120 - self.number_template = number_template - self.debug = _debug_on - self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port) - self.station_profile = self.local_realm.new_station_profile() - - self.station_profile.lfclient_url = self.lfclient_url - self.station_profile.ssid = self.ssid - self.station_profile.ssid_pass = self.password, - self.station_profile.security = self.security - self.station_profile.number_template_ = self.number_template - self.station_profile.mode = 0 - - def build(self): - # Build stations - self.station_profile.use_security(self.security, self.ssid, self.password) - self.station_profile.set_number_template(self.number_template) - print("Creating stations") - self.station_profile.set_command_flag("add_sta", "create_admin_down", 1) - self.station_profile.set_command_param("set_port", "report_timer", 1500) - self.station_profile.set_command_flag("set_port", "rpt_timer", 1) - self.station_profile.create(radio=self.radio, sta_names_=self.sta_list, debug=self.debug) - self.station_profile.admin_up() - if self.local_realm.wait_for_ip(station_list=self.sta_list, debug=self.debug, timeout_sec=30): - self._pass("Station build finished") - self.exit_success() - else: - self._fail("Stations not able to acquire IP. Please check network input.") - self.exit_fail() - - def cleanup(self, sta_list): - self.station_profile.cleanup(sta_list) - LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, port_list=sta_list, - debug=self.debug) - -def main(): - - parser = LFCliBase.create_basic_argparse( - prog='example_wep_connection.py', - # formatter_class=argparse.RawDescriptionHelpFormatter, - formatter_class=argparse.RawTextHelpFormatter, - epilog='''\ - Example code that creates a specified amount of stations on a specified SSID using WEP security. - ''', - - description='''\ - example_wep_connection.py - -------------------- - - Generic command example: - python3 ./example_wep_connection.py - --host localhost - --port 8080 - --num_stations 3 - --radio wiphy1 - --ssid jedway-wep-48 - --passwd jedway-wep-48 - --debug - ''') - - args = parser.parse_args() - num_sta = 2 - if (args.num_stations is not None) and (int(args.num_stations) > 0): - num_stations_converted = int(args.num_stations) - num_sta = num_stations_converted - - station_list = LFUtils.portNameSeries(prefix_="sta", - start_id_=0, - end_id_=num_sta-1, - padding_number_=10000) - ip_test = IPv4Test(host=args.mgr,port=args.mgr_port, ssid=args.ssid, password=args.passwd, - security="wep", radio=args.radio, sta_list=station_list) - ip_test.cleanup(station_list) - ip_test.timeout = 60 - ip_test.build() - -if __name__ == "__main__": - main() diff --git a/py-scripts/example_wpa2_connection.py b/py-scripts/example_wpa2_connection.py deleted file mode 100755 index db8bcaf6..00000000 --- a/py-scripts/example_wpa2_connection.py +++ /dev/null @@ -1,109 +0,0 @@ -#!/usr/bin/env python3 - -import sys -import os -if sys.version_info[0] != 3: - print("This script requires Python 3") - exit(1) - -if 'py-json' not in sys.path: - sys.path.append(os.path.join(os.path.abspath('..'), 'py-json')) -import LANforge -from LANforge.lfcli_base import LFCliBase -from LANforge import LFUtils -import realm -import argparse -import time -import pprint - - -class IPv4Test(LFCliBase): - def __init__(self, ssid, security, password, sta_list=None,host="localhost", port=8080, number_template="00000", radio="wiphy0",_debug_on=False, - _exit_on_error=False, - _exit_on_fail=False): - super().__init__(host, port, _debug=_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail) - self.host = host - self.port = port - self.ssid = ssid - self.radio = radio - self.security = security - self.password = password - self.sta_list = sta_list - self.timeout = 120 - self.number_template = number_template - self.debug = _debug_on - self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port) - self.station_profile = self.local_realm.new_station_profile() - - self.station_profile.lfclient_url = self.lfclient_url - self.station_profile.ssid = self.ssid - self.station_profile.ssid_pass = self.password, - self.station_profile.security = self.security - self.station_profile.number_template_ = self.number_template - self.station_profile.mode = 0 - - def build(self): - # Build stations - self.station_profile.use_security(self.security, self.ssid, self.password) - self.station_profile.set_number_template(self.number_template) - print("Creating stations") - self.station_profile.set_command_flag("add_sta", "create_admin_down", 1) - self.station_profile.set_command_param("set_port", "report_timer", 1500) - self.station_profile.set_command_flag("set_port", "rpt_timer", 1) - self.station_profile.create(radio=self.radio, sta_names_=self.sta_list, debug=self.debug) - self.station_profile.admin_up() - if self.local_realm.wait_for_ip(station_list=self.sta_list, debug=self.debug, timeout_sec=30): - self._pass("Station build finished") - self.exit_success() - else: - self._fail("Stations not able to acquire IP. Please check network input.") - self.exit_fail() - - def cleanup(self, sta_list): - self.station_profile.cleanup(sta_list) - LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, port_list=sta_list, - debug=self.debug) - -def main(): - parser = LFCliBase.create_basic_argparse( - prog='example_wpa2_connection.py', - # formatter_class=argparse.RawDescriptionHelpFormatter, - formatter_class=argparse.RawTextHelpFormatter, - epilog='''\ - Example code that creates a specified amount of stations on a specified SSID using WPA2 security. - ''', - - description='''\ - example_wpa2_connection.py - -------------------- - - Generic command example - python3 ./example_wpa2_connection.py - --host localhost - --port 8080 - --num_stations 3 - --ssid netgear-wpa2 - --passwd admin123-wpa2 - --radio wiphy1 - --debug - ''') - - args = parser.parse_args() - num_sta = 2 - if (args.num_stations is not None) and (int(args.num_stations) > 0): - num_stations_converted = int(args.num_stations) - num_sta = num_stations_converted - - station_list = LFUtils.portNameSeries(prefix_="sta", - start_id_=0, - end_id_=num_sta-1, - padding_number_=10000, - radio=args.radio) - ip_test = IPv4Test(host=args.mgr, port=args.mgr_port, ssid=args.ssid, password=args.passwd, radio=args.radio, - security="wpa2", sta_list=station_list) - ip_test.cleanup(station_list) - ip_test.timeout = 60 - ip_test.build() - -if __name__ == "__main__": - main() diff --git a/py-scripts/example_wpa3_connection.py b/py-scripts/example_wpa3_connection.py deleted file mode 100755 index a9e49286..00000000 --- a/py-scripts/example_wpa3_connection.py +++ /dev/null @@ -1,110 +0,0 @@ -#!/usr/bin/env python3 - -import sys -import os -if sys.version_info[0] != 3: - print("This script requires Python 3") - exit(1) -if 'py-json' not in sys.path: - sys.path.append(os.path.join(os.path.abspath('..'), 'py-json')) -import LANforge -from LANforge.lfcli_base import LFCliBase -from LANforge import LFUtils -import realm -import argparse -import time -import pprint - - -class IPv4Test(LFCliBase): - def __init__(self, ssid, security, password, host="localhost", port=8080,sta_list=None, number_template="00000", radio = "wiphy0",_debug_on=False, - _exit_on_error=False, - _exit_on_fail=False): - super().__init__(host, port, _debug=_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail) - self.host = host - self.port = port - self.ssid = ssid - self.radio = radio - self.security = security - self.password = password - self.sta_list = sta_list - self.timeout = 120 - self.number_template = number_template - self.debug = _debug_on - self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port) - self.station_profile = self.local_realm.new_station_profile() - - self.station_profile.lfclient_url = self.lfclient_url - self.station_profile.ssid = self.ssid - self.station_profile.ssid_pass = self.password, - self.station_profile.security = self.security - self.station_profile.number_template_ = self.number_template - self.station_profile.mode = 0 - - def build(self): - # Build stations - #print("We've gotten into the build stations function") - self.station_profile.use_security(self.security, self.ssid, self.password) - self.station_profile.set_number_template(self.number_template) - print("Creating stations") - self.station_profile.set_command_flag("add_sta", "create_admin_down", 1) - self.station_profile.set_command_param("set_port", "report_timer", 1500) - self.station_profile.set_command_flag("set_port", "rpt_timer", 1) - self.station_profile.create(radio=self.radio, sta_names_=self.sta_list, debug=self.debug) - self.station_profile.admin_up() - if self.local_realm.wait_for_ip(station_list=self.sta_list, debug=self.debug, timeout_sec=30): - self._pass("Station build finished") - self.exit_success() - else: - self._fail("Stations not able to acquire IP. Please check network input.") - self.exit_fail() - - - def cleanup(self, sta_list): - self.station_profile.cleanup(sta_list) - LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, port_list=sta_list, - debug=self.debug) - -def main(): - parser = LFCliBase.create_basic_argparse( - prog='example_wpa3_connection.py', - # formatter_class=argparse.RawDescriptionHelpFormatter, - formatter_class=argparse.RawTextHelpFormatter, - epilog='''\ - Example code that creates a specified amount of stations on a specified SSID using WPA3 security. - ''', - - description='''\ - example_wpa3_connection.py - -------------------- - - Generic command example: - python3 ./example_wpa3_connection.py - --host localhost - --port 8080 - --num_stations 3 - --ssid netgear-wpa3 - --passwd admin123-wpa3 - --radio wiphy1 - --debug - ''') - - args = parser.parse_args() - num_sta = 2 - if (args.num_stations is not None) and (int(args.num_stations) > 0): - num_stations_converted = int(args.num_stations) - num_sta = num_stations_converted - - station_list = LFUtils.portNameSeries(prefix_="sta", - start_id_=0, - end_id_=num_sta-1, - padding_number_=10000, - radio=args.radio) - ip_test = IPv4Test(host=args.mgr, port=args.mgr_port, ssid=args.ssid, password=args.passwd, radio=args.radio, - security="wpa3", sta_list=station_list) - ip_test.cleanup(station_list) - ip_test.timeout = 60 - ip_test.build() - -if __name__ == "__main__": - main() diff --git a/py-scripts/example_wpa_connection.py b/py-scripts/example_wpa_connection.py deleted file mode 100755 index db8fcf1a..00000000 --- a/py-scripts/example_wpa_connection.py +++ /dev/null @@ -1,114 +0,0 @@ -#!/usr/bin/env python3 - -import sys -import os -if sys.version_info[0] != 3: - print("This script requires Python 3") - exit(1) - -if 'py-json' not in sys.path: - sys.path.append(os.path.join(os.path.abspath('..'), 'py-json')) -import argparse -import LANforge -from LANforge.lfcli_base import LFCliBase -from LANforge import LFUtils -import realm -import time -import pprint - - -class IPv4Test(LFCliBase): - def __init__(self, ssid, security, password, sta_list=None, host="locahost", port=8080, number_template="00000", radio ="wiphy0", _debug_on=False, - _exit_on_error=False, - _exit_on_fail=False): - super().__init__(host, port, _debug=_debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail) - self.host = host - self.port = port - self.ssid = ssid - self.radio= radio - self.security = security - self.password = password - self.sta_list = sta_list - self.timeout = 120 - self.number_template = number_template - self.debug = _debug_on - self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port) - self.station_profile = self.local_realm.new_station_profile() - - self.station_profile.lfclient_url = self.lfclient_url - self.station_profile.ssid = self.ssid - self.station_profile.ssid_pass = self.password, - self.station_profile.security = self.security - self.station_profile.number_template_ = self.number_template - self.station_profile.mode = 0 - - def build(self): - # Build stations - self.station_profile.use_security(self.security, self.ssid, self.password) - self.station_profile.set_number_template(self.number_template) - print("Creating stations") - self.station_profile.set_command_flag("add_sta", "create_admin_down", 1) - self.station_profile.set_command_param("set_port", "report_timer", 1500) - self.station_profile.set_command_flag("set_port", "rpt_timer", 1) - self.station_profile.create(radio=self.radio, sta_names_=self.sta_list, debug=self.debug) - self.station_profile.admin_up() - if self.local_realm.wait_for_ip(station_list=self.sta_list, debug=self.debug, timeout_sec=30): - self._pass("Station build finished") - self.exit_success() - - else: - self._fail("Stations not able to acquire IP. Please check network input.") - self.exit_fail() - - - def cleanup(self, sta_list): - self.station_profile.cleanup(sta_list) - LFUtils.wait_until_ports_disappear(base_url=self.lfclient_url, port_list=sta_list, - debug=self.debug) - - - -def main(): - parser = LFCliBase.create_basic_argparse( - prog='example_wpa_connection.py', - # formatter_class=argparse.RawDescriptionHelpFormatter, - formatter_class=argparse.RawTextHelpFormatter, - epilog='''\ - Example code that creates a specified amount of stations on a specified SSID using WPA security. - ''', - - description='''\ - example_wpa_connection.py - -------------------- - - Generic command example: - python3 ./example_wpa_connection.py - --host localhost - --port 8080 - --num_stations 3 - --ssid netgear-wpa - --passwd admin123-wpa - --radio wiphy1 - --debug - ''') - - args = parser.parse_args() - num_sta = 2 - if (args.num_stations is not None) and (int(args.num_stations) > 0): - num_stations_converted = int(args.num_stations) - num_sta = num_stations_converted - - station_list = LFUtils.portNameSeries(prefix_="sta", - start_id_=0, - end_id_=num_sta-1, - padding_number_=10000, - radio=args.radio) - - ip_test = IPv4Test(host=args.mgr, port=args.mgr_port, ssid=args.ssid, password=args.passwd, radio=args.radio, - security="wpa", sta_list=station_list) - ip_test.cleanup(station_list) - ip_test.timeout = 60 - ip_test.build() - -if __name__ == "__main__": - main() diff --git a/py-scripts/lf_cisco_dfs.py b/py-scripts/lf_cisco_dfs.py index 2d74a086..cf8a8b2a 100644 --- a/py-scripts/lf_cisco_dfs.py +++ b/py-scripts/lf_cisco_dfs.py @@ -11,42 +11,1266 @@ if 'py-json' not in sys.path: sys.path.append(os.path.join(os.path.abspath('..'), 'py-json')) import argparse +from LANforge.lfcli_base import LFCliBase from LANforge import LFUtils +import realm import time -import test_l3_longevity as DFS +import datetime +import subprocess +import re +import csv +import random +import logging +# Check for the logs channel switching time and radar detected + + +FORMAT = '%(asctime)s %(name)s %(levelname)s: %(message)s' + +# see https://stackoverflow.com/a/13306095/11014343 +class FileAdapter(object): + def __init__(self, logger): + self.logger = logger + def write(self, data): + # NOTE: data can be a partial line, multiple lines + data = data.strip() # ignore leading/trailing whitespace + if data: # non-blank + self.logger.info(data) + def flush(self): + pass # leave it to logging to flush properly + + +class hack_rf_(): + def __init__(self, args): + self.args = args + + def lf_hackrf_enable(self): + pass + + def lf_hackrf_disable(self): + pass + + +################################################################################ +# cisco controller class :This class will be left in this file to allow for the +# Scaling and Performance to be self contained and not impact other tests +################################################################################ + +class cisco_(): + def __init__(self, args): + self.args = args + + #show summary (to get AP) (3400/9800) + #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 --action summary --series 9800 --log stdout + def controller_show_summary(self): + try: + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user, + self.args.cisco_passwd,self.args.cisco_ap,self.args.cisco_series,self.args.cisco_band,"summary")) + + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + self.args.cisco_user, "-p", self.args.cisco_passwd, + "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "summary"], + capture_output=self.args.cap_ctl_out, check=True) + if self.args.cap_ctl_out: + pss = ctl_output.stdout.decode('utf-8', 'ignore') + logg.info(pss) + + except subprocess.CalledProcessError as process_error: + logg.info("Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}" + .format(process_error.returncode, process_error.output)) + time.sleep(1) + exit(1) + + + #show ap dot11 5ghz summary (band defaults to 5ghz) --band a + #show ap dot11 24ghz summary use --band b for 2.4 ghz + #action advanced (3400/9800) + #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 --action advanced --series 9800 --log stdout + def controller_show_ap_summary(self): + try: + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user, + self.args.cisco_passwd,self.args.cisco_ap,self.args.cisco_series,self.args.cisco_band,"advanced")) + + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + self.args.cisco_user, "-p", self.args.cisco_passwd, + "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "advanced"], + capture_output=self.args.cap_ctl_out, check=True) + if self.args.cap_ctl_out: + pss = ctl_output.stdout.decode('utf-8', 'ignore') + logg.info(pss) + + except subprocess.CalledProcessError as process_error: + logg.info("Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}". + format(process_error.returncode, process_error.output)) + time.sleep(1) + exit(1) + + #show wlan summary + def controller_show_wlan_summary(self): + try: + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user, + self.args.cisco_passwd,self.args.cisco_ap,self.args.cisco_series,self.args.cisco_band,"show wlan summary")) + + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + self.args.cisco_user, "-p", self.args.cisco_passwd, + "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "show_wlan_summary"], + capture_output=self.args.cap_ctl_out, check=True) + + if self.args.cap_ctl_out: + pss = ctl_output.stdout.decode('utf-8', 'ignore') + logg.info(pss) + + except subprocess.CalledProcessError as process_error: + logg.info("Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}". + format(process_error.returncode, process_error.output)) + time.sleep(1) + exit(1) + + #disable AP + #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action disable --series 9800 + def controller_disable_ap(self): + try: + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user, + self.args.cisco_passwd,self.args.cisco_ap,self.args.cisco_series,self.args.cisco_band,"disable")) + + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", + self.args.cisco_ctlr, "-u",self.args.cisco_user, "-p", self.args.cisco_passwd, + "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "disable"], + capture_output=self.args.cap_ctl_out, check=True) + + if self.args.cap_ctl_out: + pss = ctl_output.stdout.decode('utf-8', 'ignore') + logg.info(pss) + + except subprocess.CalledProcessError as process_error: + logg.info("Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}". + format(process_error.returncode, process_error.output)) + time.sleep(1) + exit(1) + + + #disable wlan + #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action disable_wlan --series 9800 + def controller_disable_wlan(self): + try: + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user, + self.args.cisco_passwd,self.args.cisco_ap,self.args.cisco_series,self.args.cisco_band,"disable_wlan")) + + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + self.args.cisco_user, "-p", self.args.cisco_passwd, + "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "disable_wlan"], + capture_output=self.args.cap_ctl_out, check=True) + + if self.args.cap_ctl_out: + pss = ctl_output.stdout.decode('utf-8', 'ignore') + logg.info(pss) + + except subprocess.CalledProcessError as process_error: + logg.info("Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}". + format(process_error.returncode, process_error.output)) + time.sleep(1) + exit(1) + + + #disable network 5ghz + #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action disable_network_5ghz --series 9800 + def controller_disable_network_5ghz(self): + if self.args.cisco_series == "9800": + try: + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user, + self.args.cisco_passwd,self.args.cisco_ap,self.args.cisco_series,self.args.cisco_band,"disable_network_5ghz")) + + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + self.args.cisco_user, "-p", self.args.cisco_passwd, + "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "disable_network_5ghz"], + capture_output=self.args.cap_ctl_out, check=True) + + if self.args.cap_ctl_out: + pss = ctl_output.stdout.decode('utf-8', 'ignore') + logg.info(pss) + + except subprocess.CalledProcessError as process_error: + logg.info("Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}". + format(process_error.returncode, process_error.output)) + time.sleep(1) + exit(1) + else: + try: + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + self.args.cisco_band,"cmd","config 802.11a disable network")) + + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + self.args.cisco_user, "-p", self.args.cisco_passwd, + "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "cmd", "--value", "config 802.11a disable network"], + capture_output=self.args.cap_ctl_out, check=True) + + if self.args.cap_ctl_out: + pss = ctl_output.stdout.decode('utf-8', 'ignore') + logg.info(pss) + + except subprocess.CalledProcessError as process_error: + logg.info("Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}". + format(process_error.returncode, process_error.output)) + time.sleep(1) + exit(1) + + + #disable network 24ghz + #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action disable_network_24ghz --series 9800 + def controller_disable_network_24ghz(self): + if self.args.cisco_series == "9800": + try: + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user, + self.args.cisco_passwd,self.args.cisco_ap,self.args.cisco_series,self.args.cisco_band,"disable_network_24ghz")) + + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + self.args.cisco_user, "-p", self.args.cisco_passwd, + "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "disable_network_24ghz"], + capture_output=self.args.cap_ctl_out, check=True) + + if self.args.cap_ctl_out: + pss = ctl_output.stdout.decode('utf-8', 'ignore') + logg.info(pss) + + except subprocess.CalledProcessError as process_error: + logg.info("Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}". + format(process_error.returncode, process_error.output)) + time.sleep(1) + exit(1) + else: + try: + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + self.args.cisco_band,"cmd","config 802.11b disable network")) + + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + self.args.cisco_user, "-p", self.args.cisco_passwd, + "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "cmd", "--value", "config 802.11b disable network"], + capture_output=self.args.cap_ctl_out, check=True) + + if self.args.cap_ctl_out: + pss = ctl_output.stdout.decode('utf-8', 'ignore') + logg.info(pss) + + except subprocess.CalledProcessError as process_error: + logg.info("Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}". + format(process_error.returncode, process_error.output)) + time.sleep(1) + exit(1) + + + + #set manual mode - Series 9800 must be set to manual mode + #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action manual --series 9800 + # ap name dot11 5ghz radio role manual client-serving + def controller_role_manual(self): + if self.args.cisco_series == "9800": + try: + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user, + self.args.cisco_passwd,self.args.cisco_ap,self.args.cisco_series,self.args.cisco_band,"manual")) + + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + self.args.cisco_user, "-p", self.args.cisco_passwd, + "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "manual"], + capture_output=self.args.cap_ctl_out, check=True) + + if self.args.cap_ctl_out: + pss = ctl_output.stdout.decode('utf-8', 'ignore') + logg.info(pss) + + except subprocess.CalledProcessError as process_error: + logg.info("Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}". + format(process_error.returncode, process_error.output)) + time.sleep(1) + exit(1) + else: + logg.info("Check the cisco_scheme used attemping 9800 series on 3504 controller: {}".format(self.args.cisco_scheme)) + + #set manual mode - Series 9800 must be set to auto mode + #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action auto --series 9800 + # ap name dot11 5ghz radio role manual client-serving + def controller_role_auto(self): + if self.args.cisco_series == "9800": + try: + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user, + self.args.cisco_passwd,self.args.cisco_ap,self.args.cisco_series,self.args.cisco_band,"auto")) + + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + self.args.cisco_user, "-p", self.args.cisco_passwd, + "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "auto"], + capture_output=self.args.cap_ctl_out, check=True) + + if self.args.cap_ctl_out: + pss = ctl_output.stdout.decode('utf-8', 'ignore') + logg.info(pss) + + except subprocess.CalledProcessError as process_error: + logg.info("Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}". + format(process_error.returncode, process_error.output)) + time.sleep(1) + exit(1) + else: + logg.info("Check the cisco_scheme used attemping 9800 series on 3504 controller: {}".format(self.args.cisco_scheme)) + + #test parameters summary (txPower 1-8) + #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action txPower --value 5 --series 9800 + def controller_set_tx_power(self): + try: + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + self.args.cisco_band,"txPower", self.args.cisco_tx_power )) # TODO fix txPower to tx_power in cisco_wifi_ctl.py + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + self.args.cisco_user, "-p", self.args.cisco_passwd, + "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, + "--action", "txPower","--value", self.args.cisco_tx_power], + capture_output=self.args.cap_ctl_out, check=True) + + if self.args.cap_ctl_out: + pss = ctl_output.stdout.decode('utf-8', 'ignore') + logg.info(pss) + + except subprocess.CalledProcessError as process_error: + logg.info("Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}". + format(process_error.returncode, process_error.output)) + time.sleep(1) + exit(1) + + + #set channel [36, 64, 100] + #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action channel --value 36 --series 9800 + # 9800 : ap name dot11 [5ghz | 24ghz] channel + # 3504 : (Cisco Controller) >config 802.11a channel ap APA453.0E7B.CF9C 52 + def controller_set_channel(self): + try: + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + self.args.cisco_band,"channel", self.args.cisco_channel )) + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + self.args.cisco_user, "-p", self.args.cisco_passwd, + "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, + "--action", "channel","--value", self.args.cisco_channel], + capture_output=self.args.cap_ctl_out, check=True) + + if self.args.cap_ctl_out: + pss = ctl_output.stdout.decode('utf-8', 'ignore') + logg.info(pss) + + except subprocess.CalledProcessError as process_error: + logg.info("Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}". + format(process_error.returncode, process_error.output)) + time.sleep(1) + exit(1) + + + #set bandwidth [20 40 80 160] + #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action bandwidth --value 40 --series 9800 + def controller_set_bandwidth(self): + try: + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + self.args.cisco_band,"channel", self.args.cisco_chan_width )) + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + self.args.cisco_user, "-p", self.args.cisco_passwd, + "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, + "--action", "channel","--value", self.args.cisco_chan_width], + capture_output=self.args.cap_ctl_out, check=True) + + if self.args.cap_ctl_out: + pss = ctl_output.stdout.decode('utf-8', 'ignore') + logg.info(pss) + + except subprocess.CalledProcessError as process_error: + logg.info("Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}". + format(process_error.returncode, process_error.output)) + time.sleep(1) + exit(1) + + + #create wlan + #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action create_wlan --wlan "open-wlan" --wlanID 1 --series 9800 + def controller_create_wlan(self): + if self.args.cisco_series == "9800": + try: + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} wlan {} wlanID {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + self.args.cisco_band,"create_wlan", self.args.cisco_wlan, self.args.cisco_wlanID )) + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + self.args.cisco_user, "-p", self.args.cisco_passwd, + "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, + "--action", "create_wlan","--wlan", self.args.cisco_wlan, "--wlanID", self.args.cisco_wlanID], + capture_output=self.args.cap_ctl_out, check=True) + + if self.args.cap_ctl_out: + pss = ctl_output.stdout.decode('utf-8', 'ignore') + logg.info(pss) + + except subprocess.CalledProcessError as process_error: + logg.info("Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}". + format(process_error.returncode, process_error.output)) + time.sleep(1) + exit(1) + else: + logg.info("Check the cisco_scheme used attemping 9800 series on 3504 controller: {}".format(self.args.cisco_scheme)) + + #create wireless tag policy --9800 series needs to have wireless tag policy set + #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action wireless_tag_policy --series 9800 + def controller_set_wireless_tag_policy(self): + if self.args.cisco_series == "9800": + try: + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + self.args.cisco_band,"wireless_tag_policy" )) + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + self.args.cisco_user, "-p", self.args.cisco_passwd, + "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, + "--action", "wireless_tag_policy"], + capture_output=self.args.cap_ctl_out, check=True) + + if self.args.cap_ctl_out: + pss = ctl_output.stdout.decode('utf-8', 'ignore') + logg.info(pss) + + except subprocess.CalledProcessError as process_error: + logg.info("Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}". + format(process_error.returncode, process_error.output)) + time.sleep(1) + exit(1) + else: + logg.info("Check the cisco_scheme used attemping 9800 series on 3504 controller: {}".format(self.args.cisco_scheme)) + + + #enable wlan + #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action enable_wlan --series 9800 + def controller_enable_wlan(self): + try: + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + self.args.cisco_band,"enable_wlan")) + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + self.args.cisco_user, "-p", self.args.cisco_passwd, + "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, + "--action", "enable_wlan"], + capture_output=self.args.cap_ctl_out, check=True) + + if self.args.cap_ctl_out: + pss = ctl_output.stdout.decode('utf-8', 'ignore') + logg.info(pss) + + except subprocess.CalledProcessError as process_error: + logg.info("Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}". + format(process_error.returncode, process_error.output)) + time.sleep(1) + exit(1) + + + #enable 5ghz + #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action enable_network_5ghz --series 9800 + def controller_enable_network_5ghz(self): + if self.args.cisco_series == "9800": + try: + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + self.args.cisco_band,"enable_network_5ghz")) + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + self.args.cisco_user, "-p", self.args.cisco_passwd, + "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, + "--action", "enable_network_5ghz"], + capture_output=self.args.cap_ctl_out, check=True) + + if self.args.cap_ctl_out: + pss = ctl_output.stdout.decode('utf-8', 'ignore') + logg.info(pss) + + except subprocess.CalledProcessError as process_error: + logg.info("Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}". + format(process_error.returncode, process_error.output)) + time.sleep(1) + exit(1) + else: + try: + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + self.args.cisco_band,"cmd","config 802.11a enable network")) + + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + self.args.cisco_user, "-p", self.args.cisco_passwd, + "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "cmd", "--value", "config 802.11a enable network"], + capture_output=self.args.cap_ctl_out, check=True) + + if self.args.cap_ctl_out: + pss = ctl_output.stdout.decode('utf-8', 'ignore') + logg.info(pss) + + except subprocess.CalledProcessError as process_error: + logg.info("Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}". + format(process_error.returncode, process_error.output)) + time.sleep(1) + exit(1) + + + + #enable 24ghz + #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action enable_network_24ghz --series 9800 + def controller_enable_network_24ghz(self): + if self.args.cisco_series == "9800": + try: + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + self.args.cisco_band,"enable_network_24ghz")) + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + self.args.cisco_user, "-p", self.args.cisco_passwd, + "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, + "--action", "enable_network_24ghz"], + capture_output=self.args.cap_ctl_out, check=True) + + if self.args.cap_ctl_out: + pss = ctl_output.stdout.decode('utf-8', 'ignore') + logg.info(pss) + + except subprocess.CalledProcessError as process_error: + logg.info("Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}". + format(process_error.returncode, process_error.output)) + time.sleep(1) + exit(1) + else: + try: + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + self.args.cisco_band,"cmd","config 802.11b enable network")) + + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + self.args.cisco_user, "-p", self.args.cisco_passwd, + "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "cmd", "--value", "config 802.11b enable network"], + capture_output=self.args.cap_ctl_out, check=True) + + if self.args.cap_ctl_out: + pss = ctl_output.stdout.decode('utf-8', 'ignore') + logg.info(pss) + + except subprocess.CalledProcessError as process_error: + logg.info("Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}". + format(process_error.returncode, process_error.output)) + time.sleep(1) + exit(1) + + + + #enable (band a) + #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action enable --series 9800 + def controller_enable_ap(self): + try: + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + self.args.cisco_band,"enable")) + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + self.args.cisco_user, "-p", self.args.cisco_passwd, + "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, + "--action", "enable"], + capture_output=self.args.cap_ctl_out, check=True) + + if self.args.cap_ctl_out: + pss = ctl_output.stdout.decode('utf-8', 'ignore') + logg.info(pss) + + except subprocess.CalledProcessError as process_error: + logg.info("Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}". + format(process_error.returncode, process_error.output)) + time.sleep(1) + exit(1) + + + #advanced (showes summary) + #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action advanced --series 9800 + def controller_show_ap_channel(self): + advanced = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + self.args.cisco_user, "-p", self.args.cisco_passwd, + "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--action", "ap_channel"], capture_output=True) + + pss = advanced.stdout.decode('utf-8', 'ignore') + logg.info(pss) + + if self.args.cisco_series == "9800": + for line in pss.splitlines(): + search_str = self.args.cisco_ap + logg.info("line {}".format(line)) + element_list = line.lstrip().split() + logg.info("element_list {}".format(element_list)) + if (line.lstrip().startswith(search_str)): + logg.info("line {}".format(line)) + element_list = line.lstrip().split() + logg.info("element_list {}".format(element_list)) + # AP Name (0) mac (1) slot (2) Admin State [enable/disable] (3) Oper State [Up/Down] (4) Width (5) Txpwr (6,7) channel (8) mode (9) + logg.info("ap: {} slof {} channel {} chan_width {}".format(element_list[0],element_list[2],element_list[8],element_list[5])) + if (str(self.args.cisco_channel) in str(element_list[8])) and (str(self.args.cisco_chan_width) in str(element_list[5])): + logg.info("ap {} configuration successful: channel {} in expected {} chan_width {} in expected {}" + .format(element_list[0],self.args.cisco_channel,element_list[8],self.args.cisco_chan_width,element_list[5])) + else: + logg.info("WARNING ap {} configuration: channel {} in expected {} chan_width {} in expected {}" + .format(element_list[0],self.args.cisco_channel,element_list[8],self.args.cisco_chan_width,element_list[5])) + break + else: + logg.info("checking for 802.11{}".format(self.args.cisco_band)) + + for line in pss.splitlines(): + #logg.info("line {}".format(line)) + search_str = "802.11{}".format(self.args.cisco_band) + if (line.lstrip().startswith(search_str)): + logg.info("line {}".format(line)) + element_list = line.lstrip().split() + logg.info("element_list {}".format(element_list)) + logg.info("ap: {} channel {} chan_width {}".format(self.args.cisco_ap,element_list[4],element_list[5])) + if (str(self.args.cisco_channel) in str(element_list[4])) and (str(self.args.cisco_chan_width) in str(element_list[5])): + logg.info("ap configuration successful: channel {} in expected {} chan_width {} in expected {}" + .format(self.args.cisco_channel,element_list[4],self.args.cisco_chan_width,element_list[5])) + else: + logg.info("AP WARNING: channel {} expected {} chan_width {} expected {}" + .format(element_list[4],self.cisco_channel,element_list[5],self.args.cisco_chan_width)) + break + + logg.info("configure ap {} channel {} chan_width {}".format(self.args.cisco_ap,self.args.cisco_channel,self.args.cisco_chan_width)) + # Verify channel and channel width. +########################################## +# End of cisco controller class +########################################## + + + +########################################## +# Traffic Generation +########################################## +class L3VariableTime(LFCliBase): + def __init__(self, host, port, endp_type, args, tos, side_b, radio_name_list, number_of_stations_per_radio_list, + ssid_list, ssid_password_list, ssid_security_list, wifimode_list,station_lists, name_prefix, debug_on, outfile, results, + test_keys,test_config, + reset_port_enable_list, + reset_port_time_min_list, + reset_port_time_max_list, + csv_started=False, + side_a_min_bps=560000, side_a_max_bps=0, + side_a_min_pdu=1518,side_a_max_pdu=0, + side_b_min_bps=560000, side_b_max_bps=0, + side_b_min_pdu=1518,side_b_max_pdu=0, + number_template="00", test_duration="256s", + polling_interval="60s", + _exit_on_error=False, + _exit_on_fail=False): + super().__init__(host, port, _debug=debug_on, _halt_on_error=_exit_on_error, _exit_on_fail=_exit_on_fail) + self.host = host + self.port = port + self.tos = tos.split() + self.endp_type = endp_type + self.side_b = side_b + self.ssid_list = ssid_list + self.ssid_password_list = ssid_password_list + self.station_lists = station_lists + self.ssid_security_list = ssid_security_list + self.wifimode_list = wifimode_list + self.reset_port_enable_list = reset_port_enable_list + self.reset_port_time_min_list = reset_port_time_min_list + self.reset_port_time_max_list = reset_port_time_max_list + self.number_template = number_template + self.name_prefix = name_prefix + self.test_duration = test_duration + self.radio_name_list = radio_name_list + self.number_of_stations_per_radio_list = number_of_stations_per_radio_list + self.local_realm = realm.Realm(lfclient_host=self.host, lfclient_port=self.port, debug_=debug_on) + self.polling_interval_seconds = self.local_realm.duration_time_to_seconds(polling_interval) + self.cx_profile = self.local_realm.new_l3_cx_profile() + self.multicast_profile = self.local_realm.new_multicast_profile() + self.multicast_profile.name_prefix = "MLT-" + self.station_profiles = [] + self.args = args + self.outfile = outfile + self.results = results + self.csv_started = csv_started + self.epoch_time = int(time.time()) + self.debug = debug_on + self.test_keys = test_keys + self.test_config = test_config + + self.test_config_dict = dict(map(lambda x: x.split('=='), str(self.test_config).replace('[','').replace(']','').replace("'","").split())) + + + # Full spread-sheet data + if self.outfile is not None: + self.csv_file = open(self.outfile, "a+") + self.csv_writer = csv.writer(self.csv_file, delimiter=",") + + if self.results is not None: + self.csv_results = open(self.results, "a+") + self.csv_results_writer = csv.writer(self.csv_results, delimiter=",") + + for (radio_, ssid_, ssid_password_, ssid_security_, wifimode_,\ + reset_port_enable_, reset_port_time_min_, reset_port_time_max_) \ + in zip(radio_name_list, ssid_list, ssid_password_list, ssid_security_list, wifimode_list,\ + reset_port_enable_list, reset_port_time_min_list, reset_port_time_max_list): + self.station_profile = self.local_realm.new_station_profile() + self.station_profile.lfclient_url = self.lfclient_url + self.station_profile.ssid = ssid_ + self.station_profile.ssid_pass = ssid_password_ + self.station_profile.security = ssid_security_ + self.station_profile.mode = wifimode_ + self.station_profile.number_template = self.number_template + self.station_profile.mode = wifimode_ + self.station_profile.set_reset_extra(reset_port_enable=reset_port_enable_,\ + test_duration=self.local_realm.duration_time_to_seconds(self.test_duration),\ + reset_port_min_time=self.local_realm.duration_time_to_seconds(reset_port_time_min_),\ + reset_port_max_time=self.local_realm.duration_time_to_seconds(reset_port_time_max_)) + self.station_profiles.append(self.station_profile) + + self.multicast_profile.host = self.host + self.cx_profile.host = self.host + self.cx_profile.port = self.port + self.cx_profile.name_prefix = self.name_prefix + self.cx_profile.side_a_min_bps = side_a_min_bps + self.cx_profile.side_a_max_bps = side_a_min_bps + self.cx_profile.side_a_min_pdu = side_a_min_pdu + self.cx_profile.side_a_max_pdu = side_a_max_pdu + self.cx_profile.side_b_min_bps = side_b_min_bps + self.cx_profile.side_b_max_bps = side_b_min_bps + self.cx_profile.side_b_min_pdu = side_b_min_pdu + self.cx_profile.side_b_max_pdu = side_b_max_pdu + + def __get_rx_values(self): + endp_list = self.json_get("endp?fields=name,rx+bytes,rx+drop+%25", debug_=False) + endp_rx_drop_map = {} + endp_rx_map = {} + our_endps = {} + for e in self.multicast_profile.get_mc_names(): + our_endps[e] = e + for e in self.cx_profile.created_endp.keys(): + our_endps[e] = e + for endp_name in endp_list['endpoint']: + if endp_name != 'uri' and endp_name != 'handler': + for item, value in endp_name.items(): + if item in our_endps: + for value_name, value_rx in value.items(): + if value_name == 'rx bytes': + endp_rx_map[item] = value_rx + for value_name, value_rx_drop in value.items(): + if value_name == 'rx drop %': + endp_rx_drop_map[item] = value_rx_drop + + return endp_rx_map, endp_rx_drop_map + + def time_stamp(self): + return time.strftime('%Y-%m-%d %H %M %S', time.localtime(self.epoch_time)) + + def __record_rx_dropped_percent(self,rx_drop_percent): + csv_rx_drop_percent_data = [] + print("test_keys {}".format(self.test_keys)) + print("self.test_config_dict {}".format(self.test_config_dict)) + for key in self.test_keys: + csv_rx_drop_percent_data.append(self.test_config_dict[key]) + + csv_rx_drop_percent_data.extend([self.epoch_time, self.time_stamp(),'rx_drop_percent']) + # remove multi cast since downstream only if selected + for key in [key for key in rx_drop_percent if "mtx" in key]: del rx_drop_percent[key] + + if "upstream" in self.test_config_dict.values(): + for key in [key for key in rx_drop_percent if "-A" in key]: del rx_drop_percent[key] + elif "downstream" in self.test_config_dict.values(): + for key in [key for key in rx_drop_percent if "-B" in key]: del rx_drop_percent[key] + + + filtered_values = [v for _, v in rx_drop_percent.items() if v !=0] + average_rx_drop_percent = sum(filtered_values) / len(filtered_values) if len(filtered_values) != 0 else 0 + + csv_performance_rx_drop_percent_values=sorted(rx_drop_percent.items(), key=lambda x: (x[1],x[0]), reverse=False) + csv_performance_rx_drop_percent_values=self.csv_validate_list(csv_performance_rx_drop_percent_values,5) + for i in range(5): + csv_rx_drop_percent_data.append(str(csv_performance_rx_drop_percent_values[i]).replace(',',';')) + for i in range(-1,-6,-1): + csv_rx_drop_percent_data.append(str(csv_performance_rx_drop_percent_values[i]).replace(',',';')) + + csv_rx_drop_percent_data.append(average_rx_drop_percent) + + for item, value in rx_drop_percent.items(): + #logg.info(item, "rx drop percent: ", rx_drop_percent[item]) + csv_rx_drop_percent_data.append(rx_drop_percent[item]) + + self.csv_add_row(csv_rx_drop_percent_data,self.csv_writer,self.csv_file) + self.csv_add_row(csv_rx_drop_percent_data,self.csv_results_writer,self.csv_results) + + def __compare_vals(self, old_list, new_list): + passes = 0 + expected_passes = 0 + csv_performance_values = [] + csv_rx_headers = [] + csv_rx_row_data = [] + csv_result_row_data = [] + csv_rx_delta_row_data = [] + csv_rx_delta_dict = {} + test_id = "" + + #for key in self.test_keys: + # csv_rx_row_data.append(self.test_config_dict[key]) + # csv_rx_delta_row_data.append(self.test_config_dict[key]) + + + for key in [key for key in old_list if "mtx" in key]: del old_list[key] + for key in [key for key in new_list if "mtx" in key]: del new_list[key] + + filtered_values = [v for _, v in new_list.items() if v !=0] + average_rx= sum(filtered_values) / len(filtered_values) if len(filtered_values) != 0 else 0 + + # only evaluate upstream or downstream + new_evaluate_list = new_list.copy() + print("new_evaluate_list before",new_evaluate_list) + if "upstream" in self.test_config_dict.values(): + for key in [key for key in new_evaluate_list if "-A" in key]: del new_evaluate_list[key] + print("upstream in dictionary values") + elif "downstream" in self.test_config_dict.values(): + for key in [key for key in new_evaluate_list if "-B" in key]: del new_evaluate_list[key] + print("downstream in dictionary values") + #follow code left in for now, provides the best 5 worst 5 + '''print("new_evaluate_list after",new_evaluate_list) + csv_performance_values=sorted(new_evaluate_list.items(), key=lambda x: (x[1],x[0]), reverse=False) + csv_performance_values=self.csv_validate_list(csv_performance_values,5) + for i in range(5): + csv_rx_row_data.append(str(csv_performance_values[i]).replace(',',';')) + for i in range(-1,-6,-1): + csv_rx_row_data.append(str(csv_performance_values[i]).replace(',',';')) + + csv_rx_row_data.append(average_rx)''' + + old_evaluate_list = old_list.copy() + if "upstream" in self.test_config_dict.values(): + for key in [key for key in old_evaluate_list if "-A" in key]: del old_evaluate_list[key] + print("upstream in dictionary values") + elif "downstream" in self.test_config_dict.values(): + for key in [key for key in old_evaluate_list if "-B" in key]: del old_evaluate_list[key] + print("downstream in dictionary values") + + if len(old_evaluate_list) == len(new_evaluate_list): + for item, value in old_evaluate_list.items(): + expected_passes +=1 + print("ITEM: {} VALUE: {}".format(item, value)) + if new_evaluate_list[item] > old_evaluate_list[item]: + passes += 1 + #if self.debug: logg.info(item, new_evaluate_list[item], old_evaluate_list[item], " Difference: ", new_evaluate_list[item] - old_evaluate_list[item]) + print(item, new_evaluate_list[item], old_evaluate_list[item], " Difference: ", new_evaluate_list[item] - old_evaluate_list[item]) + else: + print("Failed to increase rx data: ", item, new_evaluate_list[item], old_evaluate_list[item]) + if not self.csv_started: + csv_rx_headers.append(item) + csv_rx_delta_dict.update({item:(new_evaluate_list[item] - old_evaluate_list[item])}) + + + if not self.csv_started: + csv_header = self.csv_generate_column_headers() + csv_header += csv_rx_headers + logg.info(csv_header) + self.csv_add_column_headers(csv_header) + csv_results = self.csv_generate_column_results_headers() + #csv_results += csv_rx_headers + self.csv_add_column_headers_results(csv_results) + print("###################################") + print(csv_results) + print("###################################") + + self.csv_started = True + + # need to generate list first to determine worst and best + filtered_values = [v for _, v in csv_rx_delta_dict.items() if v !=0] + #average_rx_delta= sum(filtered_values) / len(filtered_values) if len(filtered_values) != 0 else 0 + for key in self.test_keys: + csv_rx_row_data.append(self.test_config_dict[key]) + csv_result_row_data.append(self.test_config_dict[key]) + csv_rx_delta_row_data.append(self.test_config_dict[key]) + + max_tp_mbps = sum(filtered_values) + csv_rx_row_data.append(max_tp_mbps) + csv_result_row_data.append(max_tp_mbps) + + #To do needs to be read or passed in based on test type + expected_tp_mbps = max_tp_mbps + csv_rx_row_data.append(expected_tp_mbps) + csv_result_row_data.append(expected_tp_mbps) + + + #Generate TestID + for key in self.test_keys: + test_id = test_id + "_" + self.test_config_dict[key] + + print("test_id: {}".format(test_id)) + csv_rx_row_data.append(test_id) + csv_result_row_data.append(test_id) + + # Todo pass or fail + if max_tp_mbps == expected_tp_mbps: + csv_rx_row_data.append("pass") + csv_result_row_data.append("pass") + else: + csv_rx_row_data.append("fail") + csv_result_row_data.append("fail") + + csv_rx_row_data.extend([self.epoch_time, self.time_stamp(),'rx_delta']) + csv_result_row_data.extend([self.epoch_time, self.time_stamp()]) + + print("csv_rx_row_data {}".format(csv_rx_row_data)) + #TODO: may want to pass in the information that needs to be in the csv file into the class + ''' + csv_rx_row_data.extend([self.epoch_time, self.time_stamp(),'rx']) + csv_rx_delta_row_data.extend([self.epoch_time, self.time_stamp(),'rx_delta']) + + csv_performance_delta_values=sorted(csv_rx_delta_dict.items(), key=lambda x: (x[1],x[0]), reverse=False) + csv_performance_delta_values=self.csv_validate_list(csv_performance_delta_values,5) + for i in range(5): + csv_rx_delta_row_data.append(str(csv_performance_delta_values[i]).replace(',',';')) + for i in range(-1,-6,-1): + csv_rx_delta_row_data.append(str(csv_performance_delta_values[i]).replace(',',';')) + + csv_rx_delta_row_data.append(average_rx_delta)''' + + for item, value in old_evaluate_list.items(): + expected_passes +=1 + if new_evaluate_list[item] > old_evaluate_list[item]: + passes += 1 + #if self.debug: logg.info(item, new_evaluate_list[item], old_evaluate_list[item], " Difference: ", new_evaluate_list[item] - old_evaluate_list[item]) + print(item, new_evaluate_list[item], old_evaluate_list[item], " Difference: ", new_evaluate_list[item] - old_evaluate_list[item]) + else: + print("Failed to increase rx data: ", item, new_evaluate_list[item], old_evaluate_list[item]) + if not self.csv_started: + csv_rx_headers.append(item) + # note need to have all upstream and downstream in the csv table thus new_list and old_list + #csv_rx_row_data.append(new_list[item]) + # provide delta + csv_rx_row_data.append(new_list[item] - old_list[item]) + + self.csv_add_row(csv_rx_row_data,self.csv_writer,self.csv_file) + #self.csv_add_row(csv_rx_row_data,self.csv_results_writer,self.csv_results) + + #self.csv_add_row(csv_rx_delta_row_data,self.csv_writer,self.csv_file) + + if passes == expected_passes: + return True, max_tp_mbps, csv_result_row_data + else: + return False, max_tp_mbps, csv_result_row_data + else: + print("Old-list length: %i new: %i does not match in compare-vals."%(len(old_list), len(new_list))) + print("old-list:",old_list) + print("new-list:",new_list) + return False, None, None # check to see if this is valid + + def verify_controller(self): + if self.args == None: + return + + if self.args.cisco_ctlr == None: + return + + try: + logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr,self.args.cisco_user, + self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"summary")) + + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", + self.args.cisco_user, "-p", self.args.cisco_passwd, + "-a", self.args.cisco_ap,"--series", self.args.cisco_series,"--action", "summary"], capture_output=True) + pss = ctl_output.stdout.decode('utf-8', 'ignore') + logg.info(pss) + except subprocess.CalledProcessError as process_error: + logg.info("Controller unable to commicate to AP or unable to communicate to controller error code: {} output {}" + .format(process_error.returncode, process_error.output)) + time.sleep(1) + exit(1) + + + # Find our station count + searchap = False + for line in pss.splitlines(): + if (line.startswith("---------")): + searchap = True + continue + #TODO need to test with 9800 series to chelck the values + if (searchap): + pat = "%s\s+\S+\s+\S+\s+\S+\s+\S+.* \S+\s+\S+\s+(\S+)\s+\["%(self.args.cisco_ap) + #logg.info("AP line: %s"%(line)) + m = re.search(pat, line) + if (m != None): + sta_count = m.group(1) + logg.info("AP line: %s"%(line)) + logg.info("sta-count: %s"%(sta_count)) + if (int(sta_count) != int(self.total_stas)): + logg.info("WARNING: Cisco Controller reported %s stations, should be %s"%(sta_count, self.total_stas)) + + def reset_port_check(self): + for station_profile in self.station_profiles: + if station_profile.reset_port_extra_data['reset_port_enable']: + if station_profile.reset_port_extra_data['reset_port_timer_started'] == False: + logg.info("reset_port_time_min: {}".format(station_profile.reset_port_extra_data['reset_port_time_min'])) + logg.info("reset_port_time_max: {}".format(station_profile.reset_port_extra_data['reset_port_time_max'])) + station_profile.reset_port_extra_data['seconds_till_reset'] = \ + random.randint(station_profile.reset_port_extra_data['reset_port_time_min'],\ + station_profile.reset_port_extra_data['reset_port_time_max']) + station_profile.reset_port_extra_data['reset_port_timer_started'] = True + logg.info("on radio {} seconds_till_reset {}".format(station_profile.add_sta_data['radio'],station_profile.reset_port_extra_data['seconds_till_reset'])) + else: + station_profile.reset_port_extra_data['seconds_till_reset'] = station_profile.reset_port_extra_data['seconds_till_reset'] - 1 + if self.debug: logg.info("radio: {} countdown seconds_till_reset {}".format(station_profile.add_sta_data['radio'] ,station_profile.reset_port_extra_data['seconds_till_reset'])) + if ((station_profile.reset_port_extra_data['seconds_till_reset'] <= 0)): + station_profile.reset_port_extra_data['reset_port_timer_started'] = False + port_to_reset = random.randint(0,len(station_profile.station_names)-1) + logg.info("reset on radio {} station: {}".format(station_profile.add_sta_data['radio'],station_profile.station_names[port_to_reset])) + self.local_realm.reset_port(station_profile.station_names[port_to_reset]) + + def pre_cleanup(self): + self.cx_profile.cleanup_prefix() + self.multicast_profile.cleanup_prefix() + self.total_stas = 0 + for station_list in self.station_lists: + for sta in station_list: + self.local_realm.rm_port(sta, check_exists=True) + self.total_stas += 1 + + # Make sure they are gone + count = 0 + while (count < 10): + more = False + for station_list in self.station_lists: + for sta in station_list: + rv = self.local_realm.rm_port(sta, check_exists=True) + if (rv): + more = True + if not more: + break + count += 1 + time.sleep(5) + + def build(self): + index = 0 + for station_profile in self.station_profiles: + station_profile.use_security(station_profile.security, station_profile.ssid, station_profile.ssid_pass) + station_profile.set_number_template(station_profile.number_template) + logg.info("Creating stations") + + station_profile.create(radio=self.radio_name_list[index], sta_names_=self.station_lists[index], debug=self.debug, sleep_time=0) + index += 1 + + # 12/4/2020 put back in multi cast + #for etype in self.endp_types: + # if etype == "mc_udp" or etype == "mc_udp6": + # logg.info("Creating Multicast connections for endpoint type: %s"%(etype)) + # self.multicast_profile.create_mc_tx(etype, self.side_b, etype) + # self.multicast_profile.create_mc_rx(etype, side_rx=station_profile.station_names) + + for _tos in self.tos: + logg.info("Creating connections for endpoint type: {} TOS: {} stations_names {}".format(self.endp_type, _tos, station_profile.station_names)) + self.cx_profile.create(endp_type=self.endp_type, side_a=station_profile.station_names, side_b=self.side_b, sleep_time=0, tos=_tos) + self._pass("PASS: Stations build finished") + + def start(self, print_pass=False, print_fail=False): + best_max_tp_mbps = 0 + best_csv_rx_row_data = " " + max_tp_mbps = 0 + csv_rx_row_data = " " + Result = False + logg.info("Bringing up stations") + self.local_realm.admin_up(self.side_b) + for station_profile in self.station_profiles: + for sta in station_profile.station_names: + logg.info("Bringing up station %s"%(sta)) + self.local_realm.admin_up(sta) + + temp_stations_list = [] + temp_stations_list.append(self.side_b) + for station_profile in self.station_profiles: + temp_stations_list.extend(station_profile.station_names.copy()) + # need algorithm for setting time default + if self.local_realm.wait_for_ip(temp_stations_list, timeout_sec=120, debug=self.debug): + logg.info("ip's acquired") + else: + logg.info("print failed to get IP's") + exit(1) # why continue + time.sleep(30) + self.verify_controller() + # Multi cast may not be needed for scaling and performance + logg.info("Starting multicast traffic (if any configured)") + self.multicast_profile.start_mc(debug_=self.debug) + self.multicast_profile.refresh_mc(debug_=self.debug) + logg.info("Starting layer-3 traffic (if any configured)") + self.cx_profile.start_cx() + self.cx_profile.refresh_cx() + + cur_time = datetime.datetime.now() + logg.info("Getting initial values.") + old_rx_values, rx_drop_percent = self.__get_rx_values() + + end_time = self.local_realm.parse_time(self.test_duration) + cur_time + + logg.info("Monitoring throughput for duration: %s"%(self.test_duration)) + + passes = 0 + expected_passes = 0 + logg.info("polling_interval_seconds {}".format(self.polling_interval_seconds)) + + while cur_time < end_time: + interval_time = cur_time + datetime.timedelta(seconds=self.polling_interval_seconds) + while cur_time < interval_time: + cur_time = datetime.datetime.now() + self.reset_port_check() + time.sleep(1) + + self.epoch_time = int(time.time()) + new_rx_values, rx_drop_percent = self.__get_rx_values() + + expected_passes += 1 + ''' + #self.csv_add_row(csv_rx_row_data,self.csv_results_writer,self.csv_results) + + + if passes == expected_passes: + return True, max_tp_mbps, csv_rx_row_data + else: + return False, max_tp_mbps, csv_rx_row_data + ''' + # __compare_vals - does the calculations + Result, max_tp_mbps, csv_rx_row_data = self.__compare_vals(old_rx_values, new_rx_values) + if max_tp_mbps > best_max_tp_mbps: + best_max_tp_mbps = max_tp_mbps + best_csv_rx_row_data = csv_rx_row_data + + # need to check the expected max_tp_mbps + if Result: + passes += 1 + else: + self._fail("FAIL: Not all stations increased traffic", print_fail) + old_rx_values = new_rx_values + + #percentage dropped not needed for scaling and performance , needed for longevity + #self.__record_rx_dropped_percent(rx_drop_percent) + + cur_time = datetime.datetime.now() + self.csv_add_row(best_csv_rx_row_data,self.csv_results_writer,self.csv_results) + if passes == expected_passes: + self._pass("PASS: All tests passed", print_pass) + + def stop(self): + self.cx_profile.stop_cx() + self.multicast_profile.stop_mc() + for station_list in self.station_lists: + for station_name in station_list: + self.local_realm.admin_down(station_name) + + def cleanup(self): + self.cx_profile.cleanup() + self.multicast_profile.cleanup() + for station_profile in self.station_profiles: + station_profile.cleanup() + + + def csv_generate_column_headers(self): + csv_rx_headers = self.test_keys.copy() + csv_rx_headers.extend + csv_rx_headers.extend(['max_tp_mbps','expected_tp','test_id','pass_fail','epoch_time','time','monitor']) + '''for i in range(1,6): + csv_rx_headers.append("least_rx_data {}".format(i)) + for i in range(1,6): + csv_rx_headers.append("most_rx_data_{}".format(i)) + csv_rx_headers.append("average_rx_data")''' + return csv_rx_headers + + def csv_generate_column_results_headers(self): + csv_rx_headers = self.test_keys.copy() + csv_rx_headers.extend + csv_rx_headers.extend(['max_tp_mbps','expected_tp','test_id','pass_fail','epoch_time','time']) + '''for i in range(1,6): + csv_rx_headers.append("least_rx_data {}".format(i)) + for i in range(1,6): + csv_rx_headers.append("most_rx_data_{}".format(i)) + csv_rx_headers.append("average_rx_data")''' + return csv_rx_headers + + + def csv_add_column_headers(self,headers): + if self.csv_file is not None: + self.csv_writer.writerow(headers) + self.csv_file.flush() + + def csv_add_column_headers_results(self,headers): + if self.csv_results is not None: + self.csv_results_writer.writerow(headers) + self.csv_results.flush() + + def csv_validate_list(self, csv_list, length): + if len(csv_list) < length: + csv_list = csv_list + [('no data','no data')] * (length - len(csv_list)) + return csv_list + + def csv_add_row(self,row,writer,csv_file): # can make two calls eventually + if csv_file is not None: + writer.writerow(row) + csv_file.flush() def valid_endp_types(_endp_type): etypes = _endp_type.split() for endp_type in etypes: valid_endp_type=['lf_udp','lf_udp6','lf_tcp','lf_tcp6','mc_udp','mc_udp6'] if not (str(endp_type) in valid_endp_type): - print('invalid endp_type: %s. Valid types lf_udp, lf_udp6, lf_tcp, lf_tcp6, mc_udp, mc_udp6' % endp_type) + logg.info('invalid endp_type: %s. Valid types lf_udp, lf_udp6, lf_tcp, lf_tcp6, mc_udp, mc_udp6' % endp_type) exit(1) return _endp_type +########################################## +# Traffic Generation +########################################## + + def main(): + global logg lfjson_host = "localhost" lfjson_port = 8080 endp_types = "lf_udp" debug_on = False parser = argparse.ArgumentParser( - prog='lf_cisco_dfs.py', + prog='lf_cisco_snp.py', #formatter_class=argparse.RawDescriptionHelpFormatter, formatter_class=argparse.RawTextHelpFormatter, epilog='''\ - Useful Information: - 1. Polling interval for checking traffic is fixed at 1 minute - 2. The test will generate csv file - 3. The tx/rx rates are fixed at 256000 bits per second - 4. Maximum stations per radio is 64 + Scaling and Performance ''', description='''\ lf_cisco_dfs.py: -------------------- +################################################################################## +Task Description: +################################################################################## +----------------- + +DFS Testing can do multiple clients at once and various radios + +Our ultimate aim is to achieve the following things: + +1. 1 to 200 client SNP on 11ac (1, 50 and 200 client count tests) + 1. 5 Ghz with different channel widths + 2. Data encryption enabled/disabled + 3. Local/central switching and authentication combinations +2. 1 to 37 client SNP on 11ax (1, 10 and 37 client count tests) eventually 200 clients + 1. Different channel widths + 2. Data encryption enabled/disabled + 3. Local/central switching and authentication combinations + 4. MU-MIMO and OFDMA enabled/disabled combination +3. CI/CD implementation + 1. Download latest WLC images and upload them to the controller + 2. Start the test suite + 3. Generate a report per release + 4. Display and graph all result data according to each release along with each testcase historical graph + 5. Review overall AP performance across multiple AP platforms + + Summary : ---------- create stations, create traffic between upstream port and stations, run traffic. @@ -55,17 +1279,21 @@ and recieved. Generic command layout: ----------------------- -python .\\lf_cisco_dfs.py --test_duration --endp_type --upstream_port - --radio "radio== stations== ssid== ssid_pw== security==" --debug +python .\\lf_cisco_snp.py --test_duration --endp_type --upstream_port + --radio "radio== stations== ssid== ssid_pw== security== wifimode==AUTO" --debug + Multiple radios may be entered with individual --radio switches -generiic command with controller setting channel and channel width test duration 5 min -python3 lf_cisco_dfs.py --cisco_ctlr --cisco_dfs True/False --mgr +generiic command with controller setting channel and channel width test duration 30 sec +python3 lf_cisco_snp.py --cisco_ctlr --cisco_dfs True/False --mgr --cisco_channel --cisco_chan_width <20,40,80,120> --endp_type 'lf_udp lf_tcp mc_udp' --upstream_port <1.ethX> - --radio "radio== stations== ssid== ssid_pw== security==" - --radio "radio== stations== ssid== ssid_pw== security==" + --radio "radio== stations== ssid== ssid_pw== security== wifimode==" + --radio "radio== stations== ssid== ssid_pw== security== wifimode==" --duration 5m +wifimode: + : number followed by one of the following d - days @@ -105,7 +1333,7 @@ BK, BE, VI, VO: Optional wifi related Tos Settings. Or, use your preferred num -t / --endp_type example --endp_type \"lf_udp lf_tcp mc_udp\" Default: lf_udp , options: lf_udp, lf_udp6, lf_tcp, lf_tcp6, mc_udp, mc_udp6', default='lf_udp', type=valid_endp_types -u / --upstream_port example: --upstream_port eth1',default='eth1') --o / --outfile ", default='longevity_results' +-o / --outfile ", default='snp' ######################################### # Examples @@ -119,7 +1347,7 @@ Example #1 running traffic with two radios 6. Create connections with TOS of BK and VI Command: (remove carriage returns) -python3 .\\lf_cisco_dfs.py --test_duration 4m --endp_type \"lf_tcp lf_udp mc_udp\" --tos \"BK VI\" --upstream_port eth1 +python3 .\\lf_cisco_snp.py --test_duration 4m --endp_type \"lf_tcp lf_udp mc_udp\" --tos \"BK VI\" --upstream_port eth1 --radio "radio==wiphy0 stations==32 ssid==candelaTech-wpa2-x2048-4-1 ssid_pw==candelaTech-wpa2-x2048-4-1 security==wpa2" --radio "radio==wiphy1 stations==64 ssid==candelaTech-wpa2-x2048-5-3 ssid_pw==candelaTech-wpa2-x2048-5-3 security==wpa2" @@ -136,60 +1364,200 @@ Example #2 using cisco controller 10. duration 5m Command: -python3 lf_cisco_dfs.py --cisco_ctlr 192.168.100.112 --cisco_dfs True --mgr 192.168.100.178 +python3 lf_cisco_snp.py --cisco_ctlr 192.168.100.112 --cisco_dfs True --mgr 192.168.100.178 --cisco_channel 52 --cisco_chan_width 20 --endp_type 'lf_udp lf_tcp mc_udp' --upstream_port 1.eth3 --radio "radio==1.wiphy0 stations==3 ssid==test_candela ssid_pw==[BLANK] security==open" --radio "radio==1.wiphy1 stations==16 ssid==test_candela ssid_pw==[BLANK] security==open" --test_duration 5m +############################################################################## +Detailed test loop description 10/9/2020 - Karthik Recommendation +############################################################################## +Script logic loops: + +AP {Axel, Vanc} Dynamic + frequency {24ghz, 5ghz} Common (band) : 24ghz == b , 5ghz == a + wifimode{11ax (2.4 ghz or 5 ghz), 11ac (5 ghz only), 11n (2.4 ghz or 5ghz), 11bg(2.4 ghz)} Common (an anAX anAC abgn bg) + Bandwidth {20, 40, 80, 160} + data-encryption {enable/disable} Common + AP-mode {local/flexconnect} Common + client-density {1, 10, 20, 50, 100, 200} Dynamic + Packet-type {TCP, UDP} Common + Direction {Downstream, Upstream} + Packet-size { 88, 512, 1370, 1518} Common + Time (4 iterations of 30 sec and get the best average TP out of it) + +Notes: +############################################# +CandelaTech Radios and what supports +############################################# + +Radio descriptions: +ax200: so if AP is /n, then ax200 will connect at /n. But if AP is /AX, we have no way to force ax200 to act like /n +ax200: is dual band, supporting at least /b/g/n/AX on 2.4Ghz, and /a/n/ac/AX on 5Ghz. 2.4Ghz doesn't officially support /AC, but often chips will do /AC there anyway + +ath10K: if they want /AC or /n or /abg stations, then our ath10k radios can support that need (and ath9k if they have any, can do /n and /abg) +ath10K(998x) - wave -1 , dual band card it can be ac, n , a/b/g modes, up to 3x3 spacial streams +ath10K(9884) - wave-2 supports 4x4 802.11an-AC 5ghz (can act as ac , an) + +Note: wave-2 radios can act as ac, an, (802.11an-AC) or legacy a/b/g (802.11bgn-AC) + +############################################# +wifimodes needed to support +############################################# +11ax (2.4 ghz or 5 ghz), 11ac (5 ghz only), 11n (2.4ghz or 5 ghz), 11bg (2.4 ghz) (Cisco) + +############################################# +5 Ghz +############################################# +Wifi mode: 11ax - 5ghz +Radios : ax200 : 802.11 /a/n/ac/AX + +Wifi mode: 11ac - 5ghz +Radios : ath10K(9984) 802.11an-AC (9984 are single band) + +Wifi mode: 11n - 5ghz +Radios : ath10K(9984) 802.11an-AC (9984 are single band) + +############################################# +24 Ghz +############################################# +Wifi mode: 11ax - 24ghz +Radios : ax200 - 802.11 /b/g/n/AX + +Wifi mode: 11ac - 24ghz +Radios : ax200 802.11 /b/g/n/AX (2.4Ghz doesn't officially support /AC, but often chips will do /AC there anyway) (invalid) + +Wifi mode: 11n - 24ghz +Radios : ax200 802.11 /b/g/n/AX + +Wifi mode: 11bg - 24ghz +Radios : ax200 802.11 /b/g/n/AX + +############################################ +Radio support for specific Modes +############################################ +cisco_wifimode == "anAX" or cisco_wifimode == "abgn" or cisco_wifimode == "bg": + radios = radio_AX200_abgn_ax_dict[cisco_client_density] + +cisco_wifimode == "an" or cisco_wifimode == "anAC": + radios = radio_ath10K_9984_an_AC_dict[cisco_client_density] + + +############################################ +Eventual Realm at Cisco +############################################ + +1.wiphy0 802.11abgn-ax iwlwifi(AX200) 523 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn +1.wiphy1 802.11abgn-ax iwlwifi(AX200) 523 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn +1.wiphy2 802.11abgn-ax iwlwifi(AX200) 523 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn +1.wiphy3 802.11abgn-ax iwlwifi(AX200) 523 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn +1.wiphy4 802.11abgn-ax iwlwifi(AX200) 523 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn +1.wiphy5 802.11abgn-ax iwlwifi(AX200) 523 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn +1.wiphy6 802.11abgn-ax iwlwifi(AX200) 523 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn +1.wiphy7 802.11abgn-ax iwlwifi(AX200) 523 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn +1.wiphy8 802.11an-AC ath10k(9984) 523 - 64 stations - 5ghz +1.wiphy9 802.11an-AC ath10k(9984) 523 - 64 stations - 5ghz + +2.wiphy0 802.11abgn-ax iwlwifi(AX200) 521 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn +2.wiphy1 802.11abgn-ax iwlwifi(AX200) 521 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn + +3.wiphy0 802.11abgn-ax iwlwifi(AX200) 521 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn +3.wiphy1 802.11abgn-ax iwlwifi(AX200) 521 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn + +4.wiphy0 802.11abgn-ax iwlwifi(AX200) 521 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn +4.wiphy1 802.11abgn-ax iwlwifi(AX200) 521 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn + +5.wiphy0 802.11abgn-ax iwlwifi(AX200) 521 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn +5.wiphy1 802.11abgn-ax iwlwifi(AX200) 521 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn + +6.wiphy0 802.11abgn-ax iwlwifi(AX200) 523 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn +6.wiphy1 802.11abgn-ax iwlwifi(AX200) 523 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn +6.wiphy2 802.11abgn-ax iwlwifi(AX200) 523 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn +6.wiphy3 802.11abgn-ax iwlwifi(AX200) 523 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn +6.wiphy4 802.11abgn-ax iwlwifi(AX200) 523 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn +6.wiphy5 802.11abgn-ax iwlwifi(AX200) 523 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn +6.wiphy6 802.11abgn-ax iwlwifi(AX200) 523 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn +6.wiphy7 802.11abgn-ax iwlwifi(AX200) 523 - 1 stations - 5ghz/24ghz use only for 802.11ax - 24gz abgn +6.wiphy8 802.11an-AC ath10k(9984) 523 - 64 stations - 5ghz +6.wiphy9 802.11an-AC ath10k(9984) 523 - 64 stations - 5ghz ''') + # reorder to follow looping - parser.add_argument('--cisco_ctlr', help='--cisco_ctlr ',default=None) - parser.add_argument('--cisco_user', help='--cisco_user ',default="admin") - parser.add_argument('--cisco_passwd', help='--cisco_passwd ',default="Cisco123") - parser.add_argument('--cisco_prompt', help='--cisco_prompt ',default="\(Cisco Controller\) >") - parser.add_argument('--cisco_ap', help='--cisco_ap ',default="APA453.0E7B.CF9C") - - parser.add_argument('--cisco_dfs', help='--cisco_dfs ',default=False) + parser.add_argument('-ca','--cisco_all', help='--cisco_all flag present default to all tests',action="store_true") + parser.add_argument('-ct','--cisco_test', help='--cisco_test flag present default to subset tests',action="store_true") + parser.add_argument('-cca','--cisco_ap', help='--cisco_ap List of APs to test default: Axel',default="APA453.0E7B.CF9C") + parser.add_argument('-ccf','--cisco_band', help='--cisco_band ',default="a b") + # cisco wanted 11ax , 11ac, 11n, 11gb + parser.add_argument('-cwm','--cisco_wifimode', help='List of of wifi mode to test default: 11ax 11ac 11n 11gb',default="an anAX anAC abgn bg", + choices=[ "auto", "a", "b", "g", "abg", "abgn", "bgn", "bg", "abgnAC", "anAC", "an", "bgnAC", "abgnAX", "bgnAX", "anAX"]) - parser.add_argument('--cisco_channel', help='--cisco_channel ',default=None) - parser.add_argument('--cisco_chan_width', help='--cisco_chan_width <20 40 80 160>',default="20",choices=["20","40","80","160"]) - parser.add_argument('--cisco_band', help='--cisco_band ',default="a",choices=["a", "b", "abgn"]) - parser.add_argument('--cisco_series', help='--cisco_series <9800 | 3504>',default="3504",choices=["9800","3504"]) - parser.add_argument('--cisco_scheme', help='--cisco_scheme (serial|telnet|ssh): connect via serial, ssh or telnet',default="ssh",choices=["serial","telnet","ssh"]) + parser.add_argument('-ccc','--cisco_channel', help='--cisco_channel default 36',default="36") + parser.add_argument('-ccw','--cisco_chan_width', help='--cisco_chan_width <20 40 80 160> default: \"20 40 80 160\"',default="20 40 80") + parser.add_argument('-cam','--cisco_ap_mode', help='--cisco_ap_mode ',default="local flexconnect") + parser.add_argument('-cps','--cisco_packet_size', help='--cisco_packet_size List of packet sizes default \"88 512 1370 1518\"',default="88 512 1370 1518" ) + parser.add_argument('-ccd','--cisco_client_density', help='--cisco_client_density List of client densities defaults 1 10 20 50 100 200 ', + default="1 10 20 50 100 200" ) - parser.add_argument('--cisco_wlan', help='--cisco_wlan default: NA, NA means no change',default="NA") - parser.add_argument('--cisco_wlanID', help='--cisco_wlanID default: NA , NA means not change',default="NA") - parser.add_argument('--cisco_tx_power', help='--cisco_tx_power <1 | 2 | 3 | 4 | 5 | 6 | 7 | 8> 1 is highest power default NA NA means no change',default="NA" + parser.add_argument('-cde','--cisco_data_encryption', help='--cisco_data_encryption \"enable disable\"',default="disable" ) + parser.add_argument('-cs','--cisco_series', help='--cisco_series <9800 | 3504>',default="3504",choices=["9800","3504"]) + parser.add_argument('-ccp','--prompt', type=str,help="controller prompt default WLC",default="WLC") + + parser.add_argument('-cc','--cisco_ctlr', help='--cisco_ctlr default 192.168.100.178',default="192.168.100.178") + parser.add_argument('-cp','--cisco_port', help='--cisco_port ssh default 22',default="22") + parser.add_argument('-cu','--cisco_user', help='--cisco_user ',default="admin") + parser.add_argument('-cpw','--cisco_passwd', help='--cisco_passwd ',default="Cisco123") + parser.add_argument('-ccp','--cisco_prompt', help='--cisco_prompt ',default="\(Cisco Controller\) >") + parser.add_argument('-cd','--cisco_dfs', help='--cisco_dfs ',default=False) + parser.add_argument('-ccs','--cisco_scheme', help='--cisco_scheme (serial|telnet|ssh): connect via serial, ssh or telnet',default="ssh",choices=["serial","telnet","ssh"]) + parser.add_argument('-cw','--cisco_wlan', help='--cisco_wlan default: NA, NA means no change',default="NA") + parser.add_argument('-cwi','--cisco_wlanID', help='--cisco_wlanID default: NA , NA means not change',default="NA") + parser.add_argument('-ctp','--cisco_tx_power', help='--cisco_tx_power <1 | 2 | 3 | 4 | 5 | 6 | 7 | 8> 1 is highest power default NA NA means no change',default="NA" ,choices=["1","2","3","4","5","6","7","8","NA"]) + parser.add_argument('-cco','--cap_ctl_out', help='--cap_ctl_out , switch the cisco controller output will be captured', action='store_true') + + parser.add_argument('-apr','--amount_ports_to_reset', help='--amount_ports_to_reset \" \" ', default=None) + parser.add_argument('-prs','--port_reset_seconds', help='--ports_reset_seconds \" \" ', default="10 30") - - parser.add_argument('--amount_ports_to_reset', help='--amount_ports_to_reset \" \" ', default=None) - parser.add_argument('--port_reset_seconds', help='--ports_reset_seconds \" \" ', default="10 30") - - parser.add_argument('--mgr', help='--mgr ',default='localhost') - parser.add_argument('-d','--test_duration', help='--test_duration example --time 5d (5 days) default: 3m options: number followed by d, h, m or s',default='3m') + parser.add_argument('-lm','--mgr', help='--mgr ',default='localhost') + parser.add_argument('-d','--test_duration', help='--test_duration example --time 5d (5 days) default: 2m options: number followed by d, h, m or s',default='2m') parser.add_argument('--tos', help='--tos: Support different ToS settings: BK | BE | VI | VO | numeric',default="BE") - parser.add_argument('--debug', help='--debug: Enable debugging',default=False) - parser.add_argument('-t', '--endp_type', help='--endp_type example --endp_type \"lf_udp lf_tcp mc_udp\" Default: lf_udp , options: lf_udp, lf_udp6, lf_tcp, lf_tcp6, mc_udp, mc_udp6', - default='lf_udp', type=valid_endp_types) + parser.add_argument('-db','--debug', help='--debug: Enable debugging',action='store_true') + parser.add_argument('-t', '--endp_type', help='--endp_type example --endp_type \"lf_udp lf_tcp mc_udp\" Default: lf_udp lf_tcp, options: lf_udp, lf_udp6, lf_tcp, lf_tcp6, mc_udp, mc_udp6', + default='lf_udp lf_tcp', type=valid_endp_types) parser.add_argument('-u', '--upstream_port', help='--upstream_port example: --upstream_port eth1',default='eth1') - parser.add_argument('-o','--csv_outfile', help="--csv_outfile ", default='longevity_results') - parser.add_argument('--polling_interval', help="--polling_interval ", default='60s') + parser.add_argument('-o','--csv_outfile', help="--csv_outfile ", default='snp') + parser.add_argument("-l", "--log", action='store_true', help="create logfile for messages, default stdout") + parser.add_argument('-pi','--polling_interval', help="--polling_interval ", default='10s') #parser.add_argument('-c','--csv_output', help="Generate csv output", default=False) + parser.add_argument('-c','--csv_output', help="Generate csv output", default=True) + #to do add wifimode parser.add_argument('-r','--radio', action='append', nargs=1, help='--radio \ - \"radio== ssid== ssid_pw== security==\" '\ - , required=True) - parser.add_argument("--cap_ctl_out", help="--cap_ctl_out , switch the cisco controller output will be captured", action='store_true') + \"radio== ssid== ssid_pw== security== wifimode==\" '\ + , required=False) + parser.add_argument('-amr','--side_a_min_bps', help='--side_a_min_bps, station min tx bits per second default 256000', default=256000) + parser.add_argument('-amp','--side_a_min_pdu', help='--side_a_min_pdu , station ipdu size default 1518', default=1518) + parser.add_argument('-bmr','--side_b_min_bps', help='--side_b_min_bps , upstream min tx rate default 256000', default=256000) + parser.add_argument('-bmp','--side_b_min_pdu', help='--side_b_min_pdu , upstream pdu size default 1518', default=1518) + + # Parameters that allow for testing + parser.add_argument('-noc','--no_controller', help='--no_controller no configuration of the controller', action='store_true') + parser.add_argument('-nos','--no_stations', help='--no_stations , no stations', action='store_true') args = parser.parse_args() - #print("args: {}".format(args)) + cisco_args = args + + #logg.info("args: {}".format(args)) debug_on = args.debug + + ################################################################## + # Gather Test Data + ################################################################# if args.test_duration: test_duration = args.test_duration @@ -212,116 +1580,541 @@ python3 lf_cisco_dfs.py --cisco_ctlr 192.168.100.112 --cisco_dfs True --mgr 192. if args.csv_outfile != None: current_time = time.strftime("%m_%d_%Y_%H_%M_%S", time.localtime()) csv_outfile = "{}_{}.csv".format(args.csv_outfile,current_time) + csv_results = "results_{}_{}.csv".format(args.csv_outfile,current_time) print("csv output file : {}".format(csv_outfile)) - + + if args.log: + outfile_log = "{}_{}_output_log.log".format(args.outfile,current_time) + print("output file log: {}".format(outfile_log)) + else: + outfile_log = "stdout" + print("output file log: {}".format(outfile_log)) - MAX_NUMBER_OF_STATIONS = 64 + console_handler = logging.StreamHandler() + formatter = logging.Formatter(FORMAT) + logg = logging.getLogger(__name__) + logg.setLevel(logging.DEBUG) + file_handler = None + if (args.log): + file_handler = logging.FileHandler(outfile_log, "w") + + file_handler.setLevel(logging.DEBUG) + file_handler.setFormatter(formatter) + logg.addHandler(file_handler) + logg.addHandler(logging.StreamHandler(sys.stdout)) # allows to logging to file and stderr + # if loggin.basicConfig is called this will result in duplicating log entries + # logging.basicConfig(format=FORMAT, handlers=[file_handler]) + else: + # stdout logging + logging.basicConfig(format=FORMAT, handlers=[console_handler]) + + + #################################################### + # + # Static Configuration Cisco Realm one lanforge + # + #################################################### + radio_AX200_abgn_ax_list_001_one = [['radio==1.wiphy0 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto']] + + radio_AX200_abgn_ax_list_010_one = [['radio==1.wiphy0 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==1.wiphy1 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==1.wiphy2 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==1.wiphy3 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==1.wiphy4 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==1.wiphy5 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==1.wiphy6 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==1.wiphy7 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto']] + + + radio_AX200_abgn_ax_dict_one = {'1' : radio_AX200_abgn_ax_list_001_one, + '8' : radio_AX200_abgn_ax_list_010_one} + + + radio_ath10K_9984_an_AC_list_001_one = [['radio==1.wiphy8 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto']] + radio_ath10K_9984_an_AC_list_010_one = [['radio==1.wiphy8 stations==10 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto']] + radio_ath10K_9984_an_AC_list_020_one = [['radio==1.wiphy8 stations==20 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto']] + + radio_ath10K_9984_an_AC_dict_one = {'1' : radio_ath10K_9984_an_AC_list_001_one, + '10' : radio_ath10K_9984_an_AC_list_010_one, + '20' : radio_ath10K_9984_an_AC_list_020_one} + + + #################################################### + # + # Static Configuration Cisco Realm + # + #################################################### + radio_AX200_abgn_ax_list_001 = [['radio==1.wiphy0 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto']] + + radio_AX200_abgn_ax_list_010 = [['radio==1.wiphy0 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==1.wiphy1 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==1.wiphy2 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==1.wiphy3 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==1.wiphy4 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==1.wiphy5 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==1.wiphy6 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==1.wiphy7 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==2.wiphy0 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==2.wiphy1 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto']] + + + radio_AX200_abgn_ax_list_020 = [['radio==1.wiphy0 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==1.wiphy1 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==1.wiphy2 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==1.wiphy3 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==1.wiphy4 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==1.wiphy5 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==1.wiphy6 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==1.wiphy7 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==2.wiphy0 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==2.wiphy1 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==3.wiphy0 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==3.wiphy1 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==4.wiphy0 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==4.wiphy1 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==5.wiphy0 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==5.wiphy1 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==6.wiphy0 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==6.wiphy1 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==6.wiphy2 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==6.wiphy3 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ] + + radio_AX200_abgn_ax_list_024 = [['radio==1.wiphy0 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==1.wiphy1 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==1.wiphy2 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==1.wiphy3 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==1.wiphy4 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==1.wiphy5 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==1.wiphy6 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==1.wiphy7 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==2.wiphy0 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==2.wiphy1 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==3.wiphy0 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==3.wiphy1 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==4.wiphy0 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==4.wiphy1 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==5.wiphy0 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==5.wiphy1 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==6.wiphy0 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==6.wiphy1 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==6.wiphy2 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==6.wiphy3 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==6.wiphy4 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==6.wiphy5 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==6.wiphy6 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==6.wiphy7 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ] + + + radio_AX200_abgn_ax_dict = {'1' : radio_AX200_abgn_ax_list_001, + '10' : radio_AX200_abgn_ax_list_010, + '24' : radio_AX200_abgn_ax_list_024} + + + radio_ath10K_9984_an_AC_list_001 = [['radio==1.wiphy8 stations==1 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto']] + radio_ath10K_9984_an_AC_list_010 = [['radio==1.wiphy8 stations==10 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto']] + radio_ath10K_9984_an_AC_list_020 = [['radio==1.wiphy8 stations==20 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto']] + radio_ath10K_9984_an_AC_list_050 = [['radio==1.wiphy8 stations==50 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto']] + radio_ath10K_9984_an_AC_list_100 = [['radio==1.wiphy8 stations==50 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==1.wiphy9 stations==50 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto']] + radio_ath10K_9984_an_AC_list_200 = [['radio==1.wiphy8 stations==50 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==1.wiphy9 stations==50 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==6.wiphy8 stations==50 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==6.wiphy9 stations==50 ssid==test-can ssid_pw==[BLANK] security==open wifimode==auto']] + + radio_ath10K_9984_an_AC_dict = {'1' : radio_ath10K_9984_an_AC_list_001, + '50' : radio_ath10K_9984_an_AC_list_050, + '200': radio_ath10K_9984_an_AC_list_200} + + #################################################### + # + # Static dictionaries for radios on 191.168.100.178 + # Static Configuration Candela Tech Realm () + # + #################################################### + #iwlwifi(AX200) 521 + radio_AX200_abgn_ax_list_001 = [['radio==1.wiphy3 stations==1 ssid==test_candela ssid_pw==[BLANK] security==open wifimode==auto']] + radio_AX200_abgn_ax_list_004 = [['radio==1.wiphy3 stations==1 ssid==test_candela ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==1.wiphy4 stations==1 ssid==test_candela ssid_pw==[BLANK] security==open wifimode==auto'], + ['radio==1.wiphy5 stations==1 ssid==test_candela ssid_pw==[BLANK] security==open wifimode==auto']] + + radio_AX200_abgn_ax_dict_test = {'1' : radio_AX200_abgn_ax_list_001, + '4': radio_AX200_abgn_ax_list_004} + + radio_ath10K_9984_an_AC_list_001 = [['radio==1.wiphy1 stations==1 ssid==test_candela ssid_pw==[BLANK] security==open wifimode==auto']] + radio_ath10K_9984_an_AC_list_010 = [['radio==1.wiphy1 stations==10 ssid==test_candela ssid_pw==[BLANK] security==open wifimode==auto']] + radio_ath10K_9984_an_AC_list_020 = [['radio==1.wiphy1 stations==20 ssid==test_candela ssid_pw==[BLANK] security==open wifimode==auto']] + radio_ath10K_9984_an_AC_list_050 = [['radio==1.wiphy1 stations==50 ssid==test_candela ssid_pw==[BLANK] security==open wifimode==auto']] + radio_ath9K_9984_an_AC_list_200 = [['radio==1.wiphy0 stations==200 ssid==test_candela ssid_pw==[BLANK] security==open wifimode==auto']] + + radio_ath10K_9984_an_AC_dict_test = {'1' : radio_ath10K_9984_an_AC_list_001, + '10' : radio_ath10K_9984_an_AC_list_010, + '50' : radio_ath10K_9984_an_AC_list_050, + '200' : radio_ath9K_9984_an_AC_list_200} + + MAX_NUMBER_OF_STATIONS = 200 radio_name_list = [] number_of_stations_per_radio_list = [] ssid_list = [] ssid_password_list = [] ssid_security_list = [] + wifimode_list = [] #optional radio configuration reset_port_enable_list = [] reset_port_time_min_list = [] reset_port_time_max_list = [] - print("radios {}".format(radios)) - for radio_ in radios: - radio_keys = ['radio','stations','ssid','ssid_pw','security'] - radio_info_dict = dict(map(lambda x: x.split('=='), str(radio_).replace('[','').replace(']','').replace("'","").split())) - print("radio_dict {}".format(radio_info_dict)) + wifi_mode_dict = { + "auto" : "0", + "a" : "1", + "b" : "2", + "g" : "3", + "abg" : "4", + "abgn" : "5", + "bgn" : "6", + "bg" : "7", + "abgnAC" : "8", + "anAC" : "9", + "an" : "10", + "bgnAC" : "11", + "abgnAX" : "12", + "bgnAX" : "13", + "anAX" : "14" + } - for key in radio_keys: - if key not in radio_info_dict: - print("missing config, for the {}, all of the following need to be present {} ".format(key,radio_keys)) + if args.cisco_all: + cisco_aps = "APA453.0E7B.CF9C".split() +# cisco_bands = "a b".split() + cisco_bands = "a ".split() +# cisco_wifimodes = "an anAX anAC abgn bg".split() + cisco_wifimodes = "an".split() + cisco_tx_power = "3" + cisco_chan_5ghz = "36".split() + cisco_chan_24ghz = "1".split() + cisco_chan_widths = "20".split() +# cisco_ap_modes = "local flex".split() + cisco_ap_modes = "local".split() + cisco_data_encryptions = "disable".split() + cisco_packet_types = "lf_udp lf_tcp".split() + cisco_directions = "upstream downstream".split() + cisco_packet_sizes = "1518".split() + cisco_client_densities = "1".split() + cisco_data_encryptions = "disable".split() + + cisco_side_a_min_bps = 500000000 + cisco_side_b_min_bps = 500000000 + + radio_AX200_abgn_ax_dict = radio_AX200_abgn_ax_dict_one + radio_ath10K_9984_an_AC_dict = radio_ath10K_9984_an_AC_dict_one + + elif args.cisco_test: + # Note the local system only supports 802.11-abgn , 802.11a + cisco_aps = "APA453.0E7B.CF9C".split() + cisco_bands = "a".split() + #cisco_wifimodes = "an anAX anAC abgn bg".split() + cisco_wifimodes = "an".split() + cisco_tx_power = "3" + cisco_chan_5ghz = "36".split() + cisco_chan_24ghz = "1".split() + cisco_chan_widths = "20".split() + cisco_ap_modes = "local".split() + cisco_data_encryptions = "disable".split() + #cisco_packet_types = "lf_udp lf_tcp".split() + cisco_packet_types = "lf_udp".split() + #cisco_directions = "upstream downstream".split() + cisco_directions = "upstream downstream".split() + #cisco_packet_sizes = "88 512 1370 1518".split() + cisco_packet_sizes = "1518".split() + cisco_client_densities = "10".split() + cisco_data_encryptions = "disable".split() + + cisco_side_a_min_bps = 500000000 + cisco_side_b_min_bps = 500000000 + + radio_AX200_abgn_ax_dict = radio_AX200_abgn_ax_dict_test + radio_ath10K_9984_an_AC_dict = radio_ath10K_9984_an_AC_dict_test + + else: + cisco_aps = args.cisco_ap.split() + cisco_bands = args.cisco_band.split() + cisco_wifimodes = args.cisco_wifimode.split() + for mode in cisco_wifimodes: + if mode in wifi_mode_dict.keys(): + pass + else: + logg.info("wifimode [{}] not recognised. Please use: auto, a, b, g, abg, abgn, bgn, bg, abgnAC, anAC, an, bgnAC, abgnAX, bgnAX, anAX".format(mode)) exit(1) - - radio_name_list.append(radio_info_dict['radio']) - number_of_stations_per_radio_list.append(radio_info_dict['stations']) - ssid_list.append(radio_info_dict['ssid']) - ssid_password_list.append(radio_info_dict['ssid_pw']) - ssid_security_list.append(radio_info_dict['security']) + cisco_tx_power = "3" + cisco_chan_5ghz = "36".split() + cisco_chan_24ghz = "1".split() + cisco_chan_widths = args.cisco_chan_width.split() + cisco_ap_modes = args.cisco_ap_mode.split() + cisco_client_densities = args.cisco_client_density.split() + cisco_packet_types = args.endp_type.split() + cisco_directions = "upstream downstream".split() + cisco_packet_sizes = args.cisco_packet_size.split() + cisco_client_densities = args.cisco_client_density.split() + cisco_data_encryptions = args.cisco_data_encryption.split() - optional_radio_reset_keys = ['reset_port_enable'] - radio_reset_found = True - for key in optional_radio_reset_keys: - if key not in radio_info_dict: - #print("port reset test not enabled") - radio_reset_found = False - break + cisco_side_a_min_bps = args.side_a_min_bps + cisco_side_a_min_bps = args.side_b_min_bps - if radio_reset_found: - reset_port_enable_list.append(True) - reset_port_time_min_list.append(radio_info_dict['reset_port_time_min']) - reset_port_time_max_list.append(radio_info_dict['reset_port_time_max']) - else: - reset_port_enable_list.append(False) - reset_port_time_min_list.append('0s') - reset_port_time_max_list.append('0s') + + logg.info(cisco_aps) + logg.info(cisco_bands) + logg.info(cisco_wifimodes) + logg.info(cisco_chan_widths) + logg.info(cisco_chan_widths) + logg.info(cisco_ap_modes) + logg.info(cisco_client_densities) + logg.info(cisco_packet_types) + logg.info(cisco_packet_sizes) + logg.info(cisco_client_densities) + logg.info(cisco_data_encryptions) + __ap_set = None + __band_set = None + __chan_width_set = None + __ap_mode_set = None + __tx_power_set = None + __csv_started = False + + for cisco_ap in cisco_aps: + for cisco_band in cisco_bands: # frequency + for cisco_wifimode in cisco_wifimodes: + # check for valid frequency and wifi_mode combination put here to simplify logic since all radios do not support all modes + # "an anAX anAC abgn bg" + if((cisco_band == "a" and cisco_wifimode == "bg") or (cisco_band == "b" and cisco_wifimode == "anAC")): + pass # invalid combination continue + else: + for cisco_chan_width in cisco_chan_widths: #bandwidth + for cisco_data_encryption in cisco_data_encryptions: + for cisco_ap_mode in cisco_ap_modes: + for cisco_client_density in cisco_client_densities: + for cisco_packet_type in cisco_packet_types: + for cisco_direction in cisco_directions: + for cisco_packet_size in cisco_packet_sizes: + logg.info("#####################################################") + logg.info("# TEST RUNNING , TEST RUNNING ######################") + logg.info("#####################################################") + test_config = "AP=={} Band=={} wifi_mode=={} BW=={} encryption=={} ap_mode=={} clients=={} packet_type=={} direction=={} packet_size=={}".format(cisco_ap, + cisco_band,cisco_wifimode,cisco_chan_width,cisco_data_encryption,cisco_ap_mode,cisco_client_density, + cisco_packet_type,cisco_direction,cisco_packet_size) + test_keys = ['AP','Band','wifi_mode','BW','encryption','ap_mode','clients','packet_type','direction','packet_size'] + logg.info("# Cisco run settings: {}".format(test_config)) + if(args.no_controller): + logg.info("################################################") + logg.info("# NO CONTROLLER SET , TEST MODE") + logg.info("################################################") + else: + if( cisco_ap != __ap_set or + cisco_band != __band_set or + cisco_chan_width != __chan_width_set or + cisco_ap_mode != __ap_mode_set or + cisco_tx_power != __tx_power_set + ): + logg.info("###############################################") + logg.info("# NEW CONTROLLER CONFIG") + logg.info("###############################################") + __ap_set = cisco_ap + __band_set = cisco_band + __chan_width_set = cisco_chan_width + __ap_mode_set = cisco_ap_mode + __tx_power_set = cisco_tx_power + ############################################# + # configure cisco controller + ############################################# + cisco_args.cisco_ap = cisco_ap + cisco_args.cisco_band = cisco_band + if cisco_band == "a": + cisco_args.cisco_chan = cisco_chan_5ghz + else: + cisco_args.cisco_chan = cisco_chan_24ghz + cisco_args.cisco_chan_width = cisco_chan_width + cisco_args.cisco_ap_mode = cisco_ap_mode + cisco_args.cisco_tx_power = cisco_tx_power + logg.info(cisco_args) + cisco = cisco_(cisco_args) # << is there a way to make a structure as compared to passing all args + #Disable AP + cisco.controller_disable_ap() + if cisco_args.cisco_series == "9800": + cisco.controller_disable_wlan() + cisco.controller_disable_network_5ghz() + cisco.controller_disable_network_24ghz() + cisco.controller_role_manual() + else: + cisco.controller_disable_network_5ghz() + cisco.controller_disable_network_24ghz() + cisco.controller_set_tx_power() + cisco.controller_set_channel() + cisco.controller_set_bandwidth() + if cisco_args.cisco_series == "9800": + cisco.controller_create_wlan() + cisco.controller_set_wireless_tag_policy() + cisco.controller_enable_wlan() + if cisco_band == "a": + cisco.controller_enable_network_5ghz() + else: + cisco.controller_enable_network_24ghz() + cisco.controller_enable_ap() + # need to actually check the CAC timer + time.sleep(30) + #################################### + # end of cisco controller code + #################################### + else: + logg.info("###############################################") + logg.info("# NO CHANGE TO CONTROLLER CONFIG") + logg.info("###############################################") + logg.info("cisco_wifi_mode {}".format(cisco_wifimode)) + if args.radio: + radios = args.radio + elif cisco_band == "a": + if cisco_wifimode == "anAX" or cisco_wifimode == "abgn": + #AX200 dual band + radios = radio_AX200_abgn_ax_dict[cisco_client_density] + elif cisco_wifimode == "an" or cisco_wifimode == "anAC" or cisco_wifimode =="auto": + #ath10K only supports 5Ghz + radios = radio_ath10K_9984_an_AC_dict[cisco_client_density] + else: + logg.info("##################################") + logg.info("# INVALID COMBINATION 5ghz") + logg.info("# Cisco run settings: {}".format(test_config)) + logg.info("##################################") + exit(1) - index = 0 - station_lists = [] - for (radio_name_, number_of_stations_per_radio_) in zip(radio_name_list,number_of_stations_per_radio_list): - number_of_stations = int(number_of_stations_per_radio_) - if number_of_stations > MAX_NUMBER_OF_STATIONS: - print("number of stations per radio exceeded max of : {}".format(MAX_NUMBER_OF_STATIONS)) - quit(1) - station_list = LFUtils.portNameSeries(prefix_="sta", start_id_= 1 + index*1000, end_id_= number_of_stations + index*1000, - padding_number_=10000, radio=radio_name_) - station_lists.append(station_list) - index += 1 + else: # cisco_band == "b" + if cisco_wifimode == "an" or cisco_wifimode == "anAX" or cisco_wifimode == "abgn" or cisco_wifimode == "bg" or cisco_wifimode == "auto": + #AX200 dual band + radios = radio_AX200_abgn_ax_dict[cisco_client_density] + else: + logg.info("##################################") + logg.info("# INVALID COMBINATION 24 ghz") + logg.info("# Cisco run settings: {}".format(test_config)) + logg.info("##################################") + exit(1) - #print("endp-types: %s"%(endp_types)) - - dfs = DFS.L3VariableTime( - lfjson_host, - lfjson_port, - args=args, - number_template="00", - station_lists= station_lists, - name_prefix="LT-", - endp_types=endp_types, - tos=args.tos, - side_b=side_b, - radio_name_list=radio_name_list, - number_of_stations_per_radio_list=number_of_stations_per_radio_list, - ssid_list=ssid_list, - ssid_password_list=ssid_password_list, - ssid_security_list=ssid_security_list, - test_duration=test_duration, - polling_interval= polling_interval, - reset_port_enable_list=reset_port_enable_list, - reset_port_time_min_list=reset_port_time_min_list, - reset_port_time_max_list=reset_port_time_max_list, - side_a_min_rate=256000, - side_b_min_rate=256000, - debug_on=debug_on, - outfile=csv_outfile) - - dfs.pre_cleanup() - - dfs.build() - if not dfs.passes(): - print("build step failed.") - print(dfs.get_fail_message()) - exit(1) - dfs.start(False, False) - dfs.stop() - if not dfs.passes(): - print("stop test failed") - print(dfs.get_fail_message()) - - - print("Pausing 30 seconds after run for manual inspection before we clean up.") - time.sleep(30) - dfs.cleanup() - if dfs.passes(): - print("Full test passed, all connections increased rx bytes") + logg.info("radios {}".format(radios)) + for radio_ in radios: + radio_keys = ['radio','stations','ssid','ssid_pw','security','wifimode'] + radio_info_dict = dict(map(lambda x: x.split('=='), str(radio_).replace('[','').replace(']','').replace("'","").split())) + logg.info("radio_dict {}".format(radio_info_dict)) + for key in radio_keys: + if key not in radio_info_dict: + logg.info("missing config, for the {}, all of the following need to be present {} ".format(key,radio_keys)) + exit(1) + radio_name_list.append(radio_info_dict['radio']) + ssid_list.append(radio_info_dict['ssid']) + ssid_password_list.append(radio_info_dict['ssid_pw']) + ssid_security_list.append(radio_info_dict['security']) + if args.radio: + number_of_stations_per_radio_list.append(radio_info_dict['stations']) + wifimode_list.append(int(wifi_mode_dict[radio_info_dict['wifimode']])) + else: + number_of_stations_per_radio_list.append(radio_info_dict['stations']) + wifimode_list.append(int(wifi_mode_dict[radio_info_dict['wifimode']])) + optional_radio_reset_keys = ['reset_port_enable'] + radio_reset_found = True + for key in optional_radio_reset_keys: + if key not in radio_info_dict: + #logg.info("port reset test not enabled") + radio_reset_found = False + break + + if radio_reset_found: + reset_port_enable_list.append(True) + reset_port_time_min_list.append(radio_info_dict['reset_port_time_min']) + reset_port_time_max_list.append(radio_info_dict['reset_port_time_max']) + else: + reset_port_enable_list.append(False) + reset_port_time_min_list.append('0s') + reset_port_time_max_list.append('0s') + # no stations for testing reconfiguration of the controller - + if(args.no_stations): + logg.info("##################################") + logg.info("# NO STATIONS") + logg.info("##################################") + else: + index = 0 + station_lists = [] + for (radio_name_, number_of_stations_per_radio_) in zip(radio_name_list,number_of_stations_per_radio_list): + number_of_stations = int(number_of_stations_per_radio_) + if number_of_stations > MAX_NUMBER_OF_STATIONS: + logg.info("number of stations per radio exceeded max of : {}".format(MAX_NUMBER_OF_STATIONS)) + quit(1) + station_list = LFUtils.portNameSeries(prefix_="sta", start_id_= 1 + index*1000, end_id_= number_of_stations + index*1000, + padding_number_=10000, radio=radio_name_) + station_lists.append(station_list) + index += 1 + # Run Traffic Upstream (STA to AP) + if(cisco_direction == "upstream"): + side_a_min_bps = cisco_side_a_min_bps + side_b_min_bps = 0 + # Run Traffic Downstream (AP to STA) + else: + side_a_min_bps = 0 + side_b_min_bps = cisco_side_b_min_bps + # current default is to have a values + ip_var_test = L3VariableTime( + lfjson_host, + lfjson_port, + args=args, + number_template="00", + station_lists= station_lists, + name_prefix="LT-", + endp_type=cisco_packet_type, + tos=args.tos, + side_b=side_b, + radio_name_list=radio_name_list, + number_of_stations_per_radio_list=number_of_stations_per_radio_list, + ssid_list=ssid_list, + ssid_password_list=ssid_password_list, + ssid_security_list=ssid_security_list, + wifimode_list=wifimode_list, + test_duration=test_duration, + polling_interval= polling_interval, + reset_port_enable_list=reset_port_enable_list, + reset_port_time_min_list=reset_port_time_min_list, + reset_port_time_max_list=reset_port_time_max_list, + side_a_min_bps=side_a_min_bps, + side_a_min_pdu =cisco_packet_size, + side_b_min_bps=side_b_min_bps, + side_b_min_pdu =cisco_packet_size, + debug_on=debug_on, + outfile=csv_outfile, + results=csv_results, + test_keys=test_keys, + test_config=test_config, + csv_started=__csv_started ) + __csv_started = True + ip_var_test.pre_cleanup() + ip_var_test.build() + if not ip_var_test.passes(): + logg.info("build step failed.") + logg.info(ip_var_test.get_fail_message()) + exit(1) + ip_var_test.start(False, False) + ip_var_test.stop() + if not ip_var_test.passes(): + logg.info("stop test failed") + logg.info(ip_var_test.get_fail_message()) + # clean up + radio_name_list = [] + number_of_stations_per_radio_list = [] + ssid_list = [] + ssid_password_list = [] + ssid_security_list = [] + wifimode_list = [] + ip_var_test.cleanup() + if ( args.no_stations): + pass + else: + ip_var_test.passes() + logg.info("Full test passed, all connections increased rx bytes") if __name__ == "__main__": main() diff --git a/py-scripts/lf_cisco_snp.py b/py-scripts/lf_cisco_snp.py index 94d5daf7..087af28b 100755 --- a/py-scripts/lf_cisco_snp.py +++ b/py-scripts/lf_cisco_snp.py @@ -38,7 +38,8 @@ class FileAdapter(object): pass # leave it to logging to flush properly ################################################################################ -# cisco controller class :This class in the future will be moved to its own file +# cisco controller class :This class will be left in this file to allow for the +# Scaling and Performance to be self contained and not impact other tests ################################################################################ class cisco_(): @@ -49,8 +50,9 @@ class cisco_(): #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 --action summary --series 9800 --log stdout def controller_show_summary(self): try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr,self.args.cisco_user, - self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"summary")) + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user, + self.args.cisco_passwd,self.args.cisco_ap,self.args.cisco_series,self.args.cisco_band,"summary")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -73,8 +75,9 @@ class cisco_(): #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 --action advanced --series 9800 --log stdout def controller_show_ap_summary(self): try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr,self.args.cisco_user, - self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"advanced")) + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user, + self.args.cisco_passwd,self.args.cisco_ap,self.args.cisco_series,self.args.cisco_band,"advanced")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -93,8 +96,9 @@ class cisco_(): #show wlan summary def controller_show_wlan_summary(self): try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr,self.args.cisco_user, - self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"show wlan summary")) + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user, + self.args.cisco_passwd,self.args.cisco_ap,self.args.cisco_series,self.args.cisco_band,"show wlan summary")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -115,11 +119,12 @@ class cisco_(): #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action disable --series 9800 def controller_disable_ap(self): try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr,self.args.cisco_user, - self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"disable")) + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user, + self.args.cisco_passwd,self.args.cisco_ap,self.args.cisco_series,self.args.cisco_band,"disable")) - ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", - self.args.cisco_user, "-p", self.args.cisco_passwd, + ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", + self.args.cisco_ctlr, "-u",self.args.cisco_user, "-p", self.args.cisco_passwd, "-a", self.args.cisco_ap,"--series", self.args.cisco_series, "--band", self.args.cisco_band, "--action", "disable"], capture_output=self.args.cap_ctl_out, check=True) @@ -138,8 +143,9 @@ class cisco_(): #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action disable_wlan --series 9800 def controller_disable_wlan(self): try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr,self.args.cisco_user, - self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"disable_wlan")) + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user, + self.args.cisco_passwd,self.args.cisco_ap,self.args.cisco_series,self.args.cisco_band,"disable_wlan")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -162,8 +168,9 @@ class cisco_(): def controller_disable_network_5ghz(self): if self.args.cisco_series == "9800": try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr,self.args.cisco_user, - self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"disable_network_5ghz")) + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user, + self.args.cisco_passwd,self.args.cisco_ap,self.args.cisco_series,self.args.cisco_band,"disable_network_5ghz")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -181,8 +188,8 @@ class cisco_(): exit(1) else: try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value: {}".format(self.args.cisco_scheme, - self.args.cisco_ctlr,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"cmd","config 802.11a disable network")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", @@ -206,8 +213,9 @@ class cisco_(): def controller_disable_network_24ghz(self): if self.args.cisco_series == "9800": try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr,self.args.cisco_user, - self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"disable_network_24ghz")) + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user, + self.args.cisco_passwd,self.args.cisco_ap,self.args.cisco_series,self.args.cisco_band,"disable_network_24ghz")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -225,8 +233,8 @@ class cisco_(): exit(1) else: try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value: {}".format(self.args.cisco_scheme, - self.args.cisco_ctlr,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"cmd","config 802.11b disable network")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", @@ -252,8 +260,9 @@ class cisco_(): def controller_role_manual(self): if self.args.cisco_series == "9800": try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr,self.args.cisco_user, - self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"manual")) + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user, + self.args.cisco_passwd,self.args.cisco_ap,self.args.cisco_series,self.args.cisco_band,"manual")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -278,8 +287,9 @@ class cisco_(): def controller_role_auto(self): if self.args.cisco_series == "9800": try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr,self.args.cisco_user, - self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"auto")) + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user, + self.args.cisco_passwd,self.args.cisco_ap,self.args.cisco_series,self.args.cisco_band,"auto")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -302,8 +312,8 @@ class cisco_(): #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action txPower --value 5 --series 9800 def controller_set_tx_power(self): try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value {}".format(self.args.cisco_scheme,self.args.cisco_ctlr, - self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"txPower", self.args.cisco_tx_power )) # TODO fix txPower to tx_power in cisco_wifi_ctl.py ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -328,8 +338,8 @@ class cisco_(): # 3504 : (Cisco Controller) >config 802.11a channel ap APA453.0E7B.CF9C 52 def controller_set_channel(self): try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value {}".format(self.args.cisco_scheme,self.args.cisco_ctlr, - self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"channel", self.args.cisco_channel )) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -352,8 +362,8 @@ class cisco_(): #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action bandwidth --value 40 --series 9800 def controller_set_bandwidth(self): try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value {}".format(self.args.cisco_scheme,self.args.cisco_ctlr, - self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"channel", self.args.cisco_chan_width )) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -377,8 +387,8 @@ class cisco_(): def controller_create_wlan(self): if self.args.cisco_series == "9800": try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} wlan {} wlanID {}".format(self.args.cisco_scheme,self.args.cisco_ctlr, - self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} wlan {} wlanID {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"create_wlan", self.args.cisco_wlan, self.args.cisco_wlanID )) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -403,8 +413,8 @@ class cisco_(): def controller_set_wireless_tag_policy(self): if self.args.cisco_series == "9800": try: - logg.info("scheme {} ctlr {} user {} passwd {} AP {} series {} band {} action {}".format(self.args.cisco_scheme,self.args.cisco_ctlr, - self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"wireless_tag_policy" )) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -429,8 +439,8 @@ class cisco_(): #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action enable_wlan --series 9800 def controller_enable_wlan(self): try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr, - self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"enable_wlan")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -454,8 +464,8 @@ class cisco_(): def controller_enable_network_5ghz(self): if self.args.cisco_series == "9800": try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr, - self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"enable_network_5ghz")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -474,8 +484,8 @@ class cisco_(): exit(1) else: try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value: {}".format(self.args.cisco_scheme, - self.args.cisco_ctlr,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"cmd","config 802.11a enable network")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", @@ -500,8 +510,8 @@ class cisco_(): def controller_enable_network_24ghz(self): if self.args.cisco_series == "9800": try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr, - self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"enable_network_24ghz")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -520,8 +530,8 @@ class cisco_(): exit(1) else: try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value: {}".format(self.args.cisco_scheme, - self.args.cisco_ctlr,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {} value: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"cmd","config 802.11b enable network")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", @@ -545,8 +555,8 @@ class cisco_(): #./cisco_wifi_ctl.py --scheme ssh -d 172.19.36.168 -p --port 23 -a "9120-Chamber-1" --band a --action enable --series 9800 def controller_enable_ap(self): try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr, - self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user,self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"enable")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, @@ -942,8 +952,9 @@ class L3VariableTime(LFCliBase): return try: - logg.info("scheme: {} ctlr: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme,self.args.cisco_ctlr,self.args.cisco_user, - self.args.cisco_passwd, self.args.cisco_ap, self.args.cisco_series, self.args.cisco_band,"summary")) + logg.info("scheme: {} ctlr: {} port: {} prompt: {} user: {} passwd: {} AP: {} series: {} band: {} action: {}".format(self.args.cisco_scheme, + self.args.cisco_ctlr,self.args.cisco_port,self.args.prompt,self.args.cisco_user, + self.args.cisco_passwd,self.args.cisco_ap,self.args.cisco_series,self.args.cisco_band,"summary")) ctl_output = subprocess.run(["../cisco_wifi_ctl.py", "--scheme", self.args.cisco_scheme, "--prompt", self.args.prompt, "--port", self.args.cisco_port, "-d", self.args.cisco_ctlr, "-u", self.args.cisco_user, "-p", self.args.cisco_passwd, diff --git a/py-scripts/test_ipv4_variable_time.py b/py-scripts/test_ipv4_variable_time.py index c3cf963d..e21a421b 100755 --- a/py-scripts/test_ipv4_variable_time.py +++ b/py-scripts/test_ipv4_variable_time.py @@ -204,9 +204,13 @@ python3 ./test_ipv4_variable_time.py optional_args.add_argument('--ap',help='Used to force a connection to a particular AP') optional_args.add_argument('--report_file',help='where you want to store results') optional_args.add_argument('--output_format', help='choose either csv or xlsx') +<<<<<<< HEAD optional_args.add_argument('--a_min', help='--a_min bps rate minimum for side_a', default=256000) optional_args.add_argument('--b_min', help='--b_min bps rate minimum for side_b', default=256000) optional_args.add_argument('--test_duration', help='--test_duration sets the duration of the test', default="2m") +======= + optional_args.add_argument('--show', help='display results of test in terminal',default=True) +>>>>>>> e9a071eff8cfb397f9534ea865f8450e43078cee args = parser.parse_args() num_sta = 2 @@ -258,13 +262,17 @@ python3 ./test_ipv4_variable_time.py ip_var_test.start(False, False) - layer3connections=','.join([[*x.keys()][0] for x in ip_var_test.l3cxprofile.json_get('endp')['endpoint']]) - ip_var_test.l3cxprofile.monitor(col_names=['Name','Tx Rate','Rx Rate','Tx PDUs','Rx PDUs'], + try: + layer3connections=','.join([[*x.keys()][0] for x in ip_var_test.local_realm.json_get('endp')['endpoint']]) + except: + raise ValueError('Try setting the upstream port flag if your device does not have an eth1 port') + ip_var_test.l3cxprofile.monitor(col_names=['Name','Tx Rate','Rx Rate','Tx PDUs','Rx PDUs','Rx Drop % A', 'Rx Drop % B', 'Bps Rx A', 'Bps Rx B', 'Rx Rate', 'Cx Estab'], report_file=report_f, duration_sec=ip_var_test.local_realm.parse_time(args.test_duration).total_seconds(), created_cx= layer3connections, output_format=output, script_name='test_ipv4_variable_time', + show=show, arguments=args) ip_var_test.stop() diff --git a/py-scripts/Netgear_dfs.py b/py-scripts/test_netgear_dfs.py similarity index 68% rename from py-scripts/Netgear_dfs.py rename to py-scripts/test_netgear_dfs.py index adefeafb..e8a99ebf 100644 --- a/py-scripts/Netgear_dfs.py +++ b/py-scripts/test_netgear_dfs.py @@ -1,565 +1,395 @@ -""" file under progress not ffor testing - +""" file under progress not ffor testing - AP R7800 """ - - - import time - import threading - import os - import paramiko - from queue import Queue - from cx_time import IPv4Test - - - - class DFS_TESTING: - - - - def __init__(self): - + def _init_(self): pass - - - def set_dfs_channel_in_ap(self): - ssh = paramiko.SSHClient() # creating shh client object we use this object to connect to router - ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # automatically adds the missing host key - ssh.connect('192.168.200.190', port=22, username='root', password='Lanforge12345!xzsawq@!') - stdin, stdout, stderr = ssh.exec_command('conf_set system:wlanSettings:wlanSettingTable:wlan1:channel 52') - output = stdout.readlines() - print('\n'.join(output)) - time.sleep(1) - exit(0) - - def create_station_on_GUI(self,y1,y2): - global var1 - self.y1 = y1 - self.y2 = y2 - cmd = "python3 sta_cx.py --mgr 192.168.200.13 --num_stations 1 --ssid TestAP95 --passwd lanforge --security wpa2 --radio wiphy0" - print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/home/lanforge/lanforge-scripts/py-scripts') - print("Current working directory: {0}".format(os.getcwd())) - x = os.popen(cmd).read() - print("station created") - y1 ='station created' - - with open("data.txt", "w")as f: - f.write(x) - f.close() - - file = open("data.txt", "r") - for i in file: - if "channel associated is " in i: - my_list = list(i.split(" ")) - print(my_list[3]) - print(type(my_list[3])) - var1 = my_list[3] - - print(var1) - var = var1.replace("\n", "") - - if var == "52" or var == "56" or var == "60" or var == "64" or var == "100" or var == "104" or var == "108" or var == "112" or var == "116" or var == "120" or var == "124" or var == "128" or var == "132" or var == "136" or var == "140": - print('Station is on DFS Channel') - self.y2 = 'station is on DFS Channel' - else: - print('Station is on Non DFS channel') - self.y2 = 'Station is on Non DFS channel' - - return (self.y1 , self.y2) - - - - - ''' ########### HACKRF ####################### ''' - - - def generate_radar_at_ch52(self, r): - self.r = r - cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5260000" - # print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') - #print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) - self.r = "Radar detected" - return self.r - - - def generate_radar_at_ch56(self): - + def generate_radar_at_ch56(self,q): + self.q =q cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5280000" - # print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) + self.q = "Radar detected" + return self.q - - - def generate_radar_at_ch60(self): - + def generate_radar_at_ch60(self,w): + self.w = w cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5300000" - # print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') - # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) + self.w = "Radar detected" + return self.w - - - def generate_radar_at_ch64(self): - + def generate_radar_at_ch64(self,e): + self.e = e cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5320000" - # print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') - # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) + self.e = "Radar detected" + return self.e - - - def generate_radar_at_ch100(self,r): - - self.r = r - + def generate_radar_at_ch100(self,f): + self.f = f cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5500000" - # print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') - # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) + self.f = "Radar received" + return self.f - self.r = "Radar received" - - return self.r - - - - def generate_radar_at_ch104(self): - + def generate_radar_at_ch104(self,t): + self.t = t cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5520000" - # print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') - # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) + self.t = "Radar detected" + return self.t - - - def generate_radar_at_ch108(self): - + def generate_radar_at_ch108(self,u): + self.u=u cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5540000" - # print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') - # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) + self.u = "Radar detected" + return self.u - - - def generate_radar_at_ch112(self): - + def generate_radar_at_ch112(self,i): + self.i=i cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5560000" - # print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') - # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) + self.i = "Radar detected" + return self.i - - - def generate_radar_at_ch116(self): - + def generate_radar_at_ch116(self,o): + self.o =o cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5280000" - # print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') - # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) + self.o = "Radar detected" + return self.o - - - def generate_radar_at_ch120(self): - + def generate_radar_at_ch120(self,p): + self.p=p cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5600000" - #print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') - # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) + self.p = "Radar detected" + return self.p - - - def generate_radar_at_ch124(self): - + def generate_radar_at_ch124(self,a): + self.a=a cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5620000" - # print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') - # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) + self.a = "Radar detected" + return self.a - - - def generate_radar_at_ch128(self): - + def generate_radar_at_ch128(self,s): + self.s=s cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5640000" - # print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') - # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) + self.s = "Radar detected" + return self.s - - - def generate_radar_at_ch132(self): - + def generate_radar_at_ch132(self,d): + self.d = d cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5660000" - # print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') - # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) + self.d = "Radar detected" + return self.d - - - def generate_radar_at_ch136(self): - + def generate_radar_at_ch136(self,h): + self.h=h cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5680000" - # print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') - # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) + self.h = "Radar detected" + return self.h - - - def generate_radar_at_ch140(self): - + def generate_radar_at_ch140(self,j): + self.j = j cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5700000" - # print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') - # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) - - + self.j = "Radar detected" + return self.j def hackrf_status_off(self): - + cmd = "sudo python lf_hackrf.py --pulse_width 1 --pulse_interval 1428 --pulse_count 18 --sweep_time 1000 --freq 5220000" - # print("Current working directory: {0}".format(os.getcwd())) - os.chdir('/usr/lib64/python2.7/site-packages/') - # print("Current working directory: {0}".format(os.getcwd())) - os.system(cmd) - - + def monitor_station_channel(self,m): - self.m = m - obj = IPv4Test(_host="192.168.200.13", - _port=8080, - _ssid="TestAP95", - _password="lanforge", - _security="wpa2", - _radio="wiphy0") - obj.cleanup(obj.sta_list) - obj.build() - obj.station_profile.admin_up() - obj.local_realm.wait_for_ip(obj.sta_list) - time.sleep(30) - var = obj.json_get("/port/1/1/sta0000?fields=channel") - var_1 = var['interface']['channel'] - self.m = var_1 - return self.m - - - def aps_radio_off(self): - pass - - def aps_not_switch_automatically(self): - pass - - def check_ap_channel_switching_time(self): - pass - - - - def main(): - - - - - dfs = DFS_TESTING() - - que = Queue() - - - - ''' algorithm and sequence to be followed ''' - - print("Hackrf is ON") - print("press s --> enter --> q to stop hackrf") - dfs.hackrf_status_off() - print("Now hackrf is OFF") - - #set channel on ap //netgear - - threads_list = [] - t1 = threading.Thread(target=lambda q, arg1, arg2: q.put(dfs.create_station_on_GUI(arg1, arg2)), args=(que, "", "")) - t1.start() - threads_list.append(t1) - t1.join() - - # Check thread's return value - global my_var - - result = que.get() - print("hi i reached", result) - my_var = result - - list_1 = list(my_var) - print("my list", list_1) - - if any("station is on DFS Channel" in s for s in list_1): - t2 = threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch52(arg1)), args=(que, "")) - t2.start() - threads_list.append(t2) - t2.join() - x = que.get() - print("result", x) - else: - print("radar unreachable") - - t3=threading.Thread(target=lambda q, arg1: q.put(dfs.monitor_station_channel(arg1)), args=(que, "")) - t3.start() - threads_list.append(t3) - t3.join() - y = que.get() - print("channel after radar is ", y) - - - if (y != "52"): - - print("station is on Non DFS Channel") - - else: - + if y == "52": print("station is on DFS Channel") - - - - - - - - - + t4 = threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch52(arg1)), args=(que, "")) + t4.start() + t4.join() + elif y == "56": + print("station is on DFS Channel 56") + t5 =threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch56(arg1)), args=(que, "")) + t5.start() + t5.join() + elif y == "60": + print("station is on DFS Channel 60") + t6 =threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch60(arg1)), args=(que, "")) + t6.start() + t6.join() + elif y == "64": + print("station is on DFS Channel 64") + t7 =threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch64(arg1)), args=(que, "")) + t7.start() + t7.join() + elif y == "100": + print("station is on DFS Channel 100") + t8 =threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch100(arg1)), args=(que, "")) + t8.start() + t8.join() + elif y == "104": + print("station is on DFS Channel 104") + t9 =threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch104(arg1)), args=(que, "")) + t9.start() + t9.join() + elif y == "108": + print("station is on DFS Channel 108") + t10 =threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch108(arg1)), args=(que, "")) + t10.start() + t10.join() + elif y == "112": + print("station is on DFS Channel 112") + t11 =threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch112(arg1)), args=(que, "")) + t11.start() + t11.join() + elif y == "116": + print("station is on DFS Channel 116") + t12 =threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch116(arg1)), args=(que, "")) + t12.start() + t12.join() + elif y == "120": + print("station is on DFS Channel 120") + t13 =threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch120(arg1)), args=(que, "")) + t13.start() + t13.join() + elif y == "124": + print("station is on DFS Channel 124") + t14 =threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch124(arg1)), args=(que, "")) + t14.start() + t14.join() + elif y == "128": + print("station is on DFS Channel 128") + t15 =threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch128(arg1)), args=(que, "")) + t15.start() + t15.join() + elif y == "132": + print("station is on DFS Channel 132") + t16 =threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch132(arg1)), args=(que, "")) + t16.start() + t16.join() + elif y == "136": + print("station is on DFS Channel 136") + t17 =threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch136(arg1)), args=(que, "")) + t17.start() + t17.join() + elif y == "140": + print("station is on DFS Channel 140") + t18 =threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch140(arg1)), args=(que, "")) + t18.start() + t18.join() + else: + print("station is on NON DFS Channel") @@ -569,81 +399,43 @@ def main(): """t2 = threading.Thread(target=lambda q, arg1: q.put(dfs.generate_radar_at_ch52(arg1)), args=(que, "")) - t2.start() - threads_list.append(t2) - t2.join()""" - - - - - # Join all the threads - """for t in threads_list: - t.join()""" - - - - """print("my var", my_var) - empty_list = [] - list = empty_list.append(my_var) - print("list", list)""" - - - '''t2 = threading.Thread(target=dfs.generate_radar_at_ch100()) - t2.start() - t2.join() - print("radar received") - - t3 = threading.Thread(target=dfs.create_station_on_GUI()) - t3.start() - t3.join() - print("station reassociated")''' - - - - - '''dfs.hackrf_status_off() - dfs.aps_radio_off() - dfs.aps_not_switch_automatically() - #generate radar and check for all dfs channels - dfs.check_ap_channel_switching_time() - #after testing turn off hackrf''' @@ -651,15 +443,5 @@ def main(): - - - - - - - if __name__ == '__main__': - main() - - diff --git a/py-scripts/test_status_msg.py b/py-scripts/test_status_msg.py index a055d726..d76c5022 100755 --- a/py-scripts/test_status_msg.py +++ b/py-scripts/test_status_msg.py @@ -310,7 +310,10 @@ Actions can be: if args.session is None: print("requires --session") return - response_o = status_messages.json_get("/status-msg/"+args.session) + if args.key is None: + print("requires --key") + return + response_o = status_messages.json_get("/status-msg/%s/%s"%(args.session, args.key)) pprint(response_o) return diff --git a/py-scripts/vap_stations_example.py b/py-scripts/vap_stations_example.py index ba658f38..c6366ae9 100755 --- a/py-scripts/vap_stations_example.py +++ b/py-scripts/vap_stations_example.py @@ -1,4 +1,7 @@ #!/usr/bin/env python3 +""" +This is an outdated example. Please see modern py-scripts/test_X example scripts. +""" import sys if sys.version_info[0] != 3: print("This script requires Python 3") diff --git a/py-scripts/wlan_capacity_calculator.py b/py-scripts/wlan_capacity_calculator.py index 1cb8d3f5..511a9afe 100755 --- a/py-scripts/wlan_capacity_calculator.py +++ b/py-scripts/wlan_capacity_calculator.py @@ -1,66 +1,53 @@ +''' +Candela Technologies Inc. +Info : Standard Script for WLAN Capacity Calculator +Date : +Author : Anjali Rahamatkar +''' + import argparse import sys import os +from pip._internal.utils import logging + if 'py-json' not in sys.path: sys.path.append(os.path.join(os.path.abspath('..'), 'py-json')) -import wlan_test +import wlan_theoretical_sta + # main method def main(): - ap = argparse.ArgumentParser(description="WLAN Capacity Calculator") - # Station : 11abg + parse = wlan_theoretical_sta.abg11_calculator.create_argparse( prog='wlan_capacity_calculator.py', + formatter_class=argparse.RawTextHelpFormatter, + epilog='''\ + This python script calculates the theoretical value of three different stations( 11abg/11n/11ac)''', + description='''\ + wlan_capacity_calculator.py + --------------------------------------------------------------------------- - ap.add_argument("-sta", "--station", help="Enter Station Name : [11abg,11n,11ac](by Default 11abg)") - ap.add_argument("-t", "--traffic", help="Enter the Traffic Type : [Data,Voice](by Default Data)") - ap.add_argument("-p", "--phy", - help="Enter the PHY Bit Rate of Data Flow : [1, 2, 5.5, 11, 6, 9, 12, 18, 24, 36, 48, 54](by Default 54)") - ap.add_argument("-e", "--encryption", help="Enter the Encryption : [None, WEP , TKIP, CCMP](by Default None)") - ap.add_argument("-q", "--qos", help="Enter the QoS = : [No, Yes](by Default [No for 11abg] and [Yes for 11n])") - ap.add_argument("-m", "--mac", - help="Enter the 802.11 MAC Frame : [Any Value](by Default [106 for 11abg] and [1538 for 11n])") - ap.add_argument("-b", "--basic", nargs='+', - help="Enter the Basic Rate Set : [1,2, 5.5, 11, 6, 9, 12, 18, 24, 36, 48, 54]" - " (by Default [1 2 5.5 11 6 12] for 11abg, [6 12 24] for 11n/11ac])") - ap.add_argument("-pre", "--preamble", help="Enter Preamble value : [ Short, Long, N/A](by Default Short)") - ap.add_argument("-s", "--slot", help="Enter the Slot Time : [Short, Long, N/A](by Default Short)") - ap.add_argument("-co", "--codec", help="Enter the Codec Type (Voice Traffic): {[ G.711 , G.723 , G.729]" - "by Default G.723 for 11abg, G.711 for 11n} and" - "{['Mixed','Greenfield'] by Default Mixed for 11ac}") - ap.add_argument("-r", "--rts", help="Enter the RTS/CTS Handshake : [No, Yes](by Default No)") - ap.add_argument("-c", "--cts", help="Enter the CTS-to-self (protection) : [No, Yes](by Default No)") - - # Station : 11n and 11ac - - ap.add_argument("-d", "--data", - help="Enter the Data/Voice MCS Index : ['0','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']by Default 7") - ap.add_argument("-ch", "--channel", help="Enter the Channel Bandwidth = : ['20','40'] by Default 40 for 11n and " - "['20','40','80'] by Default 80 for 11ac") - ap.add_argument("-gu", "--guard", help="Enter the Guard Interval = : ['400','800'] (by Default 400)") - ap.add_argument("-high", "--highest", - help="Enter the Highest Basic MCS = : ['0','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'](by Default 1)") - ap.add_argument("-pl", "--plcp", - help="Enter the PLCP Configuration = : ['Mixed','Greenfield'] (by Default Mixed) for 11n") - ap.add_argument("-ip", "--ip", help="Enter the IP Packets per A-MSDU = : ['0','1','2','3','4','5','6','7','8','9'," - "'10','11','12','13','14','15','16','17','18','19','20'] (by Default 0)") - ap.add_argument("-mc", "--mc", - help="Enter the MAC Frames per A-MPDU = : ['0','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'](by Default [42 for 11n] and [64 for 11ac])") - ap.add_argument("-cw", "--cwin", help="Enter the CWmin (leave alone for default) = : [Any Value] (by Default 15)") - ap.add_argument("-spa", "--spatial", help="Enter the Spatial Streams = [1,2,3,4] (by Default 4)") - ap.add_argument("-rc", "--rtscts", help="Enter the RTS/CTS Handshake and CTS-to-self " - " = ['No','Yes'] (by Default No for 11ac)") + Example of command line to run(11ac Station): + ./wlan_capacity_calculator.py + -sta 11ac + -t Voice + -d 9 + -spa 3 + -ch 20 + -gu 800 + -high 1 + -e TKIP + -q Yes + -ip 3 + -mc 0 + -b 6 12 24 54 + -m 1518 + -co Greenfield + -cw 15 + ''') try: - args = ap.parse_args() + args = parse.parse_args() # Station if (args.station is not None): Calculator_name = args.station @@ -238,22 +225,26 @@ def main(): # Select station(802.11a/b/g/n/ac standards) if "11abg" in Calculator_name: - Station1 = wlan_test.abg11_calculator(traffic_name, phy_name, encryption_name, qos_name, mac_name, basic_name, + Station1 = wlan_theoretical_sta.abg11_calculator(traffic_name, phy_name, encryption_name, qos_name, mac_name, basic_name, preamble_name, slot_name, codec_name, rts_name, cts_name) - Station1.input_parameter() + Station1.calculate() + Station1.get_result() + if "11n" in Calculator_name: - Station2 = wlan_test.n11_calculator(traffic_name, data_name, channel_name, guard_name, highest_name, encryption_name, + Station2 = wlan_theoretical_sta.n11_calculator(traffic_name, data_name, channel_name, guard_name, highest_name, encryption_name, qos_name, ip_name, mc_name, basic_name, mac_name, codec_name, plcp_name, cwin_name, rts_name, cts_name) - Station2.input_parameter() + Station2.calculate() + Station2.get_result() if "11ac" in Calculator_name: - Station3 = wlan_test.ac11_calculator(traffic_name, data_name, spatial_name, channel_name, guard_name, highest_name, + Station3 = wlan_theoretical_sta.ac11_calculator(traffic_name, data_name, spatial_name, channel_name, guard_name, highest_name, encryption_name , qos_name, ip_name, mc_name, basic_name, mac_name, codec_name, cwin_name, rtscts_name) - Station3.input_parameter() + Station3.calculate() + Station3.get_result() if __name__ == "__main__": - main() \ No newline at end of file + main() \ No newline at end of file