rpki/specs/11_rtr.md
2026-03-09 11:25:42 +08:00

65 lines
1.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 11. RTR (The Resource Public Key Infrastructure (RPKI) to Router Protocol)
## 11.1 Cache Server
### 11.1.1 功能需求
- 支持Full SyncReset Query
- 支持Incremental SyncSerial Query
- 支持多客户端并发
- 支持Serial递增
- 保留一定数量的delta
- 支持原子更新
### 11.1.2 架构设计
采用一级缓存+二级缓存并存的方式。
![img.png](img/img.png)
其中,一级缓存为运行时缓存,主要职责:
- 存储当前完整的snapshot
- 历史Delta队列管理
- Serial管理
- RTR查询响应
二级缓存为持久化缓存,主要职责:
- snapshot持久化
- 缓存重启后的快速恢复snapshot和serial
- 不参与实时查询
- 异步写入
### 11.1.3 核心数据结构设计
#### 11.1.3.1 总cache
```rust
struct RtrCache {
serial: AtomicU32,
snapshot: ArcSwap<Snapshot>,
deltas: RwLock<VecDeque<Arc<Delta>>>,
max_delta: usize,
}
```
#### 11.1.3.2 Snapshot
```rust
struct Snapshot {
origins: Vec<RouteOrigin>,
router_keys: Vec<RouterKey>,
aspas: Vec<Aspa>,
created_at: Instant,
}
```
#### 11.1.3.3 Delta
```rust
struct Delta {
serial: u32,
announced: Vec<Payload>,
withdrawn: Vec<Payload>,
}
```
## 11.2 Transport
初版实现RTR over TLS(可外网)和RTR over TCP内网两种方式。