edu.colorado.cs.ns2.agents
Class Agent

java.lang.Object
  extended by edu.colorado.cs.ns2.agents.Agent
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
NullAgent, TCPAgent, TCPRenoAgent, TCPSink, TCPVegasAgent, UDPAgent

public abstract class Agent
extends java.lang.Object
implements java.io.Serializable

This is a generic Agent class. This class must be extended and its methods may be overwritten to create new Agent subtypes.

Author:
Kevin Bauer, Pushkar Sambhoos
See Also:
Serialized Form

Field Summary
protected  java.util.Vector<java.lang.String> acceptableConnectAgents
          A vector of Agents that may be connected to the current Agent.
protected  int agentId
          Agent identifier field uniquely identifying this agent.
protected  java.lang.String agentName
          Agent name, as defined by NS2 (i.e., TCP, TCPSink, UDP, Null, etc.).
protected  java.util.Vector<Application> applications
          A Vector of all applications attached to the current Agent.
protected  boolean isConnected
          boolean Returns true if the current Agent is connected.
protected  int nodeId
          Node identifier field which specifies to which node this agent is attached.
protected  java.lang.String variableName
          Agent's TCL variable name.
 
Constructor Summary
Agent()
          Default constructor - Instantiates local class variables.
 
Method Summary
 java.lang.String addAgentToScript(int nodeId)
          Returns the TCL code containing the instantiation of this Agent.
 boolean canConnectToAgent(Agent agent)
          True or False regarding whether a connection is allowed.
 boolean canHaveMultipleConnections()
          Returns true if the current Agent can support multiple connections.
 int getAgentId()
          Returns the current Agent's unique identifier.
 java.lang.String getAgentName()
          Returns the Agent's NS2 name.
 java.util.Vector getApplications()
          Returns a Vector of applications that reside on this Agent.
 Application getApplicationsElementAt(int element)
          Returns the Application at index element.
 int getNodeId()
          Returns the Node identifier on which the current Agent is attached.
 java.lang.String getVariableName()
          Returns the Agent's TCP variable name.
 boolean isConnected()
          Returns whether the current Agent is connected to another Agent.
 void removeApplicationsElement(Application app)
          An Application to remove from the Application Vector.
 void removeApplicationsElementAt(int element)
          Removes the Application at index element from the Application Vector.
 void setAgentId(int agentId)
          Sets the Agent's ID value.
abstract  void setAgentProperties()
          Set the Agent's properties.
 void setApplications(Application app)
          A new Application to add to this Agent's Application Vector.
 void setConnected(boolean isConnected)
          Sets the current Agent's connected status to true or false.
abstract  java.lang.String writeAgentProperties()
          Returns a TCP representation of the Agent's properties.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

agentId

protected int agentId
Agent identifier field uniquely identifying this agent.


nodeId

protected int nodeId
Node identifier field which specifies to which node this agent is attached.


agentName

protected java.lang.String agentName
Agent name, as defined by NS2 (i.e., TCP, TCPSink, UDP, Null, etc.).


variableName

protected java.lang.String variableName
Agent's TCL variable name.


acceptableConnectAgents

protected java.util.Vector<java.lang.String> acceptableConnectAgents
A vector of Agents that may be connected to the current Agent.

See Also:
Vector

isConnected

protected boolean isConnected
boolean Returns true if the current Agent is connected.

See Also:
Vector

applications

protected java.util.Vector<Application> applications
A Vector of all applications attached to the current Agent.

See Also:
Vector
Constructor Detail

Agent

public Agent()
Default constructor - Instantiates local class variables.

Method Detail

getAgentName

public java.lang.String getAgentName()
Returns the Agent's NS2 name.

Returns:
Returns the Agent's NS2 name.

getVariableName

public java.lang.String getVariableName()
Returns the Agent's TCP variable name.

Returns:
Returns the Agent's TCP variable name.

setAgentId

public void setAgentId(int agentId)
Sets the Agent's ID value.

Parameters:
An - new Agent ID to set for the current Agent.

getAgentId

public int getAgentId()
Returns the current Agent's unique identifier.

Returns:
Returns the current Agent's unique identifier.

getNodeId

public int getNodeId()
Returns the Node identifier on which the current Agent is attached.

Returns:
Returns the Node identifier on which the current Agent is attached.

setConnected

public void setConnected(boolean isConnected)
Sets the current Agent's connected status to true or false.

Parameters:
Sets - the current Agent's connected status to true or false.

isConnected

public boolean isConnected()
Returns whether the current Agent is connected to another Agent.

Returns:
Returns whether the current Agent is connected to another Agent.

canConnectToAgent

public boolean canConnectToAgent(Agent agent)
True or False regarding whether a connection is allowed.

Parameters:
Tests - whether a given Agent can be connected to the current Agent.
Returns:
True or False regarding whether a connection is allowed.

addAgentToScript

public java.lang.String addAgentToScript(int nodeId)
Returns the TCL code containing the instantiation of this Agent.

Parameters:
Adds - an Agent with a given identifier to the output TCL script String
Returns:
Returns the TCL code containing the instantiation of this Agent.

canHaveMultipleConnections

public boolean canHaveMultipleConnections()
Returns true if the current Agent can support multiple connections.

Returns:
Returns true if the current Agent can support multiple connections.

getApplications

public java.util.Vector getApplications()
Returns a Vector of applications that reside on this Agent.

Returns:
Returns a Vector of applications that reside on this Agent.
See Also:
Vector

getApplicationsElementAt

public Application getApplicationsElementAt(int element)
Returns the Application at index element.

Parameters:
element - An index into the Application Vector
Returns:
Returns the Application at index element.
See Also:
Application

removeApplicationsElementAt

public void removeApplicationsElementAt(int element)
Removes the Application at index element from the Application Vector. @see Vector

Parameters:
element - An index into the Application Vector

removeApplicationsElement

public void removeApplicationsElement(Application app)
An Application to remove from the Application Vector.

Parameters:
An - Application to remove from the Application Vector.
See Also:
Application

setApplications

public void setApplications(Application app)
A new Application to add to this Agent's Application Vector.

Parameters:
A - new Application to add to this Agent's Application Vector.
See Also:
Application

setAgentProperties

public abstract void setAgentProperties()
Set the Agent's properties. This method must be implemented by all classes that implement Agent, since different Agents may support a variety of different properties.


writeAgentProperties

public abstract java.lang.String writeAgentProperties()
Returns a TCP representation of the Agent's properties.

Returns:
Returns a TCP representation of the Agent's properties.