Beispiel #1
0
def write_log_file(filename, node, exp_name):
    """Writes all the log data from the node to a HDF5 file."""

    import datetime
    import wlan_exp.log.util_hdf as hdf_util
    import wlan_exp.log.util as log_util

    data_buffer = node.log_get_all_new(log_tail_pad=0)

    try:
        print("    {0}".format(filename))

        # Get the byte log_data out of the Buffer
        data = data_buffer.get_bytes()

        # Example Attribute Dictionary for the HDF5 file
        attr_dict = {
            'exp_name':
            exp_name,
            'exp_time':
            log_util.convert_datetime_to_log_time_str(
                datetime.datetime.utcnow()),
            'node_desc':
            node.description
        }

        # Write the byte Log_data to the file
        hdf_util.log_data_to_hdf5(log_data=data,
                                  filename=filename,
                                  attr_dict=attr_dict)
    except AttributeError as err:
        print("Error writing log file: {0}".format(err))
Beispiel #2
0
def end_experiment():
    """Experiment cleanup / post processing."""
    global node, log_container
    print("\nEnding experiment\n")

    # Get the last of the data
    add_data_to_log(log_tail_pad=0)

    # Create the log index
    log_container.write_log_index()

    # Get the end time as an attribute
    attr_dict['exp_end_time'] = log_util.convert_datetime_to_log_time_str(
        datetime.datetime.utcnow())

    # Add the attribute dictionary to the log file
    log_container.write_attr_dict(attr_dict)

    # Print final log size
    log_size = log_container.get_log_data_size()

    print("Final log size:  {0:15,d} bytes".format(log_size))

    # Clost the Log file for processing by other scripts
    hdf_util.hdf5_close_file(h5_file)

    print("Done.")
    return
Beispiel #3
0
def init_experiment():
    """Initialize WLAN Experiment."""
    global network_config, nodes, attr_dict

    print("\nInitializing experiment\n")

    # Log attributes about the experiment
    attr_dict['exp_start_time'] = log_util.convert_datetime_to_log_time_str(
        datetime.datetime.utcnow())

    # Create an object that describes the network configuration of the host PC
    network_config = wlan_exp_config.WlanExpNetworkConfiguration(
        network=NETWORK)

    # Create an object that describes the WARP v3 nodes that will be used in this experiment
    nodes_config = wlan_exp_config.WlanExpNodesConfiguration(
        network_config=network_config, serial_numbers=NODE_SERIAL_LIST)

    # Initialize the Nodes
    #   This command will fail if either WARP v3 node does not respond
    nodes = wlan_exp_util.init_nodes(nodes_config, network_config)

    # Do not set the node into a known state.  This example will just read
    # what the node currently has in the log.  However, the below code could
    # be used to initialize all nodes into a default state:
    #
    # Set each node into the default state
    for tmp_node in nodes:
        #     # Issue a reset command to stop current operation / initialize components
        tmp_node.reset(log=True, txrx_stats=True, ltg=True,
                       queue_data=True)  # Do not reset associations/bss_info
        #
        #     # Configure the log
        tmp_node.log_configure(log_full_payloads=True)
def end_experiment():
    """Experiment cleanup / post processing."""
    global node, log_container
    print("\nEnding experiment\n")

    # Get the last of the data
    add_data_to_log(log_tail_pad=0)

    # Create the log index
    log_container.write_log_index()

    # Get the end time as an attribute
    attr_dict['exp_end_time'] = log_util.convert_datetime_to_log_time_str(datetime.datetime.utcnow())

    # Add the attribute dictionary to the log file
    log_container.write_attr_dict(attr_dict)

    # Print final log size
    log_size = log_container.get_log_data_size()

    print("Final log size:  {0:15,d} bytes".format(log_size))

    # Clost the Log file for processing by other scripts
    hdf_util.hdf5_close_file(h5_file)

    print("Done.")
    return
