tcp和udp一次能够传递的最大数据是多少?---用winsock api的send和sendto函数的时候一次能够发送的实际缓冲区最大是多少?

stanely 2003-01-24 03:00:51
rt



...全文
758 22 打赏 收藏 转发到动态 举报
写回复
用AI写文章
22 条回复
切换为时间正序
请发表友善的回复…
发表回复
stanely 2003-04-04
  • 打赏
  • 举报
回复
??
shines77 2003-04-04
  • 打赏
  • 举报
回复
URL: http://aspn.activestate.com/ASPN/Mail/Message/python-list/543656

Re: socket, UDP, SO_MAX_MSG_SIZE ???
>
> I'm implementing an application layer on top of UDP using the
> socket module, and I'm trying to determine the local machine's
> SO_MAX_MSG_SIZE. This option doesn't appear to be
> available in the socket module.
>
> I don't really know much about maximum UDP packet sizes.
> Do they generally default to the IP 65K limit? And if not, what's
> an alternate route for determining the max msg size?
>
> C//
>
>
Just been playing games with this ratty stuff in C++ on Windows, and I
found out the following:

IP packet size is generally ~1500 bytes by default. Don't know if that's
a given on all tcp/ip stacks or just Windows specific (I got the
impression that it was a standard default though).

UDP might only support max packet size of 512 bytes since anything larger
might be subject to fragmentation - again, ymmv. The 1500 bytes mentioned
above might be the max packet size before fragmentation otoh.

I think that the IP 64k max size is just the maximum possible size for an
IP packet and the default is typically set _much_ lower - typical max
seems to be 8k at most. (Windows uses a registry setting to set the max
ip size - by default 1500 bytes).

UDP on Windows is a poor stepchild - very little documentation.

People on comp.protocols.snmp and the net-snmp project at sourceforge
might be better equipped to answer your specific question about how to
determine actual max packet size on various machines. This is because
snmp uses udp so these people would probably want/need to find this info
too. FWIW, net-snmp runs on a fair number of platforms and if you dig
through their (imho vastly over factored) C source, you can probably find
the info. There is also a python wrapper for net-snmp called (I think)
pysnmp and it lives on sourceforge too.

HTH

Dave LeBlanc
shines77 2003-04-04
  • 打赏
  • 举报
回复
mark
csdn_viking 2003-04-04
  • 打赏
  • 举报
回复
我一次发送250K都可以啊,只不接受端要多次接受(验证总和就可以了)。

我们发送多大都可以吧?反正超过MTU的话,IP协议自动就用多帧给我们发送了,不用我们管。
hejunqijiangli 2003-04-03
  • 打赏
  • 举报
回复
没关系,多大都可以!先定义一个文件信息属性结构体,先传此结构体,再在发送端循环读文件,循环传;接收端先接收文件结构体,在循环写文件,文件再大都没问题!
stanely 2003-04-03
  • 打赏
  • 举报
回复
那么请问一次性发送的缓冲区是多大?

如果我一次性发送100k缓冲区会不会成功?

否则如果循环发送那么一次性发送多少?
stanely 2003-04-02
  • 打赏
  • 举报
回复
如果用send函数发送100K的缓冲区数据,那么返回值可能是多少,分别什么意思呢?

sendto又如何?

////////////////////

如果想用send和sendto发送100k数据,那么请帮我写出代码,谢谢!
joinrry 2003-04-01
  • 打赏
  • 举报
回复
你自己设置嘛!
yanhuahui 2003-04-01
  • 打赏
  • 举报
回复
这个问题的帖子太多了,去搜索一下
lichungen 2003-04-01
  • 打赏
  • 举报
回复
用GetSockOpt() 可以得到SO_SNDBUF(SOCKET发送缓冲区)和SO_RCVBUF(SOCKET接收缓冲区),一般为8192个字节,传输一般以MTU - 40(IP与TCP包头)个字节为最佳,这样可以防止分片
wangyi9778 2003-04-01
  • 打赏
  • 举报
回复
请问一下,一个数据包就是指一帧数据吗,还是。。。。?
stanely 2003-03-23
  • 打赏
  • 举报
回复
??
stanely 2003-01-30
  • 打赏
  • 举报
回复
那么如果数据量很大,用send和sendto分别会截成多大块发送呢?
iamnotyou 2003-01-25
  • 打赏
  • 举报
回复
...../' \\   //\\
     \\  // `\
      \\ // 祝楼主:
     .-'^'-.
    .' a___a `. 春节愉快 合家欢乐!
    == (___) ==
    '. ._I_. .' 心想事成 红包拿来!
  ____/.`-----'.\____
  [###(__)####
Nizvoo 2003-01-24
  • 打赏
  • 举报
回复
对了,我是用Delphi做的。都一样
Nizvoo 2003-01-24
  • 打赏
  • 举报
回复
我做分帧传输,设BufSize为2048,我发现如果大一些就会自动分成几段传送,不符合我的要求。只能发多少我收多少。采用非阻塞式线程
zfr 2003-01-24
  • 打赏
  • 举报
回复
IP数据桢允许传输的数据量MTU(Maximum Transmission Unit)是根据具体网络而有所不同,Ethernet 1500B;Token Ring 8174B;FDDI 4470B
UDP 默认是8192B
alphapiao 2003-01-24
  • 打赏
  • 举报
回复
一般TCP一次传1024,UDP传546,大了可以传,但底层要做分片操作,所以还不如干脆小一点传,个人看法。

关注
zj510 2003-01-24
  • 打赏
  • 举报
回复
你用GetSockOpt(),就可以知道了。
有发送缓冲的大小,接收缓冲的大小,UDP的最大数据量等。
当然,你也可以通过SetSockOpt()来设置你所需要的大小。
zhaolaoxin 2003-01-24
  • 打赏
  • 举报
回复
不能超过ip包的数据部分总长度。
实际应用时的长度可以自己定义。
加载更多回复(2)

18,356

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 网络编程
c++c语言开发语言 技术论坛(原bbs)
社区管理员
  • 网络编程
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