Пример #1
0
def first_hop_latency_evaluation(entryList, pduID):
    tcp_rtt_list = []
    first_hop_rtt_list = []
    transmission_delay_ratio_rtt_list = []
    ota_delay_ratio_rtt_list = []
    entryLen = len(entryList)

    for i in range(entryLen):
        entry = entryList[i]
        if entry.rtt["tcp"] != None and entry.rtt["tcp"] > 0:
            # perform cross-layer mapping
            mapped_RLCs, mapped_sn = clw.cross_layer_mapping_WCDMA_uplink(
                entryList, i, pduID)
            if mapped_RLCs:
                transmission_delay, rlc_rtt_list = calc_first_hop_latency(
                    mapped_RLCs)
                tcp_rtt_list.append(entry.rtt["tcp"])
                first_hop_rtt_list.append(transmission_delay +
                                          util.meanValue(rlc_rtt_list))
                transmission_delay_ratio_rtt_list.append(
                    min(transmission_delay / entry.rtt["tcp"], 1.0))
                ota_delay_ratio_rtt_list.append(
                    min(util.meanValue(rlc_rtt_list) / entry.rtt["tcp"], 1.0))

    return (tcp_rtt_list, first_hop_rtt_list,
            transmission_delay_ratio_rtt_list, ota_delay_ratio_rtt_list)
Пример #2
0
def crossLayerMappingRLCRetxInfo(entryList, direction, client_ip, RLCMap, network_type):
    # A cross-layer RLC retx map
    clMap = {}
    log_of_interest_id = util.get_logID_of_interest(network_type, direction)

    for i in range(len(entryList)):
        transportEntry = entryList[i]
        if transportEntry.logID == const.PROTOCOL_ID:
            if transportEntry.ip["dst_ip"] == client_ip or \
               transportEntry.ip["src_ip"] == client_ip:
                mapped_RLCs, mapped_sn = clw.cross_layer_mapping_WCDMA_uplink(entryList, i , log_of_interest_id)
                if mapped_RLCs:
                    (count, total) = countRLCRetx([rlc[0] for rlc in mapped_RLCs], RLCMap, log_of_interest_id)
                    if total > 0:
                        clMap[transportEntry] = min(float(count) / float(total), 1.0)
        
    return clMap
Пример #3
0
def first_hop_latency_evaluation(entryList, pduID):
    tcp_rtt_list = []
    first_hop_rtt_list = []
    transmission_delay_ratio_rtt_list = []
    ota_delay_ratio_rtt_list = []
    entryLen = len(entryList)

    for i in range(entryLen):
        entry = entryList[i]
        if entry.rtt["tcp"] != None and entry.rtt["tcp"] > 0:
            # perform cross-layer mapping
            mapped_RLCs, mapped_sn = clw.cross_layer_mapping_WCDMA_uplink(entryList, i , pduID)
            if mapped_RLCs:
                transmission_delay, rlc_rtt_list = calc_first_hop_latency(mapped_RLCs)
                tcp_rtt_list.append(entry.rtt["tcp"])
                first_hop_rtt_list.append(transmission_delay + util.meanValue(rlc_rtt_list))
                transmission_delay_ratio_rtt_list.append(min(transmission_delay / entry.rtt["tcp"], 1.0))
                ota_delay_ratio_rtt_list.append(min(util.meanValue(rlc_rtt_list) / entry.rtt["tcp"], 1.0))

    return (tcp_rtt_list, first_hop_rtt_list, transmission_delay_ratio_rtt_list, ota_delay_ratio_rtt_list)
