def __init__(self, *args): super(HostapdTest, self).__init__(*args) rospy.init_node('hostapd_access_point_test') self.ap1_iface = rospy.get_param('~ap1_iface') self.ap2_iface = rospy.get_param('~ap2_iface') self.sta_iface = rospy.get_param('~sta_iface') self.dyn_ap1 = dynamic_reconfigure.client.Client("hostapd1") self.dyn_ap2 = dynamic_reconfigure.client.Client("hostapd2") self.reset_params = { "enabled": False, "ssid": "test", "wmm": False, "mode": 'b', "freq": 2412e6, "ieee80211n": False, "encryption_mode": "open", "encryption_pass": "", "txpower_auto": "True", "txpower": 0, "bitrate": 0 } self.dyn_ap1.update_configuration(self.reset_params) self.dyn_ap2.update_configuration(self.reset_params) self.hwsim_nat_setup_path = \ roslib.packages.find_node('hostapd_access_point', 'hwsim_nat_setup.sh') self.srcnode = UdpmonsourceHandle('performance_test') self.srcnode.cancel_all_tests()
def __init__(self, *args): super(DynreconfTest, self).__init__(*args) rospy.init_node('network_traffic_control_test') self.srcnode = UdpmonsourceHandle('performance_test') self.dynclient = dynamic_reconfigure.client.Client("tc_lo") self.no_traffic_control_params = { "bandwidth_egress" : 0.0, "bandwidth_ingress" : 0.0, "latency_egress" : 0.0, "latency_ingress" : 0.0, "loss_egress" : 0.0, "loss_ingress" : 0.0, "packet_size" : 1500 } self.reset_tc_rules_via_dynreconf()
def measure_link(tx_bandwidth, bandwidth_limit, latency, loss, packet_size, max_allowed_latency, max_return_time, sink_ip, direction, duration): (proj_bandwidth, proj_latency, proj_loss) = get_projected_link_metrics(bandwidth_limit, latency, loss, \ packet_size, tx_bandwidth) if proj_latency > max_allowed_latency: rospy.logerr("Max allowed latency %.2fms is smaller than projected latency %.2fms," "results will be flawed, exiting", max_allowed_latency * 1e3, proj_latency * 1e3) exit(1) dynclient = dynamic_reconfigure.client.Client("tc") config = dynclient.update_configuration({"bandwidth_egress" : 0.0, "bandwidth_ingress" : 0.0, "latency_egress" : 0.0, "latency_ingress" : 0.0, "loss_egress" : 0.0, "loss_ingress" : 0.0 }) if config['status'] != "OK": rospy.logerr("Initalizing tc node failed: " + config['errmsg']) exit(1) config = dynclient.update_configuration({"bandwidth_" + direction: bandwidth_limit, "latency_" + direction: latency, "loss_" + direction: loss }) if config['status'] != "OK": rospy.logerr("Setting tc node config failed: " + config['errmsg']) srcnode = UdpmonsourceHandle('performance_test') test = srcnode.create_test(bw = tx_bandwidth, pktsize = packet_size, duration = duration, sink_ip = sink_ip, sink_port = 12345, bw_type = LinktestGoal.BW_CONSTANT, max_return_time = max_return_time, latencybins = [ max_allowed_latency/4, max_allowed_latency/2, max_allowed_latency]) test.start() time.sleep(duration + 0.5) rospy.loginfo("Link measurement completed!") rospy.loginfo("Link parameters: bandwidth_limit %.2fkbit/s latency %.2fms loss %.2f%% tx_bandwidth %.2fkbit/s\n" " packet_size %dbytes max_allowed_latency %.2fms max_return_time %.2fms\n" " direction %s duration %.2fs", bandwidth_limit/1e3, latency*1e3, loss, tx_bandwidth/1e3, packet_size, max_allowed_latency*1e3, max_return_time*1e3, direction, duration) rospy.loginfo("\nRESULTS: measured_bandwidth %.2fkbit/s measured_latency %.2fms measured_loss %.2f%%", test.bandwidth.avg()/1e3, test.latency.avg() * 1e3, test.loss.avg())
def __init__(self, *args): super(BasicTest, self).__init__(*args) rospy.init_node('network_monitor_udp_test') self.srcnode = UdpmonsourceHandle('performance_test')
def __init__(self, *args): super(MultipleEndsTest, self).__init__(*args) rospy.init_node('network_monitor_udp_test') self.srcnode = UdpmonsourceHandle('performance_test') self.tc = TcPortControl(self) self.tc.reset()
#! /usr/bin/env python import roslib; roslib.load_manifest('network_monitor_udp') import rospy from network_monitor_udp.linktest import UdpmonsourceHandle from network_monitor_udp.linktest import LinkTest from network_monitor_udp.msg import LinktestGoal if __name__ == '__main__': rospy.init_node('test_node') source = UdpmonsourceHandle() source.cancel_all_tests() try: print "Link capacity: %.2fMbit/s"%(source.get_link_capacity(sink_ip="127.0.0.1", sink_port=12345)/1e6) finally: source.cancel_all_tests()
def setup_hostapd_ap(): config = dynclient.update_configuration({ "enabled": True, "ssid": "testnet", "mode": "g" }) if config["status"] != "OK": raise ValueError(config["errmsg"]) if __name__ == '__main__': pktsize = DEFAULT_PACKET_SIZE if len(sys.argv) == 2: pktsize = int(sys.argv[1]) rospy.init_node('testnode') dynclient = dynamic_reconfigure.client.Client(HOSTAPD_NODE) ap_source = UdpmonsourceHandle('/ap_atheros/performance_test') sta_source = UdpmonsourceHandle('/sta/performance_test') ap_source.cancel_all_tests() sta_source.cancel_all_tests() setup_hostapd_ap() print "Up: ", get_link_capacity("up") print "Down: ", get_link_capacity("down")