More Informations

1. Initialization

When the user starts the Sniffer, a new instance of the class jade.tools.sniffer.Sniffer is created: this class extends jade.core.Agent, therefore the Sniffer is like any other agent; interaction with Jade environment and with the Sniffer gui are the main tasks of this class.

In order to let the user chose which agents are to be sniffed, the Sniffer must be constantly informed on born agents, dead agents, created and deleted container: for security's sake these informations are not available to a common agent. Hence to get these informations, the Sniffer registers itself as an rma on the Agent Management System (ams). The subscription is performed by sending to the ams a message like the following one :

   

(subscribe
:sender the_sniffer
:receiver ams
:content "iota ?x ( :container-list-delta ?x )"
:reply-with RMA-subscription
:language SL
:ontology jade-agent-management
)

On the Sniffer takedown a message like the following one is sent to the ams to unsubscribe the Sniffer.

   

(cancel
:sender the_sniffer
:receiver ams
:content "iota ?x ( :container-list-delta ?x )"
:reply-with RMA-cancellation
:language SL
:ontology jade-agent-management
)

From now on, every time an agent is born, a container is created, the Sniffer is instantly informed with messages like the following one:

   

(inform
:sender ams
:receiver the_sniffer
:content (new-container Front-End )
:in-reply-to RMA-subscription
:language SL
:ontology jade-agent-management
)

2. Telling the Ams to sniff  an Agent

When the user selects an agent to be sniffed from the Add/Remove Agent window, the Sniffer gets the ams to know this by sending a message like the following one:

   

(request
:sender the_sniffer
:receiver ams
:content ( action ams ( sniff-agent-on ( :sniffer-name the_sniffer :agent-list { the_agent_list } ) ) )
:language SL0
:ontology fipa-agent-management
:protocol fipa-request
)

If the user does not want an agent to be sniffed anymore, the Sniffer informs the ams by sending a message like the following one:

   

(request
:sender the_sniffer
:receiver ams
:content ( action ams ( sniff-agent-off ( :sniffer-name the_sniffer :agent-list { the_agent_list } ) ) )
:language SL0
:ontology fipa-agent-management
:protocol fipa-request
)

Then the ams parses the incoming message and, if it turns out to be successful, the platform or the container is told to send to the Sniffer a copy of every message coming from or going to an agent in the sniffed agent list.

3. Sniffed Messages

Every time the agent platform dispatches a message, it looks in the sniffed agents table to find out whether the sender of the message, the receiver of the message or both are in the sniffed agents list: if so, the platform create a new message like the following one:

   

(inform
:sender ams
:receiver a_sniffer
:content sniffed_message
:ontology sniffed-message
)

The message is directed to one or more sniffers registered to sniff one or more agent. The list of the sniffers for an agent is contained in the sniffed agent list. The ontology of the message must be set to sniffed-message. The platform now performs a sort of tunnelling by putting the sniffed message in the :content field of the above message to be sent to the sniffer. When this one receives a message from the ams with the :ontology field set as before it extracts the content and create a new ACLMessage to be displayed from the Gui when the user double-click on the arrow representing it.

4. Integration with Jade

The integration of the Sniffer with Jade environment has been a three-step process, shortly described just after:

  1. The jade.domain.AgentManagementParser.jj grammar has been modified to parse correctly the previously described messages to enable the sniffing action upon an agent

  2. The jade.domain.ams class has been modified to correctly manage the data returned by the previous parsing step and set correct data in the agent platform

  3. The jade.core.AgentPlatformImpl and jade.core.AgentContainerImpl classes has been modified to send to the sniffer/sniffers a copy of every message coming from or directed to a sniffed agent.

The ams always listens for a sniff-on/sniff-of message to arrive: when one of these arrives it invokes the parser to check the message and extract the useful data in it. 
After that the parser has successfully analyzed the message (otherwise an exception is thrown) it returns an instance of a jade.domain.AgentManagementOntology.SniffAgentOnAction or jade.domain.AgentManagementOntology.SniffAgentOffAction object to the ams depending on the fact that the user wants to activate or disable the sniffer on a particular bunch of agents. Both mentioned classes are inner classes of the main jade.doman.AgentManagementOntology class and extend jade.domain.AgentManagementOntology.AMSAction
Making use of these classes' methods, the parser loads the sniffer name in the variable snifferName and the agents to be sniffer/not to be sniffed in a map depending on what kind of action the user would like to do. Taking for example the SniffAgentOnAction, the parser uses the method setSnifferName(String sn) to set the name of the sniffer for the agents that the parser collects in the ACLMessage (in the :agent-list field) and puts in a map called myAgentList using the method addSniffedAgent(String ag). Then the ams informs the sniffer if somethig has gone wrong or extract the sniffer name and the agent list from the returning object with the following instruction 

myAction = (AgentManagementOntology.SniffAgentOnAction)
AgentManagementOntology.SniffAgentOnAction.fromText(new StringReader(content));
myPlatform.AMSActivateSniffer(myAction.getSnifferName(),myAction.getEntireList());

and passes them to his platform telling the sniffer that the action was successful. 

Within the agent platform, the AMSActivateSniffer and AMSDisableSniffer methods add and remove agents from the SniffedAgents map according to what they have been told by the ams. The SniffedAgents list is ajava.util.Map object: in this map the agent names are the keys and sniffer vectors are the values for the keys: by doing so, every agent can be sniffed by any number of sniffers and every sniffer can sniff any number of agents. For more details please see the code or the relative documentation. It's important to underline that agents name are put in the list with the following convention: local agent names are put in the list without the address and converted to lower case whereas external agent names are put in the list with address and converted to lowercase.

This sniffing task is performed by the container in the commHandle method: as the name itself it handles every incoming or outgoing messagge with internal protocol, rmi or corba/IIOP. In more detail, the commHandle methos check if the sender or the receiver/group of recever is a sniffed agent: if so, it sends a copy of that message to every sniffer registered for that agent.

 


JADE is a trademark of CSELT. JADE has been developed jointly by CSELT and the Computer Engineering Group of the University of Parma