Starting A las2peer Network

Tom Janson edited this page Aug 6, 2018 · 2 revisions

This tutorial will guide you through the process of starting your first las2peer network. It is highly recommended that you read the step by step First Service tutorial first to have an idea of how to build your service. This tutorial builds up on it. It is split into two parts: The first part explains the build up of a las2peer instance, giving you some insight into how you can configure your node. The second part deals with starting a las2peer node with the L2pNodeLauncher.

Build-Up of a las2peer Instance

After having successfully completed the first tutorial, you should have a las2peer instance that is ready to run. It should look something like this:


To give you an insight into the configuration of a las2peer instance, let us take a look at the different directories:

The bin Directory

This directory contains a start script that is used in the second part of this tutorial and two agent generator scripts. The agent generator scripts are used to create agent XML files that are stored in the etc directory. This directory is thus not directly necessary for running a las2peer instance, but the scripts ease the handling.

The etc Directory

This directory contains all configuration files.

  • The nodeInfo.xml file contains some information about the node that can be requested by everybody. Currently, it contains a mail and description field that can be filled arbitrary.
  • The second file in the directory is a property file of the Web-Connector. These property files can be created for each service or connector. Just add a new file, named according to your service package, to this directory and the line setFieldValues() to the constructor of your main services class, and las2peer will read this file at your service startup. If your service contains a global variable named the same as a variable specified in the configuration file of your service, it will be set to the value of your configuration file. Take a look at the connector`s configuration file for the syntax.
  • The ant_configuration directory was already discussed in the previous tutorial. The ANT script used in this template project uses the agent generator scripts to create a service and an user agent according to the values it reads from the files of this directory.
  • The ivy directory is used by the ANT script to fetch the dependencies needed to build and run the project. You can take a look at the ivy.xml to see, which dependencies are loaded.
  • The third directory is called startup. Everything in here can be loaded into a las2peer network by passing the command uploadStartupDirectory to the L2pNodeLauncher. Currently, it should hold agent definitions for services and a couple of users agent that are generated by the Ant build script. The third file is called passphrases.txt and contains the passphrases needed to unlock these agents (for uploading). It is also generated by the build script.
The lib Directory

This directory contains the libraries needed to start a las2peer network. It is created (and filled) by the Ant script.

The log Directory

This is the default directory for all log files.

The service Directory

This is the default directory for all services. It should contain your service jar, since the ANT script puts it there automatically (apart from adding it to the export directory).

Other Directories

You might also recognize some additional folders. The .las2peer folder is used by a las2peer instance for storing (encrypted) content of the network. You can think of it as the storage of a node. After a node shuts down, this content is not deleted, but you can not access it anymore. So after a node has shut down, you can delete the corresponding (sub-)directory if you want. The export folder contains your service Jar and the documentation generated from your source code. You can also find your test reports there. As well as the tmp and .settings directories (and the other files located at the root directory), these folders are not used by a las2peer instance itself, but are rather part of your project configuration. You can delete them if you just want to deploy a node somewhere.

Starting a las2peer Node / Network

Now that you have configured your node, you can start it with the start_network script in your bin directory. All you have to know is a port that you can open at your machine. If you want to join an existing network, you need to know the address and port of one participant.

You need to add parameters to the last line of the script, according to the following schema:

[..] -s [PORT] ['-'|IP] [optional: additional commands  and / or 'interactive']

The [PORT] determines, at which port your node should be started. The second parameter indicates, whether a new network shall be started ('-') or if the node shall join an existing network. In that case, you need to add the IP and port here. After this, you can add additional parameters from the L2pNodeLauncher. If you add interactive, the launcher will enter the interactive mode after the node's startup (see the L2pNodeLauncher tutorial for more information on this topic).

As an example, you could do the following:

  1. Start a new network with your node starting at port 9001:

    [..] -s 9001 -
  2. Add an additional node to your network at port 9002 and enter the interactive mode:

    [..] -s 9002 YOUR_IP:9001 interactive

Each started node will continue to run if the last command is not the shutdown command.

You can stop the complete run using Ctrl-C at any point.

You can find detailed log files for each node in the directory log/ afterwards.

To end this tutorial, here is a list of commands that can be executed at a node in interactive mode to start and use the service we developed in the tutorials (please note that you might have to slightly adjust the names according to the ones you chose):

startService('', 'someNewPass')
registerUserAgent('UserA', 'userAPass')
invoke('', 'validateLogin', '')
invoke('', 'exampleMethod', 'What a beautiful service!')

The result should look something like this (open in new window):


For more information about the L2pNodeLauncher and its usage, please visit the L2pNodeLauncher Tutorial.

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.