コード例 #1
0
def assign_udp_rtt(QCATEntries, direction, clt_uplink_table,
                   clt_downlink_table):
    src_table = clt_uplink_table
    dst_table = clt_downlink_table
    if direction.lower() != "up":
        src_table = clt_downlink_table
        dst_table = clt_uplink_table

    for index_list in src_table.values():
        for index in index_list:
            cur_entry = QCATEntries[index]
            cur_seq_num = cur_entry.udp["seq_num"]
            # find the corresponding entry, and assign UDP RTT
            if cur_seq_num:
                if dst_table.has_key(cur_seq_num):
                    echo_index_list = dst_table[cur_seq_num]
                    for echo_index in echo_index_list:
                        cur_diff = QCATEntries[
                            echo_index].timestamp - cur_entry.timestamp
                        if cur_diff > 0:
                            if not cur_entry.rtt[
                                    "udp"] or cur_entry.rtt["udp"] > cur_diff:
                                cur_entry.rtt["udp"] = cur_diff
                else:
                    cur_entry.rtt["udp"] = -1.0
                if cur_entry.rtt["udp"] > const.UDP_RTT_LIMIT:
                    cur_entry.rtt["udp"] = -1.0
                if False:
                    print "UDP RTT is %f" % cur_entry.rtt["udp"]
                    pw.printUDPEntry(QCATEntries[echo_index])
    """
コード例 #2
0
def detectReTx (entry, entryHist, is_up, srv_ip):
    if (is_up and entry.ip["dst_ip"] != srv_ip) or \
       (not is_up and entry.ip["src_ip"] != srv_ip) or \
       entry.tcp["seg_size"] <= 0:          
        return False
	
    for i in entryHist[::-1]:
        #####
        # Make sure we are in the same direction
        if entry.ip["src_ip"] != i.ip["src_ip"] or \
           entry.ip["dst_ip"] != i.ip["dst_ip"]:
            continue
        # fast decline if sequence number is increasing
        if entry.tcp["seq_num"] > i.tcp["seq_num"] or \
           entry.tcp["FIN_FLAG"]:
            return False
        if i.tcp["seg_size"] > 0 and \
           entry.tcp["seq_num"] == i.tcp["seq_num"]:
           # entry.tcp["flags"] == i.tcp["flags"]
           # entry.ip["total_len"] == i.ip["total_len"]:
           #and entry.tcp["payload"] == i.tcp["payload"]:
           # TODO: debug
            if DEBUG:
                print "Original:"
                pw.printTCPEntry(i)
                print "Retx:"
                pw.printTCPEntry(entry)
            privTS = i.timestamp
            ts = entry.timestamp
            return i
    return False
コード例 #3
0
def assign_udp_rtt(QCATEntries, direction, clt_uplink_table, clt_downlink_table):
    src_table = clt_uplink_table
    dst_table = clt_downlink_table
    if direction.lower() != "up":
        src_table = clt_downlink_table
        dst_table = clt_uplink_table
    
    for index_list in src_table.values():
        for index in index_list:
            cur_entry = QCATEntries[index]
            cur_seq_num = cur_entry.udp["seq_num"]
            # find the corresponding entry, and assign UDP RTT
            if cur_seq_num:
                if dst_table.has_key(cur_seq_num):
                    echo_index_list = dst_table[cur_seq_num]
                    for echo_index in echo_index_list:
                        cur_diff = QCATEntries[echo_index].timestamp - cur_entry.timestamp
                        if cur_diff > 0:
                            if not cur_entry.rtt["udp"] or cur_entry.rtt["udp"] > cur_diff:
                                cur_entry.rtt["udp"] = cur_diff
                else:
                    cur_entry.rtt["udp"] = -1.0
                if cur_entry.rtt["udp"] > const.UDP_RTT_LIMIT:
                    cur_entry.rtt["udp"] = -1.0
                if False:
                    print "UDP RTT is %f" % cur_entry.rtt["udp"]
                    pw.printUDPEntry(QCATEntries[echo_index])

    """
