2

I am trying to have a Multi-Agent System on a distributed network (a Windows computer and a Raspberry pi with Raspbian OS installed on). I start my jade platform on windows using this command:

java mylibrary jade.Boot -gui -platfrom-id Platform1 -agents starter:Starter

I also start my jade platform on Raspbian using this command:

java mylibrary jade.Boot -gui -platform-id Raspy1 -agents starter:Starter

This is Starter.java in both computers:

import jade.core.Agent;
import jade.core.behaviours.CyclicBehaviour;
import jade.lang.acl.ACLMessage;

import java.util.Arrays;

public class Starter extends Agent {

    @Override
    protected void setup() {
        System.out.println("Setup of starter agent");

        addBehaviour(new ReceiveBehaviour());

    }

    private class ReceiveBehaviour extends CyclicBehaviour {

        @Override
        public void action() {
            ACLMessage msg = myAgent.receive();
            if (msg != null) {
                System.out.println(msg.getContent());
                System.out.println(Arrays.toString(msg.getSender().getAddressesArray()));
                ACLMessage reply = msg.createReply();
                reply.setContent("I got it. Thank you " + msg.getSender().getName());
                myAgent.send(reply);
            } else {
                block();
            }
        }
    }
}

Also, this is the mtpaddress in my windows: http://192.168.1.6:7778/acc and this is the mtpaddress on my raspbian: http://raspy1:7778/acc

Both my computers are connected to a local network (a wireless modem) using wifi.

Now what happens is that, I start my platform on both computers, start a DummyAgent on windows and try to send a message to the raspbian platform. So I add a receiver and put the name and address like the image

below: DymmyAgent in my windows to send message to my raspberry

and this is the console output:

Mar 06, 2020 7:45:33 PM jade.core.messaging.MessagingService deliverNow
WARNING: Cannot deliver message to address: http://raspy1:7778/acc [jade.mtp.MTPException: raspy1 - Caused by:  raspy1]. Trying the next one...
Mar 06, 2020 7:45:33 PM jade.core.messaging.MessageManager$Deliverer run
WARNING: Deliverer Thread Deliverer-4 - Delivery-time over threshold (9322). Receiver = da0, message size = 301
( (action ( agent-identifier :name starter@Platform1  :addresses (sequence http://192.168.1.6:7778/acc )) (ACLMessage) ) (MTS-error ( agent-identifier :name da0@Raspy1  :addresses (sequence http://raspy1:7778/acc )) (internal-error "Foreign agent unreachable: No valid address contained within the AID da0@Raspy1")) )
[http://192.168.1.6:7778/acc]

I can send a message from a DummyAgent on raspberry to my windows platform but the opposite way wont happen. What can I do?

amin rahman
  • 39
  • 10
  • Interesting question. Just to let you know, this project did something similar but with Jason: https://github.com/cleberjamaral/goldminers – Cleber Jorge Amaral Mar 09 '20 at 03:59
  • @CleberJorgeAmaral Thank you for your comment. Do they use connection between windows and raspberry? Because that is my main problem here. I think there are some configurations on raspbian that prevents other systems from connecting to it and for example, I cannot send an ACLMessage from one raspbian to another too! – amin rahman Mar 09 '20 at 20:01
  • 1
    There is no reason to be concerned about different windows and rasp together. I would start checking network issues like firewall and DNS. I suggest you check if raspy1 name is being resolved and try to figure out what is happening using a sniffer (like https://www.wireshark.org/). – Cleber Jorge Amaral Mar 11 '20 at 00:48

1 Answers1

0

We are using JADE communication between different machines (Win, Linux, Mac) extensively in a distributed Smart Grid environment.

In order to allow communication between our agents, we have setup a central agent called CEA (short for Central Exectuion Agent) that serves a communication mediator between agents. E.g. he owns and maintains a central phonebook. All agents register themselves at this CEA agent. In turn, the CEA agent can provide the exact addresses of known application agents.

To register at the CEA, the agents needs to know the address of it. The address contains of the agents name, the platform name, the CEA's MTP-URL and MTP-port. In the example below you'll find how we configure an AID, if we are on different machines.

 public AID getAID(){

    String ceaName = this.getAgentName();
    String platformName = this.getPlatformName();
    String mtpProtocol = this.getMtpType();
    String mtpUrl = this.getUrlOrIp();
    int mtpPort = this.getMtpPort();

    String ceaGUID = ceaName + "@" + platformName;
    String ceaMTPAddress = mtpProtocol.toLowerCase() + "://" + mtpUrl + ":" + mtpPort + "/acc";

    AID aid = new AID(ceaGUID, true);
    aid.addAddresses(ceaMTPAddress);
    return aid;
}

So the most important thing is that in contrast to local ACLMessages (send between agents on the same platform), you need to add the MTP information for the remote JADE platform to the AID. I'm not sure, if the JADE visualization / UI is able to do that.

With respect to the shown MTP address of your R'Pi, I doubt that the URL http://raspy1:7778/acc can be resolved in your local network (unless you have a DNS running that translates 'raspy1'). Better you start both platforms with specific MTP settings so that IP addresses are used instead of names (Have a look at the JADE Adminstrator's Guide).

CDerksen
  • 46
  • 3
  • I manually set a MTPAddress using -mtps flag as -mtps jade.mtp.http.MessageTransportProtocol(http://192.168.1.3:7778/acc) and it actually got added to the mtp addresses. But I still get the same result. The problem is not about a mediator agent. The problem is that I can send an ACLMessage from windows to raspberry but when I use the exact same method, I cannot send and ACLMessage from raspberry to windows. – amin rahman Mar 11 '20 at 21:06
  • Sure, the story with the mediator agent was just an example and in principle it shoud directly work. - If you can send the Message from Windows to RPi, does the agent on the RPi receive that message (your console output above shows that from your Win system, the RPi can not be reached)? - If successful, have you tried to print the receivers AID to console after you have created the reply in your ReceiveBehaviour? – CDerksen Mar 13 '20 at 08:01
  • I am sorry I did not provide valid info in my prev. comment. The valid state of my problem is that I can send message from agent on RPi to my agent on windows but when it tries to make a reply and send it, or when I try to send a message from a dummy agent on windows to the starter agent on RPi, the mentioned output gets printed in the console in my windows. Yes I did print the sender address of msg and it exactly prints the mtpaddress of the jade platform on raspberry. – amin rahman Mar 13 '20 at 22:06
  • So the information you can find in your console is valid, but the transfer is not successful? A firewall on your windows machine, like Windows Defender or somthing similar? Have you tried to use WireShark or something similar to monitor your network traffic? – CDerksen Mar 16 '20 at 09:01