Пример #4
0
def rlc_retx_based_on_gap(QCATEntries, direction):
    index = 0
    entry_length = len(QCATEntries)
    gap_retx_per_rrc_map = {}
    gap_retx_list_map = {}
    tot_rlc_num = 0.0

    while index < entry_length:
        cur_entry = QCATEntries[index]
        cur_gap = cur_entry.udp["gap"]

        if cur_entry.ip["tlp_id"] == const.UDP_ID and cur_gap >= 0:
            # find the last gap_period message
            last_map_index = find_last_same_gap_entry_index(
                QCATEntries, index, cur_gap)
            if GAP_DEBUG:
                print "Current index is %d" % index
                print "Last map index is %d" % last_map_index
            # map the current UDP packet to the RLC layer PDUs
            first_rlc_list, first_sn_list = clw.cross_layer_mapping_WCDMA_uplink(
                QCATEntries, index, const.UL_PDU_ID)
            last_rlc_list, last_sn_list = clw.cross_layer_mapping_WCDMA_uplink(
                QCATEntries, last_map_index, const.UL_PDU_ID)
            # get the corresponding RLC log message
            if first_rlc_list and last_rlc_list and last_sn_list:
                rlc_begin_index = first_rlc_list[0][1]
                tmp_rlc_end_index = last_rlc_list[-1][1]
                rlc_end_index = clw.find_nearest_status(
                    QCATEntries, tmp_rlc_end_index, max(last_sn_list))
                if GAP_DEBUG:
                    print "First RLC mapped index is ", rlc_begin_index
                    print "Last RLC mapped index is ", rlc_end_index

                if rlc_begin_index < rlc_end_index:
                    total_count_map, retx_count_map, retx_num, total_num = find_retx_within_a_range(
                        QCATEntries, rlc_begin_index, rlc_end_index, direction)
                    """
                    if GAP_DEBUG:
                        print "Cur_gap is %f" % cur_gap
                        print "retx_num is %f" % retx_num
                    """
                    tot_rlc_num += total_num
                    if gap_retx_list_map.has_key(cur_gap):
                        gap_retx_list_map[cur_gap].append(retx_num)
                    else:
                        gap_retx_list_map[cur_gap] = [retx_num]
                    if gap_retx_per_rrc_map.has_key(cur_gap):
                        gap_retx_per_rrc_map[cur_gap][
                            "retx"] = util.merge_two_dict(
                                gap_retx_per_rrc_map[cur_gap]["retx"],
                                retx_count_map)
                        gap_retx_per_rrc_map[cur_gap][
                            "total"] = util.merge_two_dict(
                                gap_retx_per_rrc_map[cur_gap]["total"],
                                total_count_map)
                    else:
                        gap_retx_per_rrc_map[cur_gap] = {
                            "retx": retx_count_map,
                            "total": total_count_map
                        }

            index = last_map_index

        index += 1

    # recalculate the whole group by the ratio of dividing the total group number
    #for gap, retx_list in gap_retx_list_map.items():
    #gap_retx_list_map[gap] = [i/tot_rlc_num for i in retx_list]

    # display the retransmission result
    if True:
        #print "Ready to show results ...."
        for k in sorted(gap_retx_list_map.keys()):
            mean, stdev = util.meanStdevPair(gap_retx_list_map[k],
                                             upper_bound=0.5)
            print "%f\t%f\t%f" % (k, mean, stdev / 3.0)
            #print "%f\t%s" % (k, util.listToStr(util.quartileResult(gap_retx_list_map[k])))
            #print "%f\t%s" % (k, gap_retx_list_map[k])

    return gap_retx_per_rrc_map, gap_retx_list_map
Пример #5
0
def UDP_loss_cross_analysis(QCATEntries, loss_index_list, logID):
    # Loss over cellular network if
    # 1. exceeding max Retx count
    # 2. there is a reset PDU in between the mapped RLC list and the next control message
    udp_loss_in_cellular = {
        "reset": rw.initFullRRCMap(0.0),
        "max_retx": rw.initFullRRCMap(0.0)
    }
    udp_loss_in_internet = rw.initFullRRCMap(0.0)

    entry_len = len(QCATEntries)
    max_retx_count_overall = 0.0

    for loss_index in loss_index_list:
        cur_entry = QCATEntries[loss_index]
        mapped_rlc_tuple_list, mapped_sn_list = clw.cross_layer_mapping_WCDMA_uplink(
            QCATEntries, loss_index, logID)

        if mapped_rlc_tuple_list and cur_entry.rrcID:
            first_mapped_rlc_index = mapped_rlc_tuple_list[0][1]
            last_mapped_rlc_index = mapped_rlc_tuple_list[-1][1]
            first_mapped_rlc_sn = min(
                QCATEntries[first_mapped_rlc_index].ul_pdu[0]["sn"])
            last_mapped_rlc_sn = min(
                QCATEntries[last_mapped_rlc_index].ul_pdu[0]["sn"])

            max_tx_config = cur_entry.ul_config["max_tx"]
            next_ack_index = clw.findNextCtrlMsg(QCATEntries,
                                                 loss_index,
                                                 ctrl_type="ack",
                                                 cur_seq=last_mapped_rlc_sn)
            next_list_index = clw.findNextCtrlMsg(QCATEntries,
                                                  loss_index,
                                                  ctrl_type="list",
                                                  cur_seq=last_mapped_rlc_sn)

            ctrl_index = entry_len
            if next_ack_index:
                ctrl_index = min(next_ack_index, ctrl_index)
            if next_list_index:
                ctrl_index = min(next_list_index, ctrl_index)

            # check reset
            reset_index = clw.find_reset_ack(QCATEntries,
                                             last_mapped_rlc_index + 1,
                                             ctrl_index)
            # check for exceeding retx count
            rlc_tx_map = clw.find_SN_within_interval(
                QCATEntries, first_mapped_rlc_index + 1, ctrl_index)
            max_tx_count_num = 0
            if rlc_tx_map:
                max_tx_count_num = max([len(i) for i in rlc_tx_map.values()])
                if max_tx_count_num > max_retx_count_overall:
                    max_retx_count_overall = max_tx_count_num
            if reset_index:
                udp_loss_in_cellular["reset"][cur_entry.rrcID] += 1
                if DEBUG:
                    print "-------------- Detect Reset --------------"
            elif max_tx_config and max_tx_count_num >= max_tx_config:
                udp_loss_in_cellular["max_retx"][cur_entry.rrcID] += 1
                if DEBUG:
                    print "%%%%%%%%%%%% Max retx configued: ", max_tx_config
                    print "%%%%%%%%%%%% Cur retx configued: ", max_tx_count_num
            else:
                udp_loss_in_internet[cur_entry.rrcID] += 1
            """
            # print out retransmission over PCH promotion
            # investigate high PCH loss rate
            #if cur_entry.rrcID and cur_entry.rrcID == const.PCH_TO_FACH_ID:
            print "%"* 100
            print "%"* 40 + "Curious Case:" + "%"* 40
            pw.printUDPEntry(cur_entry)
            print "%"* 100
            print "%"* 100
            # find the lower bound of the range
            max_index = clw.find_nearest_status(QCATEntries, loss_index, max(mapped_sn_list))
            print "is max index correct %s" % (max_index > loss_index)
            target_sn_set = set(mapped_sn_list)
            dup_sn_map, rlc_tx_index_list = clw.loss_analysis_with_rlc_retx(QCATEntries, loss_index, max_index, target_sn_set)
            print "max # of retx is %d" % max([len(i) for i in dup_sn_map.values()])
            pw.print_loss_case(QCATEntries, loss_index, rlc_tx_index_list)
            """

    if CUR_DEBUG:
        print "Max RLC retx is ", max_retx_count_overall

    return udp_loss_in_cellular, udp_loss_in_internet
