def create_tcp_flows(self, link_len):
        local_flow = []
        trace_index = 0

        # parse the data into list of flow of packets
        for i in range(len(self.data)):
            new_packet = self.init_tcp_pkt()
            new_packet["ts"] = dp.packet_time(self.data, i)
            new_packet["src_ip"] = dp.src_ip(self.data, i, link_len)
            new_packet["dst_ip"] = dp.dst_ip(self.data, i, link_len)
            new_packet["src_port"] = dp.src_port(self.data, i, link_len)
            new_packet["dst_port"] = dp.dst_port(self.data, i, link_len)
            new_packet["flags"]["urg"] = dp.tcp_flag_bit(self.data, i, link_len, 5)
            new_packet["flags"]["ack"] = dp.tcp_flag_bit(self.data, i, link_len, 4)
            new_packet["flags"]["psh"] = dp.tcp_flag_bit(self.data, i, link_len, 3)
            new_packet["flags"]["rst"] = dp.tcp_flag_bit(self.data, i, link_len, 2)
            new_packet["flags"]["syn"] = dp.tcp_flag_bit(self.data, i, link_len, 1)
            new_packet["flags"]["fin"] = dp.tcp_flag_bit(self.data, i, link_len, 0)
            new_packet["ack_num"] = dp.ack_num(self.data, i, link_len)
            new_packet["seq_num"] = dp.sequence_num(self.data, i, link_len)
            new_packet["win_size"] = dp.window_size_server(self.data, i, link_len)	# size match
            new_packet["seg_len"] = dp.tcp_seg_size(self.data, i, link_len)
            new_packet["hashed_payload"] = util.md5_hash(dp.udp_payload(self.data, i, link_len))
            new_packet["trace_index"] = trace_index

	        # check new flow
            if new_packet["flags"]["syn"] and not new_packet["flags"]["ack"] and local_flow:
                self.packets.append(local_flow)
                local_flow = [new_packet]
                trace_index += 1
            else:
                local_flow.append(new_packet)

        if local_flow:
            self.packets.append(local_flow)
Exemple #2
0
    def create_tcp_flows(self, link_len):
        local_flow = []
        trace_index = 0

        # parse the data into list of flow of packets
        for i in range(len(self.data)):
            new_packet = self.init_tcp_pkt()
            new_packet["ts"] = dp.packet_time(self.data, i)
            new_packet["src_ip"] = dp.src_ip(self.data, i, link_len)
            new_packet["dst_ip"] = dp.dst_ip(self.data, i, link_len)
            new_packet["src_port"] = dp.src_port(self.data, i, link_len)
            new_packet["dst_port"] = dp.dst_port(self.data, i, link_len)
            new_packet["flags"]["urg"] = dp.tcp_flag_bit(
                self.data, i, link_len, 5)
            new_packet["flags"]["ack"] = dp.tcp_flag_bit(
                self.data, i, link_len, 4)
            new_packet["flags"]["psh"] = dp.tcp_flag_bit(
                self.data, i, link_len, 3)
            new_packet["flags"]["rst"] = dp.tcp_flag_bit(
                self.data, i, link_len, 2)
            new_packet["flags"]["syn"] = dp.tcp_flag_bit(
                self.data, i, link_len, 1)
            new_packet["flags"]["fin"] = dp.tcp_flag_bit(
                self.data, i, link_len, 0)
            new_packet["ack_num"] = dp.ack_num(self.data, i, link_len)
            new_packet["seq_num"] = dp.sequence_num(self.data, i, link_len)
            new_packet["win_size"] = dp.window_size_server(
                self.data, i, link_len)  # size match
            new_packet["seg_len"] = dp.tcp_seg_size(self.data, i, link_len)
            new_packet["hashed_payload"] = util.md5_hash(
                dp.udp_payload(self.data, i, link_len))
            new_packet["trace_index"] = trace_index

            # check new flow
            if new_packet["flags"][
                    "syn"] and not new_packet["flags"]["ack"] and local_flow:
                self.packets.append(local_flow)
                local_flow = [new_packet]
                trace_index += 1
            else:
                local_flow.append(new_packet)

        if local_flow:
            self.packets.append(local_flow)
 def create_udp_trace(self, link_len):
     self.udp_trace = []
     for i in range(len(self.data)):
         new_datagram = self.init_udp_pkt()
         new_datagram["ts"] = dp.packet_time(self.data, i)
         # identical to TCP
         new_datagram["src_ip"] = dp.src_ip(self.data, i, link_len)
         new_datagram["dst_ip"] = dp.dst_ip(self.data, i, link_len)
         new_datagram["src_port"] = dp.src_port(self.data, i, link_len)
         new_datagram["dst_port"] = dp.dst_port(self.data, i, link_len)
         new_datagram["seg_size"] = dp.udp_seg_size(self.data, i, link_len)
         new_datagram["hashed_payload"] = util.md5_hash(dp.udp_payload(self.data, i, link_len))
         new_datagram["seq_num"] = dp.udp_seq_num(self.data, i, link_len)
         """            
         payload = dp.udp_payload(self.data, i, link_len)
         print "Payload with length %d:" % len(payload)
         print payload
         print "Hashed Result %s" % new_datagram["hashed_payload"]
         print "@" * 50
         """
         self.udp_trace.append(new_datagram)
Exemple #4
0
 def create_udp_trace(self, link_len):
     self.udp_trace = []
     for i in range(len(self.data)):
         new_datagram = self.init_udp_pkt()
         new_datagram["ts"] = dp.packet_time(self.data, i)
         # identical to TCP
         new_datagram["src_ip"] = dp.src_ip(self.data, i, link_len)
         new_datagram["dst_ip"] = dp.dst_ip(self.data, i, link_len)
         new_datagram["src_port"] = dp.src_port(self.data, i, link_len)
         new_datagram["dst_port"] = dp.dst_port(self.data, i, link_len)
         new_datagram["seg_size"] = dp.udp_seg_size(self.data, i, link_len)
         new_datagram["hashed_payload"] = util.md5_hash(
             dp.udp_payload(self.data, i, link_len))
         new_datagram["seq_num"] = dp.udp_seq_num(self.data, i, link_len)
         """            
         payload = dp.udp_payload(self.data, i, link_len)
         print "Payload with length %d:" % len(payload)
         print payload
         print "Hashed Result %s" % new_datagram["hashed_payload"]
         print "@" * 50
         """
         self.udp_trace.append(new_datagram)