def start_test_screens(c): """Starts screens for react, mgen, and tshark on all nodes""" global HOSTS group = ThreadingGroup(*HOSTS) group.run('screen -S mgen', pty=False) group.run('screen -S react', pty=False) group.run('screen -S tshark', pty=False)
def iperf_stop_clients(c): """Stops all iperf clients on all of the nodes. """ global HOSTS group = ThreadingGroup(*HOSTS) for conn in group: screen_stop_session(conn, 'iperf_client', interrupt=True)
def time_sync(c): """Synchronizes the time among the nodes. This is imprecise, PTPd is better for precision. """ global HOSTS group = ThreadingGroup(*HOSTS) for conn in group: conn.run('sudo service ntp stop') conn.run('sudo ntpdate time.nist.gov')
def stop_salt_all(c): """Stops react on all nodes. """ global HOSTS group = ThreadingGroup(*HOSTS) for conn in group: stop_salt(conn)
def execute(c,tag_key,tag_value,**kwargs): for key,value in kwargs.items(): print(key,value) target_hosts=[] client = boto3.client("ec2") response = client.describe_instances( Filters=[ { 'Name': "tag:" + tag_key, 'Values': [tag_value] }, { 'Name': "instance-state-name", 'Values': ["running"] } ] ) for r in response['Reservations']: for i in r["Instances"]: target_hosts.append(i["PrivateIpAddress"]) print(target_hosts) conn = ThreadingGroup(*target_hosts,config=config) print(conn) run(conn,"ls -al")
def iperf_start_servers(c): """Starts UDP and TCP iperf servers on all of the nodes. """ global HOSTS group = ThreadingGroup(*HOSTS) for conn in group: screen_start_session(conn, 'iperf_server_udp', 'iperf -s -u') screen_start_session(conn, 'iperf_server_tcp', 'iperf -s')
def set_edca_react(c): global HOSTS group = ThreadingGroup(*HOSTS) commands = [ 'sudo echo "0 2 15 1023 0" | sudo tee /sys/kernel/debug/ieee80211/phy0/ath9k/txq_params', 'sudo echo "1 2 15 1023 0" | sudo tee /sys/kernel/debug/ieee80211/phy0/ath9k/txq_params', 'sudo echo "2 2 7 15 3" | sudo tee /sys/kernel/debug/ieee80211/phy0/ath9k/txq_params', 'sudo echo "3 2 3 7 1" | sudo tee /sys/kernel/debug/ieee80211/phy0/ath9k/txq_params', ] for command in commands: for conn in group: conn.run(command)
def iperf_test(c): """Tests iperf on one of the nodes. """ global USERNAME global HOSTS group = ThreadingGroup(*HOSTS) cm = ConnMatrix() cm.add('192.168.0.1', r'192.168.0.2', '6Mbps') cm.add('192.168.0.2', r'192.168.0.3', '6Mbps') cm.add('192.168.0.3', r'192.168.0.4', '6Mbps') cm.add('192.168.0.4', r'192.168.0.1', '6Mbps') for conn in group: iperf_start_clients(conn, f"/users/{USERNAME}/", cm)
def check_awake(c): global HOSTS group = ThreadingGroup(*HOSTS) all_awake = False while not all_awake: all_awake = True time.sleep(10) try: for conn in group: result = conn.run(':') for key, item in result.items(): if not item.ok: all_awake = False except Exception: print('Not awake yet... Trying again in 10s...') print('All awake!')
def ping_test(c): """Tests pings for the nodes.""" global USERNAME global HOSTS group = ThreadingGroup(*HOSTS) cm = ConnMatrix() cm.add('192.168.0.1', r'192.168.0.3', '6Mbps') cm.add('192.168.0.3', r'192.168.0.1', '6Mbps') first = True for conn in group: if first: tos = '0xe0' first = False else: tos = '0x00' start_pings(conn, f"/users/{USERNAME}/", cm, tos=tos)
def set_tx_power(c, interface = 'wls33', tx_power = 1): """Sets tx_power for an interface. """ global HOSTS group = ThreadingGroup(*HOSTS) group.run(f'sudo iwconfig {interface} txpower {tx_power}')
def install_python_deps(c): """Install python dependencies. """ global HOSTS group = ThreadingGroup(*HOSTS) group.run("sudo apt-get update; sudo apt-get install -y python-scapy python-netifaces python-numpy python-flask")
def screening(c, run, type, params): """Function for executing a single test from the locating array. Used by the run_screening function""" global HOSTS group = ThreadingGroup(*HOSTS) shaping = True if params[0] == 'yes' else False cw_min = params[1] cw_max = params[2] qos_node_flow_type = params[3] if type == 'line': qos_node = params[4] qos_demand = params[5] protocol = params[6] flow_info = params[7] # elif type == 'complete': else: qos_node = 'node1' qos_demand = params[4] protocol = params[5] flow_info = params[6] cm, extra_cm, qos_ip = get_conn_matrices(type, qos_node_flow_type, qos_node) # make the output directories out_dirs = {} for conn in group: out_dirs[conn.host] = \ make_out_directory( conn, f'{DATA_PATH}screening/{type}/run{run}' ) # set the MAC protocol protocol = protocol.split('_') if len(protocol) == 1: use = protocol[0].lower() offered_airtime = 0.8 else: if protocol[0] == 'REACT': use = 'react' # elif protocol[0] == 'REACTQoS': else: use = 'react_qos' offered_airtime = int(protocol[1]) / 100.0 # sets access category parameters if use == 'dcf' or use == 'react': print('DCF or REACT') set_dcf(c) elif use == 'edca': print('EDCA') set_edca(c) elif use == 'react_qos': print('REACT QOS') set_edca_react(c) # starts REACT running on all of the nodes print('starting REACT') for conn in group: if use == 'dcf' or use == 'edca': tuner = 'dot' else: tuner = 'salt' # setting BE/QoS claims for REACt # qos_claim, be_claim = get_demand_amounts(use, qos_demand, cm, extra_cm) if use == 'dcf' or use == 'edca': qos_claim, be_claim = 0.0, 0.0 elif use == 'react': qos_claim, be_claim = 0.0, 1.0 elif use == 'react_qos': if get_my_ip(conn) == qos_node: # this is the qos node # now we need to check if we have two flows or one qos_claim = qos_demand if extra_cm is not None: be_claim = 1.0 else: be_claim = 0.0 else: # just a be node qos_claim, be_claim = 0.0, 1.0 else: print("Error -- no qos_claim") print(f'use: {use}') raise AssertionError() run_react_new( conn, out_dirs[conn.host], tuner=tuner, qos_claim=qos_claim, be_claim=be_claim, offered_airtime=offered_airtime, cw_min=cw_min, cw_max=cw_max, shaping=shaping ) # start pings for collecting delay and jitter print('starting pings') for conn in group: if (use == 'react_qos' or use == 'edca') and get_my_ip(conn) == qos_node: tos = '0xa0' else: tos = '0x00' start_pings(conn, out_dirs[conn.host], cm, tos=tos) if extra_cm is not None and get_my_ip(conn) == qos_node: start_pings(conn, out_dirs[conn.host], extra_cm, tos='0x00') # starts iperf streams for throughput print('starting iperf') for conn in group: if (use == 'react_qos' or use == 'edca') and get_my_ip(conn) == qos_node: tos = '0xa0' else: tos = '0x00' # parsing of TCP_8K_N print(flow_info) new_flow_info = flow_info.split('_') if new_flow_info[0] == 'TCP': tcp = True window_size = new_flow_info[1] no_delay = False if new_flow_info[2] == 'D' else True else: tcp = False rate = new_flow_info[1] if tcp: iperf_start_clients(conn, out_dirs[conn.host], cm, tos=tos, tcp=tcp, no_delay=no_delay, window_size=window_size, time=60) else: iperf_start_clients(conn, out_dirs[conn.host], cm, tos=tos, rate=rate, time=60) # if QoS is sending two flowx if extra_cm is not None and get_my_ip(conn) == qos_node: if tcp: iperf_start_clients(conn, out_dirs[conn.host], cm, tos=tos, tcp=tcp, no_delay=no_delay, window_size=window_size, time=60, extra=True) else: iperf_start_clients(conn, out_dirs[conn.host], extra_cm, tos='0x00', rate=rate, time=60, extra=True) print('running experiment for 120 seconds') time.sleep(65) print('stopping experiment') stop_exp(c)
def reset_netifaces(c): global HOSTS group = ThreadingGroup(*HOSTS) for conn in group: conn.run('sudo ifconfig wls33 down') conn.run('sudo ifconfig wls33 up')
def all_up(c): """A way to make sure you are connected to all the nodes. """ global HOSTS group = ThreadingGroup(*HOSTS) group.run(':') group.run('echo UP')
def reboot(c): """Reboots all nodes. """ global HOSTS group = ThreadingGroup(*HOSTS) for conn in group: conn.run('sudo reboot')