Пример #6
0
def parse_http_fields(entryList):
    count = 0
    goodCount = 0
    DEL = "\t"

    if HTTP_EXTRA:
        # Assign TCP RTT
        dw.calc_tcp_rtt(entryList)
        log_of_interest_id = get_logID_of_interest("wcdma", "up")

        # Uniqueness analysis
        non_unique_rlc_tuples, dummy = vw.uniqueness_analysis(entryList, log_of_interest_id)

        # RLC retransmission analysis
        [RLCULReTxCountMap, RLCDLReTxCountMap] = rw.procRLCReTx(entryList, detail="simple")

    for i in range(len(entryList)):
        entry = entryList[i]
        if entry.logID == const.PROTOCOL_ID and \
           entry.tcp["dst_port"] == const.HTTP_DST_PORT:
            http_payload = entry.hex_dump["payload"][(const.Payload_Header_Len + \
                                                     entry.ip["header_len"] + \
                                                     entry.tcp["header_len"]):]
            http_payload_by_field = "".join(http_payload).decode("hex").split(const.HTTP_LINE_DEL)
            for field in http_payload_by_field:
                splitted_field = field.split(const.HTTP_FIELD_DEL)
                if splitted_field[0].lower() == "host":
                    entry.http["host"] = splitted_field[1]
                elif splitted_field[0].lower() == "referer":
                    entry.http["referer"] = splitted_field[1]
                elif splitted_field[0].lower() == "timer":
                    entry.http["timer"] = float(splitted_field[1])

                    # move on to the next entry when we get what we want
                    if TIMER_CHECK:
                        if entry.http["host"] and \
                           entry.http["timer"] and \
                           entry.http["host"] in const.HOST_OF_INTEREST:
                            print entry.http
            line = ""
            if HTTP_EXTRA:
                if entry.http["host"] or entry.http["referer"]:
                    count += 1
                    line += util.convert_ts_in_human(entry.timestamp) + DEL + \
                            str(const.RRC_MAP[entry.rrcID]) + DEL + \
                            str(entry.http) + DEL
                
                    # check whether interference exist
                    mapped_RLCs, mapped_sn = clw.cross_layer_mapping_WCDMA_uplink(entryList, i, log_of_interest_id)
                    if mapped_RLCs:
                        if vw.is_valid_cross_layer_mapping(mapped_RLCs, mapped_sn, log_of_interest_id, non_unique_rlc_tuples):
                            if entry.rtt["tcp"]:
                                paraCountMap = count_prach_aich_status(entryList, mapped_RLCs[0][-1], mapped_RLCs[-1][-1], const.PRACH_PARA_ID)
                                line += str(paraCountMap[const.PRACH_ABORT]) + DEL
                                line += str(paraCountMap[const.PRACH_DONE]) + DEL
                                eventCountMap = count_prach_aich_status(entryList, mapped_RLCs[0][-1], mapped_RLCs[-1][-1], const.EVENT_ID)
                                line += str(eventCountMap[const.PRACH_ABORT]) + DEL
                                line += str(eventCountMap[const.PRACH_DONE]) + DEL
                                if paraCountMap[const.PRACH_ABORT] > 0 or \
                                   paraCountMap[const.PRACH_DONE] > 0 or \
                                   eventCountMap[const.PRACH_ABORT] > 0 or \
                                   eventCountMap[const.PRACH_DONE] > 0:
                                    goodCount += 1    
                                    line += "Interred_request"
                            else:
                                line += "ERROR: fail to estimate TCP rtt"
                        else:
                            line += "ERROR: not unique mapping"
                    else:
                        line += "ERROR: not mapped RLC PDUs"
                    print line
    if HTTP_EXTRA:
        print "*"*80
        print "In total, " + str(count) + " requests."
        print "Interfered URL is " + str(goodCount)
def check_mapping_feasibility_uniqueness(entryList, client_ip, direction, network_type="wcdma"):
    # determine the log of interest
    log_of_interest_id = None

    # Determine the log of interest we wanna focus on
    log_of_interest_id = util.get_logID_of_interest(network_type, direction)

    non_unique_rlc_tuples, uniqueCount = uniqueness_analysis(entryList, log_of_interest_id)

    print "Non unique RLC tuple length is %d" % (len(non_unique_rlc_tuples))

    # count the key appear twice or more
    dupChainCount = 0.0
    dupPDUCount = 0.0
    totalChainCount = 0.0
    totalPDUCount = 0.0
    DEL = ","
    sortedDuplicateCount = {}  # key is count, value is the chain bytes

    for key, val in uniqueCount.items():
        totalPDUCount += len(key) / 4 * val
        totalChainCount += val
        if val > 1:
            dupPDUCount += len(key) / 4 * val
            dupChainCount += val
            sortedDuplicateCount[val] = key

    # cross-layer analysis to check the untrusted mapping for transport layer
    transport_layer_total_count = {const.TCP_ID: 0.0, const.UDP_ID: 0.0}
    valid_transport_layer_mapping_count = {const.TCP_ID: 0.0, const.UDP_ID: 0.0}
    valid_RLC_first_hop_esimation_count = {const.TCP_ID: 0.0, const.UDP_ID: 0.0}

    for i in range(len(entryList)):
        entry = entryList[i]
        if entry.logID == const.PROTOCOL_ID:
            # Exclude TCP ACK without payload and TSL without payload
            """
            if entry.ip["tlp_id"] == const.TCP_ID and\
               (entry.ip["total_len"] == 40 or \
                entry.ip["total_len"] == 52 or \
                entry.ip["total_len"] == 83):
                continue
            """
            mapped_RLCs = mapped_sn = None
            if log_of_interest_id == const.UL_PDU_ID and entry.ip["src_ip"] == client_ip:
                if entry.ip["tlp_id"] in transport_layer_total_count:
                    transport_layer_total_count[entry.ip["tlp_id"]] += 1
                mapped_RLCs, mapped_sn = clw.cross_layer_mapping_WCDMA_uplink(entryList, i, log_of_interest_id)
            elif log_of_interest_id == const.DL_PDU_ID and entry.ip["dst_ip"] == client_ip:
                if entry.ip["tlp_id"] in transport_layer_total_count:
                    transport_layer_total_count[entry.ip["tlp_id"]] += 1
                mapped_RLCs, mapped_sn = clw.cross_layer_mapping_WCDMA_downlink(entryList, i, log_of_interest_id)
            if mapped_RLCs:
                if is_valid_cross_layer_mapping(mapped_RLCs, mapped_sn, log_of_interest_id, non_unique_rlc_tuples):
                    if entry.ip["tlp_id"] in valid_transport_layer_mapping_count:
                        valid_transport_layer_mapping_count[entry.ip["tlp_id"]] += 1
                if is_valid_first_hop_latency_estimation(mapped_RLCs, mapped_sn, log_of_interest_id):
                    if entry.ip["tlp_id"] in valid_RLC_first_hop_esimation_count:
                        valid_RLC_first_hop_esimation_count[entry.ip["tlp_id"]] += 1

    # output results
    print "Chain_occurance" + DEL + "Chain_PDU_length" + DEL + "Chain_value"

    for sortedKey in sorted(sortedDuplicateCount.keys(), reverse=True):
        print str(sortedKey) + DEL + str(len(sortedDuplicateCount[sortedKey]) / 4) + DEL + str(
            sortedDuplicateCount[sortedKey]
        )

    print "$" * 80
    print "Unique Chain ratio %f / %f = %f" % (
        totalChainCount - dupChainCount,
        totalChainCount,
        1 - dupChainCount / totalChainCount,
    )
    print "Unique PDUs ratio %f / %f = %f" % (
        totalPDUCount - dupPDUCount,
        totalPDUCount,
        1 - dupPDUCount / totalPDUCount,
    )
    print "Unique TCP ratio %f / %f = %f" % (
        valid_transport_layer_mapping_count[const.TCP_ID],
        transport_layer_total_count[const.TCP_ID],
        valid_transport_layer_mapping_count[const.TCP_ID] / transport_layer_total_count[const.TCP_ID],
    )
    print "Unique UDP ratio %f / %f = %f" % (
        valid_transport_layer_mapping_count[const.UDP_ID],
        transport_layer_total_count[const.UDP_ID],
        valid_transport_layer_mapping_count[const.UDP_ID] / transport_layer_total_count[const.UDP_ID],
    )
    print "Valid TCP first hop esitmation ratio %f / %f = %f" % (
        valid_RLC_first_hop_esimation_count[const.TCP_ID],
        transport_layer_total_count[const.TCP_ID],
        valid_RLC_first_hop_esimation_count[const.TCP_ID] / transport_layer_total_count[const.TCP_ID],
    )
    print "Valid UDP first hop esitmation ratio %f / %f = %f" % (
        valid_RLC_first_hop_esimation_count[const.UDP_ID],
        transport_layer_total_count[const.UDP_ID],
        valid_RLC_first_hop_esimation_count[const.UDP_ID] / transport_layer_total_count[const.UDP_ID],
    )
