Skip to content

Quickstart Guide

Marvin edited this page Sep 14, 2023 · 5 revisions

This guide shows how to get started with ASAPPeers and the ASAPHub using the HubTester application. Each HubTester instance represents one ASAPPeer. The application creates a ASAPPeer and uses HubConnectionManager to establish a connection to the ASAPHub.

After the ASAPHub has been launched, the HubTester application can be used to test the deployment. HubTester can be launched from different machines to check if the Hub is accessible and whether messages are being forwarded from one machine to another through the Hub.

In addition to its role as a health check or demo application, the HubTester can also be used for load testing. To accomplish this, multiple instances of HubTesters can be launched, each configured to send messages every few milliseconds. The number of HubTester instances can be continuously increased to test the stability of the hub.

The implementation of the HubTester.java is also a good reference for how to get started with ASAPPeers, the EncounterManager and the HubConnectionManager.

1. Launch the ASAPHub

  • clone the ASAPHub repository on your local machine
  • start a hub instance using a pre-build jar, maven or Docker
  • after the hub was started, the IP-address of the hub is printed to console
    • e.g. start TCP hub on 192.168.10.23:6910

2. Start the HubTester instances

  • run mvn clean package -DskipTests
    • the .jar file of the HubTester is located at target/ASAPHub-hub-tester.jar
  • alternatively, you can get the HubTester from the latest ASAPHub release
  • start the first HubTester on machine A:
    • java -jar ASAPHub-hub-tester.jar --host 192.168.10.23 --port 6910 --peerId peer1 --uri asap://exampleURI1 --log log.1.txt --send hello_from_peer_1 5 2000 --multiChannel true --format ASAP_EXAMPLE_APP
  • start the second HubTester on machine B:
    • java -jar ASAPHub-hub-tester.jar --host 192.168.10.23 --port 6910 --peerId peer2 --uri asap://exampleURI2 --log log.1.txt --send hello_from_peer_2 5 2000 --multiChannel true --format ASAP_EXAMPLE_APP
  • each HubTester instantiates one ASAPPeer

After the hub and both HubTester were started, the console output of the HubTester on machine A should look like this:

peer1: activate online messages on that peer
ASAPEngineFS(owner: peer1 | oldestEra: 0 | era: 0 | routing: true): (ASAP_EXAMPLE_APP) created new online message sender
sending message 'hello_from_peer_1_000'
sending message 'hello_from_peer_1_001'
sending message 'hello_from_peer_1_002'
sending message 'hello_from_peer_1_003'
sending message 'hello_from_peer_1_004'
peer1: received message from peer 'peer2' (ASAP_EXAMPLE_APP|asap://exampleURI): hello_from_peer_2_000 
peer1: received message from peer 'peer2' (ASAP_EXAMPLE_APP|asap://exampleURI): hello_from_peer_2_001 
peer1: received message from peer 'peer2' (ASAP_EXAMPLE_APP|asap://exampleURI): hello_from_peer_2_002 
peer1: received message from peer 'peer2' (ASAP_EXAMPLE_APP|asap://exampleURI): hello_from_peer_2_003 
peer1: received message from peer 'peer2' (ASAP_EXAMPLE_APP|asap://exampleURI): hello_from_peer_2_004 

Congratulations! You build your first ASAP Ad-Hoc network using two ASAPPeers and one ASAPHub.

Use HubTester with ASAPAndroid

The HubTester can not only be used to exchange messages between HubTester instances but also to exchange messages between a HubTester and an ASAPAndroid peer. This allows testing the connection from an ASAPPeer through the hub to an ASAPAndroidPeer.