dpkt icon indicating copy to clipboard operation
dpkt copied to clipboard

Question about checksum generated

Open jkljkjkjk opened this issue 1 year ago • 1 comments

Hi there

I didnt rly find out a method of generating checkusum value with dpkt

I need to change some hex in payload and once I pack new payload, the checksum needs to be updated as well

Any way to calculate and generate a new checksum by itself?

thx

jkljkjkjk avatar Feb 04 '24 11:02 jkljkjkjk

In general if you set the checksum to zero (pkt.sum=0), then serialize the packet (ie. call bytes(pkt)) it will be auto-recalculated. See the code here: https://github.com/kbandla/dpkt/blob/master/dpkt/ip.py#L90

obormot avatar Feb 04 '24 17:02 obormot