TCP Data Flow and Window Management(2)

Flow Control and Window Management

Every TCP segment (except those exchanged during connection establishment) includes a valid Sequence Number field, an ACK Number or Acknowledgment field, and a Window Size field (containing the window advertisement).

These sizes(contained in window advertisement field) represent the amount of space the sender of the segment has reserved for storing incoming data the peer sends.

When TCP-based applications are not busy doing other things, they are typically able to consume any and all data TCP has received and queued for them, leading to no change of the Window Size field as the connection progresses.

On slow systems, or when the application has other things to accomplish, data may have arrived for the application, been acknowledged by TCP, and be sitting in a queue waiting for the application to read or “consume” it.

When TCP starts to queue data in this way, the amount of space available to hold new incoming data decreases, and this change is reflected by a decreasing value of the Window Size field.

Eventually, if the application does not read or otherwise consume the data at all, TCP must take some action to cause the sender to cease sending new data entirely,

because there would be no place to put it on arrival. This is accomplished by sending a window advertisement of zero (no space).

The largest sequence number the sender of a segment is willing to accept in the reverse direction is equal to the sum of the Acknowledgment Number and Window Size fields in the TCP header (scaled appropriately).

Sliding Windows

The amount of data sent or received on a connection is maintained by a set of window structures.

For each active connection, each TCP endpoint maintains a send window structure and a receive window structure.

TCP maintains its window structures in terms of bytes (not packets).In Fig- ure 15-9 we have numbered the bytes 2 through 11.

The window advertised by the receiver is called the offered window and covers bytes 4 through 9,

meaning that the receiver has acknowledged all bytes up through and including number 3 and has advertised a window size of 6.

The sender computes its usable window, which is how much data it can send immediately.

The usable window is the offered window minus the amount of data already sent but not yet acknowledged.

The vari- ables SND.UNA and SND.WND are used to hold the values of the left window edge and offered window.

The variable SND.NXT holds the next sequence number to be sent, so the usable window is equal to (SND.UNA + SND.WND – SND.NXT).

Over time this sliding window moves to the right, as the receiver acknowl- edges data.

The relative motion of the two ends of the window increases or decreases the size of the window.

Three terms are used to describe the movement of the right and left edges of the window

1 The window closes as the left edge advances to the right.

This happens when data that has been sent is acknowledged and the window size gets smaller.

2 The window opens when the right edge moves to the right, allowing more data to be sent.

This happens when the receiving process on the other end reads acknowledged data, freeing up space in its TCP receive buffer.

3 The window shrinks when the right edge moves to the left.

The Host Requirements RFC [RFC1122] strongly discourages this, but TCP must be able to cope with it.

The left edge of the window cannot move to the left, because this edge is controlled by the ACK number received from the other end that is cumulative and never goes backward.

When the ACK number advances the window but the window size does not change (a common case), the window is said to advance or “slide” forward.

If the ACK number advances but the window advertisement grows smaller with other arriving ACKs, the left edge of the window moves closer to the right edge.

If the left edge reaches the right edge, it is called a zero window. This stops the sender from transmitting any data.

If this happens, the sending TCP begins to probe the peer’s window (see Section 15.5.2) to look for an increase in the offered window.

The receiver also keeps a window structure, which is somewhat simpler than the sender’s.

The receiver window structure keeps track of what data has already been received and ACKed, as well as the maximum sequence number it is willing to receive.

The TCP receiver depends on this structure to ensure the correctness of the data it receives.

In particular, it wishes to avoid storing duplicate bytes it has already received and ACKed, and it also wishes to avoid storing bytes that it should not have received

(any bytes beyond the sender’s right window edge).

Zero Windows and the TCP Persist Timer

When the receiver once again has space available, it provides a window update to the sender to indicate that data is permitted to flow once again.

Because such updates do not generally contain data (they are a form of “pure ACK”), they are not reliably delivered by TCP.

TCP must therefore handle the case where such window updates that would open the window are lost.

If an acknowledgment (containing a window update) is lost, we could end up with both sides waiting for the other: the receiver waiting to receive data

(because it provided the sender with a nonzero window and expects to see incoming data) and the sender waiting to receive the window update allowing it to send.

To pre- vent this form of deadlock from occurring, the sender uses a persist timer to query the receiver periodically, to find out if the window size has increased.

The persist timer triggers the transmission of window probes.

Window probes are segments that force the receiver to provide an ACK, which also necessarily contains a Win- dow Size field.

The Host Requirements RFC [RFC1122] suggests that the first probe should happen after one RTO and subsequent problems should occur at exponen- tially spaced intervals

(i.e., similar to the “second part” of Karn’s algorithm, which we discussed in Chapter 14).

Window probes contain a single byte of data and are therefore reliably deliv- ered (retransmitted) by TCP if lost, thereby eliminating the potential deadlock condition caused by lost window updates.

