C# UdpClient发送超过1500字节MTU的数据包会怎么样

如果不设置DontFragment

udpClient.DontFragment = false;

那么可以发送数据包。接收端随缘收到数据包。使用WireShark可以检测到网卡上对应的数据包。

如果设置DontFragment

udpClient.DontFragment = true;

在windows上会 使用winSock2的Send函数,然后会立刻返回-1。

错误码是WSAEMSGSIZE,表示message size太大。

Message too long.
A message sent on a datagram socket was larger than the internal message buffer or some other network limit, or the buffer used to receive a datagram was smaller than the datagram itself.

使用WireShark检测不到网卡上对应的数据包。

posted @   dewxin  阅读(478)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!
点击右上角即可分享
微信分享提示