def init_experiment():
    """Initialize the experiment."""
    global n_sta1, n_sta2, n_ap, rate_info, network_config, network_config, nodes, attr_dict, s

    print("\nInitializing experiment\n")

    # Print attributes about the experiment - Changed by Rebecca
    print(log_util.convert_datetime_to_log_time_str(datetime.datetime.utcnow()))

    # Create an object that describes the network configuration of the host PC
    network_config = wlan_exp_config.WlanExpNetworkConfiguration(network=NETWORK,
                                                                 jumbo_frame_support=USE_JUMBO_ETH_FRAMES)

    # Create an object that describes the WARP v3 nodes that will be used in this experiment
    nodes_config   = wlan_exp_config.WlanExpNodesConfiguration(network_config=network_config,
                                                               serial_numbers=NODE_SERIAL_LIST)

    # Initialize the Nodes
    #   This command will fail if either WARP v3 node does not respond
    nodes = wlan_exp_util.init_nodes(nodes_config, network_config, network_reset=False)

    # Set the time of all the nodes to zero
    #wlan_exp_util.broadcast_cmd_set_mac_time(0, network_config)

    # Extract the different types of nodes from the list of initialized nodes
    #     - This will work for both 'DCF' and 'NOMAC' mac_low projects
    n_ap_l  = wlan_exp_util.filter_nodes(nodes=nodes, mac_high='AP',  serial_number=NODE_SERIAL_LIST)    
    n_sta_l = wlan_exp_util.filter_nodes(nodes=nodes, mac_high='STA', serial_number=NODE_SERIAL_LIST)

    # Check that setup is valid
    if len(n_ap_l) == 1 and len(n_sta_l) == 2:
        # Extract the two nodes from the lists for easier referencing below
        n_ap  = n_ap_l[0]
        n_sta1 = n_sta_l[0]
        n_sta2 = n_sta_l[1]
    elif len(n_ap_l) == 1 and len(n_sta_l) == 1:
        n_ap  = n_ap_l[0]
        n_sta1 = n_sta_l[0]

    # Do not set the node into a known state.  This example will just read
    # what the node currently has in the log.  However, the below code could
    # be used to initialize all nodes into a default state:
    #
    # Set each node into the default state
#    for tmp_node in nodes:
#         # Issue a reset command to stop current operation / initialize components
#         tmp_node.reset(log=True, txrx_counts=True, ltg=True, queue_data=True) # Do not reset associations/bss_info
    
#         # Configure the log
#         tmp_node.log_configure(log_full_payloads=True)

    if sock_on:
        s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # replaced SOCK_STREAM with SOCK_DGRAM
def init_experiment():
    """Initialize the experiment."""
    global network_config, nodes, attr_dict

    print("\nInitializing experiment\n")

    # Log attributes about the experiment
    attr_dict['exp_start_time'] = log_util.convert_datetime_to_log_time_str(datetime.datetime.utcnow())

    # Create an object that describes the network configuration of the host PC
    network_config = wlan_exp_config.WlanExpNetworkConfiguration(network=NETWORK,
                                                                 jumbo_frame_support=USE_JUMBO_ETH_FRAMES)

    # Create an object that describes the WARP v3 nodes that will be used in this experiment
    nodes_config   = wlan_exp_config.WlanExpNodesConfiguration(network_config=network_config,
                                                               serial_numbers=NODE_SERIAL_LIST)

    # Initialize the Nodes
    #   This command will fail if either WARP v3 node does not respond
    nodes = wlan_exp_util.init_nodes(nodes_config, network_config)
Beispiel #7
0
def init_experiment():
    """Initialize WLAN Experiment."""
    global network_config, nodes, attr_dict

    print("\nInitializing experiment\n")

    # Log attributes about the experiment
    attr_dict['exp_start_time'] = log_util.convert_datetime_to_log_time_str(
        datetime.datetime.utcnow())

    # Create an object that describes the network configuration of the host PC
    network_config = wlan_exp_config.WlanExpNetworkConfiguration(
        network=NETWORK)

    # Create an object that describes the WARP v3 nodes that will be used in this experiment
    nodes_config = wlan_exp_config.WlanExpNodesConfiguration(
        network_config=network_config, serial_numbers=NODE_SERIAL_LIST)

    # Initialize the Nodes
    #   This command will fail if either WARP v3 node does not respond
    nodes = wlan_exp_util.init_nodes(nodes_config, network_config)
