def dfSeriesToPacket(self, series): series.tolist() bytes = "" label = series[0] enumerate = series[1:] for i in enumerate: bytes += chr(int(round(float(i) * 255))) if (label == "ARP"): packet = Ether(bytes) elif (label == "ICMP"): packet = IP(bytes) packet.time = 0 packet[ICMP].time = 0 if (packet[ICMP].type == 13 or packet[ICMP].type == "timestamp-request" or packet[ICMP].type == 14 or packet[ICMP].type == "timestamp-reply"): packet.show() elif (label[0:4] == "IPv6"): packet = IPv6(bytes) else: packet = IP(bytes) packet.time = 0 if TCP in packet: packet[TCP].time = 0 for i in xrange(len(packet[TCP].options)): if (packet[TCP].options[i][0] == "Timestamp"): packet[TCP].options[i] = ("Timestamp", (0, 0)) packet[TCP].seq = 0 packet[TCP].ack = 0 elif UDP in packet: packet.time = 0 packet[UDP].time = 0 elif ICMP in packet: packet = IP(bytes) packet.time = 0 packet[ICMP].time = 0 else: packet = IP(bytes) packet.show() packet.time = 0 return label, packet
def bytesModifyBytes(self, X, Y): bytes = "" enumerate = X.split(',') for i in enumerate: bytes += chr(int(round(float(i) * 255))) if (Y == "ARP"): packet = Ether(bytes) elif (Y == "ICMP"): packet = IP(bytes) packet.time = 0 packet[ICMP].time = 0 if (packet[ICMP].type == 13 or packet[ICMP].type == "timestamp-request" or packet[ICMP].type == 14 or packet[ICMP].type == "timestamp-reply"): packet.show() elif (Y[0:4] == "IPv6"): packet = IPv6(bytes) else: packet = IP(bytes) packet.time = 0 if TCP in packet: packet[TCP].time = 0 for i in xrange(len(packet[TCP].options)): if (packet[TCP].options[i][0] == "Timestamp"): packet[TCP].options[i] = ("Timestamp", (0, 0)) packet[TCP].seq = 0 packet[TCP].ack = 0 elif UDP in packet: packet.time = 0 packet[UDP].time = 0 elif ICMP in packet: packet = IP(bytes) packet.time = 0 packet[ICMP].time = 0 else: packet = IP(bytes) packet.show() packet.time = 0 return self.packetToBytes(packet)