weixin_39602005 2020-11-22 03:36
浏览 0

How can i obtain ip.src in human readable form?

From Dodin.Ro....com on April 21, 2008 09:43:34

What steps will reproduce the problem? Following code: import pcap, dpkt

def pr(hdr,data): print(dpkt.ip.IP(data[14:])['src'])

pc = pcap.pcap(None,1500,False) pc.setfilter('udp')

pc = pcap.pcap()

pc.setfilter('udp')

pc.dispatch(10,pr)

shows mystery 'R\xb3A\x1e' how to decode this?

Original issue: http://code.google.com/p/dpkt/issues/detail?id=7

该提问来源于开源项目:kbandla/dpkt

  • 写回答

7条回答 默认 最新

  • weixin_39602005 2020-11-22 03:36
    关注

    From don.mi....com on April 23, 2008 16:44:50

    there's a dpkt.hexdump() that is pretty good in that it will basically show you a sniffer view. Otherwise it helps to open the packet in a sniffer like wireshark/tcpdump/snoop/old ethereal that can decode the packet for you and tell you what each byte means (cause that's what you're dealing with sometimes). Or I've seen some other code that makes its own pcap handler that does something with packets...maybe try that? Also it appears that the dpkt lib uses .unpack() to parse packets out. Try data = IP.unpack(), get data into UDP(), then UDP.unpack()?

    评论

报告相同问题?