{"format":"brushup-mindmap-v1","id":"net-00-sheet5","title":"第四层 传输层","structure":"timeline-h","theme":"auto","root":{"id":"b16904e71cebca51ac13db94fb","topic":"第四层 传输层","expanded":true,"children":[{"id":"ea3a9408472803da13ae98e06f","topic":"功能","expanded":true,"children":[{"id":"ab924bb2-b4b3-4155-b0b9-1aa1f2dd1487","topic":"概念","expanded":true,"children":[{"id":"bc5fc1dc-0ec2-4db2-a670-e28e9cea1e45","topic":"传输层向它上面的应用层提供通信服务，属于面向通信部分的最高层，也是用户功能的最底层","expanded":true},{"id":"c86c069c-f517-432e-90e1-17260fa264c3","topic":"为运行在不同主机上的进程提供了逻辑通信","expanded":true,"children":[{"id":"4785adda-fffd-4cd5-86f6-1d45c22841ad","topic":"vs","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"c26eed29-e5ca-4207-89c3-05339776a31e","topic":"网络层","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"4655917b-b50e-49f0-bdbd-194f6ee7d95a","topic":"为不同链路层的主机提供通信","expanded":true,"style":{"background":"#FFABD5"}},{"id":"65f2c874-d761-43b4-b966-ec99370594e8","topic":"AS系统","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"81001da2-298f-4946-b62b-da8fd70b5cc3","topic":"为不同IGP的网络提供通信","expanded":true,"style":{"background":"#FFABD5"}}]}]},{"id":"b4633d94-2bb5-4973-affe-b06db540ff47","topic":"数据链路层","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"1570d79f-296e-4efb-8c7f-77f230228b7f","topic":"为不同物理层的主机提供通信","expanded":true,"style":{"background":"#FFABD5"}}]},{"id":"d96957ab-017d-41a2-85b1-c9310484ecbf","topic":"物理层","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"ea1e0a37-14de-4969-a32c-2efbdbc12d7e","topic":"提供通信","expanded":true,"style":{"background":"#FFABD5"}}]}]}]}]},{"id":"bbc2f769-93ae-4149-b1c8-f22ebce8cfba","topic":"功能","expanded":true,"children":[{"id":"0e1d978a-ea02-4d9c-b5f7-5adf7654ff8f","topic":"提供端到端的通信","expanded":true,"style":{"background":"#FDD834"}},{"id":"fc8cbfda-2d30-4728-b809-1e62fbb8bc89","topic":"复用+分用","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"1d249723-8b28-4589-9538-c6ae7d44fb0e","topic":"复用：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"116e81ba-7837-4bb7-be9f-73879e70a43d","topic":"发送方不同进程使用同一个传输层协议传输","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"3519b247-fd6a-4902-bd7c-e98db09a1b46","topic":"分用：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"cfeb5a6e-efac-41f9-927a-6e0b4fdcce68","topic":"接收方收到这些数据后可以正确交付到目的应用进程","expanded":true,"style":{"background":"#8EDDF9"}}]}]},{"id":"765191d8-324b-4b59-9adf-6786d7826f92","topic":"向更高层的用户屏蔽底层的网络","expanded":true},{"id":"7fef8cf6-36de-467b-a3bb-fa64542e97c6","topic":"传输层可以对收到的报文进行差错检测（首部+数据）","expanded":true,"children":[{"id":"4e78d330-d3f0-4174-9c3c-46eafcb8ef4a","topic":"vs","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"fe8eff00-bd32-4874-a86b-aca3b3d4e444","topic":"网络层","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"34c1fce2-72c6-4ccb-8efa-6b3b4f36b9b1","topic":"只检测首部","expanded":true,"style":{"background":"#FFABD5"}}]},{"id":"be73f94a-c8d6-4293-b670-4fcbbf96f481","topic":"数据链路层","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"d2e19925-9b5d-473c-9629-1f3728fb8df0","topic":"首部+数据","expanded":true,"style":{"background":"#FFABD5"}}]}]}]}]},{"id":"d4a6ee15-be6a-429d-ae5c-52b39f513a0f","topic":"可以提供可靠通信 --- TCP，和不可靠通信 --- UDP","expanded":true}]},{"id":"d54c153b-bc36-4789-bd44-0202695d3f6a","topic":"寻址和端口","expanded":true,"children":[{"id":"3ffe291c-6d98-4658-8543-59b8e2d3307a","topic":"考频：低","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"6aeaa9ae-f8f5-4a09-9ea4-2fa8b3197aa3","topic":"无","expanded":true}]},{"id":"0a8e9897-214b-4b01-b6f8-5878a465e815","topic":"端口作用","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"f505f15e-8033-4260-8b11-641ba527a96f","topic":"port","expanded":true,"children":[{"id":"3ccc2e2a-8f03-4890-a411-5833eb67fe56","topic":"127.0.0.1:8080","expanded":true}]},{"id":"c829f4cd-26cf-4743-9d9f-dc96594df1ab","topic":"用于标识主机的进程，是让计算机知道可以把数据交付给哪一个进程的标志","expanded":true,"style":{"background":"#8EDE99"}},{"id":"a8478a9e-b8f9-4412-b882-cc963da47737","topic":"端口只有本地意义","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"26e88c5c-9e3d-475a-a01d-2fc537fc3f00","topic":"即不同主机使用相同端口是没有任何联系的","expanded":true}]},{"id":"89f1b11a-9f39-4c7b-909f-0fa1c88925c4","topic":"vs","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"34548c5d-1040-4269-9bd6-6ac14cce2dfb","topic":"物理层MAC","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"f4830168-1d9c-4a2d-bfda-4d236baca5f5","topic":"指明物理的主机","expanded":true,"style":{"background":"#FFABD5"}}]},{"id":"f1f4b6fe-18e4-4ff1-bfe9-fd0b960e00cd","topic":"网络层IP/CIDR","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"9b6d0e2e-88f0-48b5-8640-a7feac165aea","topic":"指明逻辑上的主机、网络","expanded":true,"style":{"background":"#FFABD5"}}]},{"id":"d8c26a23-8a1f-4487-9917-5c6f5577a54a","topic":"传输层端口","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"d8355501-af2a-4b70-be78-f0ed28b23ab5","topic":"指明主机上进程使用的端口","expanded":true,"style":{"background":"#FFABD5"}}]}]}]},{"id":"fe27b706-b6fd-4e6c-bded-b5afdcc348f7","topic":"端口号：","expanded":true,"children":[{"id":"ebf11e01-7a41-4f0f-9d85-e2b18e8f8e1f","topic":"服务器端口","expanded":true,"children":[{"id":"20140550-3a2b-44de-a025-1f14adc45bfc","topic":"熟知端口号（0~1023）","expanded":true,"children":[{"id":"588a8f7b-84ae-4775-ad76-b669691fc826","topic":"FTP","expanded":true,"children":[{"id":"155e9422-c246-4fa9-8d44-32a77e9a1bce","topic":"连接端口21，数据端口20","expanded":true,"children":[{"id":"ce1ac294-84a5-4bc1-9f06-ca493bf3ed18","topic":"主动情况20，被动情况可以是1024~65335","expanded":true}]}]},{"id":"eb34c109-1899-4f71-8781-a3c8f00eca3a","topic":"TELNET","expanded":true,"children":[{"id":"2230d120-cba6-415f-a655-cfaf1dd259a0","topic":"23","expanded":true}]},{"id":"e81ae8eb-275d-47f8-99a5-cd47018fffd3","topic":"SMTP","expanded":true,"children":[{"id":"1969c759-8294-455a-8a33-2d320844e007","topic":"25","expanded":true}]},{"id":"19c60e93-659e-4a9d-86d4-2b15bd74e09d","topic":"DNS","expanded":true,"children":[{"id":"5fe11038-c735-4f94-b6cf-fcf1b76622ed","topic":"53","expanded":true}]},{"id":"236c09f5-88a8-4361-b9ff-52fddc1cb025","topic":"FTFP","expanded":true,"children":[{"id":"cff20d10-df16-4e98-aaa1-53fa7af5269a","topic":"69","expanded":true}]},{"id":"653405ea-11cd-4074-b8c5-6d121f713fe9","topic":"HTTP","expanded":true,"children":[{"id":"867c94d3-08d1-4aaa-b30d-53bbe21cc138","topic":"80","expanded":true}]},{"id":"8ff5b8e4-80cb-457e-a56e-186937435d8c","topic":"POP3","expanded":true,"children":[{"id":"4940c9ed-005e-4f54-8219-a3ca5f363ca3","topic":"110","expanded":true}]}]},{"id":"2c9f7419-72cf-4fb2-b1d1-768501f4d634","topic":"登记端口号（1024~49151）","expanded":true,"children":[{"id":"bb7539a8-84fb-4d52-a6bd-bc6e6d59131b","topic":"使用这类端口需要在IANA上登记","expanded":true}]}]},{"id":"fdbbf438-b860-4164-ab9b-1002905d390d","topic":"客户端端口（49152~65535）","expanded":true,"children":[{"id":"a2fb9747-6992-47fd-94d3-78a4d776139b","topic":"又称短暂端口号","expanded":true,"children":[{"id":"5a2b462b-4776-4a4f-855b-11107f1973de","topic":"只有在客户进程运行时动态选择","expanded":true}]},{"id":"cddb1af7-5970-4af5-865e-ce8666cc7ef0","topic":"通信结束后端口号就回收了","expanded":true}]}]},{"id":"a01e995a-45df-4086-bb75-76efb9b68221","topic":"套接字","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"3d08f8f5-8a97-4f9c-8ef0-b5c54c1e8b38","topic":"就是socket = ( IP ：port )","expanded":true,"style":{"background":"#FDD834"}},{"id":"1508b292-dd65-4627-8a5c-b540b93ee9ca","topic":"可以唯一的识别网络中一个主机上的一个进程","expanded":true,"style":{"background":"#FDD834"}},{"id":"34d51c64-9370-4996-aae2-9c4a3fb38adb","topic":"实际上是一个通信端点","expanded":true}]}]},{"id":"2bfb7094794be79c8b32e810af","topic":"UDP","expanded":true,"children":[{"id":"9af59488-a3b8-42d0-821e-6223cc545e20","topic":"特色","expanded":true,"children":[{"id":"83b74acd-a5fb-4c65-8a21-8b389f341203","topic":"实现了传输层协议最少的工作，只在IP的基础上增加了两个服务：【复用分用和差错检测】","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"b6e0a66d-228a-4b00-8763-f3072bd12cee","topic":"优点：","expanded":true,"children":[{"id":"4b6bc177-1bd4-4c5d-b9e6-c91a13fe1793","topic":"无需建立连接","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"08fe6aa9-588d-403d-a799-eef965058af4","topic":"也不会有建立连接的时延","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"466318e6-322f-4c07-b0b0-eb1d1209a4d4","topic":"即：","expanded":true,"children":[{"id":"dff07102-92a5-445f-93b0-ebab8c02f6f7","topic":"DHCP可以用UDP要IP地址","expanded":true},{"id":"140c1eb2-258f-4104-926c-7a86840b766f","topic":"DNS使用UDP可以更快的查找IP","expanded":true},{"id":"77f332f9-c512-4ed0-a12e-0bca61df59b6","topic":"HTTP不能使用UDP，因为HTTP需要文本数据的可靠性","expanded":true,"style":{"background":"#8EDE99"}}]}]}]},{"id":"620b5414-8a09-42c1-ba9e-f38bb59fb04d","topic":"无连接状态","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"975523fc-087d-4d69-b93e-b2cb20f92f7c","topic":"UDP不维护连接状态也就不需要跟踪参数，所以应用服务器使用UDP时一般可以支持更多的【活动客户机】","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"112057f6-113a-44fa-87d6-9ad43748afed","topic":"分组首部开销小","expanded":true,"children":[{"id":"216b5da1-1461-4aa6-9a78-4d6a070ecfe7","topic":"TCP首部有20B，UDP只有8B","expanded":true,"children":[{"id":"72acb314-94da-4d14-8e76-89e2e2a3737b","topic":"vs","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"29256373-5f01-431a-99e3-1f1ed8c4f842","topic":"MAC帧首部 6+6+2 B，FCS为 4 B","expanded":true,"style":{"background":"#FFABD5"}},{"id":"4420dec0-c646-4d7f-b3dc-c45843d598d6","topic":"PPP帧 F+A+C+协议+FCS+F","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"c0434aef-4c13-456b-a9a9-c8c443ee0498","topic":"1+1+1+2+2+1 B","expanded":true,"style":{"background":"#FFABD5"}},{"id":"e796a133-31cf-4e99-a4db-5a13a9aac1ef","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-30127e121f7cb9.png","width":542.97,"height":174.02}}]},{"id":"f7189cb2-9fbb-42e9-add7-fcedfe62fdf2","topic":"DHCP帧 F+A+C+FCS+F","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"78542297-773c-4d9a-aad1-e9e16eaae50f","topic":"1+1+1+2+1 B","expanded":true,"style":{"background":"#FFABD5"}}]},{"id":"3180eaa2-d4b7-4a5f-81aa-bd1bb1c066f4","topic":"IPv4首部为4*(5~15)B","expanded":true,"style":{"background":"#FFABD5"}},{"id":"d8fbb039-a59b-461a-b7fe-8a5a632a71f2","topic":"IPv6首部为40B","expanded":true,"style":{"background":"#FFABD5"}}]}]}]},{"id":"1f04051b-3d71-4513-99b3-50ccb8aa02c7","topic":"应用层可以更好的控制发送的数据和发送的时间","expanded":true,"children":[{"id":"6768a1c7-ab99-4ac5-adf7-6e6ee150d371","topic":"UDP没有拥塞控制，所以网络拥塞不会影响发送效率","expanded":true,"children":[{"id":"28920431-d402-4739-8562-5fe6f1c928c1","topic":"但是网络拥塞会影响丢包率等等，UDP只是不会向TCP那样进行流量控制","expanded":true}]},{"id":"40cabf07-3c1b-4050-b1bc-244e2f3d4a81","topic":"应用可以接受部分信息的丢失、但不允许有较大时延，就使用UDP","expanded":true,"style":{"background":"#8EDE99"}}]},{"id":"5150dfa7-34df-4512-91e3-623ed20f7f32","topic":"支持一对一、一对多、多对一、多对多","expanded":true}]},{"id":"06807154-051c-4acd-8522-dc6eb26b721a","topic":"特点：","expanded":true,"children":[{"id":"f285252e-9374-4834-a710-deb9be533b2a","topic":"UDP是面向报文的","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"3d548e47-1bd1-4673-af7f-d2508ea564a8","topic":"应用层应该自己设计好该让UDP发多大的数据报","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"4186ae0a-e9b3-42f9-ad52-779280db1777","topic":"因为UDP只负责加个头部就给IP了，其他啥也不做，如果到了IP层发现太大了网络层会自己分片，如果发现太小了，又会发现头部太长了，两者都不划算","expanded":true}]}]},{"id":"9bb0f2e3-4190-4dd5-9b10-aded97780d64","topic":"UDP常用于一次传输较少的数据","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"bc62a7d2-d251-44b3-84cc-a2da9377e424","topic":"例如DNS、SNMP","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"d927c121-7e8a-440d-9b2a-d693072e91cc","topic":"UDP不保证可靠交付","expanded":true,"style":{"background":"#FF9595"},"children":[{"id":"727c523d-d2ca-4176-a04f-7ed8d20e948a","topic":"所以应用层需要自行进行传输可靠性的维护","expanded":true}]}]},{"id":"4445c47d-15b4-494f-a74e-4aa3d159be19","topic":"UDP首部格式","expanded":true,"children":[{"id":"d221992a-b365-47b1-96d7-38e8f144ac15","topic":"图示","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-22b57375fa95ac.png","width":619,"height":231},"children":[{"id":"4555250e-9f6f-4273-b793-fabf3e3ca294","topic":"UDP部分：","expanded":true,"children":[{"id":"861ee8f6-f9df-4e92-af02-368254cf8454","topic":"源端口：需要回信的时候选用","expanded":true},{"id":"c2807a37-5854-4bfd-a713-39cb64f91c11","topic":"目的端口：目的端口号，一定需要","expanded":true,"style":{"background":"#FF9595"}},{"id":"176e358e-416e-405f-8416-0f420d454752","topic":"长度：UDP数据报的长度（首部+数据），最小值是8。","expanded":true,"style":{"background":"#FF9595"}},{"id":"dae348c4-b1aa-433a-9e47-9cae795ee4a5","topic":"校验和：检测有没有错，如果有错就直接丢弃掉","expanded":true}]},{"id":"817ba1f2-a785-4070-9040-c863c71f5791","topic":"源端口和校验和是可选的，不想要就全设置为0","expanded":true,"style":{"background":"#8EDE99"}}]}]},{"id":"abf5f7b1-c258-468f-b830-d7dd321b5f21","topic":"UDP校验和","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"01d2ddfa-7b1c-4498-b2c3-16a78c0f2126","topic":"步骤：","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"502e8eae-5300-42ef-8ab6-0de887db933c","topic":"伪首部：目的源IP+0+17+UDP长度","expanded":true,"style":{"background":"#FDD834"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-8cfb1b1c7bb12d.png","width":698.6,"height":339.75}},{"id":"ff8cfaa3-7bb1-4891-9bfd-c7a2a05d9dc0","topic":"计算UDP校验和（注意红色字）","expanded":true,"style":{"background":"#FDD834"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-3e1fc22c0ad240.png","width":483,"height":295},"children":[{"id":"c91caef7-c796-4139-8f8e-87ac277d35b2","topic":"发送端：","expanded":true,"children":[{"id":"7793dda8-02b0-4c24-84cb-36fbdf6c8a52","topic":"1. 加入伪首部","expanded":true},{"id":"63edc493-8f5f-4888-8fc4-fe55470890eb","topic":"2. 校验和全0","expanded":true},{"id":"ab38ec7d-9899-40e9-8396-479230758aef","topic":"3. 填补数据、每行4B","expanded":true},{"id":"6fd51d28-1566-4e0b-abef-7b879cd8914f","topic":"4. 伪首部、首部、数据一起求二进制反码","expanded":true},{"id":"bb4c51ac-0b09-46a7-8866-109339057685","topic":"5. 最后取求和结果反码放入校验和中","expanded":true}]},{"id":"fc564192-188c-4808-af30-4c5d4f16d508","topic":"接受端收到后：","expanded":true,"children":[{"id":"e06e746f-6580-40e5-bc2b-d0050511213e","topic":"1. 添加伪首部，数据补0","expanded":true},{"id":"5852def4-810c-4884-a32c-ffc79b5d714c","topic":"2. 伪首部、首部、数据二进制反码求和，若全为1，则说明没有错，否则会丢给应用层差错报告。","expanded":true}]}]}]},{"id":"18ab0aab-778e-47b2-a5e0-07d35d759bf1","topic":"特点：","expanded":true,"children":[{"id":"68f3b675-8c20-45ab-9626-fd37abc6024b","topic":"如果UDP校验出来发现是错了，可以直接丢弃，也可以丢给上层处理，但是得附上错误报告，告诉上层哪里错了","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"ade35906-1e01-4827-805e-f984419e2c97","topic":"连ICMP都不发送","expanded":true}]},{"id":"e614e2b9-bf07-48dc-913a-f0d1af256565","topic":"UDP这里采用的是直接求和最后求反码的方法","expanded":true,"children":[{"id":"3a97387a-e465-481a-966a-98b17131c6fa","topic":"vs","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"a8bdbe07-2b17-43e3-86a8-a8ed2919b6df","topic":"FCS","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"cbdcfc7e-9e95-4667-8ff4-a57d03742c82","topic":"模二除法","expanded":true,"style":{"background":"#FFABD5"}}]},{"id":"09631ef0-65f5-4a6a-9fcf-f843f9f5410e","topic":"海明码","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"15ff61b4-e2af-48ea-a3df-e2e7032ecbb3","topic":"偶校验、异或运算","expanded":true,"style":{"background":"#FFABD5"}}]}]}]}]}]},{"id":"579a4603-7691-4bca-a267-eb3e77efbd9b","topic":"考频：低","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"67a5ca3f-4d87-4741-a173-2ee6a59a8e8b","topic":"18","expanded":true}]}]},{"id":"160a0861233b1572719fcb5070","topic":"TCP","expanded":true,"children":[{"id":"c01cf628-6620-4a16-af3f-cf4bd236d580","topic":"考频：超高","expanded":true,"style":{"background":"#BA69C8"},"children":[{"id":"e41d38d6-470b-49d8-a455-3848b8ea49cc","topic":"09*2、10、11*2、13-15、17、19-20*2、21*3、22*2、12大、16大","expanded":true}]},{"id":"3bddaa41-900a-448b-ae68-560736989be5","topic":"目的：","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"c745adbe-26ec-4225-b861-c9a8c70dd698","topic":"建立可靠、有序、无丢失、不重复传输","expanded":true,"style":{"background":"#FDD834"}}]},{"id":"b2135e97-a6cb-4824-a330-91d42f883d74","topic":"特点：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"047eaa50-2a47-4e71-9924-f55407158ef4","topic":"面向连接的传输层协议","expanded":true,"icons":["priority:1"],"style":{"background":"#8EDDF9"}},{"id":"9ee09333-a27e-4bf2-b71d-be6d10a4211c","topic":"只支持一对一传输（端对端）","expanded":true,"icons":["priority:2"],"style":{"background":"#8EDDF9"}},{"id":"3a2476bd-0530-4620-97bb-8ac4415c6f98","topic":"可靠的传输","expanded":true,"icons":["priority:3"],"style":{"background":"#8EDDF9"}},{"id":"87072550-357f-4728-afbb-a0fee81d75e9","topic":"提供全双工，所以发送端和接受端都设置有发送和接受缓存","expanded":true,"icons":["priority:4"],"style":{"background":"#8EDDF9"},"children":[{"id":"c34495eb-8041-4ebd-a0a3-5187f36a320d","topic":"【发送缓存】存 1. 应用程序准备发送的数据 2. TCP已发送但还没收到确认的数据","expanded":true},{"id":"59f1a120-0bb5-4126-9200-e6867f25f510","topic":"【接受缓存】存 1. 按序到达的但是没有被应用程序接受的数据 2. 未按序到达的数据","expanded":true}]},{"id":"5474e2b4-c165-4104-8db6-666e29e6a1ca","topic":"TCP的传输是面向字节流的（Byte Stream）","expanded":true,"icons":["priority:5"],"style":{"background":"#8EDDF9"},"children":[{"id":"da4cae89-00ca-475e-9f37-21ba443f66e0","topic":"应用程序每次和TCP交换一个数据块的大小，但TCP把其视为无结构的字节流","expanded":true}]}]},{"id":"2ad5578e-911c-4e28-b507-035af8ce9545","topic":"发送报文采用的方式","expanded":true,"children":[{"id":"978a79ca-8299-4e19-9bc2-d3d255a5f363","topic":"UDP --- 应用程序要发多少就发多少","expanded":true},{"id":"fa1070d9-9b18-4831-bfda-e7a7e6585ae0","topic":"TCP --- 根据接受窗口和拥塞情况决定","expanded":true}]},{"id":"83fd3883-d458-4b4a-abf6-b001d1f7bf2d","topic":"TCP首部","expanded":true,"icons":["priority:1","star:#ef4444"],"style":{"background":"#FDD834"},"children":[{"id":"29b84ddb-58f4-41d8-b556-eb7280f71621","topic":"图示","expanded":true,"style":{"background":"#FDD834"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-703b8e945795ed.png","width":626.25,"height":417.5},"children":[{"id":"ebb53a28-ebf1-4fe6-bd2c-dd4a434d1aa7","topic":"数据偏移","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"0072f89c-ca51-41bd-8e26-0c0e148efdbf","topic":"= IP首部的”长度”","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"082190f1-0b3c-4f90-b214-a724e36561d0","topic":"单位为4B，占4bit，所以范围为5~15","expanded":true}]},{"id":"988b9e47-ce4a-4db1-ba06-af78fcd13c56","topic":"!= IP首部的”片偏移“","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"0e5ead30-6814-4fc5-a5d9-513c6303e1e7","topic":"各bool变量","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"befb94f0-4fcb-4ca2-a7cc-c2824ef59507","topic":"紧急位 URG","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"8eac3060-438c-4e0d-8265-8b2e9cb789a2","topic":"URG=1时，表明紧急指针字段有效。它告诉系统此报文段中有紧急数据， 应尽快传送（相当于高优先级的数据）。","expanded":true,"children":[{"id":"50a83b2c-3f15-4dc1-b289-9418fbc4e3f2","topic":"但 URG 需要和紧急指针配合使用，即数据从第一个字节到紧急指针所指字节就是紧急数据。","expanded":true}]}]},{"id":"88028730-ed2e-4d9f-b081-391a20424fbc","topic":"确认位 ACK","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"364b4d19-e5bb-43a5-b5b6-309333635c51","topic":"仅当 ACK = 1 时确认号字段才有效。当ACK = 0时，确认号无效。","expanded":true,"children":[{"id":"301dbc2f-bf16-48b1-a8d2-b210a689691b","topic":"TCP 规定，在连接建立后所有传送的报文段都必须把 ACK 置 1。","expanded":true}]}]},{"id":"8a068dac-e982-4638-8626-8ba1e000109d","topic":"推送位 PSH (Push）","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"37ef7741-7ed2-40df-846c-5e5807aafe50","topic":"接收方 TCP 收到 PSH=1 的报文段，就尽快地交付给接收应用进程， 而不再等到整个缓存都填满后再向上交付。","expanded":true}]},{"id":"297e2b36-1066-41da-b845-0b6ffdfcf656","topic":"复位位 RST (Reset)","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"2573e0e5-1f46-449b-bf55-c250a1d2cd14","topic":"RST=1 时，表明 TCP 连接中出现严重差错(如主机崩溃或其他原因），必须释放连接，然后再重新建立运输连接。","expanded":true}]},{"id":"3a008bbc-a7a8-4cdd-9130-d84faa1f22bb","topic":"同步位 SYN","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"854fbfa6-596e-4e86-965e-924b0b6751ed","topic":"同步SYN=1表示这是一个连接请求或连接接受服文。","expanded":true,"children":[{"id":"94ecd80c-694f-4673-b085-433f17b36df6","topic":"当SYN = 1, ACK = 0时，表明这是一个连接请求报文，对方若同意建立连接，则应在响应报文中使用 SYN = 1，ACK = 1。","expanded":true}]}]},{"id":"24307a3a-19c1-4f33-8f42-f59fc90f5ce8","topic":"终止位 FIN (Finish)","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"61a27add-7b4b-4ee3-8278-a7ecacf45239","topic":"用来释放一个连接。当FIN=1时，表明此报文段的发送方的数据已发送完毕，并要求释放传输连接。","expanded":true}]}]},{"id":"5c6d237a-0c25-4718-83f4-55f796fc409f","topic":"校验和添加字段：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"51f0417f-cbd0-4d71-8d4a-054cd46cd5b6","topic":"源IP + 目的IP + 0 + 6 + TCP总长度","expanded":true,"style":{"background":"#8EDDF9"}},{"id":"d3c1e063-64dc-4ecc-8774-03499d7b4206","topic":"4B + 4B + 1B + 1B + 2B","expanded":true,"style":{"background":"#8EDDF9"}}]},{"id":"a105dda4-470d-49bf-89de-9b4d8490d03b","topic":"（不是固定首部了）选项：","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"f89931d6-5d80-4c2d-9eb6-1551c40590dc","topic":"因为TCP只规定了一种选项，就是MSS（最大报文长度）","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"32aa2ca9-9113-439e-830c-27ba30b4437e","topic":"选项字段可以like","expanded":true,"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-8eeeea78cd2b85.png","width":297,"height":263}}]}]}]}]},{"id":"328717c0-1fbd-447a-9f83-956d3dbee5fd","topic":"TCP连接","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"bca1f739-a899-4046-9d48-fc5ad1c911b7","topic":"TCP连接的端口是socket套接字","expanded":true,"style":{"background":"#8EDDF9"}},{"id":"7f8ce848-b37b-4800-900e-f60a43fa0015","topic":"建立阶段（三次握手）","expanded":true,"icons":["priority:1"],"style":{"background":"#8EDDF9"},"children":[{"id":"6bf75b94-7e42-4b39-b333-e664dcf4be8c","topic":"图示","expanded":true,"style":{"background":"#8EDDF9"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-ffdad47942b2e5.png","width":676.45,"height":450.22},"children":[{"id":"6ac24746-3b7e-408e-8864-b7dd52e91f20","topic":"注意：发送的帧中的各标记位的值、客户机服务器的阶段（CLOSED、SYN-SENT、ESTABLISHED、LISTEN、SYN-RCVD、ESTABLISHED）","expanded":true},{"id":"6efaf0a3-88c4-4bbd-a0b9-19f1891164a8","topic":"在服务器进入SYN-RCVD阶段时已经为该TCP连接分配了缓存和变量了","expanded":true,"style":{"background":"#FF9595"}},{"id":"29acd863-d2dc-4022-ac80-e8805480526f","topic":"注意：","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"ab59b9ea-5cda-48fa-b189-f14ba5dd9835","topic":"区分ack和ACK","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"982a7832-6b5b-4c5a-9270-2d71658a58f5","topic":"以及和之前学的ACK n区分","expanded":true,"style":{"background":"#FDD834"}}]}]}]}]},{"id":"1915147a-bfe2-40af-82ba-a10e204ff1b5","topic":"释放连接（四次挥手）","expanded":true,"icons":["priority:2"],"style":{"background":"#8EDDF9"},"children":[{"id":"b76a6f4f-32ee-44c0-b496-5897473bd2ab","topic":"图示","expanded":true,"style":{"background":"#8EDDF9"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-9182db71c1d0a6.png","width":678.76,"height":492.59},"children":[{"id":"5192f995-a0e0-4e01-b9ff-ace8c427ea5a","topic":"MSL：最大报文生存时间","expanded":true},{"id":"3cf99d35-d181-426e-a6bd-4da0cc099065","topic":"注意客户机的半关闭状态和等待重传","expanded":true}]}]},{"id":"c17da00c-95ad-4951-a400-5a1b31e9964b","topic":"SYN洪泛攻击","expanded":true,"children":[{"id":"30208505-5bfd-4700-b02f-a9164a401484","topic":"SYN洪泛攻击发生在OSI第四层，这种方式利用TCP协议的特性，就是三次握手","expanded":true},{"id":"e71299e6-dcfc-4d1b-91ef-5b4348268918","topic":"攻击者发送TCP SYN，SYN是TCP三次握手中的第一个数据包，而当服务器返回ACK后，该攻击者就不对其进行再确认","expanded":true},{"id":"f99afbf3-ec8b-44b6-a0ac-fb5e98679d7c","topic":"那这个TCP连接就处于【挂起】状态，也就是所谓的半连接状态，服务器收不到再确认的话 ，还会重复发送ACK给攻击者","expanded":true}]}]},{"id":"223706cf-1d8d-4e1d-9d48-820bb08ee396","topic":"TCP可靠传输","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"019503b3-7063-4770-9eb6-bd7c8fe0b16b","topic":"序号","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"1dc95677-6fe9-4835-82b0-07cdf65cda06","topic":"TCP给自己传输的每个【字节流】都编上了序号","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"e5c75609-b0e4-4d1b-8f21-245388e43f66","topic":"即：一个Byte一个序号","expanded":true,"style":{"background":"#FDD834"}},{"id":"255e641c-44bf-4dec-a76d-eddc42584ed8","topic":"注意：TCP不是把报文段/数据报/帧给标上的记号，而是给自己的【字节流】","expanded":true}]},{"id":"86c3697d-86eb-4b1b-ac45-a249e48018bc","topic":"例如：TCP发送了三个报文段，第一个有5B，第二个有3B，第三个有2B","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"b78b3d91-366d-47e4-94d0-50bc0635a998","topic":"则他们的seq分别为 seq = 0, seq = 5, seq = 8","expanded":true,"style":{"background":"#8EDE99"}}]}]},{"id":"083062b6-5867-485e-a3d4-871f720b4c04","topic":"确认","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"4a82ddf5-ca4b-43ea-b6e8-3dd9a861c4bf","topic":"TCP默认采用累计确认（类似GBN），对ack = 下一个我想要的序号","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"a7c9dfe2-1932-4919-95d1-532dec116450","topic":"例如：TCP发送了三个报文段，第一个有5B，第二个有3B，第三个有2B","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"7c28500b-b695-402e-b875-bf1e15e61f81","topic":"则他们发送后对应的的ack分别为 ack = 5(seq = 0), ack = 8(seq = 5), ack = 10(seq = 8)","expanded":true,"style":{"background":"#8EDE99"}}]}]}]},{"id":"406dad01-8a61-4e53-80b4-6806917a5a67","topic":"重传","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"289f8932-bcaf-48ad-9aef-22e5a92d5250","topic":"超时","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"abf13555-ec75-4b31-8075-c4a4cdcfcc4a","topic":"TCP每发送一个报文段就设置一个计时器，计时器时间到头还没收到ACK，就重发","expanded":true,"style":{"background":"#8EDDF9"}},{"id":"6fc4007c-0b59-43ae-8830-57d17c471d86","topic":"优化：","expanded":true,"children":[{"id":"3b8f73c9-d429-4b56-817f-93b32af9a6d0","topic":"TCP采用了自适应算法来计算加权往返时间RTTs，其会随着RTT变化而变化","expanded":true}]}]},{"id":"f169840d-0be6-4ebc-83fd-9f9de86e2c9f","topic":"冗余ACK","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"a02d4e13-7a2a-4e3a-a638-e569ba6f6f5a","topic":"当TCP同时收到了3个冗余ACK的时候，可以认为该报文已经丢失","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"94092f92-60a6-49ed-b6d4-7ffddd0f6261","topic":"例如：TCP发送了五个报文段，序号为0，1，2，3，4","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"52720da3-119c-49c1-91ea-c38d247f73a3","topic":"其中 1 丢失了，则发送方会收到3个 ack = 1（接收方在收到2、3、4的时候返回的）","expanded":true}]}]},{"id":"0e9634ff-fcf2-4be4-86db-f89c2d40d0af","topic":"出现冗余ACK时，采用快速重传","expanded":true}]}]}]},{"id":"bbdd7dbb-6ead-40b1-bf9b-961e69a572dd","topic":"TCP拥塞控制","expanded":true,"style":{"background":"#7986CB"},"children":[{"id":"4a4da8c5-c3ce-43f5-8d44-07b239a14d57","topic":"目的：","expanded":true,"children":[{"id":"bcc6eed1-6e63-4042-afaf-57bbd4d861d7","topic":"防止过多的数据注入网络，保证网络中的路由器或者链路不会过载","expanded":true}]},{"id":"849eac0d-f49c-4ec6-9a0f-72717ad80c9f","topic":"vs 流量控制","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"b5649c90-0cec-4e57-900e-72b439ec2b63","topic":"相同：都是控制发送方的发送速率来达到控制效果","expanded":true,"style":{"background":"#FFABD5"}},{"id":"23d34ec8-d6d9-4934-8979-8200997e6db2","topic":"区别：","expanded":true,"style":{"background":"#FFABD5"},"children":[{"id":"8e62e7ee-24da-41b2-8657-0af3d3d189e9","topic":"拥塞控制是全局性的过程，涉及所有网络的所有设备","expanded":true,"style":{"background":"#FFABD5"}},{"id":"e2da0ca9-9ed1-484e-9ff4-cff3f65ab395","topic":"流量控制是点对点的，接收端控制发送端，抑制发送数据的速率","expanded":true,"style":{"background":"#FFABD5"}}]}]},{"id":"3ed7f8cf-0753-4739-8dee-e68a2baa37e7","topic":"窗口：","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"64cc5562-c17d-4f79-aaa8-52c0cc1b109a","topic":"rwnd 接受窗口","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"4aba27e8-7aaa-4cb2-b936-b44eaf55b1b2","topic":"是【接收端】发的帧中的窗口大小","expanded":true,"style":{"background":"#FDD834"}}]},{"id":"37f7cf52-8cf4-4302-8ae8-7ab80e569234","topic":"cwnd 拥塞窗口","expanded":true,"style":{"background":"#FDD834"},"children":[{"id":"1cd7e05b-8d1f-475d-8149-15065705f50f","topic":"是发送端根据【当前网络】的拥塞情况设置的窗口值","expanded":true,"style":{"background":"#FDD834"}}]},{"id":"bf617083-38b0-4e23-ae2d-c628e1731a4b","topic":"发送窗口大小 = min(rwnd, cwnd)","expanded":true,"style":{"background":"#FDD834"}}]},{"id":"6afce380-f62c-4433-8b7d-01ec4db160d4","topic":"慢开始+拥塞避免：","expanded":true,"style":{"background":"#8EDE99"},"children":[{"id":"88f86383-b469-4c08-963d-7a3c55316a77","topic":"【每个RTT】会发送【MSS个数据】，每个RTT中可能会有【多个序号】的数据报","expanded":true,"style":{"background":"#8EDE99"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-4c5785492134c9.png","width":580.81,"height":397.61},"children":[{"id":"3eeed295-7553-4805-9d40-5cb926a05a25","topic":"最大报文段长度（MSS）","expanded":true},{"id":"7528a4ed-ab29-4b7f-9434-2ef850e4fbb9","topic":"慢开始指数增长的本质：","expanded":true,"icons":["priority:1"],"style":{"background":"#8EDE99"},"children":[{"id":"df8b1076-0dc7-4b70-a6b5-3ec85af96925","topic":"其中每个RTT每收到一个ACK，cwnd就+1","expanded":true,"style":{"background":"#FDD834"}}]},{"id":"f90397b5-97cc-47a1-846a-eb0ea5e0f4a1","topic":"拥塞避免：","expanded":true,"icons":["priority:2"],"style":{"background":"#8EDE99"},"children":[{"id":"e5598ccf-e891-4f97-82df-580edff5aa84","topic":"当cwnd达到ssthresh值以后，开始拥塞避免","expanded":true},{"id":"e825c14c-4e9a-47b5-ba20-0c9ed5b00228","topic":"拥塞避免时，每一个RTT不管MSS中有多少个序号的数据报，其cwnd始终都只+1","expanded":true}]},{"id":"dec26b90-abd6-4130-b031-456188b2924a","topic":"网络拥塞处理：","expanded":true,"icons":["priority:3"],"style":{"background":"#8EDE99"},"children":[{"id":"01003c76-9540-4d9c-ae61-f15db7d83110","topic":"当网络出现了拥塞的时候（例如丢包etc），进行两步操作：","expanded":true,"children":[{"id":"9b362003-1ad4-4d4f-baee-6e94ea76a9a3","topic":"设置ssthresh为当前cwnd的一半","expanded":true,"icons":["priority:1"]},{"id":"cc7e7693-49bb-4f9c-b9f7-076bdb4efe64","topic":"把cwnd重新归到 1，重新开始慢开始","expanded":true,"icons":["priority:2"]}]}]}]}]},{"id":"d14e79f2-d34f-44a2-ab74-f81e5fc8b6a9","topic":"快重传+快恢复：","expanded":true,"style":{"background":"#8EDDF9"},"children":[{"id":"2a6e151a-ad74-4608-8789-e0a278971bc7","topic":"【快开始+快恢复】是在”慢开始+拥塞避免“的一种对冗余ACK的优化，【快开始】就是检测到3个重复ACK后不用等计时器，直接重传。【快恢复】就是把cwnd和ssthresh直接减到cwnd的一半，开始【拥塞避免】","expanded":true,"style":{"background":"#8EDDF9"},"image":{"src":"https://gastigado.cnies.org/d/BrushUP/mm-935a6d9f6c453a.png","width":586.17,"height":335.36}}]}]}]},{"id":"d3a4cb19-6d09-4ee8-a059-81e97d8748b5","topic":"END","expanded":true}]},"relations":[{"id":"b1c01dea-d123-430f-bbfb-272722e5ac69","from":"4186ae0a-e9b3-42f9-ad52-779280db1777","to":"bc62a7d2-d251-44b3-84cc-a2da9377e424","bidirectional":false,"label":"所以"}],"summaries":[{"id":"50a4562e-3183-4ffd-bc77-d978f29b5071","parentId":"bbc2f769-93ae-4149-b1c8-f22ebce8cfba","start":1,"end":1,"label":""},{"id":"909ce430-9c56-49cb-9ebe-1fc4d48a81f5","parentId":"c17da00c-95ad-4951-a400-5a1b31e9964b","start":0,"end":2,"label":"影响"}]}