Skip to content

IntroConnections

Thomas Schwotzer edited this page Mar 21, 2023 · 12 revisions

Connections and peers

ASAP is a protocol designed for information routing in large scale loosely coupled even ad-hoc networks. An ASAP peer is a protocol engine.

Application developers can use an ASAP peer to send messages. Applications can subscribe to receive incoming messages.

ASAP is a routing protocol that assume an existing stream based point-to-point connection. This can be

  • layer 2 protocols e.g. based on Bluetooth, Wifi, LoRaWan etc.
  • layer 4 protocols, namely TCP or protocols on top.

ASAP peers are not aware of specific protocols. They can expect an existing communication channel.

programming level

Each peer has - in general two sides: one to application developers the other to network connection. Methods provided to the first are summarized in the ASAPPeer interface

Interface ASAPConnectionHandler describes a single method (in different variants) that can deal with a connection.

It is assumed that other parts of an application create connection and ask peers (more specific ASAPConnectionHandler) to run an handle that connection which finally leads to an ASAP session.

The minimal parameter set consists of a pair of Input- and Outputstream objects.

ASAPPeerFS peer = new ASAPPeerFS(owner, rootFolder, supportedFormats);

// focus on its role as connection handler
ASAPConnectionHandler connectionHandler = (ASAPConnectionHandler)peer;

// streams
InputStream is; // must be created somewhere
OutputStream os; // must be created somewhere

connectionHandler.handleConnection(is, os);

This code sniplet does not reveal that much. A filesystem based peer is instantiated. It is used as communication handler. It would run an ASAP session of a given connection (represented by a stream pair) after calling handleConnection(is, os);.

Clone this wiki locally