capacity_test.py
Go to the documentation of this file.
00001 #! /usr/bin/env python
00002 
00003 import sys
00004 import time
00005 import subprocess
00006 
00007 import roslib; roslib.load_manifest('network_monitor_udp')
00008 import rospy
00009 from network_monitor_udp.linktest import UdpmonsourceHandle
00010 from network_monitor_udp.linktest import LinkTest
00011 from network_monitor_udp.msg import LinktestGoal
00012 import dynamic_reconfigure.client
00013 
00014 AP_PREFIX="/ap_atheros/"
00015 HOSTAPD_NODE=AP_PREFIX+"ap_control"
00016 AP_SINK_IP="192.168.69.1"
00017 AP_SINK_PORT=12345
00018 
00019 STA_PREFIX="/sta/"
00020 STA_IFACE="eth1"
00021 STA_SINK_IP="192.168.69.2"
00022 STA_SINK_PORT=12345
00023 
00024 DEFAULT_PACKET_SIZE = 1500
00025 
00026 def get_link_capacity(direction = "down"):
00027     if direction == "up":
00028         return sta_source.get_link_capacity(sink_ip=AP_SINK_IP, sink_port=AP_SINK_PORT, rostopic_prefix=AP_PREFIX, pktsize=pktsize)
00029     elif direction == "down":
00030         return ap_source.get_link_capacity(sink_ip=STA_SINK_IP, sink_port=STA_SINK_PORT, rostopic_prefix=STA_PREFIX, pktsize=pktsize)
00031         
00032 def setup_hostapd_ap():        
00033     config = dynclient.update_configuration({"enabled": True, "ssid": "testnet", "mode": "g"})
00034     if config["status"] != "OK":
00035         raise ValueError(config["errmsg"])
00036 
00037 if __name__ == '__main__':
00038     pktsize = DEFAULT_PACKET_SIZE
00039     if len(sys.argv) == 2:
00040         pktsize = int(sys.argv[1])
00041 
00042     rospy.init_node('testnode')
00043 
00044     dynclient = dynamic_reconfigure.client.Client(HOSTAPD_NODE)
00045     
00046     ap_source = UdpmonsourceHandle('/ap_atheros/performance_test') 
00047     sta_source = UdpmonsourceHandle('/sta/performance_test') 
00048     ap_source.cancel_all_tests()
00049     sta_source.cancel_all_tests()
00050 
00051     setup_hostapd_ap()
00052 
00053     print "Up: ", get_link_capacity("up")
00054     print "Down: ", get_link_capacity("down")


network_control_tests
Author(s): Catalin Drula
autogenerated on Wed Sep 16 2015 04:38:36