Пример #8
0
def check_mapping_feasibility_uniqueness(entryList,
                                         client_ip,
                                         direction,
                                         network_type="wcdma"):
    # determine the log of interest
    log_of_interest_id = None

    # Determine the log of interest we wanna focus on
    log_of_interest_id = util.get_logID_of_interest(network_type, direction)

    non_unique_rlc_tuples, uniqueCount = uniqueness_analysis(
        entryList, log_of_interest_id)

    print "Non unique RLC tuple length is %d" % (len(non_unique_rlc_tuples))

    # count the key appear twice or more
    dupChainCount = 0.0
    dupPDUCount = 0.0
    totalChainCount = 0.0
    totalPDUCount = 0.0
    DEL = ","
    sortedDuplicateCount = {}  # key is count, value is the chain bytes

    for key, val in uniqueCount.items():
        totalPDUCount += len(key) / 4 * val
        totalChainCount += val
        if val > 1:
            dupPDUCount += len(key) / 4 * val
            dupChainCount += val
            sortedDuplicateCount[val] = key

    # cross-layer analysis to check the untrusted mapping for transport layer
    transport_layer_total_count = {const.TCP_ID: 0.0, const.UDP_ID: 0.0}
    valid_transport_layer_mapping_count = {
        const.TCP_ID: 0.0,
        const.UDP_ID: 0.0
    }
    valid_RLC_first_hop_esimation_count = {
        const.TCP_ID: 0.0,
        const.UDP_ID: 0.0
    }

    for i in range(len(entryList)):
        entry = entryList[i]
        if entry.logID == const.PROTOCOL_ID:
            # Exclude TCP ACK without payload and TSL without payload
            """
            if entry.ip["tlp_id"] == const.TCP_ID and\
               (entry.ip["total_len"] == 40 or \
                entry.ip["total_len"] == 52 or \
                entry.ip["total_len"] == 83):
                continue
            """
            mapped_RLCs = mapped_sn = None
            if (log_of_interest_id == const.UL_PDU_ID and \
               entry.ip["src_ip"] == client_ip):
                if entry.ip["tlp_id"] in transport_layer_total_count:
                    transport_layer_total_count[entry.ip["tlp_id"]] += 1
                mapped_RLCs, mapped_sn = clw.cross_layer_mapping_WCDMA_uplink(
                    entryList, i, log_of_interest_id)
            elif (log_of_interest_id == const.DL_PDU_ID and \
                   entry.ip["dst_ip"] == client_ip):
                if entry.ip["tlp_id"] in transport_layer_total_count:
                    transport_layer_total_count[entry.ip["tlp_id"]] += 1
                mapped_RLCs, mapped_sn = clw.cross_layer_mapping_WCDMA_downlink(
                    entryList, i, log_of_interest_id)
            if mapped_RLCs:
                if is_valid_cross_layer_mapping(mapped_RLCs, mapped_sn,
                                                log_of_interest_id,
                                                non_unique_rlc_tuples):
                    if entry.ip[
                            "tlp_id"] in valid_transport_layer_mapping_count:
                        valid_transport_layer_mapping_count[
                            entry.ip["tlp_id"]] += 1
                if is_valid_first_hop_latency_estimation(
                        mapped_RLCs, mapped_sn, log_of_interest_id):
                    if entry.ip[
                            "tlp_id"] in valid_RLC_first_hop_esimation_count:
                        valid_RLC_first_hop_esimation_count[
                            entry.ip["tlp_id"]] += 1

    # output results
    print "Chain_occurance" + DEL + "Chain_PDU_length" + DEL + "Chain_value"

    for sortedKey in sorted(sortedDuplicateCount.keys(), reverse=True):
        print str(sortedKey) + DEL + \
              str(len(sortedDuplicateCount[sortedKey]) / 4) + DEL + \
              str(sortedDuplicateCount[sortedKey])

    print "$" * 80
    print "Unique Chain ratio %f / %f = %f" % (totalChainCount - dupChainCount,
                                               totalChainCount, 1 -
                                               dupChainCount / totalChainCount)
    print "Unique PDUs ratio %f / %f = %f" % (totalPDUCount - dupPDUCount,
                                              totalPDUCount,
                                              1 - dupPDUCount / totalPDUCount)
    print "Unique TCP ratio %f / %f = %f" % (valid_transport_layer_mapping_count[const.TCP_ID], \
                                             transport_layer_total_count[const.TCP_ID], \
                                             valid_transport_layer_mapping_count[const.TCP_ID] / \
                                             transport_layer_total_count[const.TCP_ID])
    print "Unique UDP ratio %f / %f = %f" % (valid_transport_layer_mapping_count[const.UDP_ID], \
                                             transport_layer_total_count[const.UDP_ID], \
                                             valid_transport_layer_mapping_count[const.UDP_ID] / \
                                             transport_layer_total_count[const.UDP_ID])
    print "Valid TCP first hop esitmation ratio %f / %f = %f" % \
                                            (valid_RLC_first_hop_esimation_count[const.TCP_ID], \
                                             transport_layer_total_count[const.TCP_ID], \
                                             valid_RLC_first_hop_esimation_count[const.TCP_ID] / \
                                             transport_layer_total_count[const.TCP_ID])
    print "Valid UDP first hop esitmation ratio %f / %f = %f" % \
                                            (valid_RLC_first_hop_esimation_count[const.UDP_ID], \
                                             transport_layer_total_count[const.UDP_ID], \
                                             valid_RLC_first_hop_esimation_count[const.UDP_ID] / \
                                             transport_layer_total_count[const.UDP_ID])
