如何匹配问题和答案

2024-09-27 18:11:05 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在Scapy实施一个协议,下面是我目前所做的(细节省略):

class Protocol - #Defines some common headers
    def guess_payload_class:
        return ProtocolAction1

class ProtocolAction1 - #Defines some action to be done by the protocol.


class ProtocolAnswer - #Defines some common headers
    def guess_payload_class:
        return ProtocolAction1Anser

class ProtocolAction1Answer - #Defines the answer when Action1 has been done.

bind_layers(UDP, Protocol, dport=port)
bind_layers(UDP, ProtocolAnswer, sport=port)

但是,当我执行sr(IP()/UDP()/Protocol()/ProtocolAction1())操作时,我永远无法得到答案(尽管服务器会发送它)。我的目的是得到一个IP()/UDP()/ProtocolAnswer()/ProtocolAction1Answer()。我做错了什么?我该怎么解决?在


Tags: thereturndefsomecommonprotocolclassheaders

热门问题