Chinaunix首页 | 论坛 | 博客
  • 博客访问: 510280
  • 博文数量: 100
  • 博客积分: 2058
  • 博客等级: 大尉
  • 技术积分: 1029
  • 用 户 组: 普通用户
  • 注册时间: 2010-07-14 23:29
文章分类
文章存档

2011年(94)

2010年(6)

分类: 网络与安全

2011-04-24 11:49:57

 1. nagle算法主要目的是减少网络流量,当你发送的数据包太小时,TCP并不立即发送该数据包,而是缓存起来直到数据包
   到达一定大小后才发送。

 2. 当应用程序每次发送的数据很小,特别是只发送1个字节,加上TCP和IP头的封装,TCP头占20个字节,IP头也占20个字      节,这时候发一个包是41个字节,效率太低。而nagle算法允许计算机缓冲数据,当数据缓存到一定长度后,如果之前发送     的数据得到了ACK确认且接收方有足够空间容纳数据 (当然也要考虑MSS),就发送这些数据,否则继续等待。

 3.  TCP socket提供了关闭nagle算法的接口,可以通过TCP_NODELAY选项决定是否开启该算法。  

wikipedia上面关于这个算法的资料:h

wikipedia上有一段nagle的伪代码便于理解:

if there is new data to send
     
if the window size >= MSS and available data is >= MSS
       send complete MSS segment now
     
else
       
if there is unconfirmed data still in the pipe
         enqueue data 
in the buffer until an acknowledge is received
       
else
         send data immediately
       end 
if
     end 
if
   end 
if 

   
   


阅读(9093) | 评论(2) | 转发(0) |
给主人留下些什么吧!~~

网络安全服务2011-05-31 09:35:03

cchmaho2010: [url=http://www.worldgodshop.com/]Supra Shoes[/url]   [url=http://www.worldgodshop.com/]Radii shoes[/url]  [url=http://www.worldgodshop.com/]Prada Sh.....

cchmaho20102011-05-03 22:08:15

[url=http://www.worldgodshop.com/]Supra Shoes[/url]   [url=http://www.worldgodshop.com/]Radii shoes[/url]  [url=http://www.worldgodshop.com/]Prada Shoes[/url]   [url=http://www.worldgodshop.com/]Jordan shoes[/url]  [url=http://www.worldgodshop.com/]Christian Louboutin shoes[/url]
http://www.worldgodshop.com/