BlackBerry Spark Communications Services Guide

Peer-to-Peer Data Streams

With BlackBerry Spark Communications Services, you can create true peer-to-peer connections that securely carry encrypted custom application data between two endpoints. These high-bandwidth connections allow you to create secure, real-time, and custom media streams or send application-specific protocol messages between endpoints for any purpose.

Data Connection

A data connection is a real-time secure connection created as the result of a data-only call.

Much like a voice or video call, the connection starts with an outgoing request to the callee carrying an optional meta data. Typically, the meta data contains description of the data connection for the callee to decide whether or not to accept the request.

After the incoming request is accepted by the callee, the data connection makes final security handshakes before making full connectivity. After full connectivity is made, data over the connection is encrypted using DTLS-SRTP and is peer-to-peer only.

The connection is maintained and kept active while the network path between the two endpoints remains reachable and there is data flowing. A timeout will terminate the connection after a number of seconds of inactivity. The number of seconds varies depending on the platform. If your application requires the connection to remain active, a pinging mechanism that uses a side data channel is needed.

Both endpoints of the connection can end the connection at any time. Typically, if there is no final acknowledgement from the receiver, the recipient should end the connection upon final data packet arrival.

An established connection could also drop due to network issues, in which case, the connection state will transition to disconnected and the failure reason is saved.

The following are some of the characteristics of the data connection.

A total of 32 simultaneous data connections are supported and each is independently encrypted and transmitted.

Data Channel

A data channel sends and receives data of a particular type over a data connection.

Multiple data channels identified by unique names can be created on a single data connection. This eliminates the handshakes and negotiation overhead of a new connection. However, if data segregation is required, creating multiple data connections is preferred, as each data connection encrypts the data with a different key.

A data channel is automatically formed on one endpoint when a sender of a unique name is created, and is created on the other endpoint as a receiver when the first packet of the data arrives. Any subsequent data sent over the same channel will be received by the associated receiver identified by the unique name.

Some high level types of channels are defined in the table below. Your application can extend the Stream type for more complex use cases as needed.

Type Purpose Size Large Data Min latency Auto Termination
File files or large data yes yes no yes
Data data blobs yes no no yes
Stream low latency communication, or user defined no no yes no

File

A File type data channel allows the sending and receiving of large data blobs. This channel automatically terminates when the file is fully transmitted.

The underlining buffers are adjusted to allow maximum performance.

Data

A Data type data channel allows the sending and receiving of data blobs. This channel automatically terminates when the data blob is fully transmitted.

Stream

A Stream type data channel allows the sending and receiving of arbitrary data of an unknown total size. Data is immediately sent without further buffering, and the channel stays open until the data connection terminates.

Examples