Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

LiveBroadcastTable Class Reference

This class is for routing discovery packets: When you add an ID to the table, you also add the Node you first received the discovery from. More...

#include <LiveBroadcastTable.h>

Inheritance diagram for LiveBroadcastTable::

BasicObject List of all members.

Public Methods

 LiveBroadcastTable ()
 Creates a live broadcast table and starts the onTick thread. More...

virtual ~LiveBroadcastTable ()
void addId (unsigned int id, Node *from)
 Add the specified broadcast ID to the table. More...

bool hasId (unsigned int id, Node **from)
 Return true if the ID is in the table. More...

bool hasNode (Node *)
 Returns true if the Node exists in the table. More...

int nodeCount (Node *)
 Returns the number of times the Node appears in the table. More...

virtual void toStream (std::ostream &)
 Print the live broadcast table. More...


Static Public Methods

void * onTick (void *)
 A thread that ticks through the entries in the live broadcast table. More...


Protected Types

typedef vector< NodeIdTimeSlice

Protected Attributes

vector< TimeSlicem_broadcastId
int m_curPos
bool m_dead
pthread_t m_liveBroadcastThreadId
Mutex m_lock
Condition m_cond

Detailed Description

This class is for routing discovery packets: When you add an ID to the table, you also add the Node you first received the discovery from.

When you receive any IMHERE packets, you then know who to send them back to.

It also keeps track of the discovery ID so that packets do not endlessly propogate. It keeps a list of broadcast IDs, and slowly expires them.

The table is a vector of vectors. Each position in the table is a "Timeslice". Within that timeslice are all the broadcasts we have received within that time period (which equals BROADCAST_LIFE).

Definition at line 27 of file LiveBroadcastTable.h.


Member Typedef Documentation

typedef vector<NodeId> LiveBroadcastTable::TimeSlice [protected]
 

Definition at line 40 of file LiveBroadcastTable.h.


Constructor & Destructor Documentation

LiveBroadcastTable::LiveBroadcastTable
 

Creates a live broadcast table and starts the onTick thread.

Definition at line 21 of file LiveBroadcastTable.cpp.

LiveBroadcastTable::~LiveBroadcastTable [virtual]
 

Definition at line 47 of file LiveBroadcastTable.cpp.


Member Function Documentation

void LiveBroadcastTable::addId unsigned int id,
Node * from
 

Add the specified broadcast ID to the table.

Definition at line 60 of file LiveBroadcastTable.cpp.

Referenced by NetworkLayer::handleDiscoveryPacket().

bool LiveBroadcastTable::hasId unsigned int id,
Node ** from
 

Return true if the ID is in the table.

If the node is found in the table, a pointer to the node is returned in the second parameter. This is a linear search.

Definition at line 72 of file LiveBroadcastTable.cpp.

Referenced by NetworkLayer::handleDiscoveryPacket(), and NetworkLayer::handleImHerePacket().

bool LiveBroadcastTable::hasNode Node * node
 

Returns true if the Node exists in the table.

Definition at line 95 of file LiveBroadcastTable.cpp.

int LiveBroadcastTable::nodeCount Node * node
 

Returns the number of times the Node appears in the table.

Definition at line 114 of file LiveBroadcastTable.cpp.

Referenced by NetworkLayer::handleDiscoveryPacket().

void * LiveBroadcastTable::onTick void * me [static]
 

A thread that ticks through the entries in the live broadcast table.

Definition at line 132 of file LiveBroadcastTable.cpp.

void LiveBroadcastTable::toStream std::ostream & out [virtual]
 

Print the live broadcast table.

Reimplemented from BasicObject.

Definition at line 157 of file LiveBroadcastTable.cpp.


Member Data Documentation

vector< TimeSlice > LiveBroadcastTable::m_broadcastId [protected]
 

Definition at line 41 of file LiveBroadcastTable.h.

Condition LiveBroadcastTable::m_cond [protected]
 

Definition at line 46 of file LiveBroadcastTable.h.

int LiveBroadcastTable::m_curPos [protected]
 

Definition at line 42 of file LiveBroadcastTable.h.

bool LiveBroadcastTable::m_dead [protected]
 

Definition at line 43 of file LiveBroadcastTable.h.

pthread_t LiveBroadcastTable::m_liveBroadcastThreadId [protected]
 

Definition at line 44 of file LiveBroadcastTable.h.

Mutex LiveBroadcastTable::m_lock [protected]
 

Definition at line 45 of file LiveBroadcastTable.h.


The documentation for this class was generated from the following files:
Generated at Thu Jul 11 13:31:57 2002 for Peekabooty by doxygen1.2.9 written by Dimitri van Heesch, © 1997-2001