Пример #9
0
def rlc_retx_based_on_gap (QCATEntries, direction):
    index = 0
    entry_length = len(QCATEntries)
    gap_retx_per_rrc_map = {}
    gap_retx_list_map = {}
    tot_rlc_num = 0.0

    while index < entry_length:
        cur_entry = QCATEntries[index]
        cur_gap = cur_entry.udp["gap"]

        if cur_entry.ip["tlp_id"] == const.UDP_ID and cur_gap >= 0:
            # find the last gap_period message
            last_map_index = find_last_same_gap_entry_index(QCATEntries, index, cur_gap)
            if GAP_DEBUG:
                print "Current index is %d" % index
                print "Last map index is %d" % last_map_index
            # map the current UDP packet to the RLC layer PDUs
            first_rlc_list, first_sn_list = clw.cross_layer_mapping_WCDMA_uplink(QCATEntries, index, const.UL_PDU_ID)
            last_rlc_list, last_sn_list = clw.cross_layer_mapping_WCDMA_uplink(QCATEntries, last_map_index, const.UL_PDU_ID)
            # get the corresponding RLC log message
            if first_rlc_list and last_rlc_list and last_sn_list:
                rlc_begin_index = first_rlc_list[0][1]
                tmp_rlc_end_index = last_rlc_list[-1][1]
                rlc_end_index = clw.find_nearest_status(QCATEntries, tmp_rlc_end_index, max(last_sn_list))
                if GAP_DEBUG:
                    print "First RLC mapped index is ", rlc_begin_index
                    print "Last RLC mapped index is ", rlc_end_index

                if rlc_begin_index < rlc_end_index:
                    total_count_map, retx_count_map, retx_num, total_num = find_retx_within_a_range(QCATEntries, rlc_begin_index, rlc_end_index, direction)
                    """
                    if GAP_DEBUG:
                        print "Cur_gap is %f" % cur_gap
                        print "retx_num is %f" % retx_num
                    """
                    tot_rlc_num += total_num
                    if gap_retx_list_map.has_key(cur_gap):
                        gap_retx_list_map[cur_gap].append(retx_num)
                    else:
                        gap_retx_list_map[cur_gap] = [retx_num]
                    if gap_retx_per_rrc_map.has_key(cur_gap):
                        gap_retx_per_rrc_map[cur_gap]["retx"] = util.merge_two_dict(gap_retx_per_rrc_map[cur_gap]["retx"], retx_count_map)
                        gap_retx_per_rrc_map[cur_gap]["total"] = util.merge_two_dict(gap_retx_per_rrc_map[cur_gap]["total"], total_count_map)
                    else:
                        gap_retx_per_rrc_map[cur_gap] = {"retx": retx_count_map, "total": total_count_map}
                                                                                                                                                                                                                                                                                                                             
            index = last_map_index

        index += 1

    # recalculate the whole group by the ratio of dividing the total group number
    #for gap, retx_list in gap_retx_list_map.items():
        #gap_retx_list_map[gap] = [i/tot_rlc_num for i in retx_list]

    # display the retransmission result
    if True:
        #print "Ready to show results ...."
        for k in sorted(gap_retx_list_map.keys()):
            mean, stdev = util.meanStdevPair(gap_retx_list_map[k], upper_bound = 0.5)
            print "%f\t%f\t%f" % (k, mean, stdev / 3.0)
            #print "%f\t%s" % (k, util.listToStr(util.quartileResult(gap_retx_list_map[k])))
            #print "%f\t%s" % (k, gap_retx_list_map[k])

    return gap_retx_per_rrc_map, gap_retx_list_map
