Type Definition gnunet_sys::GNUNET_TRANSPORT_PeerState[][src]

type GNUNET_TRANSPORT_PeerState = c_uint;

Possible state of a neighbour. Initially, we are #GNUNET_TRANSPORT_PS_NOT_CONNECTED.

Then, there are two main paths. If we receive a SYN message, we give the inbound address to ATS. After the check we ask ATS for a suggestion (#GNUNET_TRANSPORT_PS_CONNECT_RECV_ATS). If ATS makes a suggestion, we send our SYN_ACK and go to #GNUNET_TRANSPORT_PS_CONNECT_RECV_ACK. If we receive a ACK, we go to #GNUNET_TRANSPORT_PS_CONNECTED (and notify everyone about the new connection). If the operation times out, we go to #GNUNET_TRANSPORT_PS_DISCONNECT.

The other case is where we transmit a SYN message first. We start with #GNUNET_TRANSPORT_PS_INIT_ATS. If we get an address, we send the SYN message and go to state #GNUNET_TRANSPORT_PS_CONNECT_SENT. Once we receive a SYN_ACK, we go to #GNUNET_TRANSPORT_PS_CONNECTED (and notify everyone about the new connection and send back a ACK). If the operation times out, we go to #GNUNET_TRANSPORT_PS_DISCONNECT.

If the session is in trouble (i.e. transport-level disconnect or timeout), we go to #GNUNET_TRANSPORT_PS_RECONNECT_ATS where we ask ATS for a new address (we don’t notify anyone about the disconnect yet). Once we have a new address, we enter #GNUNET_TRANSPORT_PS_RECONNECT_SENT and send a SYN message. If we receive a SYN_ACK, we go to #GNUNET_TRANSPORT_PS_CONNECTED and nobody noticed that we had trouble; we also send a ACK at this time just in case. If the operation times out, we go to #GNUNET_TRANSPORT_PS_DISCONNECT (and notify everyone about the lost connection).

If ATS decides to switch addresses while we have a normal connection, we go to #GNUNET_TRANSPORT_PS_CONNECTED_SWITCHING_SYN_SENT and send a SESSION_CONNECT. If we get a ACK back, we switch the primary connection to the suggested alternative from ATS, go back to #GNUNET_TRANSPORT_PS_CONNECTED and send a ACK to the other peer just to be sure. If the operation times out we go to #GNUNET_TRANSPORT_PS_CONNECTED (and notify ATS that the given alternative address is “invalid”).

Once a session is in #GNUNET_TRANSPORT_PS_DISCONNECT, it is cleaned up and then goes to (#GNUNET_TRANSPORT_PS_DISCONNECT_FINISHED). If we receive an explicit disconnect request, we can go from any state to #GNUNET_TRANSPORT_PS_DISCONNECT, possibly after generating disconnect notifications.

Note that it is quite possible that while we are in any of these states, we could receive a ‘SYN’ request from the other peer. We then enter a ‘weird’ state where we pursue our own primary state machine (as described above), but with the ‘send_connect_ack’ flag set to 1. If our state machine allows us to send a ‘SYN_ACK’ (because we have an acceptable address), we send the ‘SYN_ACK’ and set the ‘send_connect_ack’ to 2. If we then receive a ‘ACK’, we go to #GNUNET_TRANSPORT_PS_CONNECTED (and reset ‘send_connect_ack’ to 0).