Skip to content

Commit

Permalink
增加 TCP 笔记。
Browse files Browse the repository at this point in the history
  • Loading branch information
jacky committed Mar 27, 2024
1 parent dc13515 commit 1a79f7b
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 19 deletions.
3 changes: 2 additions & 1 deletion .obsidian/appearance.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"accentColor": "",
"textFontFamily": "等线",
"interfaceFontFamily": "等线",
"monospaceFontFamily": "Consolas"
"monospaceFontFamily": "Consolas",
"baseFontSize": 20
}
33 changes: 16 additions & 17 deletions .obsidian/workspace.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"state": {
"type": "markdown",
"state": {
"file": "docs/Network/Network Tips.md",
"file": "docs/Network/运输层:TCP.md",
"mode": "source",
"source": false
}
Expand Down Expand Up @@ -85,7 +85,7 @@
"state": {
"type": "backlink",
"state": {
"file": "docs/Network/Network Tips.md",
"file": "docs/Network/运输层:TCP.md",
"collapseAll": false,
"extraContext": false,
"sortOrder": "alphabetical",
Expand All @@ -102,7 +102,7 @@
"state": {
"type": "outgoing-link",
"state": {
"file": "docs/Network/Network Tips.md",
"file": "docs/Network/运输层:TCP.md",
"linksCollapsed": false,
"unlinkedCollapsed": true
}
Expand All @@ -125,7 +125,7 @@
"state": {
"type": "outline",
"state": {
"file": "docs/Network/Network Tips.md"
"file": "docs/Network/运输层:TCP.md"
}
}
}
Expand All @@ -149,18 +149,23 @@
},
"active": "044546147249fa2a",
"lastOpenFiles": [
"docs/Network/网络层:IP.md",
"docs/Network/Network Tips.md",
"docs/Network/网络层:TCP.md",
"docs/Network/运输层:介绍.md",
"docs/index.md",
"mkdocs.yml",
"docs/Network/运输层:TCP.md",
"docs/Network/运输层:UDP.md",
"docs/Network/运输层:介绍.md",
"docs/OS/汇编——寻址方式.md",
"docs/Linux/时间.md",
"docs/Linux/定时任务.md",
"docs/Linux/磁盘分区挂载.md",
"docs/Linux/查找文件.md",
"docs/Linux/Linux 清理 PG WAL 日志.md",
"docs/Network/Network Tips.md",
"docs/Network/网络层:IP.md",
"docs/Network/网络层:ICMP.md",
"docs/MySQL/MySQL Tips.md",
"mkdocs.yml",
"docs/index.md",
"docs/Linux/网络.md",
"docs/Linux/curl.md",
"docs/Linux/磁盘分区挂载.md",
"docs/OS/汇编——介绍.md",
"docs/OS/并发——锁.md",
"docs/OS/并发——多线程.md",
Expand All @@ -170,12 +175,6 @@
"docs/Algorithms/求解算数表达式的值.md",
"docs/ML/Keras 入门.md",
"docs/DM/达梦安装.md",
"docs/Reading/读书计划.md",
"docs/Reading/2023.md",
"docs/Reading/2022.md",
"docs/Reading/2021.md",
"docs/MySQL/MySQL 配置主从.md",
"docs/MySQL/备份 MySQL.md",
"overrides/partials/footer.html",
"overrides/partials/comments.html",
"docs/index.html",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@

笔记

TCP 使用 IP 的服务把一个个报文段交付给接收方,但是连接本身是由 TCP 控制的。如果一个报文段丢失或收到损伤,那么这个报文段就被重传,IP 并不知道 TCP 的重传行为;如果一个报文段没有按序到达,那么 TCP 会保留它,直到丢失的报文达到为止,但是 IP 并不知道这个重新排序的过程。

TCP 首部的窗口大小是由接收方决定的,发送方服从接收方的指示。只有当一个报文段中包含了确认时,定义窗口大小才有意义。

三向握手

客户端主动打开,C->S 发送报文,seq: 800,SYN。
!!! note "SYN 报文段不携带任何数据,但是它要消耗一个序号。"

服务端被动打开,S->C发送报文,seq: 1500,ack: 801,SYN,ACK,rwnd: 5000。
!!! note "SYN + ACK 报文段不携带任何数据,但是它要消耗一个序号。"

客户端确认,C->S发送报文,seq: 800,ack: 1501,ACK,rwnd: 3000。
!!! note "ACK 报文段如果不携带数据就不消耗序号。"




Java 实现 Echo 协议代码。
```java
package com.haizhi.hivetest;
Expand Down
4 changes: 3 additions & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,11 @@ nav:
- OS/并发——锁.md
- OS/汇编——介绍.md
- OS/汇编——环境搭建.md
- OS/汇编——寄存器介绍.md
# - OS/汇编——寄存器介绍.md
- Network/网络层:IP.md
- Network/网络层:ICMP.md
- Network/运输层:UDP.md
- Network/运输层:TCP.md
# - OS/并发——可视性的问题.md
# - OS/并发——条件变量.md
# - OS/并发——信号量.md
Expand Down

0 comments on commit 1a79f7b

Please sign in to comment.