{% extends "_layout.html" %} {% block title %}I2NP{% endblock %} {% block content %}
The I2P Network Protocol (I2NP), which is sandwiched between I2CP and the various I2P transport protocols, manages the routing and mixing of messages between routers, as well as the selection of what transports to use when communicating with a peer for which there are multiple common transports supported.
While I2NP has been quite stable since its inception in August of 2003, there have been minor modifications on occasion. Here is the I2NP Protocol Specification Version 0.9 (PDF) dated August 28, 2003. That document also references the Common Data Structures Specification Version 0.9. Beware - based on a quick comparison with the code, there are substantial differences between the implementation and the 2003 specifications.
Note - The following information is extracted from the current code base, however it may be incomplete and/or inaccurate. Check the code to be sure.
I2NP (I2P Network Protocol) messages can be used for one-hop, router-to-router, point-to-point messages. By encrypting and wrapping messages in other messages, they can be sent in a secure way through multiple hops to the ultimate destination. Priority is only used locally at the origin, i.e. when queuing for outbound delivery.
Both the NTCP and UDP transports implement priority transmission, but in quite different manners. UDP has complex code with queues for each priority, however it treats messages with priorities 400-499, for example, the same. (The priority queues are 100, 200, 300, 400, 500, and 1000) These are global queues for all peers. NTCP has a trivial linear search for the highest priority within each buffer for a particular peer. This is much less effective.
It isn't clear whether the current priority scheme is generally effective, and whether the priorities for various messages should be adjusted further. This is a topic for further research, analysis and testing.
Field | Bytes |
Unique ID | 4 |
Expiration | 8 |
Payload Length | 2 |
Checksum | 1 |
Payload | 0 - 60.6KB |
While the maximum payload size is nominally 64KB, the size is further constrained by the method of fragmenting I2NP messages into multiple 1KB tunnel messages as described in tunnel-alt.html. The maximum number of fragments is 64, and the message may not be perfectly aligned, so the message must nominally fit in 63 fragments, and be padded to a 16 byte boundary. Therefore the maximum size is 960 + (62 * 986) - 12 = 62080 bytes, or approximately 60.6KB.
In addition, the transports may have additional restrictions. NTCP currently limits to 16KB - 6 = 16378 bytes but this will be increased in a future release. The SSU limit is 32KB?
Note that these are not the limits for datagrams that the client sees, as the router may bundle a reply leaseset and/or session tags together with the client message in a garlic message. The leaseset and tags together may add about 5.5KB. Therefore the current datagram limit is about 10KB. This limit will be increased in a future release.
Also, not all message types are sent unencrypted. For example, when testing a tunnel, the router wraps a DeliveryStatusMessage, which is wrapped in a GarlicMessage, which is wrapped in a DataMessage.
Message | Type | Payload Length | Priority | Comments |
DatabaseLookupMessage | 2 | 100/400 | 400 normally; 100 if from HarvesterJob and sent directly; 400 for a router lookup | |
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 | 100/400 | Usually 100 (why?) 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 as we approach release 1.0. |
DataMessage | 20 | 4 - 62080 | 400 | |
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 | 300/500 | Usually 500 (why?) |
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 | 300/500 | Shorter TunnelBuildMessage as of 0.7.12 |
VariableTunnelBuildReplyMessage | 24 | 1057 - 4225 | 300 | Shorter TunnelBuildReplyMessage as of 0.7.12 |
Others listed in 2003 Spec | 0,4-9,12 | Obsolete, Unused |