IP协议碎片错误
我正在 c# 中制作应用程序。在该应用程序中,我想使用 UDP 协议广播一些数据。我正在制作套接字,
IPEndPoint ipep = new IPEndPoint(IPAddress.Broadcast, Convert.ToInt32(ServerPort));
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
EndPoint ep = (EndPoint)ipep;
socket.SendTo(m_SendBuffer, ep);
这里 m_SendBuffer 包含我想要发送的数据。 但是每当我通过wireshark观察流量时,它都会显示协议IPV4并将信息显示为“碎片IP协议”。请帮助我为什么会发生这种情况?提前致谢。
I am making application in c#.In that application i want to broadcast some data using UDP protocol.I am making socket as
IPEndPoint ipep = new IPEndPoint(IPAddress.Broadcast, Convert.ToInt32(ServerPort));
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
EndPoint ep = (EndPoint)ipep;
socket.SendTo(m_SendBuffer, ep);
Here m_SendBuffer contains data that i want to send.
But whenever i am observing traffic through wireshark it showing protocol IPV4 and showing information as "Fragmented IP Protocol".Please help me why this happening? Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
来自维基百科:
这意味着您发送的数据包太大。
From Wikipedia:
This means you are sending too large packets.
任何给定的网络链接都会对每个 IP 数据报强制规定最大大小。最常见的是 1500 字节。 UDP 和 IP 有 28 字节的标头,因此您还剩下 1472 字节的有效负载。
如果您发送的数据超过此数量,则每个数据包将被分解为碎片。这些在网络中通过在 IP 标头中添加片段 id 来区分。如果所有碎片都到达目的地,它们将在到达接收应用程序之前被重新组装成完整的数据包。
碎片通常由于多种原因而损坏:
但避免碎片化是很棘手的。网络中的其他事物(例如 MPLS、PPPoE 或 VPN)可能会添加更多标头,从而减少每个数据包可以安全发送的数据量。为了安全起见,请将数据包控制在 1400 字节以下。为了真正安全起见,请将其控制在 500 字节以下。
Any given network link will enforce a maximum size on each IP datagram. The most common is 1500 bytes. UDP and IP have 28 bytes of headers, so you are left with 1472 bytes for payload.
If you send more than that then each packet will be broken up into fragments. These are distinguished in the network by the addition of a fragment id in the IP header. If all fragments arrive at the destination, they will be reassembled into a complete packet before they reach the receiving application.
Fragments are generally bad for several reasons:
But avoiding fragmentation is tricky. Other things in the network, like MPLS, PPPoE, or VPNs may add more headers, reducing the amount of data that you can safely send per packet. To be safe, keep packets down to less than 1400 bytes. To be really safe, keep it down below 500 bytes.