fi.helsinki.dacopan.model
Class TransferUnit

java.lang.Object
  extended by fi.helsinki.dacopan.model.TransferUnit
All Implemented Interfaces:
Identifiable, java.lang.Comparable

public class TransferUnit
extends java.lang.Object
implements java.lang.Comparable, Identifiable

A unit of transfer (packet, segment etc) for a specific protocol.

Version:
$Id: TransferUnit.java,v 1.23 2005/04/27 11:20:57 mjvaanan Exp $

Field Summary
protected  java.util.List children
          units that this unit consists of (can be null)
protected  Host destination
          destination host
protected  boolean dropped
          whether this unit was dropped or not
protected  Flow flow
          the flow this units belongs to (might be null)
protected  long id
          unique identifier
protected  TransferUnit parent
          parent unit, which this unit is a part of (can be null)
protected  Protocol protocol
          the protocol this unit belongs to
protected  float receiveEnd
          time when unit was fully received
protected  float receiveStart
          time when receiving this unit started
protected  float sendEnd
          time when unit was fully sent
protected  float sendStart
          time when sending of unit started
protected  Host source
          source host
protected  java.util.Map values
          protocol fields and other values associated with this unit, mapped by name
 
Constructor Summary
protected TransferUnit(long id, java.util.Map values, Protocol protocol, Flow flow, Host source, Host destination, boolean dropped)
           
  TransferUnit(long id, java.util.Map values, Protocol protocol, Flow flow, Host source, Host destination, float sendStart, float receiveEnd, boolean dropped)
          Constructor for lower-level units with their own timestamps.
  TransferUnit(long id, java.util.Map values, Protocol protocol, Flow flow, Host source, Host destination, java.util.List children, boolean dropped)
          Constructor for higher level units with children.
 
Method Summary
protected  void addInitialValues(java.util.Map values)
          Called from the constructor, adds all the values in the map given by the user to the actual value map (makes the values not specific to any host).
 void addVariableValue(java.lang.String name, Host host, java.lang.String value)
          Adds a variable value to this unit.
 void addVariableValue(VariableDefinition def, Host host, java.lang.String value)
           
protected  void assignChildren()
          Assigns itself as the parent of its children.
