00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
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;
00076
00078 static const int OK;
00079
00081 static const int SKIP_DISTRIBUTION;
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
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;
00232 int perfDaemonPort;
00233 int perfDaemonStatus;
00234
00235 };
00236 #endif