关于ip_append_data函数的问题
时间:2010-11-29
来源:互联网
If the L4 layer wants fast response time, it might call ip_push_pending_frames after each call to ip_append_data. But the two functions are provided so that the L4 layer can buffer as much data as possible (up to the size of the PMTU) and then send it at once to be efficient.
现在我有点不解的问题是,该文中所说的“ If the L4 layer wants fast response time” 是什么意思?换句话讲,L4层什么时候认为需要快速响应,什么时候又不需要呢?决定权在哪里?
作者: jiufei19 发布时间: 2010-11-29
作者: Godbach 发布时间: 2010-11-29
谢谢斑竹!
斑竹说的是TCP_NODELAY 这个选项吗?查了下资料,该选项的用法如下:
If set, this option disables TCP's Nagle algorithm (Section 19.4 of TCPv1 and pp. 858–859 of TCPv2). By default, this algorithm is enabled
显然,对于ip_build_and_send_pkt和ip_send_reply这两个函数而言,正好符合这个要求,因为这两个函数是TCP用于发送SYN ACKs、RST分段的,因此这两个函数都不会和应用层数据有关。那么是否能这样理解,如果L4数据是来自应用层的数据,那么是不会有所谓L4调用ip_append_data函数缓存该应用层待发送数据的现象?
作者: jiufei19 发布时间: 2010-11-29
作者: Godbach 发布时间: 2010-11-29
作者: Godbach 发布时间: 2010-11-29
谢谢!
我感觉我的表述没有清楚,我想表达的意思好像不是我的本意,晕了,我再整理下思路后,再来请教。
作者: jiufei19 发布时间: 2010-11-29
其实建议接着在后面看一些内核你就明白了。
传输层发送数据,涉及到高效率和高响应率。ip_push_pending_frames 这个函数被调用之前,可能有到多次调用 ip_append_data。
如果你想要高响应率,那么就调用一次 ip_append_data 之后,尽快执行 ip_push_pending_frames 。
如果你想高效率,一次尽可能多的发数据,那就可以多次调用 ip_append_data,知道缓冲的数据达到 PMTU,才调用 ip_push_pending_frames。这样一次发送的数据量比较大。
作者: Godbach 发布时间: 2010-11-29
回复 Godbach
谢谢斑竹的热情!
ip_append_data和ip_push_pending_frames这两个函数我已经全部阅读完了,基本上其内部的原理有一个大概的了解。我今天的疑问是发生在回头阅读原书的这几段话时,突然发现自己没有很好理解ip_append_data函数的应用场景了,尤其是对其缓存发送数据的应用场景的全面了解上。
我整理好思路后,再和斑竹交流!
-----------------------------
如果你想要高响应率,那么就调用一次 ip_append_data 之后,尽快执行 ip_push_pending_frames 。
如果你想高效率,一次尽可能多的发数据,那就可以多次调用 ip_append_data,知道缓冲的数据达到 PMTU,才调用 ip_push_pending_frames。这样一次发送的数据量比较大。
----------------------------
这段话的意思我是理解的,我现在的疑问不是指这段话所描述的本身原理,而是------我现在还不知道咋个清晰描述我的问题,呵呵!
作者: jiufei19 发布时间: 2010-11-29

作者: Godbach 发布时间: 2010-11-29
斑竹,因为好像问题有点复杂,我先将问题分解下,逐个进行表述,看看能否理清问题思路。
1、首先我想知道的是,ip_append_data被L4层协议调用时,假定L4层协议是UDP协议,那么是否有什么机制进行这里所谓的缓存数据的发送?如果有这个机制是什么?应用层能控制吗?
作者: jiufei19 发布时间: 2010-11-29
作者: Godbach 发布时间: 2010-11-29
作者: Godbach 发布时间: 2010-11-29
最后一个参数 flags 的解释中谈到了 MSG_MORE
The caller has more data to send. This flag is used with TCP sockets to obtain the same effect as the TCP_CORK socket option (see tcp(7)), with
the difference that this flag can be set on a per-call basis.
Since Linux 2.6, this flag is also supported for UDP sockets, and informs the kernel to package all of the data sent in calls with this flag set
into a single datagram which is only transmitted when a call is performed that does not specify this flag. (See also the UDP_CORK socket option
described in udp(7).)
作者: Godbach 发布时间: 2010-11-29
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28