Scapy的 sr 只是打电话 recv_packet.answers(sent_packet) 对于已发送的每个数据包。 因此,您必须实施 def answers() 对于您的图层,请参阅:
sr
recv_packet.answers(sent_packet)
def answers()
def answers(self, other): """DEV: true if self is an answer from other""" if other.__class__ == self.__class__: return self.payload.answers(other.payload) return 0
这是原作的摘录 TCP 层:
TCP
def answers(self, other): if not isinstance(other, TCP): return 0 if conf.checkIPsrc: if not ((self.sport == other.dport) and (self.dport == other.sport)): return 0 if (abs(other.seq-self.ack) > 2+len(other.payload)): return 0 return 1