Update 计算机网络 - 应用层.md

重新绘制配图,补充 DNS 解析和输入 URL 之后的过程。
This commit is contained in:
CyC2018
2026-10-26 22:04:19 +08:00
parent cc4f7ab350
commit 87f33c43f4
13 changed files with 455 additions and 7 deletions
+53
View File
@@ -0,0 +1,53 @@
<svg xmlns="http://www.w3.org/2000/svg" width="780" height="340" viewBox="0 0 780 340">
<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; }
.sub { font-size: 11px; fill: #6E6E6E; }
.note { fill: #C0605A; }
.ok { fill: #6A9F68; }
.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="390" y="28" class="title">DHCP:新接入的主机获取 IP 地址</text>
<rect x="150" y="44" width="180" height="32" rx="6" fill="#C6ECE9" stroke="#7DBCB7"/>
<text x="240" y="64.5" class="c sub b">客户端(还没有 IP)</text>
<line x1="240" y1="78" x2="240" y2="300" stroke="#BBB" stroke-dasharray="4 4"/>
<rect x="470" y="44" width="180" height="32" rx="6" fill="#C6E4FB" stroke="#7FB2D6"/>
<text x="560" y="64.5" class="c sub b">DHCP 服务器 192.168.1.1</text>
<line x1="560" y1="78" x2="560" y2="300" stroke="#BBB" stroke-dasharray="4 4"/>
<line x1="240" y1="100" x2="560" y2="114" class="arrow "/>
<text x="400" y="96" class="c sub" style="fill:#444">① Discover 0.0.0.0:68 → 255.255.255.255:67</text>
<text x="576" y="116" class="sub">广播:有没有 DHCP 服务器?</text>
<line x1="560" y1="150" x2="240" y2="164" class="arrow dash"/>
<text x="400" y="146" class="c sub" style="fill:#444">② Offer 可以用 192.168.1.100,租期 1 天</text>
<text x="228" y="166" class="sub e">附带子网掩码、网关、DNS 服务器</text>
<line x1="240" y1="200" x2="560" y2="214" class="arrow "/>
<text x="400" y="196" class="c sub" style="fill:#444">③ Request 我要 192.168.1.1 提供的这个地址</text>
<text x="576" y="216" class="sub">仍是广播,其它服务器收回提议</text>
<line x1="560" y1="250" x2="240" y2="264" class="arrow dash"/>
<text x="400" y="246" class="c sub" style="fill:#444">④ Ack 确认,从现在起租期 1 天</text>
<text x="228" y="266" class="sub e">客户端开始使用这个地址</text>
<text x="30" y="316" class="sub">前两步用广播是因为客户端还没有地址,也不知道服务器在哪;租期过半时客户端会向同一台服务器申请续租。</text>
</svg>

After

Width:  |  Height:  |  Size: 3.3 KiB

+97
View File
@@ -0,0 +1,97 @@
<svg xmlns="http://www.w3.org/2000/svg" width="760" height="400" viewBox="0 0 760 400">
<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; }
.sub { font-size: 11px; fill: #6E6E6E; }
.note { fill: #C0605A; }
.ok { fill: #6A9F68; }
.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">DNS 解析 www.example.com</text>
<rect x="38" y="150" width="44" height="29.92" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
<rect x="42" y="154" width="36" height="21.92" rx="1.5" fill="#FFFFFF" stroke="#7FB2D6" stroke-width="0.8"/>
<path d="M56,179.92 v5 M64,179.92 v5" stroke="#7FB2D6" stroke-width="1.4"/>
<rect x="48" y="184.92" width="24" height="3.5" rx="1.5" fill="#7FB2D6"/>
<text x="60" y="204" class="c b">主机</text>
<text x="60" y="222" class="c sub">先查浏览器缓存、</text>
<text x="60" y="238" class="c sub">系统缓存和 hosts</text>
<rect x="235" y="150" width="50" height="13" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
<circle cx="242" cy="156.5" r="2" fill="#7FB2D6"/>
<line x1="249" y1="156.5" x2="278" y2="156.5" stroke="#7FB2D6" stroke-width="1"/>
<rect x="235" y="166" width="50" height="13" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
<circle cx="242" cy="172.5" r="2" fill="#7FB2D6"/>
<line x1="249" y1="172.5" x2="278" y2="172.5" stroke="#7FB2D6" stroke-width="1"/>
<rect x="235" y="182" width="50" height="13" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
<circle cx="242" cy="188.5" r="2" fill="#7FB2D6"/>
<line x1="249" y1="188.5" x2="278" y2="188.5" stroke="#7FB2D6" stroke-width="1"/>
<text x="260" y="214" class="c b">本地 DNS 服务器</text>
<text x="260" y="230" class="c sub">运营商或公司提供</text>
<rect x="507" y="60" width="46" height="13" rx="3" fill="#C6ECE9" stroke="#7DBCB7" stroke-width="1.2"/>
<circle cx="514" cy="66.5" r="2" fill="#7DBCB7"/>
<line x1="521" y1="66.5" x2="546" y2="66.5" stroke="#7DBCB7" stroke-width="1"/>
<rect x="507" y="76" width="46" height="13" rx="3" fill="#C6ECE9" stroke="#7DBCB7" stroke-width="1.2"/>
<circle cx="514" cy="82.5" r="2" fill="#7DBCB7"/>
<line x1="521" y1="82.5" x2="546" y2="82.5" stroke="#7DBCB7" stroke-width="1"/>
<text x="566" y="72" class="b">根服务器</text>
<text x="566" y="88" class="sub mono">a.root-servers.net</text>
<line x1="290" y1="156" x2="502" y2="68" class="arrow "/>
<line x1="502" y1="86" x2="292" y2="166" class="arrow dash"/>
<text x="566" y="106" class="sub" style="fill:#444">去问 com 的服务器</text>
<text x="566" y="122" class="sub mono">a.gtld-servers.net 等</text>
<rect x="507" y="160" width="46" height="13" rx="3" fill="#C6ECE9" stroke="#7DBCB7" stroke-width="1.2"/>
<circle cx="514" cy="166.5" r="2" fill="#7DBCB7"/>
<line x1="521" y1="166.5" x2="546" y2="166.5" stroke="#7DBCB7" stroke-width="1"/>
<rect x="507" y="176" width="46" height="13" rx="3" fill="#C6ECE9" stroke="#7DBCB7" stroke-width="1.2"/>
<circle cx="514" cy="182.5" r="2" fill="#7DBCB7"/>
<line x1="521" y1="182.5" x2="546" y2="182.5" stroke="#7DBCB7" stroke-width="1"/>
<text x="566" y="172" class="b">com 顶级域服务器</text>
<text x="566" y="188" class="sub mono">a.gtld-servers.net</text>
<line x1="290" y1="162" x2="502" y2="168" class="arrow "/>
<line x1="502" y1="186" x2="292" y2="172" class="arrow dash"/>
<text x="566" y="206" class="sub" style="fill:#444">去问 example.com 的服务器</text>
<text x="566" y="222" class="sub mono">hera.ns.cloudflare.com 等</text>
<rect x="507" y="260" width="46" height="13" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
<circle cx="514" cy="266.5" r="2" fill="#7FB2D6"/>
<line x1="521" y1="266.5" x2="546" y2="266.5" stroke="#7FB2D6" stroke-width="1"/>
<rect x="507" y="276" width="46" height="13" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
<circle cx="514" cy="282.5" r="2" fill="#7FB2D6"/>
<line x1="521" y1="282.5" x2="546" y2="282.5" stroke="#7FB2D6" stroke-width="1"/>
<text x="566" y="272" class="b">权威服务器</text>
<text x="566" y="288" class="sub mono">hera.ns.cloudflare.com</text>
<line x1="290" y1="168" x2="502" y2="268" class="arrow "/>
<line x1="502" y1="286" x2="292" y2="178" class="arrow dash"/>
<text x="566" y="306" class="sub" style="fill:#444">www.example.com 的 A 记录</text>
<text x="566" y="322" class="sub mono">104.20.23.154,TTL 300</text>
<line x1="86" y1="160" x2="228" y2="160" class="arrow "/>
<text x="157" y="150" class="c sub">① 递归查询</text>
<line x1="228" y1="176" x2="86" y2="176" class="arrow dash"/>
<text x="157" y="192" class="c sub">④ 返回结果</text>
<text x="260" y="262" class="c sub" style="fill:#296898">② 迭代查询:每台服务器</text>
<text x="260" y="278" class="c sub" style="fill:#296898">只告诉下一步去问谁</text>
<text x="260" y="302" class="c sub" style="fill:#207773">③ 按 TTL 缓存 300 秒</text>
<text x="30" y="352" class="sub">图中的服务器和 TTL 是本机用 dig 逐级查询的结果:根服务器和 com 服务器返回的是下一级的 NS 记录(缓存 2 天),</text>
<text x="30" y="370" class="sub">只有权威服务器的回答带有 aa(权威回答)标志。缓存命中时,前面任何一级都可以直接返回,不必走完全程。</text>
</svg>

After

Width:  |  Height:  |  Size: 6.6 KiB

+76
View File
@@ -0,0 +1,76 @@
<svg xmlns="http://www.w3.org/2000/svg" width="760" height="260" viewBox="0 0 760 260">
<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; }
.sub { font-size: 11px; fill: #6E6E6E; }
.note { fill: #C0605A; }
.ok { fill: #6A9F68; }
.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">电子邮件:alice@a.com 发信给 bob@b.com</text>
<circle cx="50" cy="79" r="9" fill="#E6E3FA" stroke="#B8B0DE" stroke-width="1.2"/>
<path d="M33,110 q0,-19 17,-19 q17,0 17,19 z" fill="#E6E3FA" stroke="#B8B0DE" stroke-width="1.2"/>
<text x="50" y="130" class="c sub b">alice</text>
<text x="50" y="146" class="c sub">用户代理</text>
<rect x="227" y="74" width="46" height="13" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
<circle cx="234" cy="80.5" r="2" fill="#7FB2D6"/>
<line x1="241" y1="80.5" x2="266" y2="80.5" stroke="#7FB2D6" stroke-width="1"/>
<rect x="227" y="90" width="46" height="13" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
<circle cx="234" cy="96.5" r="2" fill="#7FB2D6"/>
<line x1="241" y1="96.5" x2="266" y2="96.5" stroke="#7FB2D6" stroke-width="1"/>
<rect x="227" y="106" width="46" height="13" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
<circle cx="234" cy="112.5" r="2" fill="#7FB2D6"/>
<line x1="241" y1="112.5" x2="266" y2="112.5" stroke="#7FB2D6" stroke-width="1"/>
<text x="250" y="138" class="c sub b">a.com 邮件服务器</text>
<rect x="477" y="74" width="46" height="13" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
<circle cx="484" cy="80.5" r="2" fill="#7FB2D6"/>
<line x1="491" y1="80.5" x2="516" y2="80.5" stroke="#7FB2D6" stroke-width="1"/>
<rect x="477" y="90" width="46" height="13" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
<circle cx="484" cy="96.5" r="2" fill="#7FB2D6"/>
<line x1="491" y1="96.5" x2="516" y2="96.5" stroke="#7FB2D6" stroke-width="1"/>
<rect x="477" y="106" width="46" height="13" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
<circle cx="484" cy="112.5" r="2" fill="#7FB2D6"/>
<line x1="491" y1="112.5" x2="516" y2="112.5" stroke="#7FB2D6" stroke-width="1"/>
<text x="500" y="138" class="c sub b">b.com 邮件服务器</text>
<circle cx="700" cy="79" r="9" fill="#E6E3FA" stroke="#B8B0DE" stroke-width="1.2"/>
<path d="M683,110 q0,-19 17,-19 q17,0 17,19 z" fill="#E6E3FA" stroke="#B8B0DE" stroke-width="1.2"/>
<text x="700" y="130" class="c sub b">bob</text>
<text x="700" y="146" class="c sub">用户代理</text>
<rect x="96" y="74" width="110" height="28" rx="3" fill="#FFFFFF" stroke="#BBBBBB" stroke-width="1.2"/>
<path d="M96,75 L110,85 L124,75" fill="none" stroke="#BBBBBB" stroke-width="1"/>
<text x="130" y="92" class="sub b">SMTP</text>
<line x1="80" y1="108" x2="222" y2="108" class="arrow "/>
<line x1="278" y1="98" x2="472" y2="98" class="arrow "/>
<text x="375" y="88" class="c sub b">SMTP(端口 25)</text>
<text x="375" y="120" class="c sub">先查 b.com 的 MX 记录</text>
<text x="375" y="136" class="c sub">找到对方的邮件服务器</text>
<line x1="672" y1="98" x2="528" y2="98" class="arrow dash"/>
<text x="600" y="88" class="c sub b">POP3 或 IMAP</text>
<text x="600" y="120" class="c sub">bob 主动来取</text>
<text x="30" y="196" class="sub">发送和服务器之间的转发用 SMTP,是“推”;收件人读取用 POP3 或 IMAP,是“拉”。</text>
<text x="30" y="214" class="sub">邮件先存放在收件方的服务器上,bob 不在线也不影响 alice 发信。</text>
<text x="30" y="238" class="sub">(用户代理到发件服务器之间通常使用端口 587 并要求登录。)</text>
</svg>

After

Width:  |  Height:  |  Size: 4.9 KiB

+82
View File
@@ -0,0 +1,82 @@
<svg xmlns="http://www.w3.org/2000/svg" width="760" height="300" viewBox="0 0 760 300">
<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; }
.sub { font-size: 11px; fill: #6E6E6E; }
.note { fill: #C0605A; }
.ok { fill: #6A9F68; }
.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">FTP 的主动模式与被动模式</text>
<text x="190" y="56" class="c b">主动模式</text>
<rect x="48" y="90" width="44" height="29.92" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
<rect x="52" y="94" width="36" height="21.92" rx="1.5" fill="#FFFFFF" stroke="#7FB2D6" stroke-width="0.8"/>
<path d="M66,119.92 v5 M74,119.92 v5" stroke="#7FB2D6" stroke-width="1.4"/>
<rect x="58" y="124.92" width="24" height="3.5" rx="1.5" fill="#7FB2D6"/>
<text x="70" y="146" class="c sub b">客户端</text>
<rect x="297" y="86" width="46" height="13" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
<circle cx="304" cy="92.5" r="2" fill="#7FB2D6"/>
<line x1="311" y1="92.5" x2="336" y2="92.5" stroke="#7FB2D6" stroke-width="1"/>
<rect x="297" y="102" width="46" height="13" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
<circle cx="304" cy="108.5" r="2" fill="#7FB2D6"/>
<line x1="311" y1="108.5" x2="336" y2="108.5" stroke="#7FB2D6" stroke-width="1"/>
<rect x="297" y="118" width="46" height="13" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
<circle cx="304" cy="124.5" r="2" fill="#7FB2D6"/>
<line x1="311" y1="124.5" x2="336" y2="124.5" stroke="#7FB2D6" stroke-width="1"/>
<text x="320" y="146" class="c sub b">服务器</text>
<line x1="100" y1="100" x2="292" y2="100" class="arrow "/>
<text x="196" y="92" class="c sub mono">控制连接 → 21</text>
<text x="196" y="118" class="c sub mono" style="fill:#296898">PORT 192,168,1,10,195,81</text>
<line x1="292" y1="132" x2="100" y2="132" class="arrow red"/>
<text x="196" y="152" class="c sub mono" style="fill:#C0605A">数据连接 20 → 50001</text>
<text x="196" y="184" class="c sub">服务器主动连接客户端的 50001,</text>
<text x="196" y="200" class="c sub">客户端的防火墙要放行</text>
<text x="560" y="56" class="c b">被动模式</text>
<rect x="418" y="90" width="44" height="29.92" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
<rect x="422" y="94" width="36" height="21.92" rx="1.5" fill="#FFFFFF" stroke="#7FB2D6" stroke-width="0.8"/>
<path d="M436,119.92 v5 M444,119.92 v5" stroke="#7FB2D6" stroke-width="1.4"/>
<rect x="428" y="124.92" width="24" height="3.5" rx="1.5" fill="#7FB2D6"/>
<text x="440" y="146" class="c sub b">客户端</text>
<rect x="667" y="86" width="46" height="13" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
<circle cx="674" cy="92.5" r="2" fill="#7FB2D6"/>
<line x1="681" y1="92.5" x2="706" y2="92.5" stroke="#7FB2D6" stroke-width="1"/>
<rect x="667" y="102" width="46" height="13" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
<circle cx="674" cy="108.5" r="2" fill="#7FB2D6"/>
<line x1="681" y1="108.5" x2="706" y2="108.5" stroke="#7FB2D6" stroke-width="1"/>
<rect x="667" y="118" width="46" height="13" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1.2"/>
<circle cx="674" cy="124.5" r="2" fill="#7FB2D6"/>
<line x1="681" y1="124.5" x2="706" y2="124.5" stroke="#7FB2D6" stroke-width="1"/>
<text x="690" y="146" class="c sub b">服务器</text>
<line x1="470" y1="100" x2="662" y2="100" class="arrow "/>
<text x="566" y="92" class="c sub mono">控制连接 → 21</text>
<text x="566" y="118" class="c sub mono" style="fill:#296898">PASV → 227 (…,195,82)</text>
<line x1="470" y1="132" x2="662" y2="132" class="arrow green"/>
<text x="566" y="152" class="c sub mono" style="fill:#6A9F68">数据连接 → 50002</text>
<text x="566" y="184" class="c sub">客户端主动连接服务器的 50002,</text>
<text x="566" y="200" class="c sub">服务器要开放一段端口</text>
<text x="30" y="252" class="sub">PORT 和 PASV 的回复中,最后两个数字表示端口:195 × 256 + 81 = 50001,195 × 256 + 82 = 50002。</text>
<text x="30" y="272" class="sub">客户端通常在 NAT 和防火墙之后,服务器连不进来,所以现在多用被动模式。</text>
</svg>

After

Width:  |  Height:  |  Size: 5.5 KiB

+52
View File
@@ -0,0 +1,52 @@
<svg xmlns="http://www.w3.org/2000/svg" width="720" height="220" viewBox="0 0 720 220">
<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; }
.sub { font-size: 11px; fill: #6E6E6E; }
.note { fill: #C0605A; }
.ok { fill: #6A9F68; }
.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">MIME:把非 ASCII 内容编码成 ASCII 字符</text>
<text x="90" y="62" class="c sub b" style="fill:#444">邮件主题</text>
<rect x="30" y="72" width="120" height="36" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
<text x="90" y="94" class="c b" style="fill:#444">你好</text>
<line x1="152" y1="90" x2="188" y2="90" class="arrow "/>
<text x="265" y="62" class="c sub b" style="fill:#444">UTF-8 编码</text>
<rect x="190" y="72" width="150" height="36" rx="3" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1"/>
<text x="265" y="94" class="c sub mono" style="fill:#444">e4 bd a0 e5 a5 bd</text>
<line x1="342" y1="90" x2="378" y2="90" class="arrow "/>
<text x="435" y="62" class="c sub b" style="fill:#444">Base64</text>
<rect x="380" y="72" width="110" height="36" rx="3" fill="#E6E3FA" stroke="#B8B0DE" stroke-width="1"/>
<text x="435" y="94" class="c sub mono" style="fill:#444">5L2g5aW9</text>
<line x1="492" y1="90" x2="528" y2="90" class="arrow "/>
<text x="615" y="62" class="c sub b" style="fill:#444">邮件首部</text>
<rect x="530" y="72" width="170" height="36" rx="3" fill="#C6ECE9" stroke="#7DBCB7" stroke-width="1"/>
<text x="615" y="94" class="c sub mono" style="fill:#444">=?utf-8?b?5L2g5aW9?=</text>
<text x="30" y="150" class="sub">SMTP 最初只能传送 7 位 ASCII 文本。MIME 不改变 SMTP,只规定如何把中文、图片、附件等内容编码成 ASCII:</text>
<text x="30" y="168" class="sub">Base64 把每 3 个字节变成 4 个可打印字符,6 个字节的“你好”编码后是 8 个字符;收件方按首部中注明的</text>
<text x="30" y="186" class="sub">字符集和编码方式还原。</text>
</svg>

After

Width:  |  Height:  |  Size: 3.3 KiB

+63
View File
@@ -0,0 +1,63 @@
<svg xmlns="http://www.w3.org/2000/svg" width="760" height="330" viewBox="0 0 760 330">
<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; }
.sub { font-size: 11px; fill: #6E6E6E; }
.note { fill: #C0605A; }
.ok { fill: #6A9F68; }
.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">访问 https://www.example.com/ 的耗时(本机一次实测,RTT 约 200 ms)</text>
<text x="148" y="82" class="sub b e" style="fill:#444">DNS 解析</text>
<rect x="160" y="64" width="6.15385" height="26" rx="3" fill="#EAE9E7" stroke="#BFBEBA" stroke-width="1"/>
<text x="174.154" y="82" class="sub">10 ms,命中缓存</text>
<text x="148" y="128" class="sub b e" style="fill:#444">TCP 三次握手</text>
<rect x="166.154" y="110" width="123.077" height="26" rx="3" fill="#C6E4FB" stroke="#7FB2D6" stroke-width="1"/>
<text x="297.231" y="128" class="sub">1 个 RTT</text>
<text x="148" y="174" class="sub b e" style="fill:#444">TLS 1.3 握手</text>
<rect x="289.231" y="156" width="131.077" height="26" rx="3" fill="#C6ECE9" stroke="#7DBCB7" stroke-width="1"/>
<text x="428.308" y="174" class="sub">1 个 RTT</text>
<text x="148" y="220" class="sub b e" style="fill:#444">请求到首字节</text>
<rect x="420.308" y="202" width="126.769" height="26" rx="3" fill="#E6E3FA" stroke="#B8B0DE" stroke-width="1"/>
<text x="555.077" y="220" class="sub">1 个 RTT + 服务器处理</text>
<line x1="160" y1="250" x2="160" y2="255" stroke="#999"/>
<text x="160" y="270" class="c sub mono">0 ms</text>
<line x1="221.538" y1="250" x2="221.538" y2="255" stroke="#999"/>
<text x="221.538" y="270" class="c sub mono">100 ms</text>
<line x1="283.077" y1="250" x2="283.077" y2="255" stroke="#999"/>
<text x="283.077" y="270" class="c sub mono">200 ms</text>
<line x1="344.615" y1="250" x2="344.615" y2="255" stroke="#999"/>
<text x="344.615" y="270" class="c sub mono">300 ms</text>
<line x1="406.154" y1="250" x2="406.154" y2="255" stroke="#999"/>
<text x="406.154" y="270" class="c sub mono">400 ms</text>
<line x1="467.692" y1="250" x2="467.692" y2="255" stroke="#999"/>
<text x="467.692" y="270" class="c sub mono">500 ms</text>
<line x1="529.231" y1="250" x2="529.231" y2="255" stroke="#999"/>
<text x="529.231" y="270" class="c sub mono">600 ms</text>
<line x1="160" y1="250" x2="560" y2="250" class="line"/>
<text x="30" y="300" class="sub">curl -w 测得:time_connect 0.210 s、time_appconnect 0.423 s、time_starttransfer 0.629 s。</text>
<text x="30" y="318" class="sub">HTTPS 首次请求至少要 3 个 RTT 才能收到响应,这也是连接复用、TLS 会话恢复和 HTTP/3 要解决的问题。</text>
</svg>

After

Width:  |  Height:  |  Size: 3.9 KiB