コード例 #4
0
def assignPrivEntryRRC(privEntries, rrc_state_id, rrc_state_timestamp):
    # Make sure you have the timer in the constant field
    # timer = const.TIMER[rrc_state_id]
    # TODO: delete after tunning
    #if CUR_DEBUG:
        #print timer
    #if not timer:
    timer = const.TIMER[rrc_state_id]
    # assign new id
    if DEBUG:
        print "#" * 40
    for entry in privEntries[::-1]:
        if entry.logID == const.PROTOCOL_ID or \
           entry.logID == const.UL_PDU_ID or \
           entry.logID == const.DL_PDU_ID:
            if entry.timestamp + timer >= rrc_state_timestamp:
                if DEBUG:
                    print "Prvious RRC:"
                    print pw.printEntry(entry)
                entry.rrcID = rrc_state_id
                if DEBUG:
                    print "Current RRC:"
                    print pw.printEntry(entry)
コード例 #5
0
def assignPrivEntryRRC(privEntries, rrc_state_id, rrc_state_timestamp):
    # Make sure you have the timer in the constant field
    # timer = const.TIMER[rrc_state_id]
    # TODO: delete after tunning
    #if CUR_DEBUG:
    #print timer
    #if not timer:
    timer = const.TIMER[rrc_state_id]
    # assign new id
    if DEBUG:
        print "#" * 40
    for entry in privEntries[::-1]:
        if entry.logID == const.PROTOCOL_ID or \
           entry.logID == const.UL_PDU_ID or \
           entry.logID == const.DL_PDU_ID:
            if entry.timestamp + timer >= rrc_state_timestamp:
                if DEBUG:
                    print "Prvious RRC:"
                    print pw.printEntry(entry)
                entry.rrcID = rrc_state_id
                if DEBUG:
                    print "Current RRC:"
                    print pw.printEntry(entry)
コード例 #6
0
def detectFastReTx (entry, entryHist, is_up, srv_ip):
    ack_count = 0
    detectFastReTx = False

    # fast decline if sequence number is increasing
    if (is_up and entry.ip["dst_ip"] != srv_ip) or \
       (not is_up and entry.ip["src_ip"] != srv_ip) or \
       entry.tcp["seg_size"] <= 0:
    	return False   

    # TODO: debug with packet of interest
    target = False
    if DEBUG:
        if util.convert_ts_in_human(entry.timestamp) == "11:00:28.738000":
            print "!!!FIND THE TARGET!!!"
            pw.printTCPEntry(entry)
            print "Priv entries length is %d" % len(entryHist[::-1])
            target = True

    for i in entryHist[::-1]:
        """
    	if (entry.ip["src_ip"] != i.ip["dst_ip"] or \
           entry.ip["dst_ip"] != i.ip["src_ip"]):
            continue
        """ 
        # print number of dup ack it encounterd
        if DEBUG and target:
            print "[=" * 40
            pw.printTCPEntry(i)
            print "# ack number is %d" % ack_count
            print "Find dup ack is %s" % detectFastReTx
            print "=]" * 40
        # Make sure we are in the opposite direction when we haven't detect a fast retx
        if not detectFastReTx and \
           (entry.ip["src_ip"] != i.ip["dst_ip"] or \
           entry.ip["dst_ip"] != i.ip["src_ip"]):
            continue
        # when we have found the fast retransmission, return the nearest entry 
        # with smaller or equivalent seq_num
        elif detectFastReTx:
            if entry.ip["src_ip"] == i.ip["src_ip"] and \
               entry.ip["dst_ip"] == i.ip["dst_ip"]:
                if entry.tcp["seq_num"] == i.tcp["seq_num"]:
                    # TODO: debug
                    if DEBUG:
                        print "$" * 40
                        print "Detect fast retransmission"
                        print "Ongoing pkt:"
                        pw.printTCPEntry(entry)
                        print "Checking pkt:"
                        pw.printTCPEntry(i)
                    return i
                elif entry.tcp["seq_num"] > i.tcp["seq_num"]:
                    break
            else:
                continue

        # Track the most recent 3 ACKs
        if ((is_up and i.ip["src_ip"] == srv_ip) or \
           (not is_up and i.ip["dst_ip"] == srv_ip)) and \
           i.tcp["seg_size"] == 0:
            # fast decline by detecting a smaller ack number
            if entry.tcp["seq_num"] != i.tcp["ack_num"]:
    	        return False
            else:
                ack_count += 1
        
        if ack_count >= const.FAST_RETX_COUNT:
            detectFastReTx = True
            # return i

    return False