def write_log_file(filename, node, exp_name):
    """Writes all the log data from the node to a HDF5 file."""

    import wlan_exp.log.util_hdf as hdf_util
    import wlan_exp.log.util as log_util

    data_buffer = node.log_get_all_new(log_tail_pad=0)

    try:
        print("    {0}".format(filename))

        # Get the byte log_data out of the Buffer
        data = data_buffer.get_bytes()

        # Example Attribute Dictionary for the HDF5 file
        attr_dict = {'exp_name'  : exp_name,
                     'exp_time'  : log_util.convert_datetime_to_log_time_str(datetime.datetime.utcnow()),
                     'node_desc' : node.description}

        # Write the byte Log_data to the file
        hdf_util.log_data_to_hdf5(log_data=data, filename=filename, attr_dict=attr_dict)
    except AttributeError as err:
        print("Error writing log file: {0}".format(err))
Beispiel #9
0
def init_experiment():
    """Initialize the experiment."""
    global n_ap, n_sta1, n_sta2, network_config, nodes, attr_dict

    print("\nInitializing experiment\n")

    # Log attributes about the experiment
    attr_dict['exp_start_time'] = log_util.convert_datetime_to_log_time_str(datetime.datetime.utcnow())

    # Create an object that describes the network configuration of the host PC
    network_config = wlan_exp_config.WlanExpNetworkConfiguration(network=NETWORK,
                                                                 jumbo_frame_support=USE_JUMBO_ETH_FRAMES)

    # Create an object that describes the WARP v3 nodes that will be used in this experiment
    nodes_config   = wlan_exp_config.WlanExpNodesConfiguration(network_config=network_config,
                                                               serial_numbers=NODE_SERIAL_LIST)

    # Initialize the Nodes
    #   This command will fail if either WARP v3 node does not respond
    nodes = wlan_exp_util.init_nodes(nodes_config, network_config)

    n_ap_l = wlan_exp_util.filter_nodes(nodes=nodes, mac_high='AP', serial_number=NODE_SERIAL_LIST)
    n_sta_l = wlan_exp_util.filter_nodes(nodes=nodes, mac_high='STA', serial_number=NODE_SERIAL_LIST)

    # Check that setup is valid
    if len(n_ap_l) == 1 and len(n_sta_l) == 2:
        # Extract the two nodes from the lists for easier referencing below
        n_ap  = n_ap_l[0]
        n_sta1 = n_sta_l[0]
        n_sta2 = n_sta_l[1]
    elif len(n_ap_l) == 1 and len(n_sta_l) == 1:
        n_ap  = n_ap_l[0]
        n_sta1 = n_sta_l[0]

        # Configure the AP to reject authentication requests from wireless clients
        #     - Uncomment this line to block any wireless associations during the experiment
        # n_ap.set_authentication_address_filter(allow='NONE')

        # Configure AP BSS
        n_ap.configure_bss(ssid=SSID, channel=CHANNEL, beacon_interval=BEACON_INTERVAL)

        # Establish the association state between nodes
        #     - This will change the STA to the appropriate channel
        n_ap.add_association(n_sta1)
        n_ap.add_association(n_sta2)
    else:
        print("ERROR: Node configurations did not match requirements of script.\n")
        print("    Ensure two nodes are ready, one using the AP design, one using the STA design\n")
        sys.exit(0)

    # Check that the nodes are part of the same BSS.  Otherwise, the LTGs below will fail.
    if not wlan_exp_util.check_bss_membership([n_ap, n_sta1]) | wlan_exp_util.check_bss_membership([n_ap, n_sta2]):
        print("\nERROR: Nodes are not part of the same BSS.")
        wlan_exp_util.check_bss_membership([n_ap, n_sta1], verbose=True)
        wlan_exp_util.check_bss_membership([n_ap, n_sta2], verbose=True)
        print("Ensure that both nodes are part of the same BSS.")
        sys.exit(0)

    # Do not set the node into a known state.  This example will just read
    # what the node currently has in the log.  However, the below code could
    # be used to initialize all nodes into a default state:
    #
    # Set each node into the default state
    for tmp_node in nodes:
        # Issue a reset command to stop current operation / initialize components
        tmp_node.reset(log=True, txrx_counts=True, ltg=True, queue_data=True) # Do not reset associations/bss_info

        # Configure the log
        tmp_node.log_configure(log_full_payloads=True)