org.iitb.untwine
Class Device

java.lang.Object
  |
  +--org.iitb.untwine.Device
All Implemented Interfaces:
java.io.Serializable

public class Device
extends java.lang.Object
implements java.io.Serializable

This class is designed to store the details of a managed link layer (Layer-2) device

See Also:
Serialized Form

Constructor Summary
Device()
          Default class constructor.
Device(java.lang.String ip, java.lang.String mac, int count, boolean commPublic)
          Class copy constructor.
 
Method Summary
 int getCostToRoot()
          Returns the cost of the path to the root in the spanning tree as seen by this device.
 java.lang.String getIP()
          Returns the IP address of host
 java.lang.String getMAC()
          Returns the MAC address of host
 int getPortCount()
          Returns the number of interfaces (ports) of this device.
 java.util.Vector getPortList()
          Returns the list of ports of this device
 int getRootPort()
          Returns the port which provides the lowest cost path to root
 int getRootPortPathCost()
          Returns the contribution of the root port to the path cost of path to root.
 boolean isPublic()
          Returns whether community name is public or the one supplied to the program.
 void portAdd(java.lang.Object obj)
          Add the object of class Port passed as parameter in the portList.
 void setCostToRoot(int ctr)
          Sets the cost of the path to the root in the spanning tree as seen by this device.
 void setPortList(java.util.Vector pl)
          Sets the list of ports of this device
 void setRootPort(int rp)
          Sets the port which provides the lowest cost path to root
 void setRootPortPathCost(int rppc)
          Sets the contribution of the root port to the path cost of path to root.
 void updatePort(Port p)
          Updates a Port, specified as parameter, in the portList.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Device

public Device()
Default class constructor. Initializes portList vector to null.

Device

public Device(java.lang.String ip,
              java.lang.String mac,
              int count,
              boolean commPublic)
Class copy constructor. Constructs the object with IP address, MAC address, number of ports and whether community is public or not as specified in parameter and initializes port List, costToRoot, rootPort and RootPortPathCost to null.
Parameters:
ip - IP address of host
mac - MAC address of host
count - Number of interfaces (ports) of Device.
commPublic - boolean specifying whether community name is public or the one supplied as input to the program.
Method Detail

getIP

public java.lang.String getIP()
Returns the IP address of host
Returns:
IP address of host as String

getMAC

public java.lang.String getMAC()
Returns the MAC address of host
Returns:
MAC address of host as String

isPublic

public boolean isPublic()
Returns whether community name is public or the one supplied to the program.
Returns:
Is community name public.

portAdd

public void portAdd(java.lang.Object obj)
Add the object of class Port passed as parameter in the portList. This Port object contains the details of port and MAC address learnt.
Parameters:
obj - Object of class Port

updatePort

public void updatePort(Port p)
Updates a Port, specified as parameter, in the portList.
Parameters:
p - Object of class Port.

getPortList

public java.util.Vector getPortList()
Returns the list of ports of this device
Returns:
Vector of Ports

setPortList

public void setPortList(java.util.Vector pl)
Sets the list of ports of this device
Parameters:
pl - Vector of Ports

getPortCount

public int getPortCount()
Returns the number of interfaces (ports) of this device.
Returns:
Number of ports.

getCostToRoot

public int getCostToRoot()
Returns the cost of the path to the root in the spanning tree as seen by this device.
Returns:
Cost of path to root.

getRootPort

public int getRootPort()
Returns the port which provides the lowest cost path to root
Returns:
Root Port which provide lowest cost path to root.

getRootPortPathCost

public int getRootPortPathCost()
Returns the contribution of the root port to the path cost of path to root.
Returns:
Contribution of root port to the path cost of path to root.

setCostToRoot

public void setCostToRoot(int ctr)
Sets the cost of the path to the root in the spanning tree as seen by this device.
Parameters:
ctr - Cost of path to root.

setRootPort

public void setRootPort(int rp)
Sets the port which provides the lowest cost path to root
Parameters:
rp - Root Port which provide lowest cost path to root.

setRootPortPathCost

public void setRootPortPathCost(int rppc)
Sets the contribution of the root port to the path cost of path to root.
Parameters:
rppc - Contribution of root port to the path cost of path to root.