Main Page   Class Hierarchy   Compound List   File List   Compound Members  

CAVERNnet_udpReflector_c Class Reference

#include <CAVERNnet_udpReflector_c.hxx>

Inheritance diagram for CAVERNnet_udpReflector_c::

CAVERNnet_socketbase_c List of all members.

Public Methods

 CAVERNnet_udpReflector_c ()
 ~CAVERNnet_udpReflector_c ()
int init ()
void setIncomingPort (unsigned short port=6000)
void setTimeOutTime (int secs)
void setForcedDestination (char *ipAddr, unsigned short port)
 Set a single ip address and port number to which all packets will be sent.

void setMulticastAddress (char *ipAddr, unsigned short port)
void setMulticastTTL (int ttl)
int process ()
void intercept (int(*callback)(CAVERNnet_udp_c *client, char **buffer, int *bufferSize, void *userData), void *userData)
void enableInstrumentation ()
void disableInstrumentation ()
void showStats (char *streamInfo, char *comment)
int logStats (char *streamInfo, char *comment, FILE *filePtr)
int sendStats (char *streamInfo, char *comment)
int initSendStats (char *monitorClientIP, int port=PERF_DAEMON_DEFAULT_PORT)
void exitSendStats ()

Static Public Attributes

const int FAILED
 Status Failed.

const int OK
 Status Ok.

const int SKIP_DISTRIBUTION
 Skip the data distribution process. Used in user callback. See intercept().


Private Methods

int initClientList ()
int addClient (CAVERNnet_udp_c *)
void replyToClients (char *mesg, int size, int exceptClientIndex)
void purgeOldClients ()
int checkClient (CAVERNnet_udp_c *mainUDPSocket)

Private Attributes

double* itsAliveClients
CAVERNnet_udp_citsForcedUDP
CAVERNnet_udp_citsMainUDPSocket
CAVERNnet_mcast_citsMcastSocket
unsigned short itsUDPPort
int itsTimeOutTime
int itsMcastTTL
double itsStartTime
char itsForcedUDPIP [CAVERNNET_UDP_REFLECTOR_IP_SIZE]
char itsMcastIP [CAVERNNET_UDP_REFLECTOR_IP_SIZE]
unsigned short itsMcastPort
unsigned short itsForcedUDPPort
CAVERNnet_udp_c** itsBunchOfClients
int itsNumberOfClients
int doMcast
int doForcedUDP
double itsLastTime
char* inBuffer
int itsInit
int (* interceptCallback )(CAVERNnet_udp_c *newClient, char **buffer, int *bufsize, void *userData)
void* interceptUserData
char* perfDaemonIP
int perfDaemonPort
int perfDaemonStatus

Detailed Description

UDP and Multicast Reflector class. Even though CAVERNsoft's key, link, and channel concept essentially acts as a data reflector there are instances where a generic packet reflector (to support legacy applications) are needed. This class fulfills that need.

This class will accept incoming UDP packets and broadcast them to all listeners. This class also accepts incoming multicast packets and broadcasts them to all listeners (whether they are on UDP or Multicast). In that case all incoming UDP packets will also be broadcasted to the Multicast group.

To add a listener to the reflector the remote client simply needs to send a packet to the reflector. The reflector will use the packet's address as the return address for future data. If a client does not send any data for a certain period of time that client is removed from the reflector's list of listeners.


Member Function Documentation

void CAVERNnet_udpReflector_c::disableInstrumentation ( )
 

Disable instrumentation - this is for turning off the performance monitoring for the UDPsocket used

void CAVERNnet_udpReflector_c::enableInstrumentation ( )
 

Enable instrumentation - this is for turning on the performance monitoring for the UDPsocket used -instrumentation for the udp sockets are turned off by default - and it should be explicitly enabled for latency, jitter and related statistics

void CAVERNnet_udpReflector_c::exitSendStats ( )
 

Properly delete the perfDaemonClient after sendStats is done

int CAVERNnet_udpReflector_c::init ( )
 

Initialize the reflector once all the parameters are set up. If you need to change the settings at a later time you need to delete this object and create a new one with the new settings.

Returns:
FAILED if failed; OK if success.

