概述
I2P网络协议(I2NP)位于I2CP与各种I2P传输协议之间,负责管理路由器之间消息的路由与混合,以及在与对等体通信时(存在多个共同支持的传输方式)选择使用哪种传输方式。
I2NP 定义
I2NP(I2P 网络协议)消息可用于单跳、路由器到路由器、点对点通信。通过将消息加密并封装在其他消息中,它们可以安全地经过多个跳点传输至最终目的地。优先级仅在源节点本地使用,即在出站传输排队时使用。
下列列出的优先级可能不是最新的,并且可能随时更改。优先级队列的实现方式可能有所不同。
消息格式
下表指定了 NTCP 中使用的传统 16 字节头部。SSU 和 NTCP2 传输协议使用经过修改的头部。
| Field | Bytes |
|---|---|
| Type | 1 |
| Unique ID | 4 |
| Expiration | 8 |
| Payload Length | 2 |
| Checksum | 1 |
| Payload | 0 - 61.2KB |
最大分片数量为64个,但由于消息可能无法完全对齐,因此消息在名义上必须能够容纳在63个分片内。
初始片段的最大大小为 956 字节(假设为 TUNNEL 传递模式);后续片段的最大大小为 996 字节。因此最大大小约为 956 + (62 × 996) = 62708 字节,即 61.2 KB。
此外,传输方式可能还有额外的限制。NTCP 的限制是 16KB - 6 = 16378 字节。SSU 的限制大约是 32 KB。NTCP2 的限制大约是 64KB - 20 = 65516 字节,这超过了隧道所能支持的最大容量。
请注意,这些并非客户端所见数据报的限制,因为路由器可能会将回复的leaseSet和/或会话标签与客户端消息捆绑在一个大蒜消息(garlic message)中。leaseSet和标签总共可能增加约5.5KB。因此,当前数据报限制约为10KB。此限制将在未来的版本中提高。
消息类型
编号较大的优先级更高。大多数流量为 TunnelDataMessages(优先级 400),因此任何高于 400 的优先级本质上属于高优先级,而低于 400 的则属于低优先级。还需注意,许多消息通常通过探索性隧道(exploratory tunnels)而非客户端隧道进行路由,因此除非第一跳恰好位于同一节点,否则它们可能不在同一个队列中。
此外,并非所有消息类型都是未加密发送的。例如,在测试隧道时,路由器会封装一个 DeliveryStatusMessage,该消息被封装在 GarlicMessage 中,而后者又被封装在 DataMessage 中。
| Message | Type | Payload Length | Priority | Comments |
|---|---|---|---|---|
| DatabaseLookupMessage | 2 | 500 | May vary | |
| DatabaseSearchReplyMessage | 3 | Typ. 161 | 300 | Size is 65 + 32*(number of hashes) where typically, the hashes for three floodfill routers are returned. |
| DatabaseStoreMessage | 1 | Varies | 460 | Priority may vary. Size is 898 bytes for a typical 2-lease leaseSet. RouterInfo structures are compressed, and size varies; however there is a continuing effort to reduce the amount of data published in a RouterInfo. |
| DataMessage | 20 | 4 - 62080 | 425 | Priority may vary on a per-destination basis |
| DeliveryStatusMessage | 10 | 12 | Used for message replies, and for testing tunnels - generally wrapped in a GarlicMessage | |
| GarlicMessage | 11 | Generally wrapped in a DataMessage - but when unwrapped, given a priority of 100 by the forwarding router | ||
| TunnelBuildMessage | 21 | 4224 | 500 | |
| TunnelBuildReplyMessage | 22 | 4224 | 300 | |
| TunnelDataMessage | 18 | 1028 | 400 | The most common message. Priority for tunnel participants, outbound endpoints, and inbound gateways was reduced to 200 as of release 0.6.1.33. Outbound gateway messages (i.e. those originated locally) remains at 400. |
| TunnelGatewayMessage | 19 | 300/400 | ||
| VariableTunnelBuildMessage | 23 | 1057 - 4225 | 500 | Shorter TunnelBuildMessage as of 0.7.12 |
| VariableTunnelBuildReplyMessage | 24 | 1057 - 4225 | 300 | Shorter TunnelBuildReplyMessage as of 0.7.12 |
| Others (Types 0, 4-9, 12) | 0, 4-9, 12 | Obsolete, Unused |
请参阅 I2NP 规范页面 以获取完整的协议规范。另请参阅 通用数据结构规范页面 。
未来工作
目前尚不清楚当前的优先级方案是否普遍有效,以及各种消息的优先级是否应进一步调整。这需要进一步的研究、分析和测试。