This object is used to classify a packet as a member of a particular flow. As their name indicates, hash classifiers use a hash table internally to assign packets to flows. These objects are used where flow-level information is required (e.g. in flow-specific queuing disciplines and statistics collection). Several ``flow granularities'' are available. In particular, packets may be assigned to flows based on flow ID, destination address, source/destination addresses, or the combination of source/destination addresses plus flow ID. The fields accessed by the hash classifier are limited to the ip header: src(), dst(), flowid() (see ip.h).
The hash classifier is created with an integer argument specifying the initial size of its hash table. The current hash table size may be subsequently altered with the resize method (see below). When created, the instance variables shift_ and mask_ are initialized with the simulator's current NodeShift and NodeMask values, respectively. These values are retrieved from the AddrParams object when the hash classifier is instantiated. The hash classifier will fail to operate properly if the AddrParams structure is not initialized. The following constructors are used for the various hash classifiers:
Classifier/Hash/SrcDest Classifier/Hash/Dest Classifier/Hash/Fid Classifier/Hash/SrcDestFid
The hash classifier receives packets, classifies them according to their flow criteria, and retrieves the classifier slot indicating the next node that should receive the packet. In several circumstances with hash classifiers, most packets should be associated with a single slot, while only a few flows should be directed elsewhere. The hash classifier includes a default_ instance variable indicating which slot is to be used for packets that do not match any of the per-flow criteria. The default_ may be set optionally.
The methods for a hash classifier are as follows:
$hashcl set-hash buck src dst fid slot $hashcl lookup buck src dst fid $hashcl del-hash src dst fid $hashcl resize nbuck
The set-hash method inserts a new entry into the hash table within the hash classifier. The buck argument specifies the hash table bucket number to use for the insertion of this entry. When the bucket number is not known, buck may be specified as auto. The src, dst and fid arguments specify the IP source, destination, and flow IDs to be matched for flow classification. Fields not used by a particular classifier (e.g. specifying src flor a flow-id classifier) is ignored. The slot argument indicates the index into the underlying slot table in the base Classifier object from which the hash classifier is derived. The lookup function returns the name of the object associated with the given buck/src/dst/fid tuple. The buck argument may be auto, as for set-hash. The del-hash function removes the specified entry from the hash table. Currently, this is done by simply marking the entry as inactive, so it is possible to populate the hash table with unused entries. The resize function resizes the hash table to include the number of buckets specified by the argument nbuck.
Provided no default is defined, a hash classifier will perform a call into OTcl when it receives a packet which matches no flow criteria. The call takes the following form:
\$obj unknown-flow src dst flowid buckThus, when a packet matching no flow criteria is received, the method unknown-flow of the instantiated hash classifier object is invoked with the source, destination, and flow id fields from the packet. In addition, the buck field indicates the hash bucket which should contain this flow if it were inserted using set-hash. This arrangement avoids another hash lookup when performing insertions into the classifier when the bucket is already known.