summaryrefslogtreecommitdiff
path: root/protocols/ace/RMCast/RMCast.h
blob: 025f82a1bfb2b4a61203fefdd9c7eaf1f82a8ff0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
/* -*- C++ -*- */
// $Id$

// ============================================================================
//
// = LIBRARY
//    ace
//
// = FILENAME
//    RMCast.h
//
// = AUTHOR
//    Carlos O'Ryan <coryan@uci.edu>
//
// ============================================================================

#ifndef ACE_RMCAST_H
#define ACE_RMCAST_H
#include "ace/pre.h"

#include "ace/OS.h"
#include "RMCast_Export.h"

#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

class ACE_Message_Block;

class ACE_RMCast_Export ACE_RMCast
{
public:

  // Message formats

  // From SENDER to RECEIVER
  //
  // POLL
  // +---------+----------------------+
  // | 8 bits  | MT_POLL              |
  // +---------+----------------------+
  //
  // ACK_JOIN
  // +---------+----------------------+
  // | 8 bits  | MT_ACK_JOIN          |
  // +---------+----------------------+
  // | 32 bits | next_sequence_number |
  // +---------+----------------------+
  //
  // ACK_LEAVE
  // +---------+----------------------+
  // | 8 bits  | ACK_LEAVE            |
  // +---------+----------------------+
  //
  // DATA
  // +---------+----------------------+
  // | 8 bits  | DATA                 |
  // +---------+----------------------+
  // | 32 bits | sequence_number      |
  // +---------+----------------------+
  // | 32 bits | message_size         |
  // +---------+----------------------+
  // | 32 bits | fragment_offset      |
  // +---------+----------------------+
  // | 32 bits | payload_size         |
  // +---------+----------------------+
  // |         | payload              |
  // +---------+----------------------+
  //

  // From RECEIVER to SENDER
  //
  // MT_JOIN
  // +---------+----------------------+
  // | 8 bits  | MT_JOIN              |
  // +---------+----------------------+
  //
  // MT_LEAVE
  // +---------+----------------------+
  // | 8 bits  | MT_LEAVE             |
  // +---------+----------------------+
  //
  // MT_ACK
  // +---------+----------------------+
  // | 8 bits  | MT_ACK               |
  // +---------+----------------------+
  // | 32 bits | last_successful      |
  // +---------+----------------------+
  // | 32 bits | last_received        |
  // +---------+----------------------+
  //

  enum Message_Type
  {
    // Sender initiated
    MT_POLL,
    MT_ACK_JOIN,
    MT_ACK_LEAVE,
    MT_DATA,
    // Receiver initiated
    MT_JOIN,
    MT_LEAVE,
    MT_ACK,
    MT_LAST
  };

  enum Receiver_State
  {
    RS_NON_EXISTENT,
    RS_JOINING,
    RS_JOINED,
    RS_LEAVING
  };

  // State transition (and actions) for the receivers.
  // This configuration is pesimistic, any invalid message is cause
  // enough to reclaim all the resources.  This partially addresses
  // situations where either accidentally or intentionally a sender is
  // multicasting packets to the wrong group.
  //
  //            NON_EXISTENT JOINING      JOINED       LEAVING
  // ----------------------------------------------------------------
  // POLL       JOINING      JOINING      JOINED       LEAVING
  //            Send/Join    Send/Join    Send/Ack     Send/Leave
  //
  // ACK        NON_EXISTENT NON_EXISTENT NON_EXISTENT NON_EXISTENT
  //            Noop         Destroy      Destroy      Destroy
  //
  // JOIN       NON_EXISTENT NON_EXISTENT NON_EXISTENT NON_EXISTENT
  //            Noop         Destroy      Destroy      Destroy
  //
  // LEAVE      NON_EXISTENT NON_EXISTENT NON_EXISTENT NON_EXISTENT
  //            Noop         Destroy      Destroy      Destroy
  //
  // ACK_JOIN   JOINING      JOINED       JOINED       LEAVING
  //            Send/Join    Update ACT   Update ACT   Send/Leave
  //
  // ACK_LEAVE  NON_EXISTENT NON_EXISTENT NON_EXISTENT NON_EXISTENT
  //            Noop         Destroy      Destroy      Destroy
  //
  // SEND_DATA  JOINING      JOINING      JOINED       LEAVING
  //            Send/Join    Send/Join    Recv/Data    Send/Leave
  //

  enum Sender_State
  {
    SS_NON_EXISTENT,
    SS_JOINED
  };

  // State transition (and actions) for the senders.
  // This configuration is pesimistic, any invalid message is cause
  // enough to reclaim all the resources.  This partially addresses
  // situations where either accidentally or intentionally a sender is
  // multicasting packets to the wrong group.
  //
  //            NON_EXISTENT   JOINED
  // ------------------------------------------
  // POLL       NON_EXISTENT   NON_EXISTENT
  //            Destroy        Destroy
  //
  // ACK        NON_EXISTENT   JOINED
  //            Noop           Process/Ack
  //
  // JOIN       JOINED         NON_EXISTENT
  //            Send/Join_Ack  Send/Join_Ack
  //
  // LEAVE      NON_EXISTENT   NON_EXISTENT
  //            Send/Leave_Ack Send/Leave_Ack
  //                           Destroy
  //
  // ACK_JOIN   NON_EXISTENT   NON_EXISTENT
  //            Noop           Destroy
  //
  // ACK_LEAVE  NON_EXISTENT   NON_EXISTENT
  //            Noop           Destroy
  //
  // SEND_DATA  NON_EXISTENT   NON_EXISTENT
  //            Noop           Destroy
  //


  // These structures define the basic layout of the messages.
  struct Data
  {
    // Source ID is implicit in recvfrom()...
    ACE_UINT32 sequence_number;
    ACE_UINT32 total_size;
    ACE_UINT32 fragment_offset;
    // @@ TODO: we may want to add optional fields, such as:
    //    - Polling clients for their status
    //    - Sending the range of messages in the queue
    //    - If we are using authentic group communication we may
    //    piggyback the ACK / NAK messages

    ACE_Message_Block *payload;
  };

  struct Ack
  {
    ACE_UINT32 expected;
    ACE_UINT32 last_received;
  };

  struct Join
  {
  };

  struct Leave
  {
  };

  struct Ack_Join
  {
    ACE_INT32 next_sequence_number;
  };

  struct Ack_Leave
  {
  };
};

#if defined (__ACE_INLINE__)
#include "RMCast.i"
#endif /* __ACE_INLINE__ */

#include "ace/post.h"
#endif /* ACE_RMCAST_H */