int CAVERNnet_udpReflector_c::initSendStats ( char * monitorClientIP,
int port = PERF_DAEMON_DEFAULT_PORT )
 

Initialize sendStats - provide the IP of the perfDaemon and an optional port number to connect to. This should be done initially before using the sendStats API.

Parameters:
monitorClientIP   IP address of the perfDameon to connect to
port   Port number at which the perfDaemon is running -this is optional. The default port number for perfDaemon is 9500 -so a different port number has to be specified if the perfDaemon is running ona different port.

Returns:
Either CAVERNnet_perfMonitor_c::OK or CAVERNnet_perfMonitor_c::FAILED

void CAVERNnet_udpReflector_c::intercept ( int(* callback)(CAVERNnet_udp_c *client, char **buffer, int *bufferSize,void *userData),
void * userData )
 

Intercept incoming messages and call a user-defined callback function. If you want you can also alter the buffer completely so that the reflector will reflect an entirely different message. You can do this by changing the contents of the buffer or by replacing the buffer entirely by allocating memory for a new buffer and stuffing it with your own data. If you choose to allocate a totally new buffer you must remember to deallocate memory for the original buffer before substituting it with yours. If after your callback function exits you do not wish the reflector to forward the contents of the buffer, return with CAVERNnet_udpReflector_c::SKIP_DISTRIBUTION. Otherwise just return CAVERNnet_udpReflector_c::OK.

Note also that the callback function will also be given a pointer to a CAVERNnet_udp_c object that can then be used to send data directly to the client that originally sent the message.

int CAVERNnet_udpReflector_c::logStats ( char * streamInfo,
char * comment,
FILE * filePtr )
 

This logs performance statistics in a file. The user opens a file and passes the file pointer with this function and results of monitoring are written into the logfile.

Parameters:
streamInfo   A label describing the stream that is being monitored.
comment   A comment on the event that marks the time at which the stream is being monitored
filePtr   File pointer to the file in which the results of monitoring are to be stored

Returns:
Either CAVERNnet_perfMonitor_c::OK or CAVERNnet_perfMonitor_c::FAILED

int CAVERNnet_udpReflector_c::process ( )
 

Call this within a while loop to let the reflector continuously do its processing.

Returns:
FAILED if error; OK if success.

int CAVERNnet_udpReflector_c::sendStats ( char * streamInfo,
char * comment )
 

Sends the performance statistics to a remote perfdaemon -for further analysis of the monitored data - the initSendStats API should be called first, before calling a sendStats (In order to connect to the perfdaemon initially)

Parameters:
streamInfo   A label describing the stream that is being monitored.
comment   A comment on the event that marks the time at which the stream is being monitored

Returns:
Either CAVERNnet_perfMonitor_c::OK or CAVERNnet_perfMonitor_c::FAILED

void CAVERNnet_udpReflector_c::setIncomingPort ( unsigned short port = 6000 )
 

Set the incoming port for the reflector to listen on. Default is set at 6000

void CAVERNnet_udpReflector_c::setMulticastAddress ( char * ipAddr,
unsigned short port )
 

Set up to also listen on a multicast address and port. This means that any incoming packets on the UDP connection will get broadcasted via this reflector to the multicast channel too.

void CAVERNnet_udpReflector_c::setMulticastTTL ( int ttl )
 

Set multicast TTL to something other than the default at 160

void CAVERNnet_udpReflector_c::setTimeOutTime ( int secs )
 

Set the time out time when connected clients who have not sent any data for a while will be removed. Default is set at 60 seconds.

void CAVERNnet_udpReflector_c::showStats ( char * streamInfo,
char * comment )
 

Displays the resultant statistics instantaneously in the netlogger format - this should be typically done after a read/write is done a network.

Also, it should be noted that a showStats call should be made at the end of atleast one send and receive for two-way information (the same applies for logStats and sendStats)

Parameters:
streamInfo   A label describing the stream that is being monitored.
comment   A comment on the event that marks the time at which the stream is being monitored


The documentation for this class was generated from the following file:
Generated at Mon Jul 2 14:24:45 2001 for CAVERNsoft by doxygen1.2.8-20010617 written by Dimitri van Heesch, © 1997-2001