Пример #1
0
 def _iperf_task(self, destination_ip, duration):
     self.log.info("Starting iPerf task")
     self.ip_server.start()
     tput_dict = {"Uplink": 0, "Downlink": 0}
     if iperf_test_by_adb(
             self.log,
             self.ad,
             destination_ip,
             self.port_num,
             True,  # reverse = true
             duration,
             rate_dict=tput_dict):
         uplink = tput_dict["Uplink"]
         downlink = tput_dict["Downlink"]
         self.ip_server.stop()
         return True
     else:
         self.log.error("iperf failed to Destination.")
         self.ip_server.stop()
         return False
Пример #2
0
    def _setup_data(self, set_simulation_func, rat):
        try:
            [self.bts1] = set_simulation_func(self.anritsu, self.user_params,
                                              self.ad.sim_card)
            set_usim_parameters(self.anritsu, self.ad.sim_card)
            set_post_sim_params(self.anritsu, self.user_params,
                                self.ad.sim_card)
            if self.lte_bandwidth == 20:
                self.bts1.bandwidth = BtsBandwidth.LTE_BANDWIDTH_20MHz
            elif self.lte_bandwidth == 15:
                self.bts1.bandwidth = BtsBandwidth.LTE_BANDWIDTH_15MHz
            elif self.lte_bandwidth == 10:
                self.bts1.bandwidth = BtsBandwidth.LTE_BANDWIDTH_10MHz
            else:
                self.bts1.bandwidth = BtsBandwidth.LTE_BANDWIDTH_5MHz

            self.anritsu.start_simulation()

            if rat == RAT_LTE:
                preferred_network_setting = NETWORK_MODE_LTE_CDMA_EVDO
                rat_family = RAT_FAMILY_LTE
            elif rat == RAT_WCDMA:
                preferred_network_setting = NETWORK_MODE_GSM_UMTS
                rat_family = RAT_FAMILY_UMTS
            elif rat == RAT_GSM:
                preferred_network_setting = NETWORK_MODE_GSM_ONLY
                rat_family = RAT_FAMILY_GSM
            elif rat == RAT_1XRTT:
                preferred_network_setting = NETWORK_MODE_CDMA
                rat_family = RAT_FAMILY_CDMA2000
            else:
                self.log.error("No valid RAT provided for SMS test.")
                return False

            if not ensure_network_rat(
                    self.log,
                    self.ad,
                    preferred_network_setting,
                    rat_family,
                    toggle_apm_after_setting=True):
                self.log.error(
                    "Failed to set rat family {}, preferred network:{}".format(
                        rat_family, preferred_network_setting))
                return False

            self.anritsu.wait_for_registration_state()
            time.sleep(self.SETTLING_TIME)

            # Fetch IP address of the host machine
            cmd = "|".join(("ifconfig", "grep eth0 -A1", "grep inet",
                            "cut -d ':' -f2", "cut -d ' ' -f 1"))
            destination_ip = exe_cmd(cmd)
            destination_ip = (destination_ip.decode("utf-8")).split("\n")[0]
            self.log.info("Dest IP is %s", destination_ip)

            if not adb_shell_ping(self.ad, DEFAULT_PING_DURATION,
                                  destination_ip):
                self.log.error("Pings failed to Destination.")
                return False
            self.bts1.output_level = self.start_power_level

            # Power, iperf, file output, power change
            for iteration in range(1, self.MAX_ITERATIONS + 1):
                self.log.info("------- Current Iteration: %d / %d -------",
                              iteration, self.MAX_ITERATIONS)
                current_power = self.bts1.output_level
                self.log.info("Current Power Level is %s", current_power)

                self.ip_server.start()
                tput_dict = {"Uplink": 0, "Downlink": 0}
                if iperf_test_by_adb(
                        self.log,
                        self.ad,
                        destination_ip,
                        self.port_num,
                        True,
                        10,
                        rate_dict=tput_dict):
                    uplink = tput_dict["Uplink"]
                    downlink = tput_dict["Downlink"]
                else:
                    self.log.error("iperf failed to Destination.")
                    self.log.info("Iteration %d Failed", iteration)
                    if float(current_power) < -55.0:
                        return True
                    else:
                        return False
                self.ip_server.stop()

                self.log.info("Iteration %d Passed", iteration)
                self.logpath = os.path.join(logging.log_path, "power_tput.txt")
                line = "Power " + current_power + " DL TPUT " + str(downlink)
                with open(self.logpath, "a") as tput_file:
                    tput_file.write(line)
                    tput_file.write("\n")
                current_power = float(current_power)
                new_power = current_power - self.step_size
                self.log.info("Setting Power Level to %f", new_power)
                self.bts1.output_level = new_power

        except AnritsuError as e:
            self.log.error("Error in connection with Anritsu Simulator: " +
                           str(e))
            return False
        except Exception as e:
            self.log.error("Exception during Data procedure: " + str(e))
            return False
        return True
Пример #3
0
 def test_tcp_download_stress(self):
     return iperf_test_by_adb(self.log, self.ad, self.iperf_server_address,
                              self.iperf_srv_tcp_port, True,
                              self.test_duration)