Mixes for Privacy and Anonymity in the Internet
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
CADatabase Class Reference

Public Member Functions

 CADatabase ()
 
 ~CADatabase ()
 
SINT32 insert (UINT8 key[16], UINT64 timestamp)
 Inserts this key in the replay DB. More...
 
SINT32 start ()
 
SINT32 stop ()
 
SINT32 test ()
 

Static Public Member Functions

static SINT32 measurePerformance (UINT8 *strLogFile, UINT32 lowerBoundEntries, UINT32 upperBoundEntries, UINT32 stepBy, UINT32 meassuresPerStep, UINT32 insertsPerMeasure)
 This mehtod can be used to measure the performance of the Replay database. More...
 

Private Member Functions

t_databaseInfocreateDBInfo ()
 Creates and initialises a dbinfo struct. More...
 
SINT32 clearDB (t_databaseInfo *pDB)
 clears the whole database pDB - but does not delete the hashtable pDB More...
 
SINT32 deleteDB (t_databaseInfo *&pDB)
 Deletes the whole database pDB. More...
 
SINT32 nextClock ()
 
SINT32 fill (UINT32 nrOfEntries)
 Pre fills the database with nrOfEntries random entries. More...
 
SINT32 simulateInsert (UINT8 key[16])
 This is a modified copy of insert() which simulates the insert() function as close as possible without actually changing the replay database. More...
 

Private Attributes

UINT64 m_lastSwitch
 
t_databaseInfom_currDatabase
 
t_databaseInfom_nextDatabase
 
t_databaseInfom_prevDatabase
 
volatile bool m_bRun
 
volatile SINT32 m_currentClock
 
CAMutexm_pMutex
 
CAThreadm_pThread
 

Friends

THREAD_RETURN db_loopMaintenance (void *param)
 

Constructor & Destructor Documentation

◆ CADatabase()

CADatabase::CADatabase ( )

◆ ~CADatabase()

CADatabase::~CADatabase ( )

Member Function Documentation

◆ clearDB()

SINT32 CADatabase::clearDB ( t_databaseInfo pDB)
private

clears the whole database pDB - but does not delete the hashtable pDB

Parameters
pDBdatabase to delete

References _t_database_info::m_pHashTable, and _t_database_entry::next.

Referenced by deleteDB(), and nextClock().

◆ createDBInfo()

t_databaseInfo * CADatabase::createDBInfo ( )
private

Creates and initialises a dbinfo struct.

Referenced by CADatabase().

◆ deleteDB()

SINT32 CADatabase::deleteDB ( t_databaseInfo *&  pDB)
private

Deletes the whole database pDB.

Parameters
pDBdatabase to delete

References clearDB(), and E_SUCCESS.

Referenced by ~CADatabase().

◆ fill()

SINT32 CADatabase::fill ( UINT32  nrOfEntries)
private

Pre fills the database with nrOfEntries random entries.

Parameters
nrOfEntriesnumber of entries to put in the database

References E_SUCCESS, getRandom(), and insert().

Referenced by measurePerformance(), and test().

◆ insert()

SINT32 CADatabase::insert ( UINT8  key[16],
UINT64  timestamp 
)

◆ measurePerformance()

SINT32 CADatabase::measurePerformance ( UINT8 strLogFile,
UINT32  lowerBoundEntries,
UINT32  upperBoundEntries,
UINT32  stepBy,
UINT32  meassuresPerStep,
UINT32  insertsPerMeasure 
)
static

This mehtod can be used to measure the performance of the Replay database.

The results are stored in a file in csv format. Ths method will do several measures with different numbers of elements in the database. These number could be specified using owerBoundEntries,upperBoundEntries and stepBy.

Parameters
strLogFilethe log file name
lowerBoundEntriesthe number of entries in the database (at beginn)
upperBoundEntriesthe number of entries in the database (at end)
stepByhow many entries should be added for each new measurement
meassuresPerStephow many measure values should be generate per step. That means that the experiement is repeated this many times.
insertsPerMeasureone measure value will be the time: (Total Insertion Time)/insertsPerMeasure

References CADatabase(), diff64(), E_SUCCESS, fill(), getcurrentTimeMicros(), getRandom(), initRandom(), O_LARGEFILE, CAMsg::printMsg(), S_IREAD, S_IWRITE, and simulateInsert().

◆ nextClock()

SINT32 CADatabase::nextClock ( )
private

◆ simulateInsert()

SINT32 CADatabase::simulateInsert ( UINT8  key[16])
private

This is a modified copy of insert() which simulates the insert() function as close as possible without actually changing the replay database.

References E_SUCCESS, CAMutex::lock(), m_currDatabase, m_currentClock, m_pMutex, _t_database_info::m_u32Size, and CAMutex::unlock().

Referenced by measurePerformance().

◆ start()

SINT32 CADatabase::start ( )

◆ stop()

SINT32 CADatabase::stop ( )

References E_SUCCESS, CAThread::join(), m_bRun, and m_pThread.

Referenced by ~CADatabase().

◆ test()

SINT32 CADatabase::test ( )

References E_SUCCESS, and fill().

Friends And Related Function Documentation

◆ db_loopMaintenance

THREAD_RETURN db_loopMaintenance ( void *  param)
friend

Referenced by start().

Member Data Documentation

◆ m_bRun

volatile bool CADatabase::m_bRun
private

Referenced by start(), and stop().

◆ m_currDatabase

t_databaseInfo* CADatabase::m_currDatabase
private

◆ m_currentClock

volatile SINT32 CADatabase::m_currentClock
private

Referenced by CADatabase(), and simulateInsert().

◆ m_lastSwitch

UINT64 CADatabase::m_lastSwitch
private

Referenced by CADatabase(), insert(), and nextClock().

◆ m_nextDatabase

t_databaseInfo* CADatabase::m_nextDatabase
private

◆ m_pMutex

CAMutex* CADatabase::m_pMutex
private

◆ m_prevDatabase

t_databaseInfo* CADatabase::m_prevDatabase
private

◆ m_pThread

CAThread* CADatabase::m_pThread
private

Referenced by CADatabase(), start(), and stop().