The probes are sent whenever the TCP persist timer expires, and the byte included may or may not be accepted by the receiver, depending on how much buffer space it has available.

As with the TCP retransmission timer (see Chapter 14), the normal exponential backoff can be used when calculating the timeout for the persist timer.

An important difference, how- ever, is that a normal TCP never gives up sending window probes, whereas it may eventually give up trying to perform retransmissions.

This can lead to a certain resource exhaustion vulnerability that we discuss in Section 15.7.

原文地址:https://www.cnblogs.com/geeklove01/p/9748726.html

时间: 2024-11-06 16:20:54

TCP Data Flow and Window Management(2)的相关文章

TCP 协议中的 Window Size与吞吐量

原地址:http://blog.sina.com.cn/s/blog_c5c2d6690102wpxl.html TCP协议中影响实际业务流量的参数很多,这里主要分析一下窗口的影响. ?TCP窗口目的 为了获得最优的连接速率,使用TCP窗口来控制流速率(flow control),滑动窗口就是一种主要的机制.这个窗口允许源端在给定连接传送数据分段而不用等待目标端返回ACK,一句话描述:窗口的大小决定在不需要对端响应(acknowledgement)情况下传送数据的数量.?官方定义:"The am

UVA 10594 Data Flow (最小费用流)

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=116&page=show_problem&problem=1535 Problem F Data Flow Time Limit 5 Seconds   In the latest Lab of IIUC, it requires to send huge amount of data from the local s

监控 Data Flow Execution Performance

在每个Package执行时,SSIS Engine都会记录日志信息,Logging Level共有四个:无,基本,性能,详细.如果想监控Data Flow Execution的性能,可以将Logging Level设置为性能,这样就能收集每个数据流组件的“活动时间(以秒为单位)”. step1,设置日志记录级别为性能 2,查看package执行日志 3,点击“执行性能”,查看package的Execution Performance 查看数据路组件的各个组件的活动时间 如果数据流存在问题,那么可

Data Flow ->> Import Column & Export Column

这两个transformation的作用是把DT_TEXT, DT_NTEXT, DT_IMAGE类型的数据在文件系统和数据库间导出或者导入.比如把某个数据库表的image类型的字段导出到文件系统成为img文件.做法是在导入导出的时候必须提供完全文件名和路径.需要注意的地方是需要在Import Column组件的Input and Output Properties页面加一个output字段来导入比如img文件,然后columnn的id必须在input column和output column间

Intel® Threading Building Blocks (Intel® TBB) Developer Guide 中文 Parallelizing Data Flow and Dependence Graphs并行化data flow和依赖图

https://www.threadingbuildingblocks.org/docs/help/index.htm Parallelizing Data Flow and Dependency Graphs In addition to loop parallelism, the Intel® Threading Building Blocks (Intel® TBB) library also supports graph parallelism. It's possible to cre

SSIS的 Data Flow 和 Control Flow

一,Control Flow 在Control Flow中,Task是最小的单元,Task通过Precedence Constraint来保持同步. 1,Control Flow 不能在组件之间传递数据,用于串行或并行执行任务,担当Task的调度者. 如果两个Task之间没有设置precedence constraint,那么这两个Task是并发执行的.在design package时,最大限度地提高task的并发处理能力,能够充分利用server的资源,有助于减少ETL执行的时间. 2,Con

OpenGL的GLUT事件处理(Event Processing)窗口管理(Window Management)函数[转]

GLUT事件处理(Event Processing)窗口管理(Window Management)函数 void glutMainLoop(void) 让glut程序进入事件循环.在一个glut程序中最多只能调用一次.一旦调用,会直到程序结束才返回. int glutCreateWindow(char* name); 产生一个顶层的窗口.name 作为窗口的名字,也就是窗口标题栏显示的内容. 返回值是生成窗口的标记符,可用函数glutGetWindow()加以引用. int glutCreate

Redux:data flow

我们使用react,是为了构建可复用的高性能的视图层,学习redux是为了处理视图组件中随应用复杂度提升而变得难以控制的state.说白了,是为了视图. 在了解了action.reducer和store之后,文档并不继而介绍怎么应用到视图层,而是带我们先了解data flow这概念. react中data的传递经常是单向的,由上一级组件通过props传给子孙组件. redux的设计结构也是围绕着严格的单项数据流模式. This means that all data in an applicat

Data Flow ->> Multiple Excel Sheet Loaded Into One Table

同个Excel文件中多个Sheet中的数据导入到单张表中,参考了文章:http://www.cnblogs.com/biwork/p/3478778.html 思路: 1) ForEach Loop组件获得Excel文件中的各个Sheet的名字,然后复制给variable 2) Loop里层的Data Flow再读取variable的值来加载数据 需要注意的点: 1) 一般新建一个Excel文件会默认生成3个Sheet,如果你滞留了某个空的Sheet在里面,就会报错 [SSIS.Pipeline