source: trunk/src/testing/include/streamProtocol.h @ 4

Revision 4, 6.2 KB checked in by ajaworski, 13 years ago (diff)

Added modified SAGE sources

Line 
1/******************************************************************************
2 * SAGE - Scalable Adaptive Graphics Environment
3 *
4 * Module: streamProtocol.h
5 * Author : Byungil Jeong, Rajvikram Singh
6 * Description: This is the header file for the stream protocol modules of SAGE.
7 *       It gives the interface to be provided by all the protocols included.
8 * Notes : This is based on the TeraVision network protocol.
9 *
10 * Copyright (C) 2004 Electronic Visualization Laboratory,
11 * University of Illinois at Chicago
12 *
13 * All rights reserved.
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions are met:
17 *
18 *  * Redistributions of source code must retain the above copyright
19 *    notice, this list of conditions and the following disclaimer.
20 *  * Redistributions in binary form must reproduce the above
21 *    copyright notice, this list of conditions and the following disclaimer
22 *    in the documentation and/or other materials provided with the distribution.
23 *  * Neither the name of the University of Illinois at Chicago nor
24 *    the names of its contributors may be used to endorse or promote
25 *    products derived from this software without specific prior written permission.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
31 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
32 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
33 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
34 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
35 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
36 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
37 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 *
39 * Direct questions, comments etc about SAGE to sage_users@listserv.uic.edu or
40 * http://www.evl.uic.edu/cavern/forum/
41 *
42 *****************************************************************************/
43
44#ifndef _STREAM_PROTOCOL_H
45#define _STREAM_PROTOCOL_H
46
47#include "sageBase.h"
48
49#define REG_MSG_SIZE 1024
50
51class sageBlock;
52class sagePixelBlock;
53class sageBlockPool;
54class sageBlockGroup;
55class sageBlockFrame;
56
57/**
58 * sageNwConfig
59 */
60class sageNwConfig {
61public:
62   int rcvBufSize;
63   int sendBufSize;
64   int mtuSize;
65   int blockSize;
66   int groupSize;
67   double maxBandWidth; // maximum data amount that can be sent in a micro-second on the host
68   int maxCheckInterval;
69   int flowWindow;
70
71   sageNwConfig() : rcvBufSize(8388608), sendBufSize(65536), mtuSize(9000),
72         blockSize(0), groupSize(0), maxBandWidth(1000), maxCheckInterval(1000),
73         flowWindow(5) {}
74};
75
76/**
77 * streamProtocol
78 */
79class streamProtocol{
80
81protected:
82   sageStreamMode sMode;
83   nwProtocol   protocol;
84   int rcvPort;
85   sageNwConfig config;
86   std::vector<int> rcvList;
87   std::vector<int> sendList;
88
89public:
90   streamProtocol() {}
91
92   /**
93    * init
94        *
95        * @param m sageStreamMode, mode of operation
96        * @param p integer, receiver port
97        * @param c sageNwConfig &, configuration info
98        * @return a false if a receiver can't be started at this port p
99        */
100   int init(sageStreamMode m, int p, sageNwConfig &c);
101
102   /**
103    * returns nwProtocol object (member variable)
104        * @param void
105        * @return member variable protocol
106        */
107   inline nwProtocol getProtocol() { return protocol; }
108
109   /**
110    * set network configurations for new network connections
111    * sets the member variable config
112        *
113        * @param c sageNwConfig
114        * @return void
115        */
116   inline void setConfig(sageNwConfig c) { config = c; }
117   // set network configurations for new network connections
118   inline void setConfig(int port, int blockSize = 0, int groupSize = 0, int sendBufSize= 0)
119   {
120      rcvPort = port;
121      if (blockSize > 0)
122         config.blockSize = blockSize;
123      if (groupSize > 0)
124         config.groupSize = groupSize;
125      if (sendBufSize > 0)
126              config.sendBufSize = sendBufSize;
127   }
128
129   virtual void setupBlockPool(sageBlockPool *pool, int id = -1) = 0;
130   virtual void setFrameSize(int id, int size) = 0;
131   virtual void resetFrameSize(int id) = 0;
132   virtual void setFrameRate(double rate, int id = -1) = 0;
133
134   int duplicate(sageApiOption op);
135
136   virtual int close(int id, int mode = -1);
137
138   /**
139        * For SAGE_RCV or SAGE_BRIDGE mode
140    * checks if there's new sender trying to connect
141        * if yes, create new connection and return the sender ID
142        * if no, return -1
143        * memory bigger than REG_MSG_SIZE should be allocated to msg
144        * @param msg char *, default NULL
145        * @param op sageApiOption, default 0
146        * @return senderID or -1
147        */
148   virtual int checkConnections(char *msg = NULL, sageApiOption op = 0) = 0; // for SAGE_RCV or SAGE_BRIDGE mode
149
150
151   /**
152        * For SAGE_SEND or SAGE_BRIDGE mode
153    * This function blocks till it connects (or cannot connect)
154    * create a connection to a receiver
155    * and return the receiver ID
156    * the length of string msg should not exceed REG_MSG_SIZE
157        * @param ip char *
158        * @param msg char *, default NULL
159        * @return receiver ID
160        */
161   virtual int connect(char* ip, char *msg = NULL) = 0; // for SAGE_SEND or SAGE_BRDIGE mode
162
163   virtual int send(int id, sageBlock *sb, sageApiOption op) = 0;
164
165   /**
166       * sungwon experimental, swexp
167       */
168    virtual int sendpixelonly(int id, sageBlockFrame *sb) = 0;
169
170   virtual int recv(int id, sageBlock *sb, sageApiOption op) = 0;
171
172   virtual int sendControl(int id, int frameID, int configID) = 0;
173
174   virtual int sendGrp(int id, sagePixelBlock *sb, int configID) = 0;
175   // id : receiver ID, sb : pixel or control Block
176
177   virtual int recvGrp(int id, sageBlockGroup *sbg) = 0;
178   // id : sender ID, sbg : vacant block group
179
180   virtual int flush(int id, int configID) = 0;
181
182   virtual int getRcvSockFd(int id) = 0;
183
184   /**
185    *  When called, it is expected to close all internal sockets and force any operation
186    * (send/recv) to be interrupted. If this function is not called explicitly the destructor is supposed
187    * to call it before cleaning up
188    */
189   virtual int close() = 0;
190   virtual ~streamProtocol() {}
191};
192
193#endif
Note: See TracBrowser for help on using the repository browser.