在Python中接收带有错误校验和的UDP数据包 [英] Receiving UDP packets with wrong checksum in Python

查看:83
本文介绍了在Python中接收带有错误校验和的UDP数据包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在PC上运行服务器应用程序,该应用程序从客户端接收UDP数据包.接收到UDP数据包(在WireShark中验证),但包含错误的校验和.我无法控制客户端,因此需要能够在Python中接收这些数据包.以下代码看不到数据包:

I am running a server application on a PC which receives UDP packets from a client. The UDP packets are received (verified in WireShark), but include the wrong checksum. I have no control over the client and need to be able to receive these packets in Python. The following code doesn't see the packets:

UDPSock = socket(AF_INET,SOCK_DGRAM)
UDPSock.bind(addr)

while 1:
    data,addr = UDPSock.recvfrom(buf)
    if not data:
        print "Client has exited!"
        break
    else:
        print "\nReceived message '", data,"'"

UDPSock.close()

在Python中无论如何,我都能收到格式错误的UDP数据包吗?

Anyway in Python I can receive malformed UDP packets?

推荐答案

找到了解决方案.

我将 pycap 库与

I used the pycap library in combination with dpkt. The pycap module is outdated, for older versions of Python, but in the "Issues" someone posted updated binaries.

这篇关于在Python中接收带有错误校验和的UDP数据包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