com.voytechs.jnetstream.codec
Class FlowKey

java.lang.Object
  extended by com.voytechs.jnetstream.codec.FlowKey

public class FlowKey
extends java.lang.Object

A flow key a set of values that either match a packet or not to a flow. So typically ip.src, ip.dst, ip.proto, tcp.sport and tcp.dport are values stored in a FlowKey. A packet when its decoded has its own flow key. Packet's flow key is used to identify flows already seen before and matching packets aganst those flows. Flows can be bi-directional meaning that certain key paramters are reversed try to match if a packet belongs to a particular flow in the opposite direction the packet was send from.

Since:
0.2.3
Author:
Mark Bednarczyk

Field Summary
static int DIM_COUNT
           
static int ENTRY_COUNT
           
static int KEY_COUNT
           
static java.lang.String MODULE
           
static int PAIR_SIZE
           
 
Constructor Summary
FlowKey()
           
 
Method Summary
 void clear()
          Clear all entries within the key.
 boolean clearEntry(int index)
          Clears all entries from the specified key
 boolean equals(java.lang.Object o)
          Compare the 2 flowkey and return true if they contain exactly matching values, otherwise false.
 int hashCode()
          Calculate a hashcode for this key
 boolean isInAPair(int index, int entry)
          Tells if a specific entry has been paired up with any other entry.
 void reversePairs(boolean flowState)
          If false the flow key is represented in its original form and sequence.
 void setEntry(int key, int entry, java.lang.Object value)
          Sets flow key entry value.
 void setEntry(int keyIndex, int entry, java.lang.Object value, java.lang.Object alias)
          Sets flow key entry value.
 void setPair(int index, long p1, long p2)
           
 java.lang.String toString()
          Format this key to a printable form.
 java.lang.String toStringEntireKey()
          Format this key to a printable form.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

MODULE

public static final java.lang.String MODULE
See Also:
Constant Field Values

KEY_COUNT

public static int KEY_COUNT

ENTRY_COUNT

public static int ENTRY_COUNT

DIM_COUNT

public static int DIM_COUNT

PAIR_SIZE

public static int PAIR_SIZE
Constructor Detail

FlowKey

public FlowKey()
Parameters:
-
Throws:
Method Detail

setPair

public void setPair(int index,
                    long p1,
                    long p2)

clearEntry

public boolean clearEntry(int index)
Clears all entries from the specified key

Parameters:
index - Key index to clear.
Returns:
true if successful. Returns false if index is out of range.

clear

public void clear()
Clear all entries within the key.


setEntry

public void setEntry(int key,
                     int entry,
                     java.lang.Object value)
Sets flow key entry value.

Parameters:
key - Index of the key
entry - Index of the entry within the key
value - Entry value

setEntry

public void setEntry(int keyIndex,
                     int entry,
                     java.lang.Object value,
                     java.lang.Object alias)
Sets flow key entry value.

Parameters:
key - Index of the key
entry - Index of the entry within the key
value - Entry value
alias - Entry value alias. If alias is used when reporting values for this particular key, the alias will be used instead. Value will still be used for matching and comparisson and never the alias.

reversePairs

public void reversePairs(boolean flowState)
If false the flow key is represented in its original form and sequence. When flowState is set to reverse the key entries that were paired up are reversed. Any operations including equals will be done with the pairs reversed. Setting the flowState back to false will restore the pairs to their original order and sequence.

Parameters:
flowState - false leaves/sets the key values to their original order and sequence. true set the key values to reverse order according to the way that flowpairs were defined.

isInAPair

public boolean isInAPair(int index,
                         int entry)
Tells if a specific entry has been paired up with any other entry.

Parameters:
index - key index.
entry - entry index.
Returns:
true if its paired, false if its not.

equals

public boolean equals(java.lang.Object o)
Compare the 2 flowkey and return true if they contain exactly matching values, otherwise false.

Overrides:
equals in class java.lang.Object
Parameters:
o - Object to compare to. Should be of FlowKey type otherwise false is returned immediately.
Returns:
True if all key values are equal to each other, otherwise false.

hashCode

public int hashCode()
Calculate a hashcode for this key

Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Format this key to a printable form.

Overrides:
toString in class java.lang.Object
Returns:
string representation of this flow key.

toStringEntireKey

public java.lang.String toStringEntireKey()
Format this key to a printable form.

Returns:
string representation of this flow key.