{% extends "_layout.html" %} {% block title %}I2CP{% endblock %} {% block content %}

The I2P Client Protocol (I2CP) exposes a strong separation of concerns between the router and any client that wishes to communicate over the network. It enables secure and asynchronous messaging by sending and receiving messages over a single TCP socket, yet never exposing any private keys and authenticating itself to the router only through signatures. With I2CP, a client application tells the router who they are (their "destination"), what anonymity, reliability, and latency tradeoffs to make, and where to send messages. In turn the router uses I2CP to tell the client when any messages have arrived, to request authorization for some tunnels to be used, and, if necessary, to notify the client that the router is under attack and unable to operate safely.

As the I2CP requires all client libraries to provide an implementation of the end to end encryption (including ElGamal/AES+SessionTag), the protocol itself isn't likely to be adopted for normal client applications (except for those implemented in Java that can use the existing I2P Client SDK). This SDK is exposed in the i2p.jar package, which implements the client-side of I2CP. Clients should never need to access the router.jar package, which contains the router itself and the router-side of I2CP.

Applications can take advantage of the base I2CP plus the streaming and datagram libraries by using the Simple Anonymous Messaging or BOB protocols, which do not require clients to deal with any sort of cryptography. Also, clients may access the network by one of several proxies - HTTP, CONNECT, and SOCKS 4/4a/5. Alternatively, Java clients may access those libraries in ministreaming.jar and streaming.jar. So there are several options for both Java and non-Java applications.

I2CP end-to-end encryption was disabled in I2P release 0.6, leaving in place the end-to-end garlic encryption. However, client libraries must still implement public/private key signing for leasesets, and key management.

While the I2CP has been quite stable since its inception in August of 2003, there have been several messages added. Here is the I2CP Protocol Specification Version 0.9 (PDF) dated August 28, 2003. That document also references the Common Data Structures Specification Version 0.9. There have been several changes to the protocol since that time, and many of the messages in those documents were never implemented.

In a standard I2P installation, port 7654 is used by java clients to communicate with the local router via I2CP. By default, the router binds to address 127.0.0.1. To bind to 0.0.0.0, set the router advanced configuration option i2cp.tcp.bindAllInterfaces=true and restart.

I2CP Definition

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. Rather than completely document the messages here, we refer you to the old protocol and data specifications linked above, together with the actual code.

R->C is Router to Client; C->R is Client to Router

MessageDirectionType
BandwidthLimitsMessage (new in release 0.7.2) R->C 23
CreateLeaseSetMessage C->R 4
CreateSessionMessage C->R 1
DestLookupMessage (new in release 0.7) C->R 34
DestReplyMessage (new in release 0.7) R->C 35
DestroySessionMessage C->R 3
DisconnectMessage R->C 30
GetBandwidthLimitsMessage (new in release 0.7.2) C->R 8
GetDateMessage C->R 32
MessagePayloadMessage R->C 31
MessageStatusMessage R->C 22
ReceiveMessageBeginMessage R->C 6
ReceiveMessageEndMessage C->R 7
ReconfigureSessionMessage (new in release 0.7.1) C->R 2
ReportAbuseMessage R->C 29
RequestLeaseSetMessage R->C 21
SendMessageExpiresMessage (new in release 0.7.1) C->R 36
SendMessageMessage C->R 5
SessionStatusMessage R->C 20
SetDateMessage R->C 33

I2CP Initialization

When a client connects to the router, it first sends a single protocol version byte (0x2A). Then it sends a GetDateMessage and waits for the SetDateMessage response. Next, it sends a CreateSessionMessage containing the session configuration. It next awaits a RequestLeaseSetMessage from the router, indicating that inbound tunnels have been built, and responds with a CreateLeaseSetMessage containing the signed LeaseSet. The client may now initiate or receive connections from other I2P destinations.

I2CP Options

The following options are traditionally passed to the router via a SessionConfig contained in a CreateSessionMessage or a ReconfigureSessionMessage.