Пример #10
0
def UDP_loss_cross_analysis(QCATEntries, loss_index_list, logID):
    # Loss over cellular network if 
    # 1. exceeding max Retx count
    # 2. there is a reset PDU in between the mapped RLC list and the next control message
    udp_loss_in_cellular = {"reset": rw.initFullRRCMap(0.0), "max_retx": rw.initFullRRCMap(0.0)}
    udp_loss_in_internet = rw.initFullRRCMap(0.0)

    entry_len = len(QCATEntries)
    max_retx_count_overall = 0.0

    for loss_index in loss_index_list:
        cur_entry = QCATEntries[loss_index] 
        mapped_rlc_tuple_list, mapped_sn_list = clw.cross_layer_mapping_WCDMA_uplink(QCATEntries, loss_index, logID)
        
        if mapped_rlc_tuple_list and cur_entry.rrcID:
            first_mapped_rlc_index = mapped_rlc_tuple_list[0][1]
            last_mapped_rlc_index = mapped_rlc_tuple_list[-1][1]
            first_mapped_rlc_sn = min(QCATEntries[first_mapped_rlc_index].ul_pdu[0]["sn"])
            last_mapped_rlc_sn = min(QCATEntries[last_mapped_rlc_index].ul_pdu[0]["sn"])
            
            max_tx_config = cur_entry.ul_config["max_tx"]
            next_ack_index = clw.findNextCtrlMsg(QCATEntries, loss_index, ctrl_type = "ack", cur_seq = last_mapped_rlc_sn)
            next_list_index = clw.findNextCtrlMsg(QCATEntries, loss_index, ctrl_type = "list", cur_seq = last_mapped_rlc_sn)
            
            ctrl_index = entry_len
            if next_ack_index:
                ctrl_index = min(next_ack_index, ctrl_index)
            if next_list_index:
                ctrl_index = min(next_list_index, ctrl_index)
            
            # check reset
            reset_index = clw.find_reset_ack(QCATEntries, last_mapped_rlc_index + 1, ctrl_index)
            # check for exceeding retx count
            rlc_tx_map = clw.find_SN_within_interval(QCATEntries, first_mapped_rlc_index + 1, ctrl_index)
            max_tx_count_num = 0
            if rlc_tx_map:
                max_tx_count_num = max([len(i) for i in rlc_tx_map.values()])
                if max_tx_count_num > max_retx_count_overall:
                    max_retx_count_overall = max_tx_count_num
            if reset_index:
                udp_loss_in_cellular["reset"][cur_entry.rrcID] += 1
                if DEBUG:
                    print "-------------- Detect Reset --------------"
            elif max_tx_config and max_tx_count_num >= max_tx_config:
                udp_loss_in_cellular["max_retx"][cur_entry.rrcID] += 1
                if DEBUG:
                    print "%%%%%%%%%%%% Max retx configued: " , max_tx_config
                    print "%%%%%%%%%%%% Cur retx configued: " , max_tx_count_num
            else:
                udp_loss_in_internet[cur_entry.rrcID] += 1
           
            """
            # print out retransmission over PCH promotion
            # investigate high PCH loss rate
            #if cur_entry.rrcID and cur_entry.rrcID == const.PCH_TO_FACH_ID:
            print "%"* 100
            print "%"* 40 + "Curious Case:" + "%"* 40
            pw.printUDPEntry(cur_entry)
            print "%"* 100
            print "%"* 100
            # find the lower bound of the range
            max_index = clw.find_nearest_status(QCATEntries, loss_index, max(mapped_sn_list))
            print "is max index correct %s" % (max_index > loss_index)
            target_sn_set = set(mapped_sn_list)
            dup_sn_map, rlc_tx_index_list = clw.loss_analysis_with_rlc_retx(QCATEntries, loss_index, max_index, target_sn_set)
            print "max # of retx is %d" % max([len(i) for i in dup_sn_map.values()])
            pw.print_loss_case(QCATEntries, loss_index, rlc_tx_index_list)
            """

    if CUR_DEBUG:
        print "Max RLC retx is ", max_retx_count_overall

    return udp_loss_in_cellular, udp_loss_in_internet
