• 请不要在回答技术问题时复制粘贴 AI 生成的内容
amiwrong123
V2EX  ›  程序员

为什么 TCP 的 payload 是通过 IP 的总长度-IP 的头部长度-TCP 的头部长度 得到? UDP 却不是?

  •  
  •   amiwrong123 · Oct 28, 2021 · 2098 views
    This topic created in 1841 days ago, the information mentioned may be changed or developed.

    如上图所示,TCP 的 payload 是通过 IP 的总长度-IP 的头部长度-TCP 的头部长度 得到的 1452 - 20 - 20 = 1412.所以这个 1412 也是通过这三个值才计算出来的,不是原本就存在的。

    如上图所示,UDP 我用同样的方式,却算不出来。 59-20-39=0.那 UDP payload 的那个 31 是怎么算出来的呢

    我蒙了,求指点

    3 replies  •  2021-10-28 23:48:20 +08:00
    ch2
    ch2
    Oct 28, 2021❤️1
    1
    源端口、目的端口、报文长度、校验和,各 2 字节
    39-2*4=31
    amiwrong123
    amiwrong123
    OP
    Oct 28, 2021
    2
    @ch2 #1
    哈哈,好吧。我的错,可以删帖嘛
    cz5424
    cz5424
    Oct 28, 2021❤️1
    3
    39 - the UDP header (8 bytes)
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1659 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 16:20 · PVG 00:20 · LAX 08:20 · JFK 11:20
    ♥ Do have faith in what you're doing.