Update 计算机网络 - 传输层.md
重新绘制 UDP 首部、TCP 首部、三次握手、四次挥手、滑动窗口、流量控制与拥塞控制、拥塞窗口变化和快重传的配图,图中使用具体的序号、端口和窗口值;RTT 和 RTO 的公式改为代码块。
|
After Width: | Height: | Size: 195 KiB |
|
After Width: | Height: | Size: 189 KiB |
|
After Width: | Height: | Size: 130 KiB |
|
After Width: | Height: | Size: 134 KiB |
|
After Width: | Height: | Size: 185 KiB |
|
After Width: | Height: | Size: 209 KiB |
|
After Width: | Height: | Size: 206 KiB |
|
After Width: | Height: | Size: 154 KiB |
@@ -25,13 +25,13 @@
|
||||
|
||||
## UDP 首部格式
|
||||
|
||||
<div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/d4c3a4a1-0846-46ec-9cc3-eaddfca71254.jpg" width="600"/> </div><br>
|
||||
<div align="center"> <img src="pics/udp-header.png" width="600px"/> </div><br>
|
||||
|
||||
首部字段只有 8 个字节,包括源端口、目的端口、长度、检验和。12 字节的伪首部是为了计算检验和临时添加的。
|
||||
|
||||
## TCP 首部格式
|
||||
|
||||
<div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/55dc4e84-573d-4c13-a765-52ed1dd251f9.png" width="700"/> </div><br>
|
||||
<div align="center"> <img src="pics/tcp-header.png" width="720px"/> </div><br>
|
||||
|
||||
- **序号** :用于对字节流进行编号,例如序号为 301,表示第一个字节的编号为 301,如果携带的数据长度为 100 字节,那么下一个报文段的序号应为 401。
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
|
||||
## TCP 的三次握手
|
||||
|
||||
<div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/e92d0ebc-7d46-413b-aec1-34a39602f787.png" width="600"/> </div><br>
|
||||
<div align="center"> <img src="pics/tcp-handshake.png" width="600px"/> </div><br>
|
||||
|
||||
假设 A 为客户端,B 为服务器端。
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
|
||||
## TCP 的四次挥手
|
||||
|
||||
<div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/f87afe72-c2df-4c12-ac03-9b8d581a8af8.jpg" width="600"/> </div><br>
|
||||
<div align="center"> <img src="pics/tcp-teardown.png" width="640px"/> </div><br>
|
||||
|
||||
以下描述不讨论序号和确认号,因为序号和确认号的规则比较简单。并且不讨论 ACK,因为 ACK 在连接建立之后都为 1。
|
||||
|
||||
@@ -103,12 +103,18 @@ TCP 使用超时重传来实现可靠传输:如果一个已经发送的报文
|
||||
|
||||
一个报文段从发送再到接收到确认所经过的时间称为往返时间 RTT,加权平均往返时间 RTTs 计算如下:
|
||||
|
||||
<div align="center"><img src="https://latex.codecogs.com/gif.latex?RTTs=(1-a)*(RTTs)+a*RTT" class="mathjax-pic"/></div> <br>
|
||||
```text
|
||||
RTTs = (1 - a) × RTTs + a × RTT
|
||||
```
|
||||
|
||||
其中,0 ≤ a < 1,RTTs 随着 a 的增加更容易受到 RTT 的影响。
|
||||
|
||||
超时时间 RTO 应该略大于 RTTs,TCP 使用的超时时间计算如下:
|
||||
|
||||
<div align="center"><img src="https://latex.codecogs.com/gif.latex?RTO=RTTs+4*RTT_d" class="mathjax-pic"/></div> <br>
|
||||
```text
|
||||
RTO = RTTs + 4 × RTTd
|
||||
```
|
||||
|
||||
其中 RTT<sub>d</sub> 为偏差的加权平均值。
|
||||
|
||||
## TCP 滑动窗口
|
||||
@@ -117,9 +123,9 @@ TCP 使用超时重传来实现可靠传输:如果一个已经发送的报文
|
||||
|
||||
发送窗口内的字节都允许被发送,接收窗口内的字节都允许被接收。如果发送窗口左部的字节已经发送并且收到了确认,那么就将发送窗口向右滑动一定距离,直到左部第一个字节不是已发送并且已确认的状态;接收窗口的滑动类似,接收窗口左部字节已经发送确认并交付主机,就向右滑动接收窗口。
|
||||
|
||||
接收窗口只会对窗口内最后一个按序到达的字节进行确认,例如接收窗口已经收到的字节为 {31, 34, 35},其中 {31} 按序到达,而 {34, 35} 就不是,因此只对字节 31 进行确认。发送方得到一个字节的确认之后,就知道这个字节之前的所有字节都已经被接收。
|
||||
接收窗口只会对窗口内最后一个按序到达的字节进行确认,例如接收窗口已经收到的字节为 {31, 34, 35},其中 {31} 按序到达,而 {34, 35} 就不是,因此只对字节 31 进行确认,确认号为 32。发送方得到一个字节的确认之后,就知道这个字节之前的所有字节都已经被接收。
|
||||
|
||||
<div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/a3253deb-8d21-40a1-aae4-7d178e4aa319.jpg" width="800"/> </div><br>
|
||||
<div align="center"> <img src="pics/tcp-sliding-window.png" width="760px"/> </div><br>
|
||||
|
||||
## TCP 流量控制
|
||||
|
||||
@@ -131,18 +137,18 @@ TCP 使用超时重传来实现可靠传输:如果一个已经发送的报文
|
||||
|
||||
如果网络出现拥塞,分组将会丢失,此时发送方会继续重传,从而导致网络拥塞程度更高。因此当出现拥塞时,应当控制发送方的速率。这一点和流量控制很像,但是出发点不同。流量控制是为了让接收方能来得及接收,而拥塞控制是为了降低整个网络的拥塞程度。
|
||||
|
||||
<div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/51e2ed95-65b8-4ae9-8af3-65602d452a25.jpg" width="500"/> </div><br>
|
||||
<div align="center"> <img src="pics/tcp-flow-vs-congestion.png" width="700px"/> </div><br>
|
||||
|
||||
TCP 主要通过四个算法来进行拥塞控制:慢开始、拥塞避免、快重传、快恢复。
|
||||
|
||||
发送方需要维护一个叫做拥塞窗口(cwnd)的状态变量,注意拥塞窗口与发送方窗口的区别:拥塞窗口只是一个状态变量,实际决定发送方能发送多少数据的是发送方窗口。
|
||||
发送方需要维护一个叫做拥塞窗口(cwnd)的状态变量,注意拥塞窗口与发送方窗口的区别:拥塞窗口只是一个状态变量,实际决定发送方能发送多少数据的是发送方窗口,它取拥塞窗口和接收方通告的窗口中的较小值。
|
||||
|
||||
为了便于讨论,做如下假设:
|
||||
|
||||
- 接收方有足够大的接收缓存,因此不会发生流量控制;
|
||||
- 虽然 TCP 的窗口基于字节,但是这里设窗口的大小单位为报文段。
|
||||
|
||||
<div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/910f613f-514f-4534-87dd-9b4699d59d31.png" width="800"/> </div><br>
|
||||
<div align="center"> <img src="pics/tcp-cwnd.png" width="760px"/> </div><br>
|
||||
|
||||
### 1. 慢开始与拥塞避免
|
||||
|
||||
@@ -164,4 +170,4 @@ TCP 主要通过四个算法来进行拥塞控制:慢开始、拥塞避免、
|
||||
|
||||
慢开始和快恢复的快慢指的是 cwnd 的设定值,而不是 cwnd 的增长速率。慢开始 cwnd 设定为 1,而快恢复 cwnd 设定为 ssthresh。
|
||||
|
||||
<div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/f61b5419-c94a-4df1-8d4d-aed9ae8cc6d5.png" width="600"/> </div><br>
|
||||
<div align="center"> <img src="pics/tcp-fast-retransmit.png" width="620px"/> </div><br>
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="760" height="420" viewBox="0 0 760 420">
|
||||
<style>
|
||||
text { font-family: "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif; fill: #3F3F3F; font-size: 12px; }
|
||||
.title { font-weight: bold; font-size: 15px; fill: #333; text-anchor: middle; }
|
||||
.b { font-weight: bold; }
|
||||
.c { text-anchor: middle; }
|
||||
.e { text-anchor: end; }
|
||||
.note { fill: #C0605A; }
|
||||
.ok { fill: #6A9F68; }
|
||||
.sub { font-size: 11px; fill: #6E6E6E; }
|
||||
.mono { font-family: Menlo, Consolas, monospace; }
|
||||
.arrow { stroke: #555; stroke-width: 1.1; fill: none; marker-end: url(#a); }
|
||||
.red { stroke: #C0605A; marker-end: url(#r); }
|
||||
.green { stroke: #6A9F68; marker-end: url(#g); }
|
||||
.dash { stroke-dasharray: 5 4; }
|
||||
.line { stroke: #555; stroke-width: 1.1; fill: none; }
|
||||
.frame { fill: none; stroke: #999; stroke-width: 1; stroke-dasharray: 4 3; }
|
||||
.shadow { fill: #DADADA; }
|
||||
</style>
|
||||
<defs>
|
||||
<marker id="a" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#555"/>
|
||||
</marker>
|
||||
<marker id="r" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#C0605A"/>
|
||||
</marker>
|
||||
<marker id="g" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#6A9F68"/>
|
||||
</marker>
|
||||
</defs>
|
||||
<rect width="100%" height="100%" fill="#FFFFFF"/>
|
||||
|
||||
<text x="380" y="28" class="title">拥塞窗口的变化:初始 ssthresh = 8,窗口单位为报文段</text>
|
||||
<line x1="80" y1="340" x2="740" y2="340" class="line"/>
|
||||
<line x1="80" y1="340" x2="80" y2="80" class="line"/>
|
||||
<text x="70" y="70" class="sub">cwnd</text>
|
||||
<text x="72" y="344" class="sub e mono">0</text>
|
||||
<text x="72" y="304" class="sub e mono">2</text>
|
||||
<line x1="80" y1="300" x2="740" y2="300" stroke="#F0F0F0" stroke-width="1"/>
|
||||
<text x="72" y="264" class="sub e mono">4</text>
|
||||
<line x1="80" y1="260" x2="740" y2="260" stroke="#F0F0F0" stroke-width="1"/>
|
||||
<text x="72" y="224" class="sub e mono">6</text>
|
||||
<line x1="80" y1="220" x2="740" y2="220" stroke="#F0F0F0" stroke-width="1"/>
|
||||
<text x="72" y="184" class="sub e mono">8</text>
|
||||
<line x1="80" y1="180" x2="740" y2="180" stroke="#F0F0F0" stroke-width="1"/>
|
||||
<text x="72" y="144" class="sub e mono">10</text>
|
||||
<line x1="80" y1="140" x2="740" y2="140" stroke="#F0F0F0" stroke-width="1"/>
|
||||
<text x="72" y="104" class="sub e mono">12</text>
|
||||
<line x1="80" y1="100" x2="740" y2="100" stroke="#F0F0F0" stroke-width="1"/>
|
||||
<text x="96" y="358" class="c sub mono">0</text>
|
||||
<text x="128" y="358" class="c sub mono">1</text>
|
||||
<text x="160" y="358" class="c sub mono">2</text>
|
||||
<text x="192" y="358" class="c sub mono">3</text>
|
||||
<text x="224" y="358" class="c sub mono">4</text>
|
||||
<text x="256" y="358" class="c sub mono">5</text>
|
||||
<text x="288" y="358" class="c sub mono">6</text>
|
||||
<text x="320" y="358" class="c sub mono">7</text>
|
||||
<text x="352" y="358" class="c sub mono">8</text>
|
||||
<text x="384" y="358" class="c sub mono">9</text>
|
||||
<text x="416" y="358" class="c sub mono">10</text>
|
||||
<text x="448" y="358" class="c sub mono">11</text>
|
||||
<text x="480" y="358" class="c sub mono">12</text>
|
||||
<text x="512" y="358" class="c sub mono">13</text>
|
||||
<text x="544" y="358" class="c sub mono">14</text>
|
||||
<text x="576" y="358" class="c sub mono">15</text>
|
||||
<text x="608" y="358" class="c sub mono">16</text>
|
||||
<text x="640" y="358" class="c sub mono">17</text>
|
||||
<text x="672" y="358" class="c sub mono">18</text>
|
||||
<text x="704" y="358" class="c sub mono">19</text>
|
||||
<text x="740" y="376" class="sub e">传输轮次</text>
|
||||
<line x1="86" y1="180" x2="330" y2="180" stroke="#C0605A" stroke-width="1" stroke-dasharray="4 3" opacity="0.7"/>
|
||||
<line x1="342" y1="220" x2="586" y2="220" stroke="#C0605A" stroke-width="1" stroke-dasharray="4 3" opacity="0.7"/>
|
||||
<line x1="598" y1="240" x2="714" y2="240" stroke="#C0605A" stroke-width="1" stroke-dasharray="4 3" opacity="0.7"/>
|
||||
<text x="86" y="174" class="sub note">ssthresh = 8</text>
|
||||
<text x="342" y="214" class="sub note">ssthresh = 6</text>
|
||||
<text x="714" y="256" class="sub note e">ssthresh = 5</text>
|
||||
<polyline points="96,320 128,300 160,260 192,180 224,160 256,140 288,120 320,100" fill="none" stroke="#7FB2D6" stroke-width="2"/>
|
||||
<polyline points="352,320 384,300 416,260 448,220 480,200 512,180 544,160 576,140" fill="none" stroke="#7FB2D6" stroke-width="2"/>
|
||||
<polyline points="608,240 640,220 672,200 704,180" fill="none" stroke="#7FB2D6" stroke-width="2"/>
|
||||
<line x1="320" y1="100" x2="352" y2="320" stroke="#C0605A" stroke-width="1.5" stroke-dasharray="5 3"/>
|
||||
<line x1="576" y1="140" x2="608" y2="240" stroke="#C0605A" stroke-width="1.5" stroke-dasharray="5 3"/>
|
||||
<circle cx="96" cy="320" r="4" fill="#C6ECE9" stroke="#7DBCB7" stroke-width="1.2"/>
|
||||
<circle cx="128" cy="300" r="4" fill="#C6ECE9" stroke="#7DBCB7" stroke-width="1.2"/>
|
||||
<circle cx="160" cy="260" r="4" fill="#C6ECE9" stroke="#7DBCB7" stroke-width="1.2"/>
|
||||
<circle cx="192" cy="180" r="4" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
|
||||
<circle cx="224" cy="160" r="4" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
|
||||
<circle cx="256" cy="140" r="4" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
|
||||
<circle cx="288" cy="120" r="4" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
|
||||
<circle cx="320" cy="100" r="4" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
|
||||
<circle cx="352" cy="320" r="4" fill="#C6ECE9" stroke="#7DBCB7" stroke-width="1.2"/>
|
||||
<circle cx="384" cy="300" r="4" fill="#C6ECE9" stroke="#7DBCB7" stroke-width="1.2"/>
|
||||
<circle cx="416" cy="260" r="4" fill="#C6ECE9" stroke="#7DBCB7" stroke-width="1.2"/>
|
||||
<circle cx="448" cy="220" r="4" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
|
||||
<circle cx="480" cy="200" r="4" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
|
||||
<circle cx="512" cy="180" r="4" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
|
||||
<circle cx="544" cy="160" r="4" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
|
||||
<circle cx="576" cy="140" r="4" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
|
||||
<circle cx="608" cy="240" r="4" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
|
||||
<circle cx="640" cy="220" r="4" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
|
||||
<circle cx="672" cy="200" r="4" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
|
||||
<circle cx="704" cy="180" r="4" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
|
||||
<circle cx="192" cy="180" r="7" fill="none" stroke="#9F94D5" stroke-width="1.5"/>
|
||||
<line x1="198" y1="185" x2="206" y2="218" stroke="#BBB" stroke-width="1"/>
|
||||
<text x="210" y="214" class="sub" style="fill:#555">① cwnd 达到 ssthresh,</text>
|
||||
<text x="210" y="229" class="sub" style="fill:#555">改为每轮加 1</text>
|
||||
<circle cx="320" cy="100" r="7" fill="none" stroke="#9F94D5" stroke-width="1.5"/>
|
||||
<line x1="326" y1="95" x2="334" y2="60" stroke="#BBB" stroke-width="1"/>
|
||||
<text x="338" y="56" class="sub" style="fill:#555">② 超时:ssthresh = 12 / 2 = 6,</text>
|
||||
<text x="338" y="71" class="sub" style="fill:#555">cwnd 从 1 重新慢开始</text>
|
||||
<circle cx="448" cy="220" r="7" fill="none" stroke="#9F94D5" stroke-width="1.5"/>
|
||||
<line x1="454" y1="225" x2="462" y2="254" stroke="#BBB" stroke-width="1"/>
|
||||
<text x="466" y="250" class="sub" style="fill:#555">③ 4 翻倍会超过 6,</text>
|
||||
<text x="466" y="265" class="sub" style="fill:#555">只增大到 ssthresh</text>
|
||||
<circle cx="576" cy="140" r="7" fill="none" stroke="#9F94D5" stroke-width="1.5"/>
|
||||
<line x1="570" y1="135" x2="562" y2="104" stroke="#BBB" stroke-width="1"/>
|
||||
<text x="558" y="100" class="sub e" style="fill:#555">④ 3 个重复确认:</text>
|
||||
<text x="558" y="115" class="sub e" style="fill:#555">ssthresh = 10 / 2 = 5,cwnd = 5</text>
|
||||
<text x="128" y="280" class="c sub" style="fill:#207773">慢开始</text>
|
||||
<text x="390" y="268" class="c sub" style="fill:#207773">慢开始</text>
|
||||
<text x="256" y="108" class="c sub" style="fill:#296898">拥塞避免</text>
|
||||
<text x="531.2" y="200" class="c sub" style="fill:#296898">拥塞避免</text>
|
||||
<text x="656" y="168" class="c sub" style="fill:#296898">快恢复后拥塞避免</text>
|
||||
<text x="40" y="404" class="sub">浅青色点处于慢开始(cwnd < ssthresh),每轮翻倍;浅蓝色点处于拥塞避免,每轮加 1。</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 8.4 KiB |
@@ -0,0 +1,75 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="620" height="530" viewBox="0 0 620 530">
|
||||
<style>
|
||||
text { font-family: "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif; fill: #3F3F3F; font-size: 12px; }
|
||||
.title { font-weight: bold; font-size: 15px; fill: #333; text-anchor: middle; }
|
||||
.b { font-weight: bold; }
|
||||
.c { text-anchor: middle; }
|
||||
.e { text-anchor: end; }
|
||||
.note { fill: #C0605A; }
|
||||
.ok { fill: #6A9F68; }
|
||||
.sub { font-size: 11px; fill: #6E6E6E; }
|
||||
.mono { font-family: Menlo, Consolas, monospace; }
|
||||
.arrow { stroke: #555; stroke-width: 1.1; fill: none; marker-end: url(#a); }
|
||||
.red { stroke: #C0605A; marker-end: url(#r); }
|
||||
.green { stroke: #6A9F68; marker-end: url(#g); }
|
||||
.dash { stroke-dasharray: 5 4; }
|
||||
.line { stroke: #555; stroke-width: 1.1; fill: none; }
|
||||
.frame { fill: none; stroke: #999; stroke-width: 1; stroke-dasharray: 4 3; }
|
||||
.shadow { fill: #DADADA; }
|
||||
</style>
|
||||
<defs>
|
||||
<marker id="a" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#555"/>
|
||||
</marker>
|
||||
<marker id="r" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#C0605A"/>
|
||||
</marker>
|
||||
<marker id="g" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#6A9F68"/>
|
||||
</marker>
|
||||
</defs>
|
||||
<rect width="100%" height="100%" fill="#FFFFFF"/>
|
||||
|
||||
<text x="310" y="28" class="title">快重传:M3 丢失</text>
|
||||
<rect x="130" y="46" width="120" height="34" rx="6" fill="#C6ECE9" stroke="#7DBCB7"/>
|
||||
<text x="190" y="67.5" class="b c">发送方</text>
|
||||
<line x1="190" y1="82" x2="190" y2="470" stroke="#BBB" stroke-width="1" stroke-dasharray="4 4"/>
|
||||
<rect x="390" y="46" width="120" height="34" rx="6" fill="#C6E4FB" stroke="#7FB2D6"/>
|
||||
<text x="450" y="67.5" class="b c">接收方</text>
|
||||
<line x1="450" y1="82" x2="450" y2="470" stroke="#BBB" stroke-width="1" stroke-dasharray="4 4"/>
|
||||
<text x="178" y="100" class="sub e">发送 M1</text>
|
||||
<line x1="190" y1="96" x2="450" y2="126" class="arrow "/>
|
||||
<line x1="450" y1="126" x2="190" y2="156" class="arrow dash"/>
|
||||
<text x="462" y="130" class="sub" style="fill:#555">确认 M1</text>
|
||||
<text x="178" y="140" class="sub e">发送 M2</text>
|
||||
<line x1="190" y1="136" x2="450" y2="166" class="arrow "/>
|
||||
<line x1="450" y1="166" x2="190" y2="196" class="arrow dash"/>
|
||||
<text x="462" y="170" class="sub" style="fill:#555">确认 M2</text>
|
||||
<text x="178" y="180" class="sub e">发送 M3</text>
|
||||
<line x1="190" y1="176" x2="360" y2="195.615" class="arrow "/>
|
||||
<circle cx="372" cy="197" r="8" fill="#F3C6C2" stroke="#D99A94" stroke-width="1.2"/>
|
||||
<path d="M368.4,193.4 L375.6,200.6 M375.6,193.4 L368.4,200.6" stroke="#C0605A" stroke-width="2" stroke-linecap="round"/>
|
||||
<text x="178" y="220" class="sub e">发送 M4</text>
|
||||
<line x1="190" y1="216" x2="450" y2="246" class="arrow "/>
|
||||
<line x1="450" y1="246" x2="190" y2="276" class="arrow dash"/>
|
||||
<text x="462" y="250" class="sub" style="fill:#C0605A">重复确认 M2</text>
|
||||
<text x="178" y="260" class="sub e">发送 M5</text>
|
||||
<line x1="190" y1="256" x2="450" y2="286" class="arrow "/>
|
||||
<line x1="450" y1="286" x2="190" y2="316" class="arrow dash"/>
|
||||
<text x="462" y="290" class="sub" style="fill:#C0605A">重复确认 M2</text>
|
||||
<text x="178" y="300" class="sub e">发送 M6</text>
|
||||
<line x1="190" y1="296" x2="450" y2="326" class="arrow "/>
|
||||
<line x1="450" y1="326" x2="190" y2="356" class="arrow dash"/>
|
||||
<text x="462" y="330" class="sub" style="fill:#C0605A">重复确认 M2</text>
|
||||
<text x="386" y="201" class="sub note">丢失</text>
|
||||
<rect x="20" y="342" width="150" height="50" rx="6" fill="#E6E3FA" stroke="#B8B0DE"/>
|
||||
<text x="95" y="359" class="c sub" style="fill:#555">收到 3 个重复确认,</text>
|
||||
<text x="95" y="376" class="c sub" style="fill:#555">不等超时,立即重传 M3</text>
|
||||
<line x1="190" y1="378" x2="450" y2="408" class="arrow green"/>
|
||||
<text x="220" y="372" class="sub ok">重传 M3</text>
|
||||
<line x1="450" y1="408" x2="190" y2="438" class="arrow dash green"/>
|
||||
<text x="462" y="412" class="sub ok">确认 M6</text>
|
||||
<text x="462" y="428" class="sub">M4~M6 已缓存</text>
|
||||
<text x="30" y="500" class="sub">接收方每收到一个失序的报文段,就重复确认最后一个按序到达的报文段(这里是 M2)。</text>
|
||||
<text x="30" y="518" class="sub">重复确认说明后面的报文段还能到达,网络没有严重拥塞,所以只重传丢失的 M3。</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.6 KiB |
@@ -0,0 +1,91 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="700" height="360" viewBox="0 0 700 360">
|
||||
<style>
|
||||
text { font-family: "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif; fill: #3F3F3F; font-size: 12px; }
|
||||
.title { font-weight: bold; font-size: 15px; fill: #333; text-anchor: middle; }
|
||||
.b { font-weight: bold; }
|
||||
.c { text-anchor: middle; }
|
||||
.e { text-anchor: end; }
|
||||
.note { fill: #C0605A; }
|
||||
.ok { fill: #6A9F68; }
|
||||
.sub { font-size: 11px; fill: #6E6E6E; }
|
||||
.mono { font-family: Menlo, Consolas, monospace; }
|
||||
.arrow { stroke: #555; stroke-width: 1.1; fill: none; marker-end: url(#a); }
|
||||
.red { stroke: #C0605A; marker-end: url(#r); }
|
||||
.green { stroke: #6A9F68; marker-end: url(#g); }
|
||||
.dash { stroke-dasharray: 5 4; }
|
||||
.line { stroke: #555; stroke-width: 1.1; fill: none; }
|
||||
.frame { fill: none; stroke: #999; stroke-width: 1; stroke-dasharray: 4 3; }
|
||||
.shadow { fill: #DADADA; }
|
||||
</style>
|
||||
<defs>
|
||||
<marker id="a" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#555"/>
|
||||
</marker>
|
||||
<marker id="r" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#C0605A"/>
|
||||
</marker>
|
||||
<marker id="g" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#6A9F68"/>
|
||||
</marker>
|
||||
</defs>
|
||||
<rect width="100%" height="100%" fill="#FFFFFF"/>
|
||||
|
||||
<text x="350" y="28" class="title">流量控制与拥塞控制</text>
|
||||
<rect x="55" y="110" width="50" height="13" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
|
||||
<circle cx="62" cy="116.5" r="2" fill="#7FB2D6"/>
|
||||
<line x1="69" y1="116.5" x2="98" y2="116.5" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<rect x="55" y="126" width="50" height="13" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
|
||||
<circle cx="62" cy="132.5" r="2" fill="#7FB2D6"/>
|
||||
<line x1="69" y1="132.5" x2="98" y2="132.5" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<rect x="55" y="142" width="50" height="13" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
|
||||
<circle cx="62" cy="148.5" r="2" fill="#7FB2D6"/>
|
||||
<line x1="69" y1="148.5" x2="98" y2="148.5" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="80" y="176" class="c b">发送方 A</text>
|
||||
<rect x="10" y="196" width="170" height="50" rx="6" fill="#E6E3FA" stroke="#B8B0DE"/>
|
||||
<text x="95" y="219" class="c sub">发送窗口 = min(cwnd, rwnd)</text>
|
||||
<text x="95" y="234" class="sub c">= min(8, 20) = 8 个报文段</text>
|
||||
<rect x="215" y="60" width="280" height="200" rx="8" class="frame"/>
|
||||
<text x="225" y="78" class="b">网络</text>
|
||||
<rect x="235" y="116" width="120" height="26" rx="13" fill="#FFFFFF" stroke="#BBBBBB" stroke-width="1.2"/>
|
||||
<rect x="245" y="120" width="22" height="18" rx="3" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1.2"/>
|
||||
<text x="256" y="133" class="c sub"></text>
|
||||
<rect x="271" y="120" width="22" height="18" rx="3" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1.2"/>
|
||||
<text x="282" y="133" class="c sub"></text>
|
||||
<rect x="297" y="120" width="22" height="18" rx="3" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1.2"/>
|
||||
<text x="308" y="133" class="c sub"></text>
|
||||
<rect x="323" y="120" width="22" height="18" rx="3" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1.2"/>
|
||||
<text x="334" y="133" class="c sub"></text>
|
||||
<text x="295" y="106" class="c sub">路由器缓存已满</text>
|
||||
<circle cx="372" cy="129" r="9" fill="#F3C6C2" stroke="#D99A94" stroke-width="1.2"/>
|
||||
<path d="M367.95,124.95 L376.05,133.05 M376.05,124.95 L367.95,133.05" stroke="#C0605A" stroke-width="2" stroke-linecap="round"/>
|
||||
<text x="386" y="133" class="sub note">丢包</text>
|
||||
<rect x="395" y="164" width="80" height="24" rx="12" fill="#FFFFFF" stroke="#BBBBBB" stroke-width="1.2"/>
|
||||
<rect x="405" y="168" width="17.3333" height="16" rx="3" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1.2"/>
|
||||
<text x="413.667" y="180" class="c sub"></text>
|
||||
<rect x="426.333" y="168" width="17.3333" height="16" rx="3" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1.2"/>
|
||||
<text x="435" y="180" class="c sub"></text>
|
||||
<rect x="447.667" y="168" width="17.3333" height="16" rx="3" fill="none" stroke="#CCC" stroke-dasharray="3 2"/>
|
||||
<line x1="108" y1="130" x2="232" y2="129" class="arrow "/>
|
||||
<line x1="355" y1="146" x2="405" y2="162" class="arrow "/>
|
||||
<line x1="478" y1="176" x2="588" y2="150" class="arrow "/>
|
||||
<text x="232" y="218" class="sub note">拥塞控制:A 根据超时和重复确认</text>
|
||||
<text x="232" y="236" class="sub note">推测网络拥塞,自己维护 cwnd</text>
|
||||
<path d="M226,222 C205,222 200,221 184,221" class="arrow dash red"/>
|
||||
<rect x="595" y="110" width="50" height="13" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
|
||||
<circle cx="602" cy="116.5" r="2" fill="#7FB2D6"/>
|
||||
<line x1="609" y1="116.5" x2="638" y2="116.5" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<rect x="595" y="126" width="50" height="13" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
|
||||
<circle cx="602" cy="132.5" r="2" fill="#7FB2D6"/>
|
||||
<line x1="609" y1="132.5" x2="638" y2="132.5" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<rect x="595" y="142" width="50" height="13" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
|
||||
<circle cx="602" cy="148.5" r="2" fill="#7FB2D6"/>
|
||||
<line x1="609" y1="148.5" x2="638" y2="148.5" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="620" y="176" class="c b">接收方 B</text>
|
||||
<text x="620" y="194" class="c sub">还能接收 20 个报文段</text>
|
||||
<rect x="290" y="290" width="210" height="30" rx="3" fill="#FFFFFF" stroke="#BBBBBB" stroke-width="1.2"/>
|
||||
<path d="M290,291 L304,301 L318,291" fill="none" stroke="#BBBBBB" stroke-width="1"/>
|
||||
<text x="324" y="309" class="sub mono">ACK,窗口 rwnd = 20</text>
|
||||
<path d="M620,204 V305 H504" class="arrow"/>
|
||||
<path d="M286,305 H95 V250" class="arrow"/>
|
||||
<text x="290" y="342" class="sub">流量控制:rwnd 由接收方在确认中告知,保证接收方来得及接收</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 6.0 KiB |
@@ -0,0 +1,62 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="600" height="410" viewBox="0 0 600 410">
|
||||
<style>
|
||||
text { font-family: "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif; fill: #3F3F3F; font-size: 12px; }
|
||||
.title { font-weight: bold; font-size: 15px; fill: #333; text-anchor: middle; }
|
||||
.b { font-weight: bold; }
|
||||
.c { text-anchor: middle; }
|
||||
.e { text-anchor: end; }
|
||||
.note { fill: #C0605A; }
|
||||
.ok { fill: #6A9F68; }
|
||||
.sub { font-size: 11px; fill: #6E6E6E; }
|
||||
.mono { font-family: Menlo, Consolas, monospace; }
|
||||
.arrow { stroke: #555; stroke-width: 1.1; fill: none; marker-end: url(#a); }
|
||||
.red { stroke: #C0605A; marker-end: url(#r); }
|
||||
.green { stroke: #6A9F68; marker-end: url(#g); }
|
||||
.dash { stroke-dasharray: 5 4; }
|
||||
.line { stroke: #555; stroke-width: 1.1; fill: none; }
|
||||
.frame { fill: none; stroke: #999; stroke-width: 1; stroke-dasharray: 4 3; }
|
||||
.shadow { fill: #DADADA; }
|
||||
</style>
|
||||
<defs>
|
||||
<marker id="a" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#555"/>
|
||||
</marker>
|
||||
<marker id="r" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#C0605A"/>
|
||||
</marker>
|
||||
<marker id="g" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#6A9F68"/>
|
||||
</marker>
|
||||
</defs>
|
||||
<rect width="100%" height="100%" fill="#FFFFFF"/>
|
||||
|
||||
<text x="300" y="28" class="title">TCP 三次握手</text>
|
||||
<rect x="110" y="46" width="120" height="34" rx="6" fill="#C6ECE9" stroke="#7DBCB7"/>
|
||||
<text x="170" y="67.5" class="b c">客户端 A</text>
|
||||
<line x1="170" y1="82" x2="170" y2="350" stroke="#BBB" stroke-width="1" stroke-dasharray="4 4"/>
|
||||
<rect x="370" y="46" width="120" height="34" rx="6" fill="#C6E4FB" stroke="#7FB2D6"/>
|
||||
<text x="430" y="67.5" class="b c">服务器 B</text>
|
||||
<line x1="430" y1="82" x2="430" y2="350" stroke="#BBB" stroke-width="1" stroke-dasharray="4 4"/>
|
||||
<rect x="99.6" y="92" width="58.4" height="20" rx="4" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1"/>
|
||||
<text x="128.8" y="106" class="c sub mono" style="fill:#555">CLOSED</text>
|
||||
<rect x="442" y="92" width="58.4" height="20" rx="4" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1"/>
|
||||
<text x="471.2" y="106" class="c sub mono" style="fill:#555">LISTEN</text>
|
||||
<line x1="170" y1="124" x2="430" y2="164" class="arrow "/>
|
||||
<text x="300" y="137" class="c sub mono" transform="rotate(8.75 300 144)" style="fill:#555">SYN=1, seq=1000</text>
|
||||
<rect x="84.8" y="124" width="73.2" height="20" rx="4" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1"/>
|
||||
<text x="121.4" y="138" class="c sub mono" style="fill:#555">SYN-SENT</text>
|
||||
<rect x="442" y="158" width="73.2" height="20" rx="4" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1"/>
|
||||
<text x="478.6" y="172" class="c sub mono" style="fill:#555">SYN-RCVD</text>
|
||||
<line x1="430" y1="184" x2="170" y2="224" class="arrow "/>
|
||||
<text x="300" y="197" class="c sub mono" transform="rotate(-8.75 300 204)" style="fill:#555">SYN=1, ACK=1, seq=5000, ack=1001</text>
|
||||
<rect x="62.6" y="218" width="95.4" height="20" rx="4" fill="#C6ECE9" stroke="#7DBCB7" stroke-width="1"/>
|
||||
<text x="110.3" y="232" class="c sub mono" style="fill:#555">ESTABLISHED</text>
|
||||
<line x1="170" y1="244" x2="430" y2="284" class="arrow "/>
|
||||
<text x="300" y="257" class="c sub mono" transform="rotate(8.75 300 264)" style="fill:#555">ACK=1, seq=1001, ack=5001</text>
|
||||
<rect x="442" y="278" width="95.4" height="20" rx="4" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="489.7" y="292" class="c sub mono" style="fill:#555">ESTABLISHED</text>
|
||||
<line x1="176" y1="318" x2="424" y2="318" class="arrow" marker-start="url(#a)"/>
|
||||
<text x="300" y="310" class="c sub">开始传输数据</text>
|
||||
<text x="40" y="380" class="sub">A 的初始序号 x = 1000,B 的初始序号 y = 5000。</text>
|
||||
<text x="40" y="398" class="sub">SYN 不携带数据也要占用一个序号,所以确认号分别是 x + 1 = 1001 和 y + 1 = 5001。</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.1 KiB |
@@ -0,0 +1,97 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="720" height="440" viewBox="0 0 720 440">
|
||||
<style>
|
||||
text { font-family: "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif; fill: #3F3F3F; font-size: 12px; }
|
||||
.title { font-weight: bold; font-size: 15px; fill: #333; text-anchor: middle; }
|
||||
.b { font-weight: bold; }
|
||||
.c { text-anchor: middle; }
|
||||
.e { text-anchor: end; }
|
||||
.note { fill: #C0605A; }
|
||||
.ok { fill: #6A9F68; }
|
||||
.sub { font-size: 11px; fill: #6E6E6E; }
|
||||
.mono { font-family: Menlo, Consolas, monospace; }
|
||||
.arrow { stroke: #555; stroke-width: 1.1; fill: none; marker-end: url(#a); }
|
||||
.red { stroke: #C0605A; marker-end: url(#r); }
|
||||
.green { stroke: #6A9F68; marker-end: url(#g); }
|
||||
.dash { stroke-dasharray: 5 4; }
|
||||
.line { stroke: #555; stroke-width: 1.1; fill: none; }
|
||||
.frame { fill: none; stroke: #999; stroke-width: 1; stroke-dasharray: 4 3; }
|
||||
.shadow { fill: #DADADA; }
|
||||
</style>
|
||||
<defs>
|
||||
<marker id="a" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#555"/>
|
||||
</marker>
|
||||
<marker id="r" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#C0605A"/>
|
||||
</marker>
|
||||
<marker id="g" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#6A9F68"/>
|
||||
</marker>
|
||||
</defs>
|
||||
<rect width="100%" height="100%" fill="#FFFFFF"/>
|
||||
|
||||
<text x="360" y="28" class="title">TCP 首部</text>
|
||||
<text x="43" y="60" class="sub mono">0</text>
|
||||
<text x="277" y="60" class="sub mono e">15</text>
|
||||
<text x="283" y="60" class="sub mono">16</text>
|
||||
<text x="517" y="60" class="sub mono e">31</text>
|
||||
<rect x="40" y="68" width="240" height="40" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="160" y="85" class="c">源端口</text>
|
||||
<text x="160" y="101" class="c sub">16 位</text>
|
||||
<rect x="280" y="68" width="240" height="40" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="400" y="85" class="c">目的端口</text>
|
||||
<text x="400" y="101" class="c sub">16 位</text>
|
||||
<rect x="40" y="108" width="480" height="40" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="280" y="125" class="c">序号</text>
|
||||
<text x="280" y="141" class="c sub">本报文段数据第一个字节的编号</text>
|
||||
<rect x="40" y="148" width="480" height="40" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="280" y="165" class="c">确认号</text>
|
||||
<text x="280" y="181" class="c sub">期望收到的下一个字节的编号</text>
|
||||
<rect x="40" y="188" width="60" height="40" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="70" y="205" class="c">数据偏移</text>
|
||||
<text x="70" y="221" class="c sub">4 位</text>
|
||||
<rect x="100" y="188" width="60" height="40" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="130" y="205" class="c">保留</text>
|
||||
<text x="130" y="221" class="c sub">4 位</text>
|
||||
<rect x="160" y="188" width="15" height="40" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="167.5" y="213" class="c sub mono" style="fill:#555">C</text>
|
||||
<rect x="175" y="188" width="15" height="40" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="182.5" y="213" class="c sub mono" style="fill:#555">E</text>
|
||||
<rect x="190" y="188" width="15" height="40" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="197.5" y="213" class="c sub mono" style="fill:#555">U</text>
|
||||
<rect x="205" y="188" width="15" height="40" fill="#E6E3FA" stroke="#B8B0DE" stroke-width="1"/>
|
||||
<text x="212.5" y="213" class="c sub mono" style="fill:#555">A</text>
|
||||
<rect x="220" y="188" width="15" height="40" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="227.5" y="213" class="c sub mono" style="fill:#555">P</text>
|
||||
<rect x="235" y="188" width="15" height="40" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="242.5" y="213" class="c sub mono" style="fill:#555">R</text>
|
||||
<rect x="250" y="188" width="15" height="40" fill="#E6E3FA" stroke="#B8B0DE" stroke-width="1"/>
|
||||
<text x="257.5" y="213" class="c sub mono" style="fill:#555">S</text>
|
||||
<rect x="265" y="188" width="15" height="40" fill="#E6E3FA" stroke="#B8B0DE" stroke-width="1"/>
|
||||
<text x="272.5" y="213" class="c sub mono" style="fill:#555">F</text>
|
||||
<rect x="280" y="188" width="240" height="40" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="400" y="205" class="c">窗口</text>
|
||||
<text x="400" y="221" class="c sub">16 位</text>
|
||||
<rect x="40" y="228" width="240" height="40" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="160" y="245" class="c">检验和</text>
|
||||
<text x="160" y="261" class="c sub">16 位</text>
|
||||
<rect x="280" y="228" width="240" height="40" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="400" y="245" class="c">紧急指针</text>
|
||||
<text x="400" y="261" class="c sub">16 位</text>
|
||||
<rect x="40" y="268" width="360" height="40" fill="#FFFFFF" stroke="#BBBBBB" stroke-width="1"/>
|
||||
<text x="220" y="285" class="c">选项</text>
|
||||
<text x="220" y="301" class="c sub mono">长度可变</text>
|
||||
<rect x="400" y="268" width="120" height="40" fill="#FFFFFF" stroke="#BBBBBB" stroke-width="1"/>
|
||||
<text x="460" y="285" class="c">填充</text>
|
||||
<text x="460" y="301" class="c sub">补齐 4 字节</text>
|
||||
<rect x="40" y="308" width="480" height="40" fill="#FFFFFF" stroke="#BBBBBB" stroke-width="1"/>
|
||||
<text x="280" y="332.5" class="c sub">数据(可以没有)</text>
|
||||
<path d="M534,70 q8,0 8,10 V160.0 q0,8 8,8 q-8,0 -8,8 V256 q0,10 -8,10" class="line"/>
|
||||
<text x="556" y="172" class="b">固定 20 字节</text>
|
||||
<path d="M534,270 q8,0 8,8 V282.0 q0,6 6,6 q-6,0 -6,6 V298 q0,8 -8,8" class="line"/>
|
||||
<text x="556" y="288" class="sub">0~40 字节,例如 MSS、</text>
|
||||
<text x="556" y="304" class="sub">窗口扩大、SACK、时间戳</text>
|
||||
<text x="40" y="374" class="sub">标志位:URG 紧急,ACK 确认,PSH 推送,RST 复位连接,SYN 建立连接,FIN 释放连接;</text>
|
||||
<text x="40" y="392" class="sub">CWR、ECE 用于显式拥塞通知(ECN)。淡紫色是正文介绍的 ACK、SYN、FIN。</text>
|
||||
<text x="40" y="418" class="sub">数据偏移以 4 字节为单位:5 表示首部 20 字节,最大值 15 表示 60 字节。</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 6.3 KiB |
@@ -0,0 +1,167 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="760" height="470" viewBox="0 0 760 470">
|
||||
<style>
|
||||
text { font-family: "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif; fill: #3F3F3F; font-size: 12px; }
|
||||
.title { font-weight: bold; font-size: 15px; fill: #333; text-anchor: middle; }
|
||||
.b { font-weight: bold; }
|
||||
.c { text-anchor: middle; }
|
||||
.e { text-anchor: end; }
|
||||
.note { fill: #C0605A; }
|
||||
.ok { fill: #6A9F68; }
|
||||
.sub { font-size: 11px; fill: #6E6E6E; }
|
||||
.mono { font-family: Menlo, Consolas, monospace; }
|
||||
.arrow { stroke: #555; stroke-width: 1.1; fill: none; marker-end: url(#a); }
|
||||
.red { stroke: #C0605A; marker-end: url(#r); }
|
||||
.green { stroke: #6A9F68; marker-end: url(#g); }
|
||||
.dash { stroke-dasharray: 5 4; }
|
||||
.line { stroke: #555; stroke-width: 1.1; fill: none; }
|
||||
.frame { fill: none; stroke: #999; stroke-width: 1; stroke-dasharray: 4 3; }
|
||||
.shadow { fill: #DADADA; }
|
||||
</style>
|
||||
<defs>
|
||||
<marker id="a" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#555"/>
|
||||
</marker>
|
||||
<marker id="r" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#C0605A"/>
|
||||
</marker>
|
||||
<marker id="g" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#6A9F68"/>
|
||||
</marker>
|
||||
</defs>
|
||||
<rect width="100%" height="100%" fill="#FFFFFF"/>
|
||||
|
||||
<text x="380" y="28" class="title">滑动窗口:A 发送了 31~36,B 收到 31、34、35</text>
|
||||
<text x="20" y="96" class="b">① A 发送</text>
|
||||
<text x="20" y="112" class="sub">31~36</text>
|
||||
<rect x="121" y="84" width="32" height="30" rx="3" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1"/>
|
||||
<text x="137" y="103" class="c sub mono" style="fill:#888">28</text>
|
||||
<rect x="155" y="84" width="32" height="30" rx="3" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1"/>
|
||||
<text x="171" y="103" class="c sub mono" style="fill:#888">29</text>
|
||||
<rect x="189" y="84" width="32" height="30" rx="3" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1"/>
|
||||
<text x="205" y="103" class="c sub mono" style="fill:#888">30</text>
|
||||
<rect x="223" y="84" width="32" height="30" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="239" y="103" class="c sub mono" style="fill:#555">31</text>
|
||||
<rect x="257" y="84" width="32" height="30" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="273" y="103" class="c sub mono" style="fill:#555">32</text>
|
||||
<rect x="291" y="84" width="32" height="30" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="307" y="103" class="c sub mono" style="fill:#555">33</text>
|
||||
<rect x="325" y="84" width="32" height="30" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="341" y="103" class="c sub mono" style="fill:#555">34</text>
|
||||
<rect x="359" y="84" width="32" height="30" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="375" y="103" class="c sub mono" style="fill:#555">35</text>
|
||||
<rect x="393" y="84" width="32" height="30" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="409" y="103" class="c sub mono" style="fill:#555">36</text>
|
||||
<rect x="427" y="84" width="32" height="30" rx="3" fill="#FFFFFF" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="443" y="103" class="c sub mono" style="fill:#555">37</text>
|
||||
<rect x="461" y="84" width="32" height="30" rx="3" fill="#FFFFFF" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="477" y="103" class="c sub mono" style="fill:#555">38</text>
|
||||
<rect x="495" y="84" width="32" height="30" rx="3" fill="#FFFFFF" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="511" y="103" class="c sub mono" style="fill:#555">39</text>
|
||||
<rect x="529" y="84" width="32" height="30" rx="3" fill="#FFFFFF" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="545" y="103" class="c sub mono" style="fill:#555">40</text>
|
||||
<rect x="563" y="84" width="32" height="30" rx="3" fill="#FFFFFF" stroke="#DDDDDD" stroke-width="1"/>
|
||||
<text x="579" y="103" class="c sub mono" style="fill:#BBB">41</text>
|
||||
<rect x="597" y="84" width="32" height="30" rx="3" fill="#FFFFFF" stroke="#DDDDDD" stroke-width="1"/>
|
||||
<text x="613" y="103" class="c sub mono" style="fill:#BBB">42</text>
|
||||
<rect x="631" y="84" width="32" height="30" rx="3" fill="#FFFFFF" stroke="#DDDDDD" stroke-width="1"/>
|
||||
<text x="647" y="103" class="c sub mono" style="fill:#BBB">43</text>
|
||||
<rect x="665" y="84" width="32" height="30" rx="3" fill="#FFFFFF" stroke="#DDDDDD" stroke-width="1"/>
|
||||
<text x="681" y="103" class="c sub mono" style="fill:#BBB">44</text>
|
||||
<rect x="699" y="84" width="32" height="30" rx="3" fill="#FFFFFF" stroke="#DDDDDD" stroke-width="1"/>
|
||||
<text x="715" y="103" class="c sub mono" style="fill:#BBB">45</text>
|
||||
<rect x="220" y="78" width="344" height="42" rx="5" fill="none" stroke="#B8B0DE" stroke-width="2"/>
|
||||
<text x="392" y="72" class="c sub" style="fill:#766AA8">A 的发送窗口 10 字节:31~40</text>
|
||||
<text x="222" y="136" class="sub" style="fill:#555">31~36 已发送,等待确认;37~40 还可以发送</text>
|
||||
<text x="20" y="212" class="b">② B 收到</text>
|
||||
<text x="20" y="228" class="sub">31、34、35</text>
|
||||
<rect x="121" y="200" width="32" height="30" rx="3" fill="#C6ECE9" stroke="#7DBCB7" stroke-width="1"/>
|
||||
<text x="137" y="219" class="c sub mono" style="fill:#555">28</text>
|
||||
<rect x="155" y="200" width="32" height="30" rx="3" fill="#C6ECE9" stroke="#7DBCB7" stroke-width="1"/>
|
||||
<text x="171" y="219" class="c sub mono" style="fill:#555">29</text>
|
||||
<rect x="189" y="200" width="32" height="30" rx="3" fill="#C6ECE9" stroke="#7DBCB7" stroke-width="1"/>
|
||||
<text x="205" y="219" class="c sub mono" style="fill:#555">30</text>
|
||||
<rect x="223" y="200" width="32" height="30" rx="3" fill="#C6ECE9" stroke="#7DBCB7" stroke-width="1"/>
|
||||
<text x="239" y="219" class="c sub mono" style="fill:#555">31</text>
|
||||
<rect x="257" y="200" width="32" height="30" rx="3" fill="#FFFFFF" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="273" y="219" class="c sub mono" style="fill:#888">32</text>
|
||||
<rect x="291" y="200" width="32" height="30" rx="3" fill="#FFFFFF" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="307" y="219" class="c sub mono" style="fill:#888">33</text>
|
||||
<rect x="325" y="200" width="32" height="30" rx="3" fill="#E6E3FA" stroke="#B8B0DE" stroke-width="1"/>
|
||||
<text x="341" y="219" class="c sub mono" style="fill:#555">34</text>
|
||||
<rect x="359" y="200" width="32" height="30" rx="3" fill="#E6E3FA" stroke="#B8B0DE" stroke-width="1"/>
|
||||
<text x="375" y="219" class="c sub mono" style="fill:#555">35</text>
|
||||
<rect x="393" y="200" width="32" height="30" rx="3" fill="#FFFFFF" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="409" y="219" class="c sub mono" style="fill:#888">36</text>
|
||||
<rect x="427" y="200" width="32" height="30" rx="3" fill="#FFFFFF" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="443" y="219" class="c sub mono" style="fill:#888">37</text>
|
||||
<rect x="461" y="200" width="32" height="30" rx="3" fill="#FFFFFF" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="477" y="219" class="c sub mono" style="fill:#888">38</text>
|
||||
<rect x="495" y="200" width="32" height="30" rx="3" fill="#FFFFFF" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="511" y="219" class="c sub mono" style="fill:#888">39</text>
|
||||
<rect x="529" y="200" width="32" height="30" rx="3" fill="#FFFFFF" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="545" y="219" class="c sub mono" style="fill:#888">40</text>
|
||||
<rect x="563" y="200" width="32" height="30" rx="3" fill="#FFFFFF" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="579" y="219" class="c sub mono" style="fill:#888">41</text>
|
||||
<rect x="597" y="200" width="32" height="30" rx="3" fill="#FFFFFF" stroke="#DDDDDD" stroke-width="1"/>
|
||||
<text x="613" y="219" class="c sub mono" style="fill:#BBB">42</text>
|
||||
<rect x="631" y="200" width="32" height="30" rx="3" fill="#FFFFFF" stroke="#DDDDDD" stroke-width="1"/>
|
||||
<text x="647" y="219" class="c sub mono" style="fill:#BBB">43</text>
|
||||
<rect x="665" y="200" width="32" height="30" rx="3" fill="#FFFFFF" stroke="#DDDDDD" stroke-width="1"/>
|
||||
<text x="681" y="219" class="c sub mono" style="fill:#BBB">44</text>
|
||||
<rect x="699" y="200" width="32" height="30" rx="3" fill="#FFFFFF" stroke="#DDDDDD" stroke-width="1"/>
|
||||
<text x="715" y="219" class="c sub mono" style="fill:#BBB">45</text>
|
||||
<rect x="254" y="194" width="344" height="42" rx="5" fill="none" stroke="#B8B0DE" stroke-width="2"/>
|
||||
<text x="426" y="188" class="c sub" style="fill:#766AA8">B 的接收窗口:31 已按序收到,窗口移到 32~41</text>
|
||||
<text x="256" y="252" class="sub" style="fill:#555">32、33、36 未到,34、35 先缓存;只能确认到 31,回复确认号 32、窗口 10</text>
|
||||
<text x="20" y="328" class="b">③ A 收到</text>
|
||||
<text x="20" y="344" class="sub">确认号 32</text>
|
||||
<rect x="121" y="316" width="32" height="30" rx="3" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1"/>
|
||||
<text x="137" y="335" class="c sub mono" style="fill:#888">28</text>
|
||||
<rect x="155" y="316" width="32" height="30" rx="3" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1"/>
|
||||
<text x="171" y="335" class="c sub mono" style="fill:#888">29</text>
|
||||
<rect x="189" y="316" width="32" height="30" rx="3" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1"/>
|
||||
<text x="205" y="335" class="c sub mono" style="fill:#888">30</text>
|
||||
<rect x="223" y="316" width="32" height="30" rx="3" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1"/>
|
||||
<text x="239" y="335" class="c sub mono" style="fill:#888">31</text>
|
||||
<rect x="257" y="316" width="32" height="30" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="273" y="335" class="c sub mono" style="fill:#555">32</text>
|
||||
<rect x="291" y="316" width="32" height="30" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="307" y="335" class="c sub mono" style="fill:#555">33</text>
|
||||
<rect x="325" y="316" width="32" height="30" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="341" y="335" class="c sub mono" style="fill:#555">34</text>
|
||||
<rect x="359" y="316" width="32" height="30" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="375" y="335" class="c sub mono" style="fill:#555">35</text>
|
||||
<rect x="393" y="316" width="32" height="30" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="409" y="335" class="c sub mono" style="fill:#555">36</text>
|
||||
<rect x="427" y="316" width="32" height="30" rx="3" fill="#FFFFFF" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="443" y="335" class="c sub mono" style="fill:#555">37</text>
|
||||
<rect x="461" y="316" width="32" height="30" rx="3" fill="#FFFFFF" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="477" y="335" class="c sub mono" style="fill:#555">38</text>
|
||||
<rect x="495" y="316" width="32" height="30" rx="3" fill="#FFFFFF" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="511" y="335" class="c sub mono" style="fill:#555">39</text>
|
||||
<rect x="529" y="316" width="32" height="30" rx="3" fill="#FFFFFF" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="545" y="335" class="c sub mono" style="fill:#555">40</text>
|
||||
<rect x="563" y="316" width="32" height="30" rx="3" fill="#FFFFFF" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="579" y="335" class="c sub mono" style="fill:#555">41</text>
|
||||
<rect x="597" y="316" width="32" height="30" rx="3" fill="#FFFFFF" stroke="#DDDDDD" stroke-width="1"/>
|
||||
<text x="613" y="335" class="c sub mono" style="fill:#BBB">42</text>
|
||||
<rect x="631" y="316" width="32" height="30" rx="3" fill="#FFFFFF" stroke="#DDDDDD" stroke-width="1"/>
|
||||
<text x="647" y="335" class="c sub mono" style="fill:#BBB">43</text>
|
||||
<rect x="665" y="316" width="32" height="30" rx="3" fill="#FFFFFF" stroke="#DDDDDD" stroke-width="1"/>
|
||||
<text x="681" y="335" class="c sub mono" style="fill:#BBB">44</text>
|
||||
<rect x="699" y="316" width="32" height="30" rx="3" fill="#FFFFFF" stroke="#DDDDDD" stroke-width="1"/>
|
||||
<text x="715" y="335" class="c sub mono" style="fill:#BBB">45</text>
|
||||
<rect x="254" y="310" width="344" height="42" rx="5" fill="none" stroke="#B8B0DE" stroke-width="2"/>
|
||||
<text x="426" y="304" class="c sub" style="fill:#766AA8">A 的窗口右移 1 字节:32~41,可以再发 37~41</text>
|
||||
<rect x="20" y="390" width="16" height="16" rx="3" fill="#EAE9E7" stroke="#BFBEBA"/>
|
||||
<text x="42" y="403" class="sub">已发送并收到确认</text>
|
||||
<rect x="138" y="390" width="16" height="16" rx="3" fill="#C6E4FB" stroke="#7FB2D6"/>
|
||||
<text x="160" y="403" class="sub">已发送未确认</text>
|
||||
<rect x="234" y="390" width="16" height="16" rx="3" fill="#FFFFFF" stroke="#7FB2D6"/>
|
||||
<text x="256" y="403" class="sub">窗口内,还可以发送或接收</text>
|
||||
<rect x="396" y="390" width="16" height="16" rx="3" fill="#C6ECE9" stroke="#7DBCB7"/>
|
||||
<text x="418" y="403" class="sub">按序收到</text>
|
||||
<rect x="470" y="390" width="16" height="16" rx="3" fill="#E6E3FA" stroke="#B8B0DE"/>
|
||||
<text x="492" y="403" class="sub">未按序收到,先缓存</text>
|
||||
<text x="20" y="446" class="sub">之后 32、33 到达,B 一次确认到 35(确认号 36),A 的窗口随之右移 4 字节;36 要等它到达后才能确认。</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 13 KiB |
@@ -0,0 +1,79 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="640" height="520" viewBox="0 0 640 520">
|
||||
<style>
|
||||
text { font-family: "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif; fill: #3F3F3F; font-size: 12px; }
|
||||
.title { font-weight: bold; font-size: 15px; fill: #333; text-anchor: middle; }
|
||||
.b { font-weight: bold; }
|
||||
.c { text-anchor: middle; }
|
||||
.e { text-anchor: end; }
|
||||
.note { fill: #C0605A; }
|
||||
.ok { fill: #6A9F68; }
|
||||
.sub { font-size: 11px; fill: #6E6E6E; }
|
||||
.mono { font-family: Menlo, Consolas, monospace; }
|
||||
.arrow { stroke: #555; stroke-width: 1.1; fill: none; marker-end: url(#a); }
|
||||
.red { stroke: #C0605A; marker-end: url(#r); }
|
||||
.green { stroke: #6A9F68; marker-end: url(#g); }
|
||||
.dash { stroke-dasharray: 5 4; }
|
||||
.line { stroke: #555; stroke-width: 1.1; fill: none; }
|
||||
.frame { fill: none; stroke: #999; stroke-width: 1; stroke-dasharray: 4 3; }
|
||||
.shadow { fill: #DADADA; }
|
||||
</style>
|
||||
<defs>
|
||||
<marker id="a" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#555"/>
|
||||
</marker>
|
||||
<marker id="r" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#C0605A"/>
|
||||
</marker>
|
||||
<marker id="g" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#6A9F68"/>
|
||||
</marker>
|
||||
</defs>
|
||||
<rect width="100%" height="100%" fill="#FFFFFF"/>
|
||||
|
||||
<text x="320" y="28" class="title">TCP 四次挥手</text>
|
||||
<rect x="130" y="46" width="120" height="34" rx="6" fill="#C6ECE9" stroke="#7DBCB7"/>
|
||||
<text x="190" y="67.5" class="b c">客户端 A</text>
|
||||
<line x1="190" y1="82" x2="190" y2="466" stroke="#BBB" stroke-width="1" stroke-dasharray="4 4"/>
|
||||
<rect x="390" y="46" width="120" height="34" rx="6" fill="#C6E4FB" stroke="#7FB2D6"/>
|
||||
<text x="450" y="67.5" class="b c">服务器 B</text>
|
||||
<line x1="450" y1="82" x2="450" y2="466" stroke="#BBB" stroke-width="1" stroke-dasharray="4 4"/>
|
||||
<rect x="186" y="168" width="268" height="124" fill="#E6E3FA" opacity="0.3"/>
|
||||
<text x="198" y="286" class="sub">半关闭:只剩 B → A 方向</text>
|
||||
<rect x="82.6" y="92" width="95.4" height="20" rx="4" fill="#C6ECE9" stroke="#7DBCB7" stroke-width="1"/>
|
||||
<text x="130.3" y="106" class="c sub mono" style="fill:#555">ESTABLISHED</text>
|
||||
<rect x="462" y="92" width="95.4" height="20" rx="4" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="509.7" y="106" class="c sub mono" style="fill:#555">ESTABLISHED</text>
|
||||
<line x1="190" y1="124" x2="450" y2="160" class="arrow "/>
|
||||
<text x="320" y="135" class="c sub mono" transform="rotate(7.88 320 142)" style="fill:#555">FIN=1, seq=3000</text>
|
||||
<rect x="90" y="124" width="88" height="20" rx="4" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1"/>
|
||||
<text x="134" y="138" class="c sub mono" style="fill:#555">FIN-WAIT-1</text>
|
||||
<rect x="462" y="154" width="88" height="20" rx="4" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1"/>
|
||||
<text x="506" y="168" class="c sub mono" style="fill:#555">CLOSE-WAIT</text>
|
||||
<text x="462" y="190" class="sub">通知应用程序,</text>
|
||||
<text x="462" y="206" class="sub">等它发完数据后调用 close()</text>
|
||||
<line x1="450" y1="176" x2="190" y2="212" class="arrow "/>
|
||||
<text x="320" y="187" class="c sub mono" transform="rotate(-7.88 320 194)" style="fill:#555">ACK=1, ack=3001</text>
|
||||
<rect x="90" y="206" width="88" height="20" rx="4" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1"/>
|
||||
<text x="134" y="220" class="c sub mono" style="fill:#555">FIN-WAIT-2</text>
|
||||
<line x1="450" y1="230" x2="190" y2="266" class="arrow "/>
|
||||
<text x="320" y="241" class="c sub" transform="rotate(-7.88 320 248)" style="fill:#555">B 继续发送剩余的数据</text>
|
||||
<line x1="450" y1="312" x2="190" y2="348" class="arrow "/>
|
||||
<text x="320" y="323" class="c sub mono" transform="rotate(-7.88 320 330)" style="fill:#555">FIN=1, ACK=1, seq=9000, ack=3001</text>
|
||||
<rect x="462" y="306" width="73.2" height="20" rx="4" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1"/>
|
||||
<text x="498.6" y="320" class="c sub mono" style="fill:#555">LAST-ACK</text>
|
||||
<line x1="190" y1="364" x2="450" y2="400" class="arrow "/>
|
||||
<text x="320" y="375" class="c sub mono" transform="rotate(7.88 320 382)" style="fill:#555">ACK=1, seq=3001, ack=9001</text>
|
||||
<rect x="97.4" y="342" width="80.6" height="20" rx="4" fill="#E6E3FA" stroke="#B8B0DE" stroke-width="1"/>
|
||||
<text x="137.7" y="356" class="c sub mono" style="fill:#555">TIME-WAIT</text>
|
||||
<path d="M140,366 V440" class="line dash"/>
|
||||
<circle cx="140" cy="402" r="11" fill="#FFFFFF" stroke="#BBBBBB" stroke-width="1.2"/>
|
||||
<path d="M140,395.4 V402 L144.95,405.3" fill="none" stroke="#888" stroke-width="1.4" stroke-linecap="round"/>
|
||||
<text x="122" y="398" class="sub e">等待 2MSL</text>
|
||||
<text x="122" y="414" class="sub e">Linux 为 60 秒</text>
|
||||
<rect x="119.6" y="444" width="58.4" height="20" rx="4" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1"/>
|
||||
<text x="148.8" y="458" class="c sub mono" style="fill:#555">CLOSED</text>
|
||||
<rect x="462" y="394" width="58.4" height="20" rx="4" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1"/>
|
||||
<text x="491.2" y="408" class="c sub mono" style="fill:#555">CLOSED</text>
|
||||
<text x="40" y="494" class="sub">主动关闭的一方最后进入 TIME-WAIT;被动关闭的一方在应用调用 close() 之前一直处于 CLOSE-WAIT。</text>
|
||||
<text x="40" y="512" class="sub">如果最后的 ACK 丢失,B 会重传 FIN,A 还在 TIME-WAIT 中,可以再确认一次。</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 5.6 KiB |
@@ -0,0 +1,78 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="600" height="420" viewBox="0 0 600 420">
|
||||
<style>
|
||||
text { font-family: "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif; fill: #3F3F3F; font-size: 12px; }
|
||||
.title { font-weight: bold; font-size: 15px; fill: #333; text-anchor: middle; }
|
||||
.b { font-weight: bold; }
|
||||
.c { text-anchor: middle; }
|
||||
.e { text-anchor: end; }
|
||||
.note { fill: #C0605A; }
|
||||
.ok { fill: #6A9F68; }
|
||||
.sub { font-size: 11px; fill: #6E6E6E; }
|
||||
.mono { font-family: Menlo, Consolas, monospace; }
|
||||
.arrow { stroke: #555; stroke-width: 1.1; fill: none; marker-end: url(#a); }
|
||||
.red { stroke: #C0605A; marker-end: url(#r); }
|
||||
.green { stroke: #6A9F68; marker-end: url(#g); }
|
||||
.dash { stroke-dasharray: 5 4; }
|
||||
.line { stroke: #555; stroke-width: 1.1; fill: none; }
|
||||
.frame { fill: none; stroke: #999; stroke-width: 1; stroke-dasharray: 4 3; }
|
||||
.shadow { fill: #DADADA; }
|
||||
</style>
|
||||
<defs>
|
||||
<marker id="a" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#555"/>
|
||||
</marker>
|
||||
<marker id="r" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#C0605A"/>
|
||||
</marker>
|
||||
<marker id="g" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
||||
<path d="M1,1.5 L9.5,5 L1,8.5 z" fill="#6A9F68"/>
|
||||
</marker>
|
||||
</defs>
|
||||
<rect width="100%" height="100%" fill="#FFFFFF"/>
|
||||
|
||||
<text x="300" y="28" class="title">UDP 首部与伪首部:一次 DNS 查询</text>
|
||||
<text x="43" y="60" class="sub mono">0</text>
|
||||
<text x="237" y="60" class="sub mono e">15</text>
|
||||
<text x="243" y="60" class="sub mono">16</text>
|
||||
<text x="437" y="60" class="sub mono e">31</text>
|
||||
<rect x="40" y="68" width="400" height="40" fill="#F5F5F5" stroke="#BBBBBB" stroke-width="1"/>
|
||||
<text x="240" y="85" class="c">源 IP 地址</text>
|
||||
<text x="240" y="101" class="c sub mono">192.168.1.10</text>
|
||||
<rect x="40" y="108" width="400" height="40" fill="#F5F5F5" stroke="#BBBBBB" stroke-width="1"/>
|
||||
<text x="240" y="125" class="c">目的 IP 地址</text>
|
||||
<text x="240" y="141" class="c sub mono">8.8.8.8</text>
|
||||
<rect x="40" y="148" width="100" height="40" fill="#F5F5F5" stroke="#BBBBBB" stroke-width="1"/>
|
||||
<text x="90" y="165" class="c">全 0</text>
|
||||
<text x="90" y="181" class="c sub mono">0</text>
|
||||
<rect x="140" y="148" width="100" height="40" fill="#F5F5F5" stroke="#BBBBBB" stroke-width="1"/>
|
||||
<text x="190" y="165" class="c">协议</text>
|
||||
<text x="190" y="181" class="c sub mono">17</text>
|
||||
<rect x="240" y="148" width="200" height="40" fill="#F5F5F5" stroke="#BBBBBB" stroke-width="1"/>
|
||||
<text x="340" y="165" class="c">UDP 长度</text>
|
||||
<text x="340" y="181" class="c sub mono">37</text>
|
||||
<rect x="34" y="62" width="412" height="132" rx="6" class="frame"/>
|
||||
<text x="462" y="98" class="b">伪首部 12 字节</text>
|
||||
<text x="462" y="118" class="sub">从 IP 首部取来,</text>
|
||||
<text x="462" y="134" class="sub">只参与检验和计算,</text>
|
||||
<text x="462" y="150" class="sub">不随报文发送</text>
|
||||
<rect x="40" y="214" width="200" height="40" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="140" y="231" class="c">源端口</text>
|
||||
<text x="140" y="247" class="c sub mono">51000</text>
|
||||
<rect x="240" y="214" width="200" height="40" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="340" y="231" class="c">目的端口</text>
|
||||
<text x="340" y="247" class="c sub mono">53</text>
|
||||
<rect x="40" y="254" width="200" height="40" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="140" y="271" class="c">长度</text>
|
||||
<text x="140" y="287" class="c sub mono">37</text>
|
||||
<rect x="240" y="254" width="200" height="40" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
|
||||
<text x="340" y="271" class="c">检验和</text>
|
||||
<text x="340" y="287" class="c sub mono">0x7CDB</text>
|
||||
<text x="462" y="250" class="b">UDP 首部 8 字节</text>
|
||||
<text x="462" y="268" class="sub">每个字段 16 位</text>
|
||||
<rect x="40" y="294" width="400" height="48" fill="#FFFFFF" stroke="#BBBBBB" stroke-width="1"/>
|
||||
<text x="240" y="315" class="c">数据 29 字节</text>
|
||||
<text x="240" y="331" class="c sub">DNS 查询:example.com 的 A 记录</text>
|
||||
<text x="462" y="322" class="b">UDP 数据</text>
|
||||
<text x="40" y="376" class="sub">长度 = 首部 8 + 数据 29 = 37 字节。</text>
|
||||
<text x="40" y="396" class="sub">发送方把伪首部、首部和数据按 16 位相加后取反,填入检验和;接收方重新计算,不一致就丢弃。</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.6 KiB |