jade.tools.sniffer
Class Sniffer

java.lang.Object
  |
  +--jade.core.Agent
        |
        +--jade.tools.ToolAgent
              |
              +--jade.tools.sniffer.Sniffer
All Implemented Interfaces:
java.lang.Runnable, jade.util.leap.Serializable, java.io.Serializable, jade.core.TimerListener

public class Sniffer
extends jade.tools.ToolAgent

This is the Sniffer agent.
This class implements the low level part of the Sniffer, interacting with Jade environment and with the sniffer GUI.
At startup, the sniffer subscribes itself as an rma to be informed every time an agent is born or dead, a container is created or deleted.
For more information see Introduction to the Sniffer.

A properties file while may be used to control different sniffer properties. These optional properties are as follows:

The property file is looked for in the current directory, and if not found, it looks in the parent directory and continues this until the file is either found or there isn't a parent directory.

The original implementation processed a .inf file. For backward compatability this has been preserved but its usage should be converted to use the new .properties file. The format of the .inf file is each line contains an agent name and optional list of performatives.
Example:

 da0
 da1 inform propose
 

Notes:

  1. If a message is one that is to be ignored, then it is dropped totally. If you look at the sniffer dump of messages, it will not be there. Might want to change this.
  2. Should develop a GUI to allow dynamically setting which messages are filtered instead of forcing them to be in the properties file.
  3. Probably should allow one to turn on and off the display of the performative name. Although, it seems pretty nice to have this information and although one might consider that it clutters the display, it sure provides a lot of information with it.

Version:
$Date: 2003/09/02 07:06:16 $ $Revision: 2.26 $
Author:
Alessandro Beneventi (Developement), Gianluca Tanca (Concept & Early Version), Robert Kessler University of Utah (preload configuration, don't scroll agent boxes), Martin Griss HP Labs (display additional message information), Dick Cowan HP Labs (property handling, display full agent name when mouse over)
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class jade.tools.ToolAgent
jade.tools.ToolAgent.AMSListenerBehaviour, jade.tools.ToolAgent.EventHandler
 
Field Summary
static boolean SNIFF_OFF
           
static boolean SNIFF_ON
           
 
Fields inherited from class jade.core.Agent
AP_ACTIVE, AP_COPY, AP_DELETED, AP_IDLE, AP_INITIATED, AP_MAX, AP_MIN, AP_SUSPENDED, AP_TRANSIT, AP_WAITING, currentBehaviour, currentMessage, D_ACTIVE, D_MAX, D_MIN, D_RETIRED, D_SUSPENDED, D_UNKNOWN
 
Constructor Summary
Sniffer()
           
 
Method Summary
 jade.lang.acl.ACLMessage getSniffMsg(jade.util.leap.List agents, boolean onFlag)
          Creates the ACLMessage to be sent to the Ams with the list of the agent to be sniffed/unsniffed.
protected  boolean isMatch(java.lang.String aMatchExpression, java.lang.String aString)
          Given two strings determine if they match.
protected  java.lang.String preloadContains(java.lang.String agentName)
          Search keys in preload for a string which matches (using isMatch method) the agent name.
 void sniffMsg(jade.util.leap.List agents, boolean onFlag)
          This method add an AMSBehaviour the perform a request to the AMS for sniffing/unsniffing list of agents.
 void toolSetup()
          ACLMessages for subscription and unsubscription as rma are created and corresponding behaviours are set up.
protected  void toolTakeDown()
          Cleanup during agent shutdown.
 
Methods inherited from class jade.tools.ToolAgent
getCancel, getRequest, getSubscribe, setup, takeDown
 
Methods inherited from class jade.core.Agent
addBehaviour, afterClone, afterMove, beforeClone, beforeMove, blockingReceive, blockingReceive, blockingReceive, blockingReceive, doActivate, doClone, doDelete, doMove, doStart, doSuspend, doTimeOut, doWait, doWait, doWake, extractPassword, extractUsername, getAgentState, getAID, getAMS, getArguments, getAuthority, getCertificateFolder, getContainerController, getContentManager, getCurQueueSize, getDefaultDF, getHap, getHelper, getLocalName, getName, getO2AObject, getPrincipal, getProperty, getQueueSize, getState, here, notifyChangeBehaviourState, notifyRestarted, postMessage, putBack, putO2AObject, read, read, receive, receive, removeBehaviour, restartLater, restore, run, send, setArguments, setEnabledO2ACommunication, setGenerateBehaviourEvents, setOwnership, setPrincipal, setQueueSize, waitUntilStarted, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SNIFF_ON

public static final boolean SNIFF_ON
See Also:
Constant Field Values

SNIFF_OFF

public static final boolean SNIFF_OFF
See Also:
Constant Field Values
Constructor Detail

Sniffer

public Sniffer()
Method Detail

preloadContains

protected java.lang.String preloadContains(java.lang.String agentName)
Search keys in preload for a string which matches (using isMatch method) the agent name.

Parameters:
agentName - The agent name.
Returns:
String The key which matched.

isMatch

protected boolean isMatch(java.lang.String aMatchExpression,
                          java.lang.String aString)
Given two strings determine if they match. We iterate over the match expression string from left to right as follows:
  1. If we encounter a '*' in the expression token they match.
  2. If there aren't any more characters in the subject string token they don't match.
  3. If we encounter a '?' in the expression token we ignore the subject string's character and move on to the next iteration.
  4. If the character in the expression token isn't equal to the character in the subject string they don't match.
If we complete the iteration they match only if there are the same number of characters in both strings.

Parameters:
aMatchExpression - An expression string with special significance to '?' and '*'.
aString - The subject string.
Returns:
True if they match, false otherwise.

toolSetup

public void toolSetup()
ACLMessages for subscription and unsubscription as rma are created and corresponding behaviours are set up.

Overrides:
toolSetup in class jade.tools.ToolAgent

toolTakeDown

protected void toolTakeDown()
Cleanup during agent shutdown. This method cleans things up when Sniffer agent is destroyed, disconnecting from AMS agent and closing down the Sniffer administration GUI. Currently sniffed agents are also unsniffed to avoid errors.

Overrides:
toolTakeDown in class jade.tools.ToolAgent

sniffMsg

public void sniffMsg(jade.util.leap.List agents,
                     boolean onFlag)
This method add an AMSBehaviour the perform a request to the AMS for sniffing/unsniffing list of agents.


getSniffMsg

public jade.lang.acl.ACLMessage getSniffMsg(jade.util.leap.List agents,
                                            boolean onFlag)
Creates the ACLMessage to be sent to the Ams with the list of the agent to be sniffed/unsniffed. The internal list of sniffed agents is also updated.

Parameters:
onFlag - can be:
  • Sniffer.SNIFF_ON to activate sniffer on an agent/group
  • Sniffer.SNIFF_OFF to deactivate sniffer on an agent/group