C Programming TCP Checksum

后端 未结 4 436
不知归路
不知归路 2020-12-10 17:12

I have been having trouble doing the checksum for TCP for several days now. I have looked at many sources on the Internet but none of the examples that I have seen show you

4条回答
  •  北海茫月
    2020-12-10 17:23

    I see a couple of things:

    • You are not accounting for odd length data by padding with zero.
    • You will need to account for network byte order when reading each word from the packet.
    • Your use of htonl(0x0000ffff) seems suspicious. Why are you converting a constant to network byte order to combine it with data in host byte order?

提交回复
热议问题