Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#2197 closed enhancement (fixed)

Support TURN extensions for TCP allocations (RFC 6062)

Reported by: nanang Owned by: nanang
Priority: normal Milestone: release-2.9
Component: pjnath Version: trunk
Keywords: Cc:
Backport to 1.x milestone: Backported: no

Description (last modified by nanang)

This ticket will enable TURN client to establish TCP connection with the client's peers:

client <--[tcp]--> TURN server <--[tcp]--> peer

The RFC 6062 describes two modes: open outgoing TCP connection to peer and accept incoming TCP connection from peer, this ticket implements only the latter mode, i.e: accept mode.

General flow for accept mode:

  1. Client establishes TCP connection to TURN server, this is called control connection.
  2. Client sends Allocate request with REQUESTED-TRANSPORT attribute with value set to TCP.
  3. Client sends CreatePermission request to allow peer to initiate TCP connection to TURN server.
  4. When peer initiates TCP connection to the allocated address on TURN server, client will receive ConnectionAttempt indication with CONNECTION-ID attribute.
  5. If client decides to accept the connection, it should establish another TCP connection to TURN server, this connection is for data connection.
  6. Client sends ConnectionBind request on that data connection with CONNECTION-ID attribute with value set to the same value in previous ConnectionAttempt indication.
  7. Once client receives ConnectionBind success response, the data connection is fully established, the TURN server will simply relay data until any side closes the connection.

How to use

TURN socket application needs to do the following:

  1. When calling pj_turn_sock_create(), conn_type must be set to PJ_TURN_TP_TCP.
  2. When calling pj_turn_sock_alloc(), param.peer_conn_type must be set to PJ_TURN_TP_TCP.
  3. Implement TURN socket callbacks on_connection_attempt and on_connection_status, please check the TURN socket docs for more info.
  4. The rest is as usual, e.g: sending data can be done using pj_turn_sock_sendto(), incoming data will be notified via callback on_rx_data.

Thank you Guillaume Roguez and Sébastien Blin from Savoir-faire Linux for the patch.

Change History (3)

comment:1 Changed 6 years ago by nanang

  • Owner set to nanang
  • Resolution set to fixed
  • Status changed from new to closed

In 5987:

Close #2197: Support TURN extensions for TCP allocations (RFC 6062).

comment:2 Changed 6 years ago by nanang

In 5988:

Re #2197: Fixed silly mistake of wrong size param in bzero-ing a var.

comment:3 Changed 6 years ago by nanang

  • Description modified (diff)
Note: See TracTickets for help on using tickets.