Class Sniffer

  • All Implemented Interfaces:
    TimerListener, Serializable, Serializable, Runnable

    public class Sniffer
    extends 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:

    • preload - A list of preload descriptions seperated by a semi-colon. Each description consists of an agent name match string and optional list of performatives each seperated by a space. For details on the agent name match string, see the method isMatch(). If there is no @ in the agent name, it assumes the current HAP for it. If the performative list is not present, then the sniffer will display all messages; otherwise, only those messages that have a matching performative mentioned will be displayed.
      Examples:
       preload=da0;da1 inform propose
       preload=agent?? inform
       preload=*
       
    • clip - A list of agent name prefixes seperated by a semi-colon which will be removed when showing the agent's name in the agent box. This is helpful to eliminate common agent prefixes.
      Example:
       clip=com.hp.palo-alto.;helper.
       
    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$ $Revision$
    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
    • Constructor Detail

      • Sniffer

        public Sniffer()
    • Method Detail

      • preloadContains

        protected String preloadContains​(String agentName)
      • isMatch

        protected boolean isMatch​(String aMatchExpression,
                                  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 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 ToolAgent
      • sniffMsg

        public void sniffMsg​(List agents,
                             boolean onFlag)
        This method adds an AMSClientBehaviour that performs a request to the AMS for sniffing/unsniffing list of agents.
      • getSniffMsg

        public ACLMessage getSniffMsg​(List agents,
                                      boolean onFlag)
        Creates the ACLMessage to be sent to the Ams with the list of the agents to be sniffed/unsniffed. The internal list of sniffed agents is also updated.
        Parameters:
        agentVect - vector containing TreeData item representing the agents
        onFlag - can be:
        • Sniffer.SNIFF_ON to activate sniffer on an agent/group
        • Sniffer.SNIFF_OFF to deactivate sniffer on an agent/group