Option Recommended Arguments Allowable RangeDefaultDescription
inbound.quantity number from 1 to 3 1 to 62Number of tunnels in
outbound.quantity number from 1 to 3 No limit2Number of tunnels out
inbound.length number from 0 to 3 0 to 72Length of tunnels in
outbound.length number from 0 to 3 0 to 72Length of tunnels out
inbound.lengthVariance number from -1 to 2 -7 to 70Random amount to add or subtract to the length of tunnels in. A positive number x means add a random amount from 0 to x inclusive. A negative number -x means add a random amount from -x to x inclusive. The router will limit the total length of the tunnel to 0 to 7 inclusive. The default variance was 1 prior to release 0.7.6.
outbound.lengthVariance number from -1 to 2 -7 to 70Random amount to add or subtract to the length of tunnels out. A positive number x means add a random amount from 0 to x inclusive. A negative number -x means add a random amount from -x to x inclusive. The router will limit the total length of the tunnel to 0 to 7 inclusive. The default variance was 1 prior to release 0.7.6.
inbound.backupQuantity number from 0 to 3 No limit0Number of redundant fail-over for tunnels in
outbound.backupQuantity number from 0 to 3 No limit0Number of redundant fail-over for tunnels out
inbound.nickname string  Name of tunnel - generally used in routerconsole, which will use the first few characters of the Base64 hash of the destination by default.
outbound.nickname string  Name of tunnel - generally ignored unless inbound.nickname is unset.
inbound.allowZeroHop true, false trueIf incoming zero hop tunnel is allowed
outbound.allowZeroHop true, false trueIf outgoing zero hop tunnel is allowed
inbound.IPRestriction number from 0 to 4 0 to 42Number of IP bytes to match to determine if two routers should not be in the same tunnel. 0 to disable.
outbound.IPRestriction number from 0 to 4 0 to 42Number of IP bytes to match to determine if two routers should not be in the same tunnel. 0 to disable.
i2cp.dontPublishLeaseSet true, false falseShould generally be set to true for clients and false for servers
i2cp.messageReliability  BestEffort, GuaranteedBestEffortGuaranteed is disabled

Note: Large quantity, length, or variance settings may cause significant performance or reliability problems.

Note: As of release 0.7.7, option names and values must use UTF-8 encoding. This is primarily useful for nicknames. Prior to that release, options with multi-byte characters were corrupted.

The following options are interpreted on the client side, and will be interpreted if passed to the I2PSession via the I2PClient.createSession() call. The streaming lib should also pass these options through to I2CP.

Option As Of ReleaseRecommended Arguments Allowable RangeDefaultDescription
i2cp.tcp.host    localhostRouter hostname
i2cp.tcp.port   1-655357654Router I2CP port
i2cp.gzip0.6.5true, false  trueGzip outbound data
i2cp.reduceOnIdle0.7.1true, false  falseReduce tunnel quantity when idle
i2cp.closeOnIdle0.7.1true, false  falseClose I2P session when idle
i2cp.reduceIdleTime0.7.11200000300000 minimum (ms) Idle time required (default 20 minutes, minimum 5 minutes)
i2cp.closeIdleTime0.7.11800000300000 minimum (ms) Idle time required (default 30 minutes)
i2cp.reduceQuantity0.7.111 to 51Tunnel quantity when reduced (applies to both inbound and outbound)
i2cp.encryptLeaseSet0.7.1true, false  falseEncrypt the lease
i2cp.leaseSetKey0.7.1   Base64 SessionKey (44 characters)

Note: All arguments, including numbers, are strings. True/false values are case-insensitive strings. Anything other than case-insensitive "true" is interpreted as false. All option names are case-sensitive.

I2CP Data Format and Multiplexing

The end-to-end messages handled by I2CP (i.e. the data sent by the client in a SendMessageMessage and received by the client in a MessagePayloadMessage) is gzipped with a standard 10-byte gzip header beginning with 0x1F 0x8B 0x08 as specified by RFC 1952. As of release 0.7.1, I2P uses ignored portions of the gzip header to include protocol, from-port, and to-port information, thus supporting streaming and datagrams on the same destination, and allowing query/response using datagrams to work reliably in the presence of multiple channels.

The gzip function cannot be completely turned off, however setting i2cp.gzip=false turns the gzip effort setting to 0, which may save a little CPU.

BytesContent
0-2Gzip header 0x1F 0x8B 0x08
3Gzip flags
4-5I2P Source port (Gzip mtime)
6-7I2P Destination port (Gzip mtime)
8Gzip xflags
9I2P Protocol (6 = Streaming, 17 = Datagram) (Gzip OS)
{% endblock %}