A Discrete-Event Network Simulator
API
ns3::Hash::Function::Fnv1a Class Reference

Fnv1a hash function implementation. More...

#include "hash-fnv.h"

+ Inheritance diagram for ns3::Hash::Function::Fnv1a:
+ Collaboration diagram for ns3::Hash::Function::Fnv1a:

Public Member Functions

 Fnv1a ()
 Constructor. More...
 
void clear () override
 Restore initial state. More...
 
uint32_t GetHash32 (const char *buffer, const size_t size) override
 Compute 32-bit hash of a byte buffer. More...
 
uint64_t GetHash64 (const char *buffer, const size_t size) override
 Compute 64-bit hash of a byte buffer. More...
 
- Public Member Functions inherited from ns3::Hash::Implementation
 Implementation ()
 Constructor. More...
 
virtual ~Implementation ()
 Destructor. More...
 
virtual uint32_t GetHash32 (const char *buffer, const std::size_t size)=0
 Compute 32-bit hash of a byte buffer. More...
 
virtual uint64_t GetHash64 (const char *buffer, const std::size_t size)
 Compute 64-bit hash of a byte buffer. More...
 
- Public Member Functions inherited from ns3::SimpleRefCount< Implementation >
 SimpleRefCount ()
 Default constructor. More...
 
 SimpleRefCount (const SimpleRefCount &o[[maybe_unused]])
 Copy constructor. More...
 
uint32_t GetReferenceCount () const
 Get the reference count of the object. More...
 
SimpleRefCountoperator= (const SimpleRefCount &o[[maybe_unused]])
 Assignment operator. More...
 
void Ref () const
 Increment the reference count. More...
 
void Unref () const
 Decrement the reference count. More...
 

Private Attributes

uint32_t m_hash32
 Cache last hash value, for incremental hashing. More...
 
uint64_t m_hash64
 Cache last hash value, for incremental hashing. More...
 

Static Private Attributes

static constexpr auto SEED {0x8BADF00D}
 Seed value. More...
 

Detailed Description

Fnv1a hash function implementation.

This is the venerable Fowler-Noll-Vo hash, version 1A. (See the FNV page.)

The implementation here is taken directly from the published FNV reference code, with minor modifications to wrap into this class. See the hash-fnv.cc file for details.

Definition at line 55 of file hash-fnv.h.

Constructor & Destructor Documentation

◆ Fnv1a()

ns3::Hash::Function::Fnv1a::Fnv1a ( )

Constructor.

Definition at line 757 of file hash-fnv.cc.

References clear().

+ Here is the call graph for this function:

Member Function Documentation

◆ clear()

void ns3::Hash::Function::Fnv1a::clear ( )
overridevirtual

Restore initial state.

Implements ns3::Hash::Implementation.

Definition at line 777 of file hash-fnv.cc.

References FNV1_32A_INIT, FNV1A_64_INIT, m_hash32, and m_hash64.

Referenced by Fnv1a().

+ Here is the caller graph for this function:

◆ GetHash32()

uint32_t ns3::Hash::Function::Fnv1a::GetHash32 ( const char *  buffer,
const size_t  size 
)
override

Compute 32-bit hash of a byte buffer.

Call clear () between calls to GetHash32() to reset the internal state and hash each buffer separately.

If you don't call clear() between calls to GetHash32, you can hash successive buffers. The final return value will be the cumulative hash across all calls.

Parameters
[in]bufferpointer to the beginning of the buffer
[in]sizelength of the buffer, in bytes
Returns
32-bit hash of the buffer

Definition at line 763 of file hash-fnv.cc.

References ns3::Hash::Function::Fnv1aImplementation::fnv_32a_buf(), and m_hash32.

+ Here is the call graph for this function:

◆ GetHash64()

uint64_t ns3::Hash::Function::Fnv1a::GetHash64 ( const char *  buffer,
const size_t  size 
)
override

Compute 64-bit hash of a byte buffer.

Call clear () between calls to GetHash64() to reset the internal state and hash each buffer separately.

If you don't call clear() between calls to GetHash64, you can hash successive buffers. The final return value will be the cumulative hash across all calls.

Parameters
[in]bufferpointer to the beginning of the buffer
[in]sizelength of the buffer, in bytes
Returns
64-bit hash of the buffer

Definition at line 770 of file hash-fnv.cc.

References ns3::Hash::Function::Fnv1aImplementation::fnv_64a_buf(), and m_hash64.

+ Here is the call graph for this function:

Member Data Documentation

◆ m_hash32

uint32_t ns3::Hash::Function::Fnv1a::m_hash32
private

Cache last hash value, for incremental hashing.

Definition at line 105 of file hash-fnv.h.

Referenced by clear(), and GetHash32().

◆ m_hash64

uint64_t ns3::Hash::Function::Fnv1a::m_hash64
private

Cache last hash value, for incremental hashing.

Definition at line 106 of file hash-fnv.h.

Referenced by clear(), and GetHash64().

◆ SEED

constexpr auto ns3::Hash::Function::Fnv1a::SEED {0x8BADF00D}
staticconstexprprivate

Seed value.

Definition at line 101 of file hash-fnv.h.


The documentation for this class was generated from the following files: