Return to The DoDWAN platform

Running the sample programs

DoDWAN

The DoDWAN platform

Overview
Download
Contact

DoDWAN Apps for netbooks

Installation
Starting DoDWAN Apps
DoDWAN Apps Overview

DoDWAN Apps for smartphones

Overview
Hints and tips

DoDWAN SDK

Installation
Running DoDWAN programs
Using the DoDWAN API
Reference Java API

Additional documentation

Network configuration
Configuration properties
Launching environment

Configuring the Wi-Fi interface for ad hoc networking

Before starting any DoDWAN-based application on a mobile host, one must configure this host’s Wi-Fi interface so it can operate in ad hoc mode. The scripts set_dodwan_network.sh (for Linux systems) and set_dodwan_network.ps1 (for Windows 7 systems) are meant to help you achieve this task. If you cannot configure your Wi-Fi interface using these script files, please refer to Network_configuration for further instructions regarding network configuration.

On a Linux platform

The shell script set-dodwan-network.sh must be used on a Linux platform. Note that this script must be executed with root privileges, as it must configure the Wi-Fi interface for ad hoc networking:

% sudo sh set_dodwan_network.sh
Detected Wi-Fi interface: wlan0
Interface wlan0 is now configured for ad hoc networking (ssid=DODWAN-ADHOC, channel=1)

On a Windows 7 platform

On a Windows 7 platform execute the following command in a Powershell launched with Administrator privileges. Note that you may additionally have to deactivate your firewall to allow DoDWAN traffic (UDP, default port 8500).

> set-dodwan-network.ps1
Detected Wi-Fi interface: Wireless network connection
Profile DODWAN is added on interface Wireless network connection.
Profile "DODWAN" of interface "Wireless network connection" is updated.
Connection request is received successfully.
Ok.

Running the sample programs

The Java source programs samplePublisher.java and sampleSubscriber.java illustrate the roles of publisher and subscriber in a publish/subscribe distributed application.

Assuming the DoDWAN package was installed in the home directory, and the file samplePublisher.java is in the current directory, the publisher code can be compiled and run the following way (substitute $HOME with %USERPROFILE% on Windows):

% javac -cp $HOME/DoDWAN/home/lib/dodwan-2.1.0.jar samplePublisher.java
% java -cp ".:$HOME/DoDWAN/home/lib/dodwan-2.1.0.jar" samplePublisher

Note: while typing the above commands you may have to adjust the version number of DoDWAN based on the actual version of the distribution file you have downloaded.

The subscriber code can be compiled and run similarly:

% javac -cp $HOME/DoDWAN/home/lib/dodwan-2.1.0.jar sampleSubscriber.java
% java -cp ".:$HOME/DoDWAN/home/lib/dodwan-2.1.0.jar" sampleSubscriber

First run the subscriber and the publisher on two distinct properly configured devices (see Network_configuration for instructions on how to prepare hosts to run DoDWAN).

On the subscriber side, the program subscribes to messages in “French” or “English” and that pertain to a topic that contains “DTN”. This subscription is bound to a ’processor’ that handles received messages by simply displaying in XML the descriptor of the message before the content itself. Leave this program running until no reception is wished. Then quit by interrupting the Java program (CTRL-C).

On the publisher side, the user is repeatdly asked for the characteristics (language, topic and content) of a message that is published in the network. Again, you can quit by interrupting the Java program (CTRL-C).

As far as the characteristics typed in on the publisher side are compatible with the subscription pattern hard-coded in the sucriber program, the subscriber will effectively receive and display the published messages. Note that the reception is not immediate: a DoDWAN instance performs exchanges with neighbouring devices periodically, with a default period of 15 seconds.

You can run other instances of the subscriber and the publisher on other hosts in the network. You should thus observe that:

  • All the subscribers receive the published messages;
  • A subscriber that is started after a message has been published may however be able to receive this message, provided the message has not reached its deadline yet (a message published by samplePublisher.java has a lifetime of 1 minute by default, as specified in its descriptor).

A device can play the role of a publisher and the role of a subscriber. In this case, you should merge the two corresponding Java sources into one.