API Documentation

Burst Protocol

To use the probabilistic NAT traversal library, the peers to be connected must first be synchronized. For that, each peer has to use two API calls.

enum GNUNET_GenericReturnValue
GNUNET_is_burst_ready (struct GNUNET_TIME_Relative rtt_avarage,
             struct GNUNET_BurstSync *burst_sync,
             GNUNET_SCHEDULER_TaskCallback task,
             struct GNUNET_StartBurstCls *task_cls)

and

struct GNUNET_BurstSync *
GNUNET_get_burst_sync_msg (struct GNUNET_TIME_Relative rtt_avarage,
             enum GNUNET_GenericReturnValue sync_ready)

The second is to create the synchronisation message which the caller has to send to the other peer. Within GNUnet the Distance Vector DV protocol is used for sending the synchronisation message. Applications which do not want to use the complete GNUnet stack have to use transportion by other means.

The API call needs two parameters. The avarage round trip time rtt_avarage has to be provided by the callers application. In GNUnet this information is constantly calculated from messages delivered by DV. Again, applications not using the GNUnet stack have to assemble this information by themself. The round trip time has to be calculated as the time a message needs to arrive at another peer plus the time a response to this message needs to travel back. The messages used to measure this time needs to be send via the same transportion mechanism like the burst synchromisation method. The value used in the API should be an average over several RTTs. rtt_average is measured in microseconds.

The second parameter is returned by the first API call and must be temporarily stored to use it in the second. This is the burst synchromisation method, which encapsulates the RTT calculated by the sending peer, and if that peer is ready to sync.

The first API call also needs the avarage RTT and the synchronisation message received from another peer. The callback is called, if both peers are ready to synchronize. Therefore the callback should start the burst mode which will finally do the hole punch for NAT traversal. One can find an example in the GNUnet code src/service/transport/gnunet-service-transport.c in the function handle_flow_control.

Burst API

After the to peers were synchronized each peer starts the burst mode. The burst mode is started by calling the function

struct GNUNET_SCHEDULER_Task *
GNUNET_get_udp_socket (struct GNUNET_UdpSocketInfo *sock_info,
              GNUNET_NotifyUdpSocket nus);

this function shall be called from within the callback function

GNUNET_SCHEDULER_TaskCallback task

which was a parameter of the function

GNUNET_is_burst_ready

we used to check if the peers are synchronized. The first parameter is the default socket the application is using. The second parameter the callback to call, if the hole punching was successful. The callback is a function with one parameter GNUNET_NotifyUdpSocket which holds information about the socket we received a message from the other peer and the address we can reach the other peer. The socket can be used to receive further message.

The function

void
GNUNET_stop_burst (struct GNUNET_NETWORK_Handle *do_not_touch);

must be called, if the hole punch message was received via the default socked, because the library does not recognize this. It also must be called, before one starts a new burst to be sure an old one is not running anymore. A third case is, when the system shuts down.

Again, one can find an example in the GNUnet code src/service/transport/gnunet-service-transport.c