fastdds源码分析之Locator
文章目录Locator 是什么1. 概念2. Locator 类型3. Locator vs 地址4. 与 Endpoint 的关系5. 总结Locator 是什么1. 概念Locator 是 RTPS 中标识通信通道的结构类似于网络中的 “地址端口” 组合用于定位目标。Locator_t kind port address[16]成员类型说明kindint32_t传输类型 (UDPv4/TCPv6/SHM 等)portuint32_t端口号addressoctet[16]IP 地址 (支持 IPv4/IPv6)2. Locator 类型类型Kind 值说明LOCATOR_KIND_UDPv41UDP over IPv4LOCATOR_KIND_UDPv62UDP over IPv6LOCATOR_KIND_TCPv44TCP over IPv4LOCATOR_KIND_TCPv68TCP over IPv6LOCATOR_KIND_SHM16共享内存LOCATOR_KIND_ETHERNET0x02000000以太网3. Locator vs 地址┌─────────────────────────────────────────────────────────────────────┐ │ Locator 统一不同传输协议 │ ├─────────────────────────────────────────────────────────────────────┤ │ │ │ UDPv4 Locator: │ │ kind UDPv4, port 7412, address [0,0,0,0,0,0,0,0,0,0,0,0,192,168,1,100] │ │ ↓ │ │ 192.168.1.100:7412 │ │ │ │ SHM Locator: │ │ kind SHM, port 0, address M │ │ ↓ │ │ Shared Memory Segment │ │ │ │ TCPv4 Locator: │ │ kind TCPv4, port 7412, address [192,168,1,100] │ │ ↓ │ │ TCPv4:192.168.1.100:7412 │ │ │ └─────────────────────────────────────────────────────────────────────┘4. 与 Endpoint 的关系Endpoint │ ├── unicastLocatorList // 本机单播地址列表 ├── multicastLocatorList // 多播地址列表 └── remoteLocatorList // 远程地址列表5. 总结┌────────────────────────────────────────────────────────────────────┐ │ Locator 总结 │ ├────────────────────────────────────────────────────────────────────┤ │ │ │ 本质: 网络地址 端口的抽象 │ │ │ │ 作用: │ │ • 定位目标 (UDP/TCP/SHM) │ │ • 统一不同传输协议的地址表示 │ │ • 用于发送和接收数据 │ │ │ │ 特点: │ │ • 支持 IPv4/IPv6/SHM/Ethernet │ │ • kind 区分传输类型 │ │ • 16 字节地址支持 IPv6 │ │ │ └────────────────────────────────────────────────────────────────────┘