Пример #11
0
def parse_http_fields(entryList):
    count = 0
    goodCount = 0
    DEL = "\t"

    if HTTP_EXTRA:
        # Assign TCP RTT
        dw.calc_tcp_rtt(entryList)
        log_of_interest_id = get_logID_of_interest("wcdma", "up")

        # Uniqueness analysis
        non_unique_rlc_tuples, dummy = vw.uniqueness_analysis(
            entryList, log_of_interest_id)

        # RLC retransmission analysis
        [RLCULReTxCountMap,
         RLCDLReTxCountMap] = rw.procRLCReTx(entryList, detail="simple")

    for i in range(len(entryList)):
        entry = entryList[i]
        if entry.logID == const.PROTOCOL_ID and \
           entry.tcp["dst_port"] == const.HTTP_DST_PORT:
            http_payload = entry.hex_dump["payload"][(const.Payload_Header_Len + \
                                                     entry.ip["header_len"] + \
                                                     entry.tcp["header_len"]):]
            http_payload_by_field = "".join(http_payload).decode("hex").split(
                const.HTTP_LINE_DEL)
            for field in http_payload_by_field:
                splitted_field = field.split(const.HTTP_FIELD_DEL)
                if splitted_field[0].lower() == "host":
                    entry.http["host"] = splitted_field[1]
                elif splitted_field[0].lower() == "referer":
                    entry.http["referer"] = splitted_field[1]
                elif splitted_field[0].lower() == "timer":
                    entry.http["timer"] = float(splitted_field[1])

                    # move on to the next entry when we get what we want
                    if TIMER_CHECK:
                        if entry.http["host"] and \
                           entry.http["timer"] and \
                           entry.http["host"] in const.HOST_OF_INTEREST:
                            print entry.http
            line = ""
            if HTTP_EXTRA:
                if entry.http["host"] or entry.http["referer"]:
                    count += 1
                    line += util.convert_ts_in_human(entry.timestamp) + DEL + \
                            str(const.RRC_MAP[entry.rrcID]) + DEL + \
                            str(entry.http) + DEL

                    # check whether interference exist
                    mapped_RLCs, mapped_sn = clw.cross_layer_mapping_WCDMA_uplink(
                        entryList, i, log_of_interest_id)
                    if mapped_RLCs:
                        if vw.is_valid_cross_layer_mapping(
                                mapped_RLCs, mapped_sn, log_of_interest_id,
                                non_unique_rlc_tuples):
                            if entry.rtt["tcp"]:
                                paraCountMap = count_prach_aich_status(
                                    entryList, mapped_RLCs[0][-1],
                                    mapped_RLCs[-1][-1], const.PRACH_PARA_ID)
                                line += str(
                                    paraCountMap[const.PRACH_ABORT]) + DEL
                                line += str(
                                    paraCountMap[const.PRACH_DONE]) + DEL
                                eventCountMap = count_prach_aich_status(
                                    entryList, mapped_RLCs[0][-1],
                                    mapped_RLCs[-1][-1], const.EVENT_ID)
                                line += str(
                                    eventCountMap[const.PRACH_ABORT]) + DEL
                                line += str(
                                    eventCountMap[const.PRACH_DONE]) + DEL
                                if paraCountMap[const.PRACH_ABORT] > 0 or \
                                   paraCountMap[const.PRACH_DONE] > 0 or \
                                   eventCountMap[const.PRACH_ABORT] > 0 or \
                                   eventCountMap[const.PRACH_DONE] > 0:
                                    goodCount += 1
                                    line += "Interred_request"
                            else:
                                line += "ERROR: fail to estimate TCP rtt"
                        else:
                            line += "ERROR: not unique mapping"
                    else:
                        line += "ERROR: not mapped RLC PDUs"
                    print line
    if HTTP_EXTRA:
        print "*" * 80
        print "In total, " + str(count) + " requests."
        print "Interfered URL is " + str(goodCount)