def count_cross_layer_mapping_WCDMA_downlink(entryList, client_ip): total_transport_layer_protocol = 0.0 mapped_transport_layer_protocol = 0.0 unmapped_entry_list = [] for entryIndex in range(len(entryList)): entry = entryList[entryIndex] if entry.logID == const.PROTOCOL_ID and entry.ip["dst_ip"] == client_ip: (rlc_list, rlc_sn_list) = clw.cross_layer_mapping_WCDMA_downlink(entryList, entryIndex, const.DL_PDU_ID) if rlc_list: mapped_transport_layer_protocol += 1 else: unmapped_entry_list.append(entry) total_transport_layer_protocol += 1 size_list = [entry.ip["total_len"] for entry in unmapped_entry_list] tcp_unmapped_count = 0.0 total_unmapped_count = float(len(unmapped_entry_list)) for entry in unmapped_entry_list: if entry.ip["tlp_id"] == const.TCP_ID: tcp_unmapped_count += 1 print "Unmapped transport layer size distribution is %s" % (str(util.quartileResult(size_list))) print "Unmapped TCP protocol portion is %f / %f = %f" % ( tcp_unmapped_count, total_unmapped_count, tcp_unmapped_count / total_unmapped_count, ) print "WCDMA downlink mapping accuracy is %f / %f = %f" % ( mapped_transport_layer_protocol, total_transport_layer_protocol, mapped_transport_layer_protocol / total_transport_layer_protocol, )
def count_cross_layer_mapping_WCDMA_downlink(entryList, client_ip): total_transport_layer_protocol = 0.0 mapped_transport_layer_protocol = 0.0 unmapped_entry_list = [] for entryIndex in range(len(entryList)): entry = entryList[entryIndex] if entry.logID == const.PROTOCOL_ID and \ entry.ip["dst_ip"] == client_ip: (rlc_list, rlc_sn_list) = clw.cross_layer_mapping_WCDMA_downlink( entryList, entryIndex, const.DL_PDU_ID) if rlc_list: mapped_transport_layer_protocol += 1 else: unmapped_entry_list.append(entry) total_transport_layer_protocol += 1 size_list = [entry.ip["total_len"] for entry in unmapped_entry_list] tcp_unmapped_count = 0.0 total_unmapped_count = float(len(unmapped_entry_list)) for entry in unmapped_entry_list: if entry.ip["tlp_id"] == const.TCP_ID: tcp_unmapped_count += 1 print "Unmapped transport layer size distribution is %s" % (str( util.quartileResult(size_list))) print "Unmapped TCP protocol portion is %f / %f = %f" % (tcp_unmapped_count, total_unmapped_count, \ tcp_unmapped_count / total_unmapped_count) print "WCDMA downlink mapping accuracy is %f / %f = %f" % \ (mapped_transport_layer_protocol, \ total_transport_layer_protocol, \ mapped_transport_layer_protocol / total_transport_layer_protocol)
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], )
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])