Mobile Protocol specification

From Bitmessage Wiki
Jump to navigation Jump to search

This is a DRAFT for protocol extensions to enable mobile devices to participate in bitmessage communication.


If you want to let mobile devices participate in bitmessage communication, you need a gateway device. Theoretically the device could participate like a standard node, but this will cause too much traffic. Even if you have a flat rate, it'll cost to much battery. This page describes a way, the standard protocol could be enhanced, to let mobile devices participate, at least through a gateway.

The Gateway

The gateway first of all is a standard bitmessage node. As a bitmessage node it connects to other nodes and collects and exchanges objects. The mobile gateway functionality is an extension, an additional protocol variant.

When a mobile device connects to a gateway it will identify itself in the "services" field of the version message to be a mobile device. The gateway will answer in the same field, that it is a gateway.

Therefore the service table has to be enhanced:

Value Name Description
1 NODE_NETWORK This is a normal network node.
2 NODE_MOBILE This is a mobile device with limited bandwidth.
4 NODE_GATEWAY This node can send reduced traffic and work as a gateway.

Differences in protocol behavior

Network address

Because we have to share private keys between mobile node and gateway, we do ssh encryption on the connection. For that reason the "Network Address" gets an additional (optional) field for the public ssh key.

Field Size Description Data type Comments
4 (or 8) time uint32 the Time. Protocol version 1 clients use 4 byte time while protocol version 2 clients use 8 byte time.
4 stream uint32 Stream number for this node
8 services uint64_t same service(s) listed in version
16 IPv6/4 char[16] IPv6 address. The original client only supports IPv4 and only reads the last 4 bytes to get the IPv4 address. However, the IPv4 address is written into the message as a 16 byte IPv4-mapped IPv6 address

(12 bytes 00 00 00 00 00 00 00 00 00 00 FF FF, followed by the 4 bytes of the IPv4 address).

2 port uint16_t port number
1+ ssh fingerprint var_str This field is optional. It contains the ssh fingerprint, for nodes that support ssh

Sending messages

When accessed by a NODE_MOBILE the NODE_GATEWAY will not send any "addr" message, because the NODE_MOBILE will connect to the bitmessage network only through well known gateways. It will neither send a "inv" message, because it wants to reduce the traffic to the NODE_MOBILE.

When accessed to a NODE_GATEWAY the NODE_MOBILE will not send a "addr" message, too. But it might send an "inv" message, when it has objects to share. and it can share already all types of objects with the network.

With this very small protocol changes the NODE_MOBILE is already able to send messages using the bitmessage protocol, but with very reduced traffic load.

Receiving messages

For the receive direction we must bring the NODE_GATEWAY in the position to select the objects the NODE_MOBILE is interested in.

For that we introduce a new Message type:


Receiving this message, the NODE_GATEWAY starts to send "inv" messages and offers the NODE_MOBILE objects. In opposite to a standard node connection, it offers only objects, which are already found to be for this node.

Field Size Description Data type Comments
64 private encryption key uchar[] The ECC private key used for encryption (uncompressed format; normally prepended with \x04 )

there might be multiple of this messages.

NODE_GATEWAY stores this information only as long as the connection exists. It can now filter the objects that are intended for NODE_MOBILE.

Whenever the NODE_GATEWAY notifies, that NODE_MOBILE might be interested in objects, it sends a "inv" message to offer them (must be only the objects, NODE_MOBILE is interested in!).

How does NODE_GATEWAY know, which objects are of interest: It uses the private key received in "setreceivekey" to filter private messages. Every "getpubkey" object is translated into a request. When the object arrives at NODE_GATEWAY or if its already there, it is offered in an "inv" message.