简体   繁体   English

转移插座的TCP校验和计算

[英]TCP checksum calculation for divert socket

I have a divert socket. 我有一个转向插座。 I am trying to change the port on packets as I see them. 我正在尝试更改数据包上的端口,因为我看到它们。 When I do this - do I need to recalculate the TCP checksum, and the IP checksum? 当我这样做时 - 我是否需要重新计算TCP校验和和IP校验和?

I am trying to do this, but I am seeing reset packets in tcpdump. 我试图这样做,但我在tcpdump中看到重置数据包。 I dont know if this is because I am calculating the tcp checksum wrong, or if its something else going on. 我不知道这是因为我正在计算tcp校验和错误,或者是否正在进行其他事情。

I used the cksum methods from this site: 我使用了这个网站的cksum方法:

http://www.enderunix.org/docs/en/rawipspoof/ http://www.enderunix.org/docs/en/rawipspoof/

I thought with using a divert socket, if I change one thing, it should be fairly straightforward, but doesnt seem to be. 我想使用一个转移插座,如果我改变一件事,它应该是相当简单的,但似乎不是。 is there a TCP checksum calculator out there I can use to verify I am getting the right value? 有没有TCP校验和计算器,我可以用它来验证我得到了正确的值?

You do need to recompute the checksum. 您需要重新计算校验和。 Here is a description of the calculation: TCP/IP Checksum calculation 以下是计算的说明: TCP / IP校验和计算

See Section 3.3 of RFC 1631 for the checksum adjustments that a NAT/PAT must make. 有关NAT / PAT必须进行的校验和调整,请参见RFC 1631的第3.3节。 You don't have to go through the entire packet, you just need to adjust the checksum based on the bytes that you modify. 您不必遍历整个数据包,只需根据修改的字节调整校验和。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM