#include <SearchMsgBookkeeping.h>
Public Types | |
typedef std::map < OverlayKey, SearchMessageItem > | SearchBookkeepingList |
typedef for hashmap of OverlayKey and SearchMessageItem | |
typedef std::map < OverlayKey, SearchMessageItem > ::iterator | SearchBookkeepingListIterator |
typedef for an iterator of SearchBookkeepingList | |
typedef std::map < OverlayKey, SearchMessageItem > ::const_iterator | SearchBookkeepingListConstIterator |
typedef for an constant iterator of SearchBookkeepingList | |
Public Member Functions | |
~SearchMsgBookkeeping () | |
Destructor. | |
uint | getSize () const |
Returns size of Search-Message-Bookkeeping-List. | |
void | addMessage (const OverlayKey &searchKey) |
Add SearchMessage to SearchMsgBookkeeping. | |
void | removeMessage (const OverlayKey &searchKey) |
Removes SearchMessage from SearchMsgBookkeeping. | |
bool | contains (const OverlayKey &searchKey) const |
checks if Search-Message-Bookkeeping-List contains a specified key | |
void | updateItem (const OverlayKey &searchKey, uint hopCount) |
Updates hop-count, min-response-delay, max-response-delay of given searchMessage. | |
GiaSearchStats | getStatisticalData () const |
Returns statistical data. | |
Protected Attributes | |
SearchBookkeepingList | messages |
bookkeeping list of all sent search messages | |
Classes | |
struct | SearchMessageItem |
structure containing all necessary values to gather statistical data More... |
typedef std::map<OverlayKey, SearchMessageItem> SearchMsgBookkeeping::SearchBookkeepingList |
typedef for hashmap of OverlayKey and SearchMessageItem
typedef std::map<OverlayKey, SearchMessageItem>::iterator SearchMsgBookkeeping::SearchBookkeepingListIterator |
typedef for an iterator of SearchBookkeepingList
typedef std::map<OverlayKey, SearchMessageItem>::const_iterator SearchMsgBookkeeping::SearchBookkeepingListConstIterator |
typedef for an constant iterator of SearchBookkeepingList
SearchMsgBookkeeping::~SearchMsgBookkeeping | ( | ) |
uint SearchMsgBookkeeping::getSize | ( | ) | const |
Returns size of Search-Message-Bookkeeping-List.
00033 { 00034 return messages.size(); 00035 }
void SearchMsgBookkeeping::addMessage | ( | const OverlayKey & | searchKey | ) |
Add SearchMessage to SearchMsgBookkeeping.
searchKey |
00038 { 00039 SearchMessageItem item; 00040 item.searchKey = searchKey; 00041 item.creationTime = simulation.simTime(); 00042 item.minDelay = 0; 00043 item.maxDelay = 0; 00044 item.minHopCount = 0; 00045 item.maxHopCount = 0; 00046 item.responseCount = 0; 00047 messages[searchKey] = item; 00048 }
void SearchMsgBookkeeping::removeMessage | ( | const OverlayKey & | searchKey | ) |
Removes SearchMessage from SearchMsgBookkeeping.
searchKey |
00051 { 00052 SearchBookkeepingListIterator it = messages.find(searchKey); 00053 00054 if(it->first == searchKey) 00055 messages.erase(it); 00056 }
bool SearchMsgBookkeeping::contains | ( | const OverlayKey & | searchKey | ) | const |
checks if Search-Message-Bookkeeping-List contains a specified key
searchKey | Key to check |
00059 { 00060 SearchBookkeepingListConstIterator it = messages.find(searchKey); 00061 return (it != messages.end()); 00062 }
void SearchMsgBookkeeping::updateItem | ( | const OverlayKey & | searchKey, | |
uint | hopCount | |||
) |
Updates hop-count, min-response-delay, max-response-delay of given searchMessage.
searchKey | Id of search message | |
hopCount | New hopCount-Value |
00066 { 00067 SearchBookkeepingListIterator it = messages.find(searchKey); 00068 SearchMessageItem currentItem; 00069 00070 if(it->first == searchKey) { 00071 currentItem = it->second; 00072 simtime_t currentTime = simulation.simTime(); 00073 00074 double delay = currentTime - currentItem.creationTime; 00075 00076 // initialize first minDelay 00077 if (currentItem.minDelay == 0) 00078 currentItem.minDelay = delay; 00079 // initialize first minHopCount 00080 if (currentItem.minHopCount == 0) 00081 currentItem.minHopCount = hopCount; 00082 00083 if (delay < currentItem.minDelay) 00084 currentItem.minDelay = delay; 00085 if (delay > currentItem.maxDelay) 00086 currentItem.maxDelay = delay; 00087 00088 if (hopCount < currentItem.minHopCount) 00089 currentItem.minHopCount = hopCount; 00090 if (hopCount > currentItem.maxHopCount) 00091 currentItem.maxHopCount = hopCount; 00092 00093 currentItem.responseCount++; 00094 00095 it->second = currentItem; 00096 } 00097 }
GiaSearchStats SearchMsgBookkeeping::getStatisticalData | ( | ) | const |
Returns statistical data.
00100 { 00101 SearchMessageItem currentItem; 00102 GiaSearchStats temp = {0, 0, 0, 0, 0}; 00103 00104 for(SearchBookkeepingListConstIterator it = messages.begin(); 00105 it != messages.end(); it++) { 00106 currentItem = it->second; 00107 temp.minDelay += currentItem.minDelay; 00108 temp.maxDelay += currentItem.maxDelay; 00109 temp.minHopCount += currentItem.minHopCount; 00110 temp.maxHopCount += currentItem.maxHopCount; 00111 temp.responseCount += currentItem.responseCount; 00112 } 00113 uint size = messages.size(); 00114 00115 temp.minDelay /= size; 00116 temp.maxDelay /= size; 00117 temp.minHopCount /= size; 00118 temp.maxHopCount /= size; 00119 temp.responseCount /= size; 00120 00121 return temp; 00122 }
SearchBookkeepingList SearchMsgBookkeeping::messages [protected] |
bookkeeping list of all sent search messages