{"format":"brushup-mindmap-v1","id":"05-transport-layer","title":"运输层【王道】","structure":"logic-right","theme":"auto","root":{"id":"46aa5fa2a43811031caac8fdbe","topic":"第五章 运输层","expanded":true,"children":[{"id":"20a9de99dbaae2ab62200a2aa8","topic":"运输层概述","expanded":true,"children":[{"id":"05e6c5ed-e6bd-49ec-bb29-663aa591f840","topic":"之前课程介绍的物理层、数据链路层和网络层共同解决了将主机通过异构网络互联起来所面临的问题，实现了主机到主机的通信","expanded":true},{"id":"8e9e66d0-194d-491a-87bb-65e031010caf","topic":"实际上计算机网络中进行通信的真正实体是位于通信两端主机中的进程","expanded":true},{"id":"735ba609-fd3b-4b9a-bd11-96b194840c7a","topic":"如何为运行在不同主机上的应用进程提供直接的通信服务是运输层的任务（运输层协议又称为端到端协议）","expanded":true},{"id":"00858cd9-d6fb-4f6e-8bb1-2bf3b7349f32","topic":"图示","expanded":true,"style":{"branchColor":"#EA8ABA"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-4f85631466f2c2.png","width":619.48,"height":317.97},"children":[{"id":"0ab22866-b4c6-4bc5-994a-c1b907b530ee","topic":"运输层“直接”为应用进程间的逻辑通信提供服务","expanded":true},{"id":"921bf25b-1e0f-40e0-a51a-8979c6fe7fa7","topic":"运输层向高层用户屏蔽了下面网络核心的细节（如网络拓扑、所采用的路由选择协议等），它使应用进程看见的就好像是在两个运输层实体之间有一条端到端的逻辑通信信道","expanded":true},{"id":"4fc92ffb-6d0d-4b3c-b936-5c5179dbbec1","topic":"根据应用需求的不同，因特网的运输层为应用层提供了两种不同的运输协议，即面向连接的TCP和无连接的UDP，这两种协议就是本章的主要内容","expanded":true}]},{"id":"60351296-52fd-4490-a3b1-ca2885fa38ef","topic":"功能（王道）","expanded":true,"children":[{"id":"4f912b6f-ce19-46b0-8171-bc965c9d1fc4","topic":"传输层提供应用进程之间的逻辑通信（即端到端的通信）","expanded":true},{"id":"ffd958ed-529e-4f49-a403-5f16af2ed6dd","topic":"OSI模型，上三层为资源子网，下三层为通信子网，运输层承上启下，是两者接口","expanded":true,"style":{"borderColor":"#EB4D3D"}},{"id":"dd26ae15-ad4c-4091-b014-faa113e05cc8","topic":"复用与分用","expanded":true,"children":[{"id":"26be8179-777a-472d-af87-3050fef4dd9e","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-f8e8939a7654ce.png","width":549.95,"height":186.41},"children":[{"id":"b255f480-785a-4b85-b683-78aa23cf6222","topic":"复用：发送方不同的应用进程都可以使用同一个传输层协议传送数据","expanded":true},{"id":"117b687d-1c5a-4a5a-b166-351696ad24b5","topic":"分用：接收方的传输层在剥去报文的首部后能够把这些数据正确交付到目的应用进程","expanded":true}]}]},{"id":"b20b7408-3564-421f-b10b-c6114d13dbaa","topic":"传输层还要对收到的报文进行差错检测（首部和数据部分）","expanded":true},{"id":"00b5a781-d8b9-4a55-9b8a-7c7b62a803dd","topic":"提供两种不同的传输协议，即面向连接的TCP和无连接的UDP","expanded":true}]}]},{"id":"32faf0b55b58a2bf6eaa6b23db","topic":"传输层的寻址与端口","expanded":true,"children":[{"id":"720679da-d7ee-45b1-b035-aab885809e49","topic":"端口（传输层的SAP，服务访问点）的作用","expanded":true,"children":[{"id":"d4c2c035-2c4f-440e-8098-03952bd0afe3","topic":"端口可以标识主机中的应用进程","expanded":true},{"id":"05eb4a61-71ca-4799-97d0-456411f06981","topic":"让应用层各种应用进程将其数据通过端口向下交付给传输层，以及让传输层知道应当将报文段中的数据向上通过端口交付给应用层相应的进程","expanded":true},{"id":"3b4d0d1d-d0be-478e-a9a2-7a8a687d57c5","topic":"端口号只有本地意义，在因特网中不同计算机的相同端口是没有联系的","expanded":true}]},{"id":"93cb4aa6-4bf6-4819-b07c-ed38b6ab9e65","topic":"软件端口与硬件端口","expanded":true,"style":{"branchColor":"#15831C"},"children":[{"id":"2dea28f6-bc51-4671-9df3-7152aec649c3","topic":"软件端口：协议栈层间的抽象的协议端口，是应用层的各种协议进程与传输实体进行层间交互的一种地址（传输层使用）","expanded":true},{"id":"e7b531f4-2153-4bc4-94dc-05b43e41fbf8","topic":"硬件端口：路由器、交换机，不同硬件设备进行交互的接口","expanded":true}]},{"id":"4ee185d8-400e-4c51-891f-41fa5829d3cc","topic":"端口号","expanded":true,"children":[{"id":"737c1127-49f1-4b39-b677-a72dfcdae051","topic":"服务端使用的端口号","expanded":true,"children":[{"id":"c39205c1-ad8c-4cd5-925e-bba8445d9c6c","topic":"熟知端口号：0 - 1023","expanded":true,"style":{"borderColor":"#E32C2D"},"children":[{"id":"4a599c77-d2bd-4e16-819a-21b923ff49a8","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-50b2b6780da0bd.png","width":571.34,"height":82.63}}]},{"id":"ef194d2f-f342-4241-85e7-80d5f7010ed4","topic":"登记端口号：1024 - 49151","expanded":true,"children":[{"id":"ba0da714-596d-4473-b129-270becbdb248","topic":"使用这类端口号必须登记在IANA，以防重复","expanded":true}]}]},{"id":"40a10260-8fcd-4832-ac24-51ff932631aa","topic":"客户端使用的端口号：49152 - 65535","expanded":true,"children":[{"id":"b543e6b2-bcc4-46c3-a15c-347f3642519f","topic":"又称短暂端口号（临时端口号）：仅在客户进程运行时才动态选择，通信结束后收回","expanded":true}]}]},{"id":"2a836517-c7dd-42f0-b950-0516c54e91f4","topic":"套接字","expanded":true,"style":{"branchColor":"#15831C"},"children":[{"id":"4bcdf07f-9f71-46cf-a1c6-611503c1848e","topic":"套接字 = 主机IP地址 + 端口号","expanded":true,"children":[{"id":"7cecb769-7357-4a87-9e84-8b5f533363d9","topic":"IP地址来标识不同主机，端口号区分不同进程","expanded":true}]},{"id":"e48119e4-0d79-49fe-9fa8-e02c8a33cd1c","topic":"在网络中采用发送方和接收方的套接字（Socket）组合来识别端点","expanded":true,"children":[{"id":"7f480a01-69eb-4949-a84b-05255b2ebcf0","topic":"唯一地标识网络中的一台主机和其上的一个应用进程","expanded":true}]}]}]},{"id":"afeaca855128b35382d278f2af","topic":"UDP和TCP的对比","expanded":true,"style":{"borderColor":"#FF9F00"},"children":[{"id":"d3ce77e1-6b1b-4bf5-bff6-e3ce2e1b7ad0","topic":"UDP","expanded":true,"children":[{"id":"e9b819a8-1285-447b-94d1-65767eacaeb1","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-7a65c8ffd84de8.png","width":283.08,"height":254.26},"children":[{"id":"ad7bd4c3-f510-4813-b094-713e43b3c525","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-38a043698428f2.png","width":308.56,"height":243.33},"children":[{"id":"c33ed6eb-1e44-4e3f-937e-3230aad85aeb","topic":"无连接","expanded":true},{"id":"4d4eab5f-c2fb-493f-a280-ee758da36a86","topic":"支持一对一、一对多、多对一和多对多交互通信","expanded":true},{"id":"58a7747f-a7c1-475a-8cb8-89069967d832","topic":"对应用层交付的报文直接打包","expanded":true},{"id":"f6e77037-6248-4d1f-80df-4cfd53968f9b","topic":"尽最大努力交付，也就是不可靠；不使用流量控制拥塞控制","expanded":true},{"id":"5e874c8a-cec3-4a51-a98f-c501cd4d7f3f","topic":"首部开销小，仅8字节","expanded":true}]}]}]},{"id":"c1622368-568f-4a1d-89e6-1b6c45526e30","topic":"TCP","expanded":true,"style":{"branchColor":"#BA69C8"},"children":[{"id":"1f392fae-f46c-49bb-9661-b5cf54b88f06","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-1ccb2342028897.png","width":286.77,"height":251},"children":[{"id":"14c7995e-e744-4b52-aa3b-12867ef63c61","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-3b11456d0a2c4a.png","width":316.56,"height":264.32},"children":[{"id":"8e24ca0c-648e-46d9-b500-38b58d07db7d","topic":"面向连接","expanded":true},{"id":"07656958-4a9a-4106-8750-772e8da43614","topic":"每条TCP连接只能有两个端点EP，只能是一对一通信","expanded":true},{"id":"8c5244f2-0eff-41e5-8735-a9074b721c1d","topic":"面向字节流","expanded":true},{"id":"568b5164-c37b-4433-9ee9-b00416972b75","topic":"可靠传输，使用流量控制和拥塞控制","expanded":true},{"id":"c87cf7e7-830a-4d97-9cf6-798ce572c4e7","topic":"首部最小20字节，最大60字节","expanded":true}]}]}]}]},{"id":"91e0e8fb-b50d-4f37-857c-685c5128e740","topic":"UDP","expanded":true,"children":[{"id":"6c044d44-ada3-4cf9-9042-3c9ab91349da","topic":"UDP数据报","expanded":true,"style":{"borderColor":"#FF9F00"},"children":[{"id":"c498f06c-88a0-49ff-b15f-68cffd1dfb30","topic":"特点","expanded":true,"children":[{"id":"97240ff1-0aa0-4172-8f40-8afec44d7076","topic":"UDP常用于一次性传输较少数据的网络应用，如DNS、SNMP等","expanded":true},{"id":"b417025d-2caa-4ec8-919b-c9b866f56609","topic":"UDP提供尽最大努力交付，即不保证可靠交付（应用层完成）","expanded":true},{"id":"6e43426b-cf3a-43a5-91d0-75a3b5082f68","topic":"UDP面向报文（最小处理单位，应用层给多长报文，都照样发）","expanded":true}]},{"id":"7ddc461e-d11d-4a69-9611-bc4e3966318a","topic":"UDP首部格式","expanded":true,"children":[{"id":"db9a7bbf-bfd6-4f19-b235-4ef484add843","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-4b059b5f013fe6.png","width":684.33,"height":196.32},"children":[{"id":"e6504c7b-7a89-479f-aefd-b00bb89a4dcf","topic":"长度；UDP数据报的长度（首部+数据），其最小值是8（仅首部8B，单位1B）","expanded":true},{"id":"5570cfbf-fe71-4633-8d11-0eb6d47772f5","topic":"校验和：检测UDP数据报在传输中是否有错，有错就丢弃。该字段是可选的，当主机不想计算则为0","expanded":true}]}]},{"id":"db8258da-229e-42ee-ab87-5a33543c8cd5","topic":"收到数据报","expanded":true,"children":[{"id":"d4022f99-220f-49ab-b5ce-5aba595892a4","topic":"根据首部中的目的端口，把UDP数据报通过相应的端口上交给应用进程","expanded":true},{"id":"6b668533-3f13-4249-bb90-942bf31e790f","topic":"如果接收方UDP发现收到的报文中的目的端口号不正确，丢弃该报文，并由ICMP发送“端口不可达”差错报文给发送方","expanded":true}]}]},{"id":"a63f4c5c-301b-4f4b-b3bd-de6731c7b4b0","topic":"UDP校验","expanded":true,"style":{"branchColor":"#EA8ABA"},"children":[{"id":"9d7cac21-1b83-44e5-87e9-1a481fd395a8","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-fcb67e104450ac.png","width":436.96,"height":233.31},"children":[{"id":"aeb1e900-e10e-48a1-9633-e52e3d07ff14","topic":"伪首部只有在计算校验和时才出现，不向下传送也不向上递交","expanded":true},{"id":"18857235-8626-4c67-9851-1f4f75cb7544","topic":"17：封装UDP报文的IP数据报首部协议字段是17","expanded":true},{"id":"1d5eb378-2bbc-4f4c-8dd0-9090d39291a4","topic":"UDP长度：UDP首部8B+数据部分长度（不包括伪首部）","expanded":true}]},{"id":"d4d74dac-3219-48ea-ad36-4fdcd4fda19b","topic":"校验过程","expanded":true,"children":[{"id":"f00b7e73-0c01-4136-b520-a5588884f474","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-03abbbf4da68aa.png","width":694.84,"height":328.72},"children":[{"id":"5750be25-af46-448f-960c-7bdab60b625c","topic":"若主机不想计算校验和，则校验和段全0","expanded":true,"style":{"borderColor":"#EB4D3D"}}]}]}]}]},{"id":"b5bda9a2-17e9-454d-b642-b7f5d8507164","topic":"TCP连接管理","expanded":true,"style":{"borderColor":"#E32C2D"},"children":[{"id":"8ce1e78c-53cd-453b-81ae-999b0b1e5290","topic":"连接的三个阶段","expanded":true,"children":[{"id":"53f289b4-9497-4445-8b71-040ea0e125b6","topic":"连接建立","expanded":true,"children":[{"id":"c05e1a3c-41dc-47fd-84da-1c58c1e3a72b","topic":"数据传送","expanded":true,"children":[{"id":"a9daf3dd-fd19-4ea0-8103-881632ac58b2","topic":"连接释放","expanded":true}]}]}]},{"id":"5831ad86-ad5e-4145-b128-f522d7cb18dd","topic":"图示","expanded":true,"style":{"borderColor":"#EB4D3D","branchColor":"#15831C"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-bec872ad196aa6.png","width":664.61,"height":235.06}},{"id":"a1af139a-90fe-402d-8b36-f7e1e85af291","topic":"连接已建立后","expanded":true,"children":[{"id":"75b3aaea-f9a3-4ac6-b1d1-ea5fbd7a7118","topic":"TCP服务器进程没收到一次TCP客户进程的数据，就重新设置并启动保活计时器（2H）","expanded":true},{"id":"fff0f4f5-26a2-4915-8308-2f6fb35f3f3e","topic":"若保活计时器到时后，TCP服务器进程就向TCP客户进程发送一个探测报文段（每75s一次，十次后仍无响应，则关闭连接）","expanded":true}]},{"id":"920abedc-08c8-4317-b087-d16ff800b2e4","topic":"图示","expanded":true,"style":{"borderColor":"#EB4D3D","branchColor":"#15831C"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-af814ecf3b4329.png","width":659.38,"height":323.77},"children":[{"id":"9144cfe5-7bad-4ac6-8ade-1163682b5be2","topic":"若问发送应用层数据的字节数，从第三次握手到释放连接前","expanded":true,"style":{"borderColor":"#EB4D3D"}}]}]},{"id":"7cf7f3e5-7819-40ac-bd2d-5c4f3a1d26a4","topic":"SYN洪泛攻击","expanded":true,"children":[{"id":"b5c6dac4-cc7a-4918-9d76-af5cdb25ba04","topic":"SYN洪泛攻击发生在OSI传输层，这种方式利用TCP协议的特性，即三次握手","expanded":true},{"id":"0b249cea-c464-4435-a948-c7c1fcf624ea","topic":"攻击者发送大量TCP SYN，SYN是TCP三次握手中的第一个数据包，当服务器返回ACK后，攻击者不对其进行再确认","expanded":true},{"id":"18c1cc74-d28a-4542-8046-cc2b087578be","topic":"那这个TCP连接就处于挂起状态（半连接状态），服务器收不到再确认的话，还会重复发送ACK给攻击者","expanded":true},{"id":"fc599366-92f1-4f7b-9aa3-470b8b72bca7","topic":"攻击者对这些服务器发送非常大量的这种TCP连接；服务器上这些TCP连接会因为挂起状态而消耗CPU和内存，最后服务器可能死机","expanded":true}]},{"id":"c7bc3c55-2737-4e45-a87a-5c7dcd209d02","topic":"TCP可靠传输的实现","expanded":true,"style":{"borderColor":"#E32C2D"},"children":[{"id":"cadc53d4-1e35-49dc-895b-e75ce178e423","topic":"可靠","expanded":true,"children":[{"id":"ad2892a6-0b3a-4835-a959-c5228b704c7d","topic":"接收方读出字节流与发送方一致（顺序、内容）","expanded":true,"children":[{"id":"9df5f8b5-2a11-4998-bb52-2deb95ee6cba","topic":"保证可靠性，TCP采用对报文段确认的机制","expanded":true,"style":{"borderColor":"#EB4D3D"}}]}]},{"id":"b1142020-d471-47ec-8286-fd3b21c21fd1","topic":"图示","expanded":true,"style":{"branchColor":"#EA8ABA"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-874cedbf65c309.png","width":500.75,"height":238.86},"children":[{"id":"def1414a-5d27-4a64-b6f3-eab39c61d292","topic":"发送方在未收到接收方的确认时，可将发送窗口内还未发送的数据全部发送出去","expanded":true},{"id":"d298ed63-5b78-4c5e-9f27-f34f3e11a3fa","topic":"接收方只接收序号落在发送窗口内的数据","expanded":true},{"id":"9b2e9318-5f6a-4919-9fbd-68182d08dcc6","topic":"TCP要求接收方必须有累积确认和捎带确认机制","expanded":true},{"id":"b9c29388-a622-499a-b8c3-51aded6e078c","topic":"接收方不应过分推迟发送确认，会导致发送方不必要的超时重传","expanded":true},{"id":"f525c701-7104-49b0-80f1-920bfc0537c0","topic":"全双工字节流传输","expanded":true,"style":{"borderColor":"#EB4D3D"}}]},{"id":"a82bcb74-1d1a-4b16-8d2d-06eecd043b34","topic":"校验","expanded":true},{"id":"d47a9704-fe6e-43e6-ac5f-36b4faf5fafb","topic":"序号","expanded":true,"children":[{"id":"bdc543f4-bd6b-43ab-8e9d-8cb3e35ad56d","topic":"TCP首部的序号字段用来保证数据能有序提交给应用层，序号建立在传送的字节流之上","expanded":true}]},{"id":"1262fd5e-4685-404e-9416-1ea0cde369ba","topic":"确认","expanded":true,"children":[{"id":"501dd80f-26dc-472d-b0bb-2bc7dd4725f2","topic":"TCP首部的确认号表明期望收到对方的下一个报文段数据的第一个字节的序号","expanded":true,"children":[{"id":"8dfc7922-ea87-49f7-b346-c3ab6bca591e","topic":"TCP默认使用累计确认","expanded":true}]}]},{"id":"87c1a9c5-f6c1-4e6f-9eef-6a4703bcea62","topic":"重传","expanded":true,"children":[{"id":"d6f5ad7e-f463-4680-9191-4adc51ad4d82","topic":"超时","expanded":true,"children":[{"id":"9ae49c36-8a29-488e-8e1a-b1d8fe2ba689","topic":"TCP每发送一个报文段，就对这个报文段设置一次计时器。计时器设置的重传时间到期但还未收到确认时，就要重传这一报文段","expanded":true}]},{"id":"e426f9d7-36fa-4051-83f2-b9f01ca70832","topic":"冗余ACK","expanded":true,"children":[{"id":"7c717473-6fd0-4840-aaca-85f6c6a7114c","topic":"再次确认某个报文段的ACK，而发送方先前已经收到过该报文段的确认","expanded":true},{"id":"010bbb8e-1c71-4212-8f8c-d7d8aed5c197","topic":"当收到对于某个报文段的3个冗余ACK，可以认为该报文段已经丢失（快速重传），这时发送方可以立即对该报文执行重传","expanded":true}]}]}]},{"id":"4e0a09a2-52df-4d03-9bfb-38440af8e54a","topic":"超时重传时间的选择","expanded":true,"children":[{"id":"41a4abd7-3257-4314-b9b5-e1bad1eee4cc","topic":"RFC6298 超时重传时间计算","expanded":true,"children":[{"id":"3b55af89-1751-4656-893a-757f9b0fb3ac","topic":"超时重传时间RTO因略大于往返时间RTT","expanded":true},{"id":"8551e8b2-6ebe-4065-af9c-b99f171bad65","topic":"利用每次测量得到的RTT样本，计算加权平均往返时间RTTs","expanded":true}],"note":"RFC6298 建议：初始 RTT_S1 = RTT_1，α = 1/8 = 0.125（0 ≤ α < 1）；初始 RTT_D1 = RTT_1 / 2，β = 1/4 = 0.25（0 ≤ β < 1）。","formula":{"tex":"\\begin{aligned} RTO &= RTT_S + 4 \\times RTT_D \\\\ RTT_S' &= (1 - \\alpha)RTT_S + \\alpha\\,RTT_{\\text{样本}} \\\\ RTT_D' &= (1 - \\beta)RTT_D + \\beta\\,|RTT_S - RTT_{\\text{样本}}| \\end{aligned}","displayMode":true,"mathml":"<span class=\"katex\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\"><semantics><mtable rowspacing=\"0.25em\" columnalign=\"right left\" columnspacing=\"0em\"><mtr><mtd><mstyle scriptlevel=\"0\" displaystyle=\"true\"><mrow><mi>R</mi><mi>T</mi><mi>O</mi></mrow></mstyle></mtd><mtd><mstyle scriptlevel=\"0\" displaystyle=\"true\"><mrow><mrow></mrow><mo>=</mo><mi>R</mi><mi>T</mi><msub><mi>T</mi><mi>S</mi></msub><mo>+</mo><mn>4</mn><mo>×</mo><mi>R</mi><mi>T</mi><msub><mi>T</mi><mi>D</mi></msub></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel=\"0\" displaystyle=\"true\"><mrow><mi>R</mi><mi>T</mi><msubsup><mi>T</mi><mi>S</mi><mo mathvariant=\"normal\" lspace=\"0em\" rspace=\"0em\">′</mo></msubsup></mrow></mstyle></mtd><mtd><mstyle scriptlevel=\"0\" displaystyle=\"true\"><mrow><mrow></mrow><mo>=</mo><mo stretchy=\"false\">(</mo><mn>1</mn><mo>−</mo><mi>α</mi><mo stretchy=\"false\">)</mo><mi>R</mi><mi>T</mi><msub><mi>T</mi><mi>S</mi></msub><mo>+</mo><mi>α</mi><mtext> </mtext><mi>R</mi><mi>T</mi><msub><mi>T</mi><mtext>样本</mtext></msub></mrow></mstyle></mtd></mtr><mtr><mtd><mstyle scriptlevel=\"0\" displaystyle=\"true\"><mrow><mi>R</mi><mi>T</mi><msubsup><mi>T</mi><mi>D</mi><mo mathvariant=\"normal\" lspace=\"0em\" rspace=\"0em\">′</mo></msubsup></mrow></mstyle></mtd><mtd><mstyle scriptlevel=\"0\" displaystyle=\"true\"><mrow><mrow></mrow><mo>=</mo><mo stretchy=\"false\">(</mo><mn>1</mn><mo>−</mo><mi>β</mi><mo stretchy=\"false\">)</mo><mi>R</mi><mi>T</mi><msub><mi>T</mi><mi>D</mi></msub><mo>+</mo><mi>β</mi><mtext> </mtext><mi mathvariant=\"normal\">∣</mi><mi>R</mi><mi>T</mi><msub><mi>T</mi><mi>S</mi></msub><mo>−</mo><mi>R</mi><mi>T</mi><msub><mi>T</mi><mtext>样本</mtext></msub><mi mathvariant=\"normal\">∣</mi></mrow></mstyle></mtd></mtr></mtable><annotation encoding=\"application/x-tex\">\\begin{aligned} RTO &amp;= RTT_S + 4 \\times RTT_D \\\\ RTT_S&#x27; &amp;= (1 - \\alpha)RTT_S + \\alpha\\,RTT_{\\text{样本}} \\\\ RTT_D&#x27; &amp;= (1 - \\beta)RTT_D + \\beta\\,|RTT_S - RTT_{\\text{样本}}| \\end{aligned}</annotation></semantics></math></span>"}},{"id":"afcc8173-f3e5-4f26-8807-4f66e44b5db0","topic":"举例","expanded":true,"style":{"branchColor":"#15831C"},"children":[{"id":"c891d777-bb06-4e96-8ac8-ea078aa41682","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-165cfcf2ca5164.png","width":590.56,"height":282.95},"children":[{"id":"ba9f72cc-264e-4176-9ae5-b5827283177e","topic":"针对出现超时重传时无法测准往返时间RTT的问题","expanded":true},{"id":"b3f0a649-43ef-4443-9760-7632375ab482","topic":"Karn提出计算加权平均往返时间RTTs时，只要报文段重传，就不采用其往返时间RTT样本","expanded":true},{"id":"ad8372ac-880a-450b-9f27-da0a7524aa01","topic":"对Karn修正后：报文段每重传一次，就把超时重传时间RTO增大一些，RTO新 = RTO旧 * 2","expanded":true}]}]}]},{"id":"59f8ccfd261864f2ea706868e9","topic":"TCP流量控制","expanded":true,"style":{"borderColor":"#E32C2D"},"children":[{"id":"29e98d5a-778d-449d-bbc4-bd27c108894d","topic":"一般来说我们总希望数据传输快一些","expanded":true,"children":[{"id":"035e785e-79d1-4d83-abb6-f26bad49941a","topic":"但如果数据发送过快，接收方可能来不及接收，造成数据丢失","expanded":true}]},{"id":"25c9bd83-94cc-4ad3-9bef-6db159023295","topic":"流量控制：让发送方的发送速率不要太快，让接收方来得及接收","expanded":true},{"id":"42ce63cb-b613-416b-a188-a06dcd57784c","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-22b545f9a03a65.png","width":523.92,"height":257.61},"children":[{"id":"61a14142-55c4-43c2-bdc4-8ed2e6441290","topic":"利用滑动窗口机制可以在TCP连接上实现对发送方的流量控制","expanded":true},{"id":"b17b1c7f-bb4f-4c55-9aa6-4b939fd92680","topic":"发送窗口 = Min{接收窗口，拥塞窗口}","expanded":true,"style":{"borderColor":"#EB4D3D"},"children":[{"id":"62446bc3-fd39-4e89-bda3-6d6c196f066e","topic":"接收方根据自己的接收窗口的大小，动态调整发送方发送窗口的大小，限制发送速率","expanded":true},{"id":"e83c1b71-072d-4fb5-8924-b2b813a086d6","topic":"发送方根据其对当前网络拥塞的估计而确定拥塞窗口值，大小与网络带宽和时延有关","expanded":true}]},{"id":"e9836afc-c3fc-472b-a2cf-7f6e19c2bd89","topic":"TCP发送方收到接收方的零窗口通知后，应启动持续计时器。持续计时器超时后，向接收方发送零窗口探测报文","expanded":true}]}]},{"id":"32351443-213a-4796-ab0e-5c6fd2a99d2c","topic":"TCP拥塞控制","expanded":true,"style":{"borderColor":"#E32C2D"},"children":[{"id":"39a9f25d-9dbe-4325-93ae-d0a871f45c44","topic":"概述","expanded":true,"children":[{"id":"cdb68858-7368-4158-9caa-edb7dd6e583c","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-723e5b8708d664.png","width":364.09,"height":174.07},"children":[{"id":"e9aba3e7-a91c-4e84-b54b-69af8b3c8f8e","topic":"拥塞","expanded":true,"children":[{"id":"b21009bb-f57b-419b-85e1-46c368b60f85","topic":"对网络中某一资源的需求超过了该资源所能提供的可用部分，网络性能就要变坏","expanded":true}]},{"id":"f132e482-0c4c-4f0c-81d9-4312ffb1798a","topic":"拥塞控制","expanded":true,"children":[{"id":"93148374-12c2-45d6-b2fd-1ae94b04dc5a","topic":"防止过多数据注入网络，保证网络中的路由器或链路不致过载","expanded":true}]},{"id":"054258b3-64db-47ae-b622-2b04e679ac2c","topic":"若出现拥塞而不进行控制，整个网络的吞吐量将随输入负荷的增大而下降","expanded":true}]}]},{"id":"e0d1ba01-96d2-4040-8c2d-1c39cbea6fbc","topic":"四种拥塞控制算法的条件","expanded":true,"style":{"branchColor":"#EA8ABA"},"children":[{"id":"b64b5811-6735-4828-9dfc-8ef073c8f712","topic":"数据是单方向传送，而另一个方向只传送确认","expanded":true},{"id":"05f40a03-fd4a-4bc5-af44-2348acb538d8","topic":"接收方总是有足够大的缓存空间，因而发送方发送窗口的大小由网络的拥塞程度来决定","expanded":true},{"id":"06da1c15-6373-4a1b-b9b4-7ed03326cada","topic":"以最大报文段MSS的个数为讨论问题的单位，而不是以字节为单位","expanded":true}]},{"id":"29de7398-f03d-49b2-9bbf-d0b2168dcc49","topic":"慢开始+拥塞避免","expanded":true,"children":[{"id":"663fb9de-ea0b-44f5-a57d-11b40f9f4910","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-5400cb3b904eea.png","width":566.61,"height":191.75},"children":[{"id":"98b4d48b-d11e-4e55-89be-a38b73b1c3a3","topic":"慢开始","expanded":true,"children":[{"id":"a82584fa-4626-451c-9c15-f4b7fa2fa49f","topic":"是指一开始向网络注入的报文段少，而非增长速度慢","expanded":true},{"id":"d450d16b-ef13-4f8e-b100-21a16f0a8464","topic":"每经过一个传输轮次（RTT）拥塞窗口翻倍","expanded":true},{"id":"8c0a96a9-314a-4d74-b698-f3e04240bc63","topic":"关注于一个传输轮次，每收到一个新报文段的确认后，拥塞窗口+1，宏观体现为翻倍","expanded":true}]},{"id":"652dd38d-3040-4a94-b16d-572da1811eb0","topic":"拥塞避免并非完全能够避免拥塞，而是指在拥塞避免阶段将拥塞窗口控制为按线性规律增长，使网络比较不容易出现拥塞","expanded":true}]}]},{"id":"a6524845-e76c-4ce7-b999-56d023d37297","topic":"快重传+快恢复","expanded":true,"style":{"branchColor":"#EA8ABA"},"children":[{"id":"02b12ec8-17fa-407f-81d4-81d6488a3cb8","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-fa3718fdc86e31.png","width":586.3,"height":225.95},"children":[{"id":"78fe6162-a7a3-49c3-bf8f-438f42e7613e","topic":"所谓快重传，就是使发送方尽快进行重传，而不是等超时重传计时器超时再重传","expanded":true},{"id":"326fe14f-1df8-4103-aada-0a01d6f71d50","topic":"要求接收方不要等待自己发送数据时才进行捎带确认，而是立即发送确认","expanded":true},{"id":"2dca4d93-eabe-487d-b340-372fa11a37cf","topic":"即使收到了失序的报文段也要立即发出对已收到报文段的重复确认","expanded":true},{"id":"4cc32102-ab9b-4590-85f0-73c315af00d4","topic":"发送方一旦收到三个连续的重复确认，就将相应的报文段立即重传，而非等待超时再重传","expanded":true},{"id":"9a0e25d8-92ac-4d3c-8792-fecb398ca33a","topic":"对于个别丢失的报文段，发送方不会出现超时重传，不会误以为是拥塞，可提高20%网络吞吐量","expanded":true}]}]}]},{"id":"34ed58cc-e4d0-4dbe-a0e9-2a2716b15a00","topic":"TCP报文段首部格式","expanded":true,"style":{"borderColor":"#E32C2D"},"children":[{"id":"765a126c-2fef-4531-9557-029d97a341f5","topic":"图示","expanded":true,"style":{"branchColor":"#15831C"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-a80f35aaa582a2.png","width":273.74,"height":220.42},"children":[{"id":"96aa7343-3897-463d-b97c-c95e0e31ce96","topic":"为了实现可靠传输，TCP采用面向字节流的方式","expanded":true},{"id":"5d613085-6131-4962-aed0-b5c141470fba","topic":"但TCP发送数据时，从发送缓存取出一部分或全部字节并给其添加一个首部使之成为TCP报文段后进行发送","expanded":true,"children":[{"id":"f269d0e2-1880-4e3e-92a0-bf03fcde9ecf","topic":"一个TCP报文段由首部和数据载荷两部分构成","expanded":true},{"id":"914d283c-f1ce-4c3d-9656-464ae74da14e","topic":"TCP的全部功能都体现在它首部中各字段的作用","expanded":true}]}]},{"id":"5e7dc35b-9e6b-4ace-8b97-2123f2d7a887","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-fa67bc17242ceb.png","width":730.75,"height":235.94},"children":[{"id":"fc79a9b6-1e7c-4c14-bec7-a2a568c6396a","topic":"源端口和目的端口：标识该TCP报文段的应用进程","expanded":true},{"id":"ab7d7837-30f2-49ef-91c9-a6b3566682ab","topic":"序号：指出本TCP报文段数据载荷的第一个字节的序号","expanded":true},{"id":"7324a21c-f82f-4fa7-9a72-1a785ef660f8","topic":"确认号：期望收到对方下一个数据报的数据载荷的第一个字节的序号，也是对收到所有数据的确认","expanded":true,"children":[{"id":"201bebb3-da0c-4aa3-874c-a03c96a21cd8","topic":"若确认号=n，n-1数据已经正确接收","expanded":true}]},{"id":"8b505dbb-4d1f-4b29-847e-1395d1e97a18","topic":"数据偏移：指出TCP报文段的数据起始处距离TCP报文段的起始处有多远（指出首部长度）","expanded":true,"children":[{"id":"edbf12ed-83ee-4b8c-a9ff-8c294c0747ec","topic":"单位为4字节","expanded":true}]},{"id":"5f1f1b80-b3a4-4947-b1f5-0f37baa8654a","topic":"保留：今后使用","expanded":true},{"id":"bf5a934e-af83-43b4-bb4a-0ca970770f99","topic":"URG：紧急指针字段有效","expanded":true},{"id":"f17acf5e-7fde-4d09-901c-08cac82cfe6a","topic":"ACK：取值为1时确认号字段才有效","expanded":true},{"id":"b9c80533-3f63-496a-b4c9-49a16fbdc5a5","topic":"PSH：报文段尽快上交应用进程，不必等到接收缓存都填满后再向上交付","expanded":true},{"id":"67abf904-a61e-477e-89d4-04619d7e7765","topic":"RST：用来复位TCP连接，为1时，表明TCP连接出现了异常，必须释放连接再重新建立连接；还用来拒绝一个非法的报文段或拒绝打开一个TCP连接","expanded":true},{"id":"6bae5f2e-f70e-4072-a9e0-8a6dfc16a618","topic":"SYN：在TCP连接建立时用来同步序号","expanded":true},{"id":"f3f76487-5f6e-4d4f-b69a-c1791aaa2dad","topic":"FIN：用来释放TCP连接","expanded":true},{"id":"0c1b1b98-a636-43e9-9f82-87ee23250b23","topic":"窗口：指出发送本报文段一方的接收窗口","expanded":true},{"id":"c9c58655-8bd3-4e3a-8efa-3bf644522961","topic":"校验和：检查包括TCP报文段首部和数据载荷两部分（校验时需加上前面12字节伪首部）","expanded":true},{"id":"44d1059a-e7ad-46e6-8c28-83c3ff51c5fd","topic":"紧急指针：指出在本报文段中紧急数据共有多少字节（当发送方有紧急数据时，可将紧急数据插队到发送缓存的最前面）","expanded":true},{"id":"ec5393c3-b9f2-49b7-843c-be1f9de1f672","topic":"选项","expanded":true,"children":[{"id":"349d62b5-abd1-4586-810f-e6f8b78af282","topic":"最大报文段长度MSS选项：TCP报文段数据载荷部分的最大长度","expanded":true},{"id":"b5b8efec-8cfc-44f6-a375-f6999a23822a","topic":"窗口扩大选项：为了扩大窗口（提高吞吐率）","expanded":true},{"id":"b058825c-17a0-426c-8373-d73bbad2eb85","topic":"时间戳选项：用来计算往返时间RTT；用于处理序号超范围情况","expanded":true},{"id":"eaeed3ba-001c-4e8b-8329-7b0fa55f898b","topic":"选择确认选项","expanded":true}]},{"id":"01284b8d-1790-45f2-9c31-33b6411e5a29","topic":"填充：使整个首部长度是4B的整数倍","expanded":true}]}]}]}}