wiki:JoeSandbox/PingPongExample/Execute

Ping-Pong Example

Hello GENI index Hello GENI index Hello GENI index

STEPS FOR EXECUTING EXAMPLE

In this section, we will see how communication is carried out through LGI middleware and how regulation is imposed on it. LGI governs the communication by an explicitly specified policy, called the "interaction law", or simply the law. For the law that allows arbitrary messages, please see here, and for the law that specifies the communication protocol, please see here. You can compare them to have a better understanding while doing the experiment.

There are two actors need to talk to each other. In order to enforce the communication protocol, we associate each of them with a LGI controller. The actors cannot send message to each other unless the message is sent through their controllers. According to the law, the controllers will decide whether a message can be sent or received based on the actor's interaction history.

1 Basic communication

1.1 Start Controllers

  1. Log into C1 (the hostname for Controller 1) and C2 in separate windows.
  1. On C1, start the controller using this command:
    C1:~$ java moses.Controller
    

You should see output like this:

Controller starts (use -help option for help)
C1:9000 is sandboxed
Location of the configuration files is:
/tmp/moses/controllerConf
  1. On C2, start the controller using the same command.

1.2 Start Actors

  1. Log into A1 (the hostname for Actor 1) and A2 in separate windows.
  1. On A1, start the actor using the following commands:
    A1:~$ cd /tmp/
    A1:/tmp$ java SomeAgent C1 9000 simple.java1 a1
    

This indicates you are using actor program SomeAgent to communicate with a controller, whose hostname is C1 and port number is 9000. The communication is under the protocol written in LGI law file simple.java1 and the actor is using name a1.

You should see output like this:

> java SomeAgent contrname contrport lawfile agname
> java SomeAgent contrname contrport lawfile agname CApub
> java SomeAgent contrname contrport lawfile agname CApub Mycert Myprivkey
-1
Type exit to quit
  1. Similarly on A2, start the actor using following commands:
    A2:~$ cd /tmp/
    A2:/tmp$ java SomeAgent C2 9000 simple.java1 a2
    

1.3 Communication

You can now send a message using command:

send(msg,dest)

where msg is the content of the message you want to send and dest is the LGI address of the destination. For example, in our case, A2's address is a2@C2, where a2 is the name you chose when connecting to the controller and C2 is the hostname of its controller.

  1. On A1, send a message to A2. For example:
    send(hello,a2@C2)
    
  1. On A2, you should see:
    Received: hello
    

You can continue sending messages with each other. Any message should be sent and delivered.

2 Regulated Communication

Now we want to impose the following protocol over the community:

We allow the exchange of two types of messages: ping messages, which might represent such things as a question, or a request; and pong messages, used as a reply to a previously received ping messages. The ping-pong policy regulates the flow of messages between any two actors a1, a2 as follows: a1 cannot send any pong message to a2 unless a2 has previously sent a ping message to a1; and a1 cannot send a second ping message to a2 unless a2 answers with a pong message to a1 following the initial ping.

We call a ping message sent by a1(a2) to a2(a1) unresolved, if a1(a2) did not receive a corresponding pong to it.

2.1 Start Actors

  1. CTRL-C in A1 and A2 windows to stop the agents. Use command below to adopt the new law Pingpong.java1.
    A1:/tmp$ java SomeAgent C1 9000 Pingpong.java1 a1
    
  1. Similarly, start Actor 2:
    A2:/tmp$ java SomeAgent C2 9000 Pingpong.java1 a2
    

2.2 Communication

  1. On A1, send a message that does not start with "ping(" or "pong(" to A2. For example:
    send(hello,a2@C2)
    
  2. On A2, nothing should be received and displayed, because we only allow the two types of messages. Any other messages will be discarded.
  1. On A1, send a message that starts with "ping(" to A2. For example:
    send(ping(hi),a2@C2)
    
  2. On A2, you should see:
    Received: ping(hi)
    

because it is a legitimate message and A1 does not have an unresolved ping message sent to A2.

  1. On A1, send another message that starts with "ping(" to A2. For example:
    send(ping(hey),a2@C2)
    
  1. On A2, this message should not be received and displayed, because A1 now has an unresolved ping message sent, therefore this message is discarded.
  1. On A2, send a message that starts with "pong(" to A1. For example:
    send(pong(howdy),a1@C1)
    
  2. On A1, you should see:
    Received: pong(howdy)
    

because there is an unresolved ping message sent by A1 to A2, therefore this pong message is legitimate and allowed to be sent.

  1. After A1 receives this pong(howdy) message, its previous ping(hi) message is resolved. Therefore A1 can send ping message to A2 now. But let's not to do that for a moment.
  1. On A2, send another message that starts with "pong(" to A1. For example:
    send(pong(yo),a1@C1)
    
  2. On A1, nothing should be received and displayed, as there is no unresolved ping message sent by A1 to A2, therefore this pong message is discarded.

You can continue sending messages to test the behavior and compare the law files.

If you want to explore how this protocol is enforced over the whole community and what other policies can be imposed on communication, please see here and here.

Next: Teardown Experiment

Last modified 10 years ago Last modified on 08/13/14 18:17:45