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
CAReplayDatabase Class Reference

Public Member Functions

 CAReplayDatabase ()
 
 ~CAReplayDatabase ()
 
SINT32 insert (UINT8 key[16])
 Inserts this key in the replay DB. More...
 
SINT32 start ()
 
SINT32 stop ()
 
SINT32 getCurrentReplayTimestamp (tReplayTimestamp &replayTimestamp) const
 Returns the current Replay timestamp for this database. More...
 
UINT32 getRefTime () const
 Returns the local time in seconds since epoch for replay timestamp='0' for this database. More...
 

Static Public Member Functions

static SINT32 getReplayTimestampForTime (tReplayTimestamp &replayTimestamp, UINT32 aktTime, UINT32 refTime)
 Returns the replay timestamp for this reference time (seconds since epoch) and time. More...
 
static SINT32 getTimeForReplayTimestamp (UINT32 &refTime, tReplayTimestamp replayTimestamp)
 Returns the refernce time (seconds since epoch) for the given replay timestamp. More...
 
static SINT32 test ()
 
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

LP_replay_databaseEntry getNewDBEntry (t_replay_databaseInfo *pDB)
 
t_replay_databaseInfocreateDBInfo ()
 Creates and initialises a dbinfo struct. More...
 
SINT32 clearDB (t_replay_databaseInfo *pDB)
 clears the whole database pDB - but does not delete the hashtable pDB More...
 
SINT32 deleteDB (t_replay_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

t_replay_databaseInfom_currDatabase
 
t_replay_databaseInfom_nextDatabase
 
t_replay_databaseInfom_prevDatabase
 
volatile bool m_bRun
 
UINT32 m_refTime
 
volatile SINT32 m_currentClock
 
CAMutexm_pMutex
 
CAThreadm_pThread
 

Friends

THREAD_RETURN replaydb_loopMaintenance (void *param)
 

Constructor & Destructor Documentation

◆ CAReplayDatabase()

CAReplayDatabase::CAReplayDatabase ( )

◆ ~CAReplayDatabase()

CAReplayDatabase::~CAReplayDatabase ( )

Member Function Documentation

◆ clearDB()

SINT32 CAReplayDatabase::clearDB ( t_replay_databaseInfo pDB)
private

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

Parameters
pDBdatabase to delete

References E_SUCCESS, __t_database_info::m_pHeap, __t_database_info::m_pLastHeap, and __t_replay_database_heap::next.

Referenced by deleteDB(), and nextClock().

◆ createDBInfo()

t_replay_databaseInfo * CAReplayDatabase::createDBInfo ( )
private

Creates and initialises a dbinfo struct.

Referenced by CAReplayDatabase().

◆ deleteDB()

SINT32 CAReplayDatabase::deleteDB ( t_replay_databaseInfo *&  pDB)
private

Deletes the whole database pDB.

Parameters
pDBdatabase to delete

References clearDB(), and E_SUCCESS.

Referenced by ~CAReplayDatabase().

◆ fill()

SINT32 CAReplayDatabase::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().

◆ getCurrentReplayTimestamp()

SINT32 CAReplayDatabase::getCurrentReplayTimestamp ( tReplayTimestamp replayTimestamp) const

Returns the current Replay timestamp for this database.

Returns the current replay timestamp for this database.

Parameters
replayTimestampstores the current replay timestamp

References getReplayTimestampForTime(), and m_refTime.

Referenced by nextClock(), and replaydb_loopMaintenance().

◆ getNewDBEntry()

LP_replay_databaseEntry CAReplayDatabase::getNewDBEntry ( t_replay_databaseInfo pDB)
private

◆ getRefTime()

UINT32 CAReplayDatabase::getRefTime ( ) const

Returns the local time in seconds since epoch for replay timestamp='0' for this database.

◆ getReplayTimestampForTime()

SINT32 CAReplayDatabase::getReplayTimestampForTime ( tReplayTimestamp replayTimestamp,
UINT32  aktTime,
UINT32  refTime 
)
static

Returns the replay timestamp for this reference time (seconds since epoch) and time.

References E_SUCCESS, t_replay_timestamp::interval, t_replay_timestamp::offset, and SECONDS_PER_INTERVALL.

Referenced by getCurrentReplayTimestamp().

◆ getTimeForReplayTimestamp()

static SINT32 CAReplayDatabase::getTimeForReplayTimestamp ( UINT32 refTime,
tReplayTimestamp  replayTimestamp 
)
static

Returns the refernce time (seconds since epoch) for the given replay timestamp.

References E_SUCCESS, t_replay_timestamp::interval, t_replay_timestamp::offset, replaydb_loopMaintenance(), SECONDS_PER_INTERVALL, and THREAD_RETURN.

◆ insert()

SINT32 CAReplayDatabase::insert ( UINT8  key[16])

◆ measurePerformance()

SINT32 CAReplayDatabase::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 CAReplayDatabase(), diff64(), E_SUCCESS, fill(), getcurrentTimeMicros(), getRandom(), initRandom(), m_currentClock, myfilewrite, O_LARGEFILE, CAMsg::printMsg(), S_IREAD, S_IWRITE, and simulateInsert().

Referenced by main().

◆ nextClock()

SINT32 CAReplayDatabase::nextClock ( )
private

◆ simulateInsert()

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

◆ start()

SINT32 CAReplayDatabase::start ( )

◆ stop()

SINT32 CAReplayDatabase::stop ( )

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

Referenced by test(), and ~CAReplayDatabase().

◆ test()

SINT32 CAReplayDatabase::test ( )
static

TODO WRONG - fixme

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

Friends And Related Function Documentation

◆ replaydb_loopMaintenance

THREAD_RETURN replaydb_loopMaintenance ( void *  param)
friend

Referenced by start().

Member Data Documentation

◆ m_bRun

volatile bool CAReplayDatabase::m_bRun
private

◆ m_currDatabase

t_replay_databaseInfo* CAReplayDatabase::m_currDatabase
private

◆ m_currentClock

volatile SINT32 CAReplayDatabase::m_currentClock
private

◆ m_nextDatabase

t_replay_databaseInfo* CAReplayDatabase::m_nextDatabase
private

◆ m_pMutex

CAMutex* CAReplayDatabase::m_pMutex
private

◆ m_prevDatabase

t_replay_databaseInfo* CAReplayDatabase::m_prevDatabase
private

◆ m_pThread

CAThread* CAReplayDatabase::m_pThread
private

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

◆ m_refTime

UINT32 CAReplayDatabase::m_refTime
private