framexmit/framerecv.hh

00001 #ifndef _GDS_FRAMERECV_H
00002 #define _GDS_FRAMERECV_H
00003 /*----------------------------------------------------------------------*/
00004 /*                                                                      */
00005 /* Module Name: framexmit                                               */
00006 /*                                                                      */
00007 /* Module Description: API for broadcasting frames                      */
00008 /*                     implements a reliable UDP/IP broadcast for       */
00009 /*                     large data sets over high speed links            */
00010 /*                                                                      */
00011 /* Module Arguments: none                                               */
00012 /*                                                                      */
00013 /* Revision History:                                                    */
00014 /* Rel   Date     Programmer    Comments                                */
00015 /* 1.0   10Aug99  D. Sigg       First release                           */
00016 /*                                                                      */
00017 /* Documentation References:                                            */
00018 /*      Man Pages: doc/index.html (use doc++)                           */
00019 /*      References: none                                                */
00020 /*                                                                      */
00021 /* Author Information:                                                  */
00022 /* Name          Telephone       Fax             e-mail                 */
00023 /* Daniel Sigg   (509) 372-8132  (509) 372-8137  sigg_d@ligo.mit.edu    */
00024 /*                                                                      */
00025 /* Code Compilation and Runtime Specifications:                         */
00026 /*      Code Compiled on: Ultra-Enterprise, Solaris 5.7                 */
00027 /*      Compiler Used: egcs-1.1.2                                       */
00028 /*      Runtime environment: sparc/solaris                              */
00029 /*                                                                      */
00030 /* Code Standards Conformance:                                          */
00031 /*      Code Conforms to: LIGO standards.       OK                      */
00032 /*                        Lint.                 TBD                     */
00033 /*                        ANSI                  OK                      */
00034 /*                        POSIX                 OK                      */
00035 /*                                                                      */
00036 /* Known Bugs, Limitations, Caveats:                                    */
00037 /*                                                                      */
00038 /*                                                                      */
00039 /*                                                                      */
00040 /*                      -------------------                             */
00041 /*                                                                      */
00042 /*                             LIGO                                     */
00043 /*                                                                      */
00044 /*        THE LASER INTERFEROMETER GRAVITATIONAL WAVE OBSERVATORY.      */
00045 /*                                                                      */
00046 /*                     (C) The LIGO Project, 1996.                      */
00047 /*                                                                      */
00048 /*                                                                      */
00049 /* California Institute of Technology                                   */
00050 /* LIGO Project MS 51-33                                                */
00051 /* Pasadena CA 91125                                                    */
00052 /*                                                                      */
00053 /* Massachusetts Institute of Technology                                */
00054 /* LIGO Project MS NW17-161                                             */
00055 /* Cambridge MA 01239                                                   */
00056 /*                                                                      */
00057 /* LIGO Hanford Observatory                                             */
00058 /* P.O. Box 1970 S9-02                                                  */
00059 /* Richland WA 99352                                                    */
00060 /*                                                                      */
00061 /* LIGO Livingston Observatory                                          */
00062 /* 19100 LIGO Lane Rd.                                                  */
00063 /* Livingston, LA 70754                                                 */
00064 /*                                                                      */
00065 /*----------------------------------------------------------------------*/
00066 
00067 // include files
00068 #include <netinet/in.h>
00069 #include <deque>
00070 #include <string>
00071 #include "framexmit/framexmittypes.hh"
00072 
00073 namespace framexmit {
00074 
00084    class frameRecv {
00085    public:
00086    
00099       explicit frameRecv (int QoS = 1) 
00100       : sock (-1), qos (QoS), logison (false), maxlog (25) {
00101       }
00102    
00107       ~frameRecv () {
00108          close();
00109       }
00110    
00127       bool open (const char* mcast_addr, const char* interface = 0, 
00128                 int port = frameXmitPort);
00129    
00135       bool open (int port = frameXmitPort) {
00136          return open (0, 0, port);
00137       }
00138    
00143       void close ();
00144    
00154       bool purge ();
00155    
00172       int receive (char*& data, int maxlen, 
00173                   unsigned int* sequence = 0,
00174                   unsigned int* timestamp = 0, 
00175                   unsigned int* duration = 0);
00176    
00181       const char* logmsg ();
00182    
00188       void clearlog ();
00189    
00194       void logging (bool set = true) {
00195          logison = set; }
00196    
00201       void setmaxlog (int max = 25) {
00202          maxlog = max; }
00203    
00204    private:
00206       int                       sock;
00208       bool                      multicast;
00210       ip_mreq                   group;
00212       unsigned int              seq;
00214       int                       qos;
00216       double                    retransmissionRate;
00218       bool                      first;
00220       unsigned int              oldseq;
00222       struct sockaddr_in        name;
00224       typedef std::deque<auto_pkt_ptr> packetlist;
00226       packetlist                pkts;
00228       bool                      logison;
00230       int                       maxlog;
00232       std::deque<std::string>   logs;
00234       std::string               logbuf;
00235    
00237       bool getPacket (bool block = true);
00239       bool putPacket (retransmitpacket& pkt);
00241       static long long calcDiff (const packetlist& pkts, 
00242                         unsigned int newseq);
00243    
00245       frameRecv (const frameRecv&);
00247       frameRecv& operator= (const frameRecv&);
00248    
00250       void addLog (const std::string& s);
00252       void addLog (const char* s);
00254       const char* copyLog ();
00255    
00256    };
00257 
00258 }
00259 
00260 #endif // _GDS_FRAMERECV_H

Generated on Sun Mar 8 19:20:47 2009 for dmt by  doxygen 1.5.4