Main Page   Class Hierarchy   Compound List   File List   Compound Members  

CAVERNnet_udpReflector_c.hxx

00001 /******************************************************************
00002  * CAVERNsoft
00003  * Copyright (C) 1994-2000 Electronic Visualization Laboratory,
00004  * all rights reserved
00005  * By Jason Leigh, Yong-joo Cho, Naveen Krishnaprasad, Chris Scharver,
00006  * Stuart Bailey, Atul Nayak, Shalini Venkataraman
00007  * University of Illinois at Chicago
00008  * 
00009  * This publication and its text and code may not be copied for commercial 
00010  * use without the express written permission of the University of Illinois
00011  * at Chicago.
00012  * The contributors disclaim any representation of warranty: use this
00013  * code at your own risk.
00014  * Direct questions, comments etc to cavern@evl.uic.edu
00015  ******************************************************************/
00016 
00017 /*
00018 CAVERNnet_udpReflector_c
00019 - setIncomingPort(int)
00020 - setTimeOutTime(int)
00021 - setForcedDestination(ip,port);
00022 - newDataCB()
00023 - deliver(data)
00024 - setMulticast(ON or OFF);
00025 - setMulticastPort(int)
00026 - setMulticastAddress()
00027 
00028 CAVERNnet_tcpReflector_c
00029 - setIncomingPort(int)
00030 - setTimeOutTime(int)
00031 - setForcedDestination(ip,port);
00032 - newDataCB()
00033 - deliver(data)
00034 */
00035 
00036 #include "CAVERNnet_udp_c.hxx"
00037 #include "CAVERNnet_mcast_c.hxx"
00038 
00039 #ifndef CAVERNNET_UDP_REFLECTOR
00040 #define CAVERNNET_UDP_REFLECTOR
00041 
00042 #define CAVERNNET_UDP_REFLECTOR_MAX_MSG_SIZE 8192
00043 #define CAVERNNET_UDP_REFLECTOR_SEND_TO_ALL_UDP_CLIENTS -1
00044 #define CAVERNNET_UDP_REFLECTOR_MAX_NUM_CLIENTS 1024
00045 #define CAVERNNET_UDP_REFLECTOR_DEFAULT_TIMEOUT 60
00046 #define CAVERNNET_UDP_REFLECTOR_IP_SIZE 256
00047 #define CAVERNNET_UDP_REFLECTOR_MCAST_TTL 160
00048 #define PERFDAEMON_ALIVE 1
00049 #define PERFDAEMON_NOT_ALIVE 0
00050 
00067 class CAVERNnet_udpReflector_c : public CAVERNnet_socketbase_c
00068 {
00069 public:
00070         CAVERNnet_udpReflector_c();
00071         ~CAVERNnet_udpReflector_c();
00072 
00074 
00075         static const int FAILED/* = 0*/;
00076 
00078         static const int OK/* = 1*/;
00079 
00081         static const int SKIP_DISTRIBUTION/* = 2*/;
00082         
00084 
00090         int init();
00091 
00093         void setIncomingPort(unsigned short port = 6000);
00094 
00098         void setTimeOutTime(int secs);
00099 
00101         void setForcedDestination(char *ipAddr, unsigned short port);
00102 
00107         void setMulticastAddress(char *ipAddr,unsigned short port);
00108 
00110         void setMulticastTTL(int ttl);
00111 
00116         int process();
00117 
00123      void intercept(int (*callback) (CAVERNnet_udp_c *client, char** buffer, int *bufferSize,  void *userData), void* userData);
00124   
00127     void enableInstrumentation();
00128     
00131     void disableInstrumentation();
00132 
00133     //Functions added for performance monitoring interface
00134 
00146     void showStats(char* streamInfo, char* comment);
00147     
00164     int logStats(char* streamInfo, char* comment, FILE* filePtr);
00165 
00181     int sendStats(char* streamInfo, char* comment);
00182 
00196     int initSendStats(char* monitorClientIP, int port = PERF_DAEMON_DEFAULT_PORT);
00197     
00202     void exitSendStats();
00203 
00204 private:
00205         double *itsAliveClients;
00206         CAVERNnet_udp_c *itsForcedUDP, *itsMainUDPSocket;
00207         CAVERNnet_mcast_c *itsMcastSocket;
00208         unsigned short itsUDPPort;
00209         int itsTimeOutTime;
00210         int itsMcastTTL;
00211         double itsStartTime;
00212         char itsForcedUDPIP[CAVERNNET_UDP_REFLECTOR_IP_SIZE];
00213         char itsMcastIP[CAVERNNET_UDP_REFLECTOR_IP_SIZE];
00214         unsigned short itsMcastPort;
00215         unsigned short itsForcedUDPPort;
00216         CAVERNnet_udp_c **itsBunchOfClients;
00217         int itsNumberOfClients;
00218         int doMcast, doForcedUDP;
00219         double itsLastTime;
00220         char* inBuffer; 
00221         int itsInit;
00222         int initClientList();
00223         int addClient(CAVERNnet_udp_c*);
00224         void replyToClients(char *mesg, int size, int exceptClientIndex);
00225         void purgeOldClients();
00226         int  checkClient(CAVERNnet_udp_c *mainUDPSocket);
00227     
00228     int (*interceptCallback) (CAVERNnet_udp_c *newClient, char** buffer, int* bufsize, void *userData);
00229     void *interceptUserData;
00230    
00231     char* perfDaemonIP;     //IP of the perf-daemon - used for initSendStats
00232     int perfDaemonPort;     //PerfDaemon port
00233     int perfDaemonStatus;   //Status that indicates if the perfdaemon is running
00234 
00235 };
00236 #endif

Generated at Mon Jul 2 14:24:42 2001 for CAVERNsoft by doxygen1.2.8-20010617 written by Dimitri van Heesch, © 1997-2001