MaDKit forum

Welcome All !
Please, use explicit topic names when creating new threads. Thanks.

You are not logged in.

#1 Re: HowTo » How to create a distributed society? » 2019-06-07 14:54:42

fmichel wrote:

Hello,

Yes it is possible. To try it out quickly on a single host, you can use the desktop mode and just launch one instance of, for the example, "PingPong". Then start the network mode (in the menu or icon). Then just redo this with another instance of the desktop : The two MDK kernels should automatically connect and the PingPong agents should see each other right after that.

Hello,

I would to know how the network and the IP address is managed in MaDKit ... because, I wanted to retry your method to launch several PingPong agents which normally should automatically find them-selves, but it seems that there is a problem with the IP addresses used. For instance, I launch one agent like this:

D:\LIST_BGa\development\Java>java -cp MaDKit-5.2\demos\MaDKit-ping-pong-2.0.jar madkit.pingpong.PingPong

        ---------------------------------------
                        MaDKit
                   version: 5.2
                build-id: 20170718-1301
               MaDKit Team (c) 1997-2019
        ---------------------------------------

[NetworkAgent-2] INFO :
                                ----- @MK-20 network started on /10.122.10.45:4445 -- WAN : 158.64.4.213 ------

Then I launch another agent like that:

D:\LIST_BGa\development\Java\MaDKit-5.2\demos>java -cp MaDKit-ping-pong-2.0.jar madkit.pingpong.PingPong

        ---------------------------------------
                        MaDKit
                   version: 5.2
                build-id: 20170718-1301
               MaDKit Team (c) 1997-2019
        ---------------------------------------

[NetworkAgent-2] INFO :
                                ----- @MK-19 network started on /10.122.10.45:4444 -- WAN : 158.64.4.213 ------

[NetworkAgent-2] WARNING : Unable to contact peer: /10.0.75.1 port = 4445 because Connection refused: connect

Do you see the problem? It started on a IP address and then try to connect to another one ...

The address 10.122.10.45 is provided by "Ethernet adapter Ethernet" as said by the "ipconfig" command in Windows and the 10.0.75.1 address is provided by the "Ethernet adapter vEthernet (DockerNAT)" (see below)

Ethernet adapter vEthernet (DockerNAT):
   Description . . . . . . . . . . . : Hyper-V Virtual Ethernet Adapter #2
   DHCP Enabled. . . . . . . . . . . : No
   Autoconfiguration Enabled . . . . : Yes
   IPv4 Address. . . . . . . . . . . : 10.0.75.1(Preferred)


Ethernet adapter Ethernet:
   Description . . . . . . . . . . . : Intel(R) Ethernet Connection (4) I219-V
   IPv4 Address. . . . . . . . . . . : 10.122.10.45(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.0.0

I tested it in linux and if I have a docker service also running, the agent connects to an address and want to communicate with another agent with the other address (in linux case 10.122.10.107 vs 172.17.0.1)

Do you have any clue how solve that problem?

Regards

#2 Re: HowTo » How to create a distributed society? » 2018-02-12 14:43:21

I tested your version and it works also.

Benjamin

#3 Re: HowTo » How to create a distributed society? » 2018-01-30 17:18:38

Hello again,

I create a PingPongNet class extending the PingPong class as following:

public class PingPongNet extends PingPong {

	public String ip = "10.122.10.74"; 
	
	public void activate() {
		super.activate();
		getLogger().info("I just activated the agent");
    	
		try {
			this.sendMessage(LocalCommunity.NAME, Groups.SYSTEM, DefaultMaDKitRoles.GROUP_MANAGER_ROLE,
					new KernelMessage(KernelAction.CONNECT_TO_IP, InetAddress.getByName(ip)));
		} catch (UnknownHostException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public static void main(String[] args) {
		String[] argss = { "--network", "--launchAgents", PingPongNet.class.getName(), ",true" };
		Madkit.main(argss);
	    }
}

And when I launch this agent, it automatically launch the network and also connect the kernel in which it is to the kernel having the IP stored in variable "ip" ... and it is work! Both agents interact and play ping-pong.

What do you think? Is it a good way to do it? Or something better is possible? I found the command to connect to another host in the class dealing with the menu of the GUI.

Benjamin

#4 Re: HowTo » How to create a distributed society? » 2018-01-30 12:19:16

fmichel wrote:

"launch network" starts the "network agent" and put the kernel online and thus make it available for receiving connections. It should also automatically connect to other kernels which are on the same LAN. "Connect to IP" is more about reaching hosts located on the WAN, but could also indeed be used to connect to any host thanks to its IP.

Hello,

OK, I launched to MaDKit platforms (kernels?) on two different computers. I launched one PingPong agent on each kernel and then I launched network on both. Then I connected one kernel to the other kernel with the "connect to IP" menu. And PingPong agent from one kernel succeed to automatically communicate with the PingPong agent from the other kernel. I launched more agents on both platforms and every agents played with all agents.

But I did that with the MaDKit Desktop (with the menu). Is it possible in the "main(String[] args)" (or somewhere else) of the PingPong java class to add a method or argument to make the kernel of the agent this object will launch connect automatically to another kernel (a kind of broker one) and have for instance:

public static void main(String[] args) {
    String[] argss = { "--network", "--launchAgents", "--connectToIP", "10.122.10.64", PingPong.class.getName(), ",true" };
    Madkit.main(argss);
}

Thanks for your time.

Benjamin

or

public static void main(String[] args) {
    executeThisAgent(1, true, "10.122.10.64");
}

#5 Re: HowTo » How to create a distributed society? » 2018-01-24 16:49:36

fmichel wrote:

Hello,

bgateau wrote:

Thanks for your answer. Just before checking your message, I saw in the Desktop instance of MaDKit 3 menu items dealing with network. Than I read your message.

MaDKit 3 ? You meant 5, right ?

I use MaDKit 5 indeed, but I meant that in the window of the MaDKit desktop, I saw 3 menu items: "launch network", "stop network" and "connect to IP" ! And I think that I will need to use the "connect to IP" command to make an agent of HOST1 (my laptop) able to communicate with agent of HOST2 (my desktop computer).

Benjamin

#6 Re: HowTo » How to create a distributed society? » 2018-01-24 16:11:49

Hello,

Thanks for your answer. Just before checking your message, I saw in the Desktop instance of MaDKit 3 menu items dealing with network. Than I read your message.

Unfortunately, I didn't success to execute your example. As you said, I launched two instances of MaDKit desktop, launched network on both instances and started a PingPong agent on each ... and nothing happened. They didn't communicate.

Besides, is there another way to launch network and connect two kernels (on the same host or not) without using an instance of the desktop. My goal is to launch an agent on a computer linked to the network and make it communicate with others agents on others hosts.

I will continue to investigate by firstly studying tutorials.

Regards

Benjamin

#7 HowTo » How to create a distributed society? » 2018-01-23 18:19:19

bgateau
Replies: 11

Hello,

I would like to know if it is possible to create a distributed society. I mean a society with agents on different hosts. And how to send message between those distributed agents?

Regards

Board footer