net.clackrouter.component.extension
Class Classifier

java.lang.Object
  extended by net.clackrouter.component.base.ClackComponent
      extended by net.clackrouter.component.extension.Classifier
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Alarm

public class Classifier
extends ClackComponent
implements java.lang.Cloneable, java.io.Serializable

Classifies packets and sends them out distict ports if they match user-specified byte-string/offset pairs called patterns.

This is a very powerful but very general component that can be used to demultiplex packets based on different header information. The number of output ports is dynamic, depending on the total number of possible pattern matches.

See Also:
Serialized Form

Nested Class Summary
 class Classifier.PatternMatcher
           
protected  class Classifier.QuickMatch
           
 
Nested classes/interfaces inherited from class net.clackrouter.component.base.ClackComponent
ClackComponent.Waiter
 
Field Summary
protected  java.util.ArrayList mPatternMatchers
           
static int sFROM_IFACE
           
 
Fields inherited from class net.clackrouter.component.base.ClackComponent
componentCell, m_has_error, m_log, m_name, m_num_ports, m_packetcount_in, m_packetcount_out, m_ports, mListeners, mRouter, pendingError, SIGNAL_ERROR_LEN_MSEC, UNIQUE_COUNT, view
 
Constructor Summary
Classifier(Router router, java.lang.String name)
           
 
Method Summary
 void acceptPacket(VNSPacket packet, int port_number)
          The starting point for packet-processing when packets are "pushed" to this component.
protected  void addNewPortToArray(java.lang.String descr)
           
 boolean addPattern(java.lang.String pattern)
           
 boolean delPattern(int index)
           
 Classifier.PatternMatcher getPattern(int index)
           
 java.lang.Object[] getPatterns()
           
 javax.swing.JPanel getPropertiesView()
          Method for getting the properties view associated with this component Property views are used to display more detailed information about internal component state.
 java.util.Properties getSerializableProperties(boolean isTransient)
          Used to get all values the component would like to serialize to file.
 void initializeProperties(java.util.Properties props)
          Method used to initialize a component based on serialized properties values saved to a file.
 boolean isModifying()
          Reports whether this component modifies packets passed through it This value is used by the static checking algorithm used to make sure port connections are valid.
protected  void removePortFromArray(int portNum)
           
protected  void setupPorts(int numports)
          Allocates an array of ClackPort objects to be used by this component
 
Methods inherited from class net.clackrouter.component.base.ClackComponent
createCopy, createInputPullPort, createInputPushPort, createOutputPullPort, createOutputPushPort, error, fireListeners, getColor, getComponentCell, getHierarchicalView, getLog, getName, getNumPorts, getPacketCountIn, getPacketCountOut, getPendingError, getPort, getRouter, getTime, getTypeName, getUniqueCount, getView, handlePullRequest, hasError, isHierarchical, log, notifyAlarm, poll, registerListener, sendOutPort, setAlarm, setComponentCell, setName, setPendingError, setView, showErrorDialog, signalError, try_repaint, unregisterListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sFROM_IFACE

public static int sFROM_IFACE

mPatternMatchers

protected java.util.ArrayList mPatternMatchers
Constructor Detail

Classifier

public Classifier(Router router,
                  java.lang.String name)
Method Detail

setupPorts

protected void setupPorts(int numports)
Description copied from class: ClackComponent
Allocates an array of ClackPort objects to be used by this component

Overrides:
setupPorts in class ClackComponent
Parameters:
numports - the number of ports to create

isModifying

public boolean isModifying()
Description copied from class: ClackComponent
Reports whether this component modifies packets passed through it This value is used by the static checking algorithm used to make sure port connections are valid. Sub-classes that do not modify packets should override this method

Overrides:
isModifying in class ClackComponent
Returns:
by default, we assume the component modifies packets

addNewPortToArray

protected void addNewPortToArray(java.lang.String descr)

removePortFromArray

protected void removePortFromArray(int portNum)

delPattern

public boolean delPattern(int index)

addPattern

public boolean addPattern(java.lang.String pattern)

acceptPacket

public void acceptPacket(VNSPacket packet,
                         int port_number)
Description copied from class: ClackComponent

The starting point for packet-processing when packets are "pushed" to this component.

The default implementation warns that the packet is being ignored.

Overrides:
acceptPacket in class ClackComponent
Parameters:
packet - The pushed packet
port_number - The number of the port that this packet is arriving on

getPattern

public Classifier.PatternMatcher getPattern(int index)

getPatterns

public java.lang.Object[] getPatterns()

getPropertiesView

public javax.swing.JPanel getPropertiesView()
Description copied from class: ClackComponent
Method for getting the properties view associated with this component Property views are used to display more detailed information about internal component state. This method creates a default property view, and can be overriden to provide custom properties views

Overrides:
getPropertiesView in class ClackComponent
Returns:
this component's property view

getSerializableProperties

public java.util.Properties getSerializableProperties(boolean isTransient)
Description copied from class: ClackComponent

Used to get all values the component would like to serialize to file.

These values are stored as String -> String pairs in a Properties object. These properties will be passed to ClackComponent.initializeProperties(Properties) when the Component is recreated.

Serialization can be transient or not, which determines whether all or just some of the internal component state is saved. Transient serialization means that some properties will be saved which may make this serialized file invalid for use on different network or router set-ups. For example, saving info specific to the IP addresses of a certain topology would only happen if transient serialization was used. However, it can be desireable to save these properties when setting up exact demonstrations.

By default we have no properties to serialize, so we return an empty object

Overrides:
getSerializableProperties in class ClackComponent
Parameters:
isTransient - flag indicating if serialization is transient
Returns:
all property key-value pairs to serialize

initializeProperties

public void initializeProperties(java.util.Properties props)
Description copied from class: ClackComponent

Method used to initialize a component based on serialized properties values saved to a file.

By default, no action is performed

Overrides:
initializeProperties in class ClackComponent
Parameters:
props - all property values serialized for this component