如果我在 C# 中发送 0 有效载荷数据,udp 数据包的大小是多少? [英] What is the size of udp packets if I send 0 payload data in c#?

查看:30
本文介绍了如果我在 C# 中发送 0 有效载荷数据,udp 数据包的大小是多少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经计算出使用 udp 的 2 个端点之间的分段之前的最大数据是 1472(其他端点可能会有所不同).这表明 mtu 为 1500 字节,每个数据包的标头开销为 28 字节.假设如果我发送 0 字节数据(有效负载),实际传输的数据是 28 字节,是否安全?我正在做一些基准测试,因此了解频道中发生了什么对我来说至关重要.

I have figured out the maximum data before fragmentation between 2 endpoints using udp is 1472(other endpoints may vary). This states that mtu is 1500bytes and header overhead per packet is 28bytes. Is it safe to assume that if I send 0 bytes data (payload), the actual data being transferred is 28bytes? I am doing some benchmark, so it is crucial for me to know, what happens in the channel.

推荐答案

  • MTU 是可以在不分片的情况下传输的 IP 数据包的最大大小.

    • The MTU is the maximum size of an IP packet that can be transmitted without fragmentation.

      IPv4 要求路径 MTU 至少为 576 字节,IPv6 至少为 1280 字节.

      IPv4 mandates a path MTU of at least 576 bytes, IPv6 of at least 1280 bytes.

      以太网的 MTU 为 1500 字节.

      Ethernet has an MTU of 1500 bytes.

      一个IP包由两部分组成:包头和有效载荷.

      An IP packet is composed of two parts: the packet header and the payload.

      IPv4 标头的大小至少 20 字节,IPv6 标头的大小至少 40 字节.

      The size of an IPv4 header is at least 20 bytes, the size of an IPv6 header at least 40 bytes.

      IP 数据包的负载通常是 TCP 段或 UDP 数据报.

      The payload of an IP packet is typically a TCP segment or a UDP datagram.

      一个 UDP 数据报由一个 UDP 报头和传输的数据组成.

      A UDP datagram consists of a UDP header and the transported data.

      UDP 报头的大小为 8 个字节.

      The size of a UDP header is 8 bytes.

      这意味着以空 UDP 数据报作为有效负载的 IP 数据包需要至少 28 (IPv4) 或 48 (IPv6) 字节,但可能需要更多字节.

      This means an IP packet with an empty UDP datagram as payload takes at least 28 (IPv4) or 48 (IPv6) bytes, but may take more bytes.

      另请注意,在以太网的情况下,IP 数据包将另外包装在一个 MAC 数据包(14 字节标头 + 4 字节 CRC)中,该 MAC 数据包将嵌入以太网帧(8 字节前导序列)中.这会将 26 字节的数据添加到 IP 数据包,但不计入 MTU.

      Also note that in the case of Ethernet, the IP packet will additionally be wrapped in a MAC packet (14 byte header + 4 byte CRC) which will be embedded in an Ethernet frame (8 byte preamble sequence). This adds 26 bytes of data to the IP packet, but doesn't count against the MTU.

      因此您不能假设 UDP 数据报会导致传输特定数量的字节.

      So you cannot assume that a UDP datagram will cause a specific number of bytes to be transmitted.

      这篇关于如果我在 C# 中发送 0 有效载荷数据,udp 数据包的大小是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