protected  void calculateTimestamps()
          Calculates the timestamps of this unit by looking at its children.
 int compareTo(java.lang.Object o)
          TransferUnits are ordered primarily by sendStart, then by receiveEnd.
 boolean equals(java.lang.Object o)
           
 java.util.List getChildren()
          Returns the children units of this unit (ordered by default ordering).
 Host getDestination()
          Returns the destination host of this unit.
 Flow getFlow()
          Returns the flow this unit belongs to (may be null).
 long getId()
          Returns the unique identifier of this object.
 TransferUnit getParent()
          Returns the parent of this unit (may be null)
 int getPayloadSize()
          Calculates the payload data length in this transfer unit.
 Protocol getProtocol()
          Returns the protocol of this unit.
 float getReceiveEnd()
          Returns the time this unit was fully received.
 float getReceiveStart()
          Returns the time the destination host started to receive this unit.
 TransferUnit getRoot()
          Returns the root of the TransferUnit tree this unit belongs to.
 float getSendEnd()
          Returns the time the sending of this unit was completed.
 float getSendStart()
          Returns the time this unit was sent.
 Host getSource()
          Returns the source host of this unit.
 java.lang.String getValue(VariableDefinition variable)
          Gets the value of the given variable (ignoring if it's host-specific).
 java.lang.String getValue(VariableDefinition variable, Host host)
          Returns the value of the given variable.
 java.lang.String getValueReceive(VariableDefinition variable)
          Gets the value of the given variable (specific to the destination host).
 java.lang.String getValueSend(VariableDefinition variable)
          Gets the value of the given variable (specific to the source host).
 boolean isDropped()
          Returns true if this unit was dropped.
 boolean isOneUnit()
          Returns true if unit's sending and receiving are both just points in time and not time intervals where start and end times are not equal.
 void setParent(TransferUnit parent)
          Sets the parent unit of this unit.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

id

protected long id
unique identifier


parent

protected TransferUnit parent
parent unit, which this unit is a part of (can be null)


children

protected java.util.List children
units that this unit consists of (can be null)


values

protected java.util.Map values
protocol fields and other values associated with this unit, mapped by name


protocol

protected Protocol protocol
the protocol this unit belongs to


flow

protected Flow flow
the flow this units belongs to (might be null)


source

protected Host source
source host


destination

protected Host destination
destination host


sendStart

protected float sendStart
time when sending of unit started


sendEnd

protected float sendEnd
time when unit was fully sent


receiveStart

protected float receiveStart
time when receiving this unit started


receiveEnd

protected float receiveEnd
time when unit was fully received


dropped

protected boolean dropped
whether this unit was dropped or not

Constructor Detail

TransferUnit

protected TransferUnit(long id,
                       java.util.Map values,
                       Protocol protocol,
                       Flow flow,
                       Host source,
                       Host destination,
                       boolean dropped)
See Also:
TransferUnit(long, Map, Protocol, Flow, Host, Host, float, float, boolean)

TransferUnit

public TransferUnit(long id,
                    java.util.Map values,
                    Protocol protocol,
                    Flow flow,
                    Host source,
                    Host destination,
                    float sendStart,
                    float receiveEnd,
                    boolean dropped)
Constructor for lower-level units with their own timestamps.

Parameters:
id - unique id of the unit
values - map (String->String) of variable names and values of this unit (not specific to any host)
protocol - of the unit
flow - (protocol-specific connection) of the unit
source - host
destination - host
sendStart - time when sending of unit started
receiveEnd - time when unit was fully received
dropped - whether the unit was dropped

TransferUnit

public TransferUnit(long id,
                    java.util.Map values,
                    Protocol protocol,
                    Flow flow,
                    Host source,
                    Host destination,
                    java.util.List children,
                    boolean dropped)
Constructor for higher level units with children.

Parameters:
children - list of children units
See Also:
TransferUnit(long, Map, Protocol, Flow, Host, Host, float, float, boolean)
Method Detail

getId

public long getId()
Description copied from interface: Identifiable
Returns the unique identifier of this object.

Specified by:
getId in interface Identifiable
Returns:
a unique long id

addVariableValue

public void addVariableValue(java.lang.String name,
                             Host host,
                             java.lang.String value)
Adds a variable value to this unit.

Parameters:
name - name of the variable
host - the value's specific to, use null if none
value - of the variable

addVariableValue

public void addVariableValue(VariableDefinition def,
                             Host host,
                             java.lang.String value)
See Also:
addVariableValue(String, Host, String)

getValue

public java.lang.String getValue(VariableDefinition variable)
Gets the value of the given variable (ignoring if it's host-specific).


getValueSend

public java.lang.String getValueSend(VariableDefinition variable)
Gets the value of the given variable (specific to the source host).


getValueReceive

public java.lang.String getValueReceive(VariableDefinition variable)
Gets the value of the given variable (specific to the destination host).


getValue

public java.lang.String getValue(VariableDefinition variable,
                                 Host host)
Returns the value of the given variable.

Parameters:
variable - whose value to return
host - to whom the value is specific (if any)
Returns:
the value, null if none

getProtocol

public Protocol getProtocol()
Returns the protocol of this unit.


getFlow

public Flow getFlow()
Returns the flow this unit belongs to (may be null).


getSource

public Host getSource()
Returns the source host of this unit.


getDestination

public Host getDestination()
Returns the destination host of this unit.


getChildren

public java.util.List getChildren()
Returns the children units of this unit (ordered by default ordering).


getSendStart

public float getSendStart()
Returns the time this unit was sent.


getReceiveEnd

public float getReceiveEnd()
Returns the time this unit was fully received.


getSendEnd

public float getSendEnd()
Returns the time the sending of this unit was completed. If the unit has no children, this is always the same as the value returned from getSendStart().


getReceiveStart

public float getReceiveStart()
Returns the time the destination host started to receive this unit.


getParent

public TransferUnit getParent()
Returns the parent of this unit (may be null)


getRoot

public TransferUnit getRoot()
Returns the root of the TransferUnit tree this unit belongs to.

Returns:
the root unit, this if parent is null

setParent

public void setParent(TransferUnit parent)
Sets the parent unit of this unit. The only setter method in this otherwise immutable class. Needed because information on the parent unit is not available when a unit is created in a bottom-up approach.


getPayloadSize

public int getPayloadSize()

Calculates the payload data length in this transfer unit. Calculation is based on protocol specific header variables and uses the following formulas:

ipv4: tot_len - 4 * ihl
tcp: [sum of child ip payload size] - 4 * data_offset
udp: len - 8

Other protocols are not supported.

Returns:
data length in bytes, or negative value if not available

isDropped

public boolean isDropped()
Returns true if this unit was dropped.


isOneUnit

public boolean isOneUnit()
Returns true if unit's sending and receiving are both just points in time and not time intervals where start and end times are not equal.


compareTo

public int compareTo(java.lang.Object o)
TransferUnits are ordered primarily by sendStart, then by receiveEnd.

Specified by:
compareTo in interface java.lang.Comparable

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

calculateTimestamps

protected void calculateTimestamps()
Calculates the timestamps of this unit by looking at its children.


assignChildren

protected void assignChildren()
Assigns itself as the parent of its children.


addInitialValues

protected void addInitialValues(java.util.Map values)
Called from the constructor, adds all the values in the map given by the user to the actual value map (makes the values not specific to any host).



© Dacopan2 team, 2005-