From c3202e229a4a4e8735455e90d5ca1626f4d92bf6 Mon Sep 17 00:00:00 2001 From: Hanzhang ma Date: Mon, 24 Feb 2025 23:38:30 +0100 Subject: [PATCH] add some notes --- OralNotes.md | 350 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 350 insertions(+) diff --git a/OralNotes.md b/OralNotes.md index 639128a..7228d95 100644 --- a/OralNotes.md +++ b/OralNotes.md @@ -1,7 +1,19 @@ +还差什么? + +1-3 Theoretical Problems + +4 ask yourself questions + +3 RIP OSPF BGP? + +3 讲述一下RA RS NA NS的过程 + [toc] + + ## 什么是一个自治系统?(Autonome Systeme) 自治系统(Autonomous System,AS)指的是在互联网中由单一管理实体(如网络运营商、企业、大学等)控制的一组IP网络和路由器集合。每个自治系统都有一个唯一的自治系统号码(ASN),用于在边界网关协议(BGP)中标识和交换路由信息。自治系统内部使用统一的路由策略管理数据流,而各AS之间则通过BGP互联,从而构成全球互联网的基础架构。 @@ -335,3 +347,341 @@ NDP 维护一个 **邻居缓存表(Neighbor Cache)**,用于跟踪邻居的 2. 自适应链路状态方法 1. **链路状态(Link State)**:每个路由器维护整个网络的拓扑图,包含所有路由器和链路的状态。 2. **自适应(Adaptive)**:路由器根据网络拓扑的变化动态更新链路状态数据库。 + +## 讲一下RIP? + +## 什么是OSPF? + +## 什么是BGP? + +**OSPF**、**RIP** 和 **BGP** 是三种常见的路由协议,分别适用于不同的网络环境和需求。以下是它们的详细说明: + +--- + +## **1. OSPF(Open Shortest Path First)** + +### **1.1 概述** +- **类型**:链路状态路由协议(Link-State Routing Protocol)。 +- **适用范围**:中大型企业网络、ISP 网络。 +- **标准**:RFC 2328。 + +### **1.2 工作原理** +1. **链路状态信息收集**: + - 每个路由器通过 **Hello 协议** 发现邻居路由器,并收集链路状态信息(如链路成本、带宽等)。 + +2. **链路状态广播**: + - 每个路由器将收集到的链路状态信息封装成 **链路状态通告(LSA, Link State Advertisement)**,并广播给整个网络。 + - 使用 **泛洪(Flooding)** 机制确保所有路由器收到 LSA。 + +3. **链路状态数据库同步**: + - 每个路由器维护一个 **链路状态数据库(LSDB, Link State Database)**,存储整个网络的拓扑信息。 + - 通过交换 LSA,所有路由器的 LSDB 最终同步。 + +4. **最短路径计算**: + - 每个路由器使用 **Dijkstra 算法** 计算到所有目标网络的最短路径。 + - 根据计算结果更新路由表。 + +5. **区域划分**: + - OSPF 支持将网络划分为多个 **区域(Area)**,以减少路由信息的传播范围。 + - **Area 0** 是骨干区域,其他区域必须与 Area 0 直接或间接连接。 + +### **1.3 特点** +- **快速收敛**:在网络拓扑变化时,路由信息传播较快,收敛速度快。 +- **支持分层设计**:通过区域划分减少路由信息的传播范围。 +- **计算复杂度高**:需要更多的计算资源和存储空间。 + +### **1.4 适用场景** +- 中大型企业网络。 +- ISP 网络。 + +--- + +## **2. RIP(Routing Information Protocol)** + +### **2.1 概述** +- **类型**:距离向量路由协议(Distance-Vector Routing Protocol)。 +- **适用范围**:小型网络。 +- **版本**:RIP v1(RFC 1058)、RIP v2(RFC 2453)。 + +### **2.2 工作原理** +1. **路由表初始化**: + - 每个路由器初始化自己的路由表,记录到直连网络的距离(通常为 0)和下一跳路由器。 + +2. **定期广播路由信息**: + - 每个路由器定期(默认 30 秒)向邻居路由器广播自己的路由表。 + - 广播的内容包括目标网络和到该网络的距离(跳数)。 + +3. **更新路由表**: + - 路由器收到邻居的路由表后,根据以下规则更新自己的路由表: + - 如果通过邻居到达目标网络的距离更短,则更新路由表。 + - 如果邻居的路由表中包含新的目标网络,则添加到自己的路由表中。 + +4. **路由收敛**: + - 通过多次广播和更新,路由表最终收敛到稳定的状态。 + +### **2.3 特点** +- **简单易实现**:算法简单,适合小型网络。 +- **慢收敛问题**:在网络拓扑变化时,路由信息传播较慢,可能导致路由环路。 +- **最大跳数限制**:RIP 的最大跳数为 15,超过 15 跳的网络被视为不可达。 + +### **2.4 适用场景** +- 小型网络。 +- 对路由计算复杂度要求较低的场景。 + +--- + +## **3. BGP(Border Gateway Protocol)** + +### **3.1 概述** +- **类型**:路径向量路由协议(Path-Vector Routing Protocol)。 +- **适用范围**:互联网骨干网、ISP 之间的路由。 +- **版本**:BGP-4(RFC 4271)。 + +### **3.2 工作原理** +1. **建立邻居关系**: + - BGP 路由器通过 **TCP 连接(端口 179)** 建立邻居关系(Peer)。 + - 邻居关系可以是 **内部 BGP(iBGP)** 或 **外部 BGP(eBGP)**。 + +2. **交换路由信息**: + - 邻居之间交换 **BGP 更新消息(Update Message)**,包含目标网络和路径属性(如 AS 路径、下一跳等)。 + +3. **路径选择**: + - 每个 BGP 路由器根据路径属性(如 AS 路径长度、本地优先级等)选择最佳路径。 + - 最佳路径被添加到路由表中,并广播给其他邻居。 + +4. **路由策略**: + - BGP 支持灵活的路由策略配置,如路由过滤、路径偏好设置等。 + +### **3.3 特点** +- **支持大规模网络**:BGP 是互联网的核心路由协议,支持大规模路由表。 +- **路径向量协议**:通过 AS 路径属性避免路由环路。 +- **路由策略灵活**:支持复杂的路由策略配置。 + +### **3.4 适用场景** +- 互联网骨干网。 +- ISP 之间的路由。 +- 大型企业网络的多宿主连接。 + +--- + +## **4. 三种协议的对比** + +| **特性** | **OSPF** | **RIP** | **BGP** | +| -------------- | ------------------------ | ---------- | ---------------------------- | +| **类型** | 链路状态 | 距离向量 | 路径向量 | +| **适用范围** | 中大型企业网络、ISP 网络 | 小型网络 | 互联网骨干网、ISP 之间的路由 | +| **收敛速度** | 快 | 慢 | 中等 | +| **计算复杂度** | 高 | 低 | 高 | +| **路由策略** | 有限 | 无 | 灵活 | +| **典型应用** | 企业内网、ISP 网络 | 小型局域网 | 互联网骨干网 | + +--- + +## **5. 总结** +- **OSPF**:适用于中大型网络,支持分层设计和快速收敛,计算复杂度较高。 +- **RIP**:适用于小型网络,简单易实现,但存在慢收敛问题。 +- **BGP**:适用于互联网骨干网和 ISP 之间的路由,支持复杂的路由策略,但配置和管理较为复杂。 + +根据网络规模和需求,可以选择合适的路由协议。 + +## A200 Address Resolution and Neighbor Discovery (Theorie) + +Das RFC 826 definiert das Address Resolution Protocol (ARP). In RFC 4861 wird das Neighbor Discovery Protocol (NDP) spezifiziert. RFC 826 定义了地址解析协议(ARP)。RFC 4861 规定了邻居发现协议(NDP)。 + +1. **Wozu wird ARP eingesetzt? Was ist der Unterschied zu NDP?** **ARP 的用途是什么?它与 NDP 的区别是什么?** + My answer: ARP is used to convert the IPv4 Address to Hardware address, i.e. MAC address. + NDP is used in IPv6 protocol + While ARP works by broadcasting requests, NDP uses ICMPv6 messages and **multicast** addresses to achieve more efficient neighbor discovery. + +2. **Beschreiben Sie den Aufbau einer ARP-PDU und erläutern Sie die Bedeutung der einzelnen Felder!** **描述 ARP-PDU 的结构并解释各个字段的含义!** + Hardware type 2 + protocol type 2 + hardware size 1 + protocol size 1 + + op code 2 + src_ip: 4 + src_hw: 6 + dst_ip: 4 + dst_hw: 6(ff) + +3. **Welche unterschiedlichen ARP-PDUs gibt es? Welche NDP-PDUs gibt es?** **有哪些不同的 ARP-PDU?NDP-PDU 又有哪些?** + reply and request + NA NS RS rA + + + +4. **Wie lang (in Bytes) ist eine ARP-PDU in einem Netz in dem IPv4 und Ethernet eingesetzt werden?** **在 IPv4 和以太网网络中,ARP-PDU 的长度是多少字节?** 28 + +5. **Wie lang (in Bytes) ist eine Neighbor Solicitation Nachricht?** **Neighbor Solicitation 消息的长度是多少字节?** + ![image-20250224232406578](./assets/image-20250224232406578.png) + +6. **Das RFC 826 spricht von einer Tabelle (table), deren Implementierung meist als ARP-Cache bezeichnet wird. Was soll laut RFC mit einer Ethernet-SDU passieren, wenn kein Eintrag zur Ziel-IP-Adresse in der Tabelle gefunden wird?** **RFC 826 提到了一张表(table),其实现通常称为 ARP 缓存。RFC 规定如果表中没有找到目标 IP 地址的条目,对以太网 SDU 应该怎么处理?** + First, the host broadcast the ARP request packet to every neighbor in the network. + If the host receives the ARP reply packet, add the entry to both sides. + else drop the packet. + +### A300 Fragmentierung und IP-Tunneling (Theorie) + +i) In wie viele Fragmente wird ein IP-Paket mit Größe 9000 Byte zerlegt, um über ein Ethernet mit MTU = 1500 Byte übertragen zu werden? Geben Sie eine vollständige Rechnung an! 一个大小为 9000 字节的 IP 包在 Ethernet 的 MTU 为 1500 字节的情况下会被分成多少个片段?请提供完整的计算过程! + +ii) Nennen Sie drei Gründe dafür, dass Netzbetreiber IP-Fragmentierung in ihren Netzen verbieten. Erläutern Sie diese Gründe! 请列举网络运营商在其网络中禁止 IP 分片的三个原因,并对这些原因进行解释!**Three Reasons Why Network Operators Prohibit IP Fragmentation and Their Explanations** + +IP fragmentation occurs when a packet exceeds the Maximum Transmission Unit (MTU) of a network link and must be broken into smaller fragments. Many **network operators prohibit IP fragmentation** due to the following reasons: + +**1. Performance Degradation & Increased Overhead** + +- Fragmentation increases the number of packets that must be processed, leading to **higher CPU and memory usage** in routers and firewalls. +- Each fragment requires additional headers, increasing **network overhead** and reducing effective data transmission efficiency. +- Reassembly at the destination requires buffer space, which can cause delays and resource exhaustion in high-throughput environments. + +**2. Security Risks & Susceptibility to Attacks** + +- Fragmentation makes networks vulnerable to **fragmentation-based attacks**, such as **overlapping fragments (Teardrop attack)** and **tiny fragment attacks** used to evade security filters. +- Intrusion Detection Systems (IDS) and firewalls may struggle to inspect fragmented packets, allowing attackers to **bypass security policies** and smuggle malicious payloads. +- Attackers can send fragmented packets with missing fragments, causing **DoS (Denial of Service)** by exhausting resources on the target system waiting for reassembly. + +**3. Complications in Path MTU Discovery (PMTUD) & Packet Loss Issues** + +- Many modern networks use **Path MTU Discovery (PMTUD)** to dynamically determine the optimal packet size. If fragmentation is allowed, incorrect PMTUD settings can result in persistent retransmissions. +- If a single fragment of a fragmented packet is lost, the entire packet must be retransmitted, leading to **higher packet loss rates** and inefficiencies. +- Some middleboxes (e.g., NAT devices, firewalls) drop fragmented packets, causing unpredictable failures in communication. + +### **Conclusion:** + +Because of these issues, **network operators often prohibit IP fragmentation and instead rely on techniques like MSS (Maximum Segment Size) adjustment and PMTUD** to ensure efficient packet transmission without fragmentation. + +------ + +**网络运营商在其网络中禁止 IP 分片的三个原因及其解释** + +IP 分片(IP Fragmentation)发生在数据包超过网络链路的 **最大传输单元(MTU)** 时,需要拆分成多个小片进行传输。许多**网络运营商禁止 IP 分片**的原因如下: + +**1. 性能下降 & 额外开销增加** + +- 分片会导致 **路由器和防火墙的 CPU 及内存负载增加**,因为它们需要处理更多的小数据包。 +- 每个分片都需要附加额外的头部信息,增加了**协议开销**,降低了有效数据传输效率。 +- 目标端的 **数据重组** 需要缓冲区(buffer),在高吞吐量环境下容易造成**延迟**或**资源耗尽**。 + +**2. 安全风险增加 & 易受攻击** + +- 分片容易受到 **基于分片的攻击**,例如**重叠分片攻击(Teardrop attack)\**和\**微小分片攻击(Tiny Fragment Attack)**,这些攻击可用于绕过安全检查。 +- **入侵检测系统(IDS)和防火墙** 可能无法正确分析分片数据包,导致攻击者可以绕过安全策略,传输恶意负载。 +- 攻击者可以发送 **丢失部分片段的数据包**,导致目标设备的**资源耗尽(DoS 攻击)**,因为系统需要长时间等待完整数据包。 + +**3. PMTUD(路径 MTU 发现)问题 & 数据丢失风险** + +- 现代网络通常使用 **路径 MTU 发现(PMTUD)** 机制来动态确定最佳数据包大小,如果允许分片,错误的 PMTUD 配置可能导致**持续的重传**问题。 +- 如果 **一个分片丢失**,整个数据包必须重新传输,导致**更高的数据丢失率**和**不必要的网络流量**。 +- 一些中间设备(如 **NAT 设备、防火墙**)可能会**直接丢弃**分片数据包,导致通信失败。 + +iii) Wie wird in modernen TCP/IP-Implementierungen dafür gesorgt, dass Fragmentierung in der Regel nicht erforderlich ist? 在现代的 TCP/IP 实现中,是如何确保通常情况下不需要分片的? + +### **How Do Modern TCP/IP Implementations Avoid the Need for Fragmentation?** + +Modern TCP/IP implementations use several techniques to **minimize or eliminate IP fragmentation**, ensuring efficient packet transmission. The key mechanisms include: + +#### **1. Path MTU Discovery (PMTUD)** + +- **PMTUD dynamically determines the maximum packet size** that can be transmitted without fragmentation. +- It works by sending packets with the **Don't Fragment (DF) flag** set. If a router cannot forward the packet due to MTU limitations, it drops the packet and sends an **ICMP "Fragmentation Needed" message** back to the sender. +- The sender then **reduces the packet size** accordingly until it finds a suitable MTU. +- **Drawback:** Some networks block ICMP messages, causing PMTUD to fail. + +#### **2. TCP Maximum Segment Size (MSS) Adjustment** + +- During the **TCP handshake**, both communicating hosts negotiate the **Maximum Segment Size (MSS)**, which defines the largest payload a TCP segment can carry. +- The MSS is set to ensure that the TCP segment, when combined with headers, does not exceed the MTU. +- This prevents the need for IP fragmentation at the transport layer. + +#### **3. IPv6 Enforces No Fragmentation by Routers** + +- Unlike IPv4, **IPv6 does not allow routers to fragment packets**. Instead, **only the sender can fragment** based on the discovered MTU. +- IPv6 requires **end-to-end PMTUD**, ensuring that packets fit within the smallest MTU along the path. +- This shifts the responsibility of fragmentation from routers to the sender, improving network efficiency. + +#### **4. Datagram Packetization Layer Path MTU Discovery (DPLPMTUD)** + +- To address ICMP blocking issues in traditional PMTUD, **DPLPMTUD** uses **probe packets** of increasing sizes to discover the optimal MTU. +- This method is more reliable since it does not rely on ICMP messages. +- Supported in protocols like **QUIC and modern TCP implementations**. + +### **Conclusion:** + +Modern TCP/IP implementations avoid fragmentation by: + +1. **Using PMTUD** to dynamically adjust packet sizes. +2. **Negotiating MSS** in TCP to prevent oversized packets. +3. **Relying on IPv6's no-fragmentation rule** and sender-side control. +4. **Using DPLPMTUD** as an advanced method for MTU discovery. + +------ + +### **在现代的 TCP/IP 实现中,是如何确保通常情况下不需要分片的?** + +现代 TCP/IP 实现采用多个技术来**减少或避免 IP 分片**,从而提高数据传输效率。主要方法包括: + +#### **1. 路径 MTU 发现(PMTUD)** + +- **PMTUD 负责动态确定数据包的最大可传输大小**,以避免分片。 +- 它通过发送 **“不分片(DF)”标志** 的数据包来测试路径 MTU。 +- 如果路由器无法转发该数据包(因为 MTU 限制),它会丢弃数据包并返回 **ICMP “需要分片”** 消息。 +- 发送方根据反馈**调整数据包大小**,直到找到合适的 MTU。 +- **缺点:**某些网络会屏蔽 ICMP 消息,导致 PMTUD 失败。 + +#### **2. TCP 最大段大小(MSS)调整** + +- 在 **TCP 握手** 过程中,双方会协商 **最大段大小(MSS)**,决定 TCP 段的最大有效负载。 +- MSS 设定时会确保 TCP 段加上 **IP 和 TCP 头部** 不会超过 MTU。 +- 这样可以在 **传输层避免 IP 分片**,确保数据包大小适应网络环境。 + +#### **3. IPv6 取消路由器分片** + +- IPv6 **不允许路由器对数据包进行分片**,只有**发送端**可以执行分片。 +- IPv6 依赖 **端到端的 PMTUD**,确保数据包适应最小 MTU。 +- 这使得分片的控制权交给发送方,**提升了网络效率**。 + +#### **4. 数据报分组层路径 MTU 发现(DPLPMTUD)** + +- 传统 PMTUD 依赖 ICMP 消息,但某些网络会**屏蔽 ICMP**,导致失败。 +- **DPLPMTUD** 通过发送不同大小的**探测数据包**来测试路径 MTU,而不依赖 ICMP。 +- 这种方法更可靠,并已在 **QUIC 和现代 TCP 实现** 中得到支持。 + +### **总结:** + +现代 TCP/IP 通过以下方式避免分片: + +1. **使用 PMTUD** 动态调整数据包大小。 +2. **TCP 通过 MSS 协商**,确保 TCP 段不会超出 MTU 限制。 +3. **IPv6 取消路由器分片**,让发送方控制数据包大小。 +4. **DPLPMTUD 提供更先进的 MTU 发现机制**,解决 ICMP 屏蔽问题。 + +### A301 IPv6 (Theorie) + +i) Erklären Sie anhand eines Beispiels auf einer Ihrer VMs wie link-local Adressen aus der MAC-Adresse abgeleitet werden! 请结合您虚拟机中的一个示例,解释链路本地地址是如何从 MAC 地址派生的! + +1. Split the MAC address into two halves: + + - `08:00:27:53:8a:e0` → `08:00:27` and `53:8a:e0` + +2. Insert `FF:FE` in the middle: + + - `08:00:27:FF:FE:53:8a:e0` + +3. Invert the 7th bit (Universal/Local bit) of the first byte (08): + + - Convert `08` to binary: `00001000` + - Flip the **7th bit**: `00001010` (which is `0A` in hex) + - New identifier: **0A:00:27:FF:FE:53:8A:E0** + +4. + +5. ``` + FE80::0A00:27FF:FE53:8AE0 + ``` + +ii) Wie implementiert IPv6 „Broadcasts”? IPv6 是如何实现“广播”的? + +iii) Welches sind die privaten Adressbereiche in IPv6, analog zu 10.0.0.0/8, 172.16.0.0/12 und 192.168.0.0/16 in IPv4? IPv6 中的私有地址范围与 IPv4 中的 10.0.0.0/8、172.16.0.0/12 和 192.168.0.0/16 对应的是什么? + +iv) Für besondere Zwecke, außer für den privaten Gebrauch, sind noch weitere Bereiche reserviert. Wie teilt sich der IPv6 Addressraum auf? Hinweis: IANA, ignorieren Sie die vom IETF reservierten Bereiche 除了私人用途外,还有其他特殊用途的地址范围被保留。IPv6 地址空间如何划分?提示:请参考 IANA,并忽略由 IETF 保留的范围。