# ch20: TCP Bulk Data Flow

![20.TCP Bulk Data Flow](https://tva1.sinaimg.cn/large/007S8ZIlly1gh85rkghbuj312q0u0gs9.jpg)

## 1. Normal Data Flow

从svr发送8192个字节的数据到bsdi：

![](https://tva1.sinaimg.cn/large/007S8ZIlly1gh97d3bkraj30u0108af1.jpg)

bsdi每次ack都会通知一个win，其中segment 8的win大小是3072，说明还有1024个字节的数据在TCP的缓冲区中，还没有被应用层读取。

### 1.1 Fast Sender, Slow Receiver

![](https://tva1.sinaimg.cn/large/007S8ZIlly1gh97ia30pej30u00uadk8.jpg)

其中segment 9和15都是更新win的大小，叫做window update。

## 2. Sliding Windows

滑动窗口：

![](https://tva1.sinaimg.cn/large/007S8ZIlly1gh97josq3mj315k0euq5n.jpg)

滑动窗口有三种动作：

* close
* open
* shrink

每种动作的含义如下：

![](https://tva1.sinaimg.cn/large/007S8ZIlly1gh97ki77cjj30oc07ywf2.jpg)

## 3. Window Size

窗口大小

默认4096字节，还可以通过设置接收缓存大小来控制窗口大小，因为接收缓存的大小就是滑动窗口的上限。

## 4. PUSH Flag

大多数实现不同通过API来设置这个PUSH标志，而是TCP自己根据情况来设置。

如果待发送数据将清空发送缓存，大多数Berkeley实现会设置PUSH，但是直接忽略掉接收到的PUSH。

当通知窗口大小是0之后，需要额外发送一个ack来更新这个窗口。

当窗口变为两个segment大小或最大窗口的50%时，也会发送一个ack来更新窗口大小。

## 5. Slow Start

慢启动

连接开始后一点点发送数据。

第一次一个数据报，收到ack后，发送两个。

相关的参数是congestion window，即cwnd，以字节为单位，但是增长幅度是segment的大小。

虽然是慢启动，但是是按照指数增长的。

![](https://tva1.sinaimg.cn/large/007S8ZIlly1gh97yz8ip2j30ye0u0wih.jpg)

## 6. Bulk Data Throughput

capacity(bit) = bandwidth(b/s) \* round-trip time(s)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://valineliu.gitbook.io/deuterium-wiki/reading/cs-jing-dian-shu-ji/tcpv1/ch20-tcp-bulk-data-flow.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
