diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-01-18 14:01:02 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-01-18 14:01:02 +0000 |
commit | 6c88f7b55d10ed741cfcf1696dedda1322872a5d (patch) | |
tree | d6ba9830c6d15c81adcdf22417fbc7286948444a /src/stream/stream_protocol.h | |
parent | b435918c10c47f73401a8b93fdb739469b9c7056 (diff) | |
download | gnunet-6c88f7b55d10ed741cfcf1696dedda1322872a5d.tar.gz gnunet-6c88f7b55d10ed741cfcf1696dedda1322872a5d.zip |
-hints for stream lib development
Diffstat (limited to 'src/stream/stream_protocol.h')
-rw-r--r-- | src/stream/stream_protocol.h | 64 |
1 files changed, 38 insertions, 26 deletions
diff --git a/src/stream/stream_protocol.h b/src/stream/stream_protocol.h index 0624323d9..f4ad37fdd 100644 --- a/src/stream/stream_protocol.h +++ b/src/stream/stream_protocol.h | |||
@@ -35,10 +35,7 @@ extern "C" | |||
35 | #endif | 35 | #endif |
36 | #endif | 36 | #endif |
37 | 37 | ||
38 | #include <sys/types.h> | 38 | #include "gnunet_util_lib.h" |
39 | |||
40 | #include "gnunet_stream_lib.h" | ||
41 | #include "gnunet_mesh_service.h" | ||
42 | 39 | ||
43 | 40 | ||
44 | /** | 41 | /** |
@@ -113,20 +110,14 @@ enum GNUNET_STREAM_MessageType | |||
113 | struct GNUNET_STREAM_MessageHeader | 110 | struct GNUNET_STREAM_MessageHeader |
114 | { | 111 | { |
115 | /** | 112 | /** |
116 | * The GNUNET message header | 113 | * The GNUNET message header, types are from GNUNET_MESSAGE_TYPE_STREAM_*-range. |
117 | */ | 114 | */ |
118 | struct GNUNET_MessageHeader header; | 115 | struct GNUNET_MessageHeader header; |
119 | 116 | ||
120 | /** | 117 | /** |
121 | * A number which identifies a session | 118 | * A number which identifies a session between the two peers. |
122 | */ | ||
123 | uint16_t session_id; | ||
124 | |||
125 | /** | ||
126 | * The message type | ||
127 | * ? Should we rather use the type field in GNUNET_MessageHeader ? | ||
128 | */ | 119 | */ |
129 | enum GNUNET_STREAM_MessageType type; | 120 | uint32_t session_id; |
130 | 121 | ||
131 | }; | 122 | }; |
132 | 123 | ||
@@ -137,19 +128,32 @@ struct GNUNET_STREAM_MessageHeader | |||
137 | */ | 128 | */ |
138 | struct GNUNET_STREAM_DataMessage | 129 | struct GNUNET_STREAM_DataMessage |
139 | { | 130 | { |
131 | |||
140 | /** | 132 | /** |
141 | * Sequence number; Always starts with 0 and should wrap around. | 133 | * Type is GNUNET_MESSAGE_TYPE_STREAM_DATA |
142 | * Immune to Sequence Prediction Attack as we take cover under GNUNET's secure | ||
143 | * messaging | ||
144 | */ | 134 | */ |
145 | uint32_t seq; | 135 | struct GNUNET_STREAM_MessageHeader header; |
146 | 136 | ||
147 | /** | 137 | /** |
148 | * number of milliseconds to the soft deadline for sending acknowledgement | 138 | * number of milliseconds to the soft deadline for sending acknowledgement |
149 | * measured from the time this message is received. It is optimal for the | 139 | * measured from the time this message is received. It is optimal for the |
150 | * communication to send the ack within the soft deadline | 140 | * communication to send the ack within the soft deadline |
151 | */ | 141 | */ |
152 | uint16_t ack_deadline; | 142 | struct GNUNET_TIME_RelativeNBO ack_deadline; |
143 | |||
144 | /** | ||
145 | * Sequence number; starts with a random value. (Just in case | ||
146 | * someone breaks mesh and is able to try to do a Sequence | ||
147 | * Prediction Attack on us.) | ||
148 | */ | ||
149 | uint32_t sequence_number; | ||
150 | |||
151 | /** | ||
152 | * Offset of the packet in the overall stream, modulo 2^32; allows | ||
153 | * the receiver to calculate where in the destination buffer the | ||
154 | * message should be placed. | ||
155 | */ | ||
156 | uint32_t offset; | ||
153 | 157 | ||
154 | /** | 158 | /** |
155 | * The data should be appended here | 159 | * The data should be appended here |
@@ -158,30 +162,38 @@ struct GNUNET_STREAM_DataMessage | |||
158 | 162 | ||
159 | /** | 163 | /** |
160 | * The Selective Acknowledgement Bitmap | 164 | * The Selective Acknowledgement Bitmap |
161 | * | ||
162 | * ? WARNING ? Possibility for Denial of Service ?? | ||
163 | * ? Receiver may force the sender to mantain a buffer of ~ 64*64k !?? | ||
164 | */ | 165 | */ |
165 | typedef uint64_t GNUNET_STREAM_AckBitmap; | 166 | typedef uint64_t GNUNET_STREAM_AckBitmap; |
166 | 167 | ||
167 | 168 | ||
168 | /** | 169 | /** |
169 | * The Acknowledgment Message, should be prefixed with Stream Message header | 170 | * The Acknowledgment Message to confirm receipt of DATA. |
170 | * with its type set to GNUNET_STREAM_MESSAGE_ACK | ||
171 | */ | 171 | */ |
172 | struct GNUNET_STREAM_AckMessage | 172 | struct GNUNET_STREAM_AckMessage |
173 | { | 173 | { |
174 | |||
174 | /** | 175 | /** |
175 | * The sequence number of the Data Message upto which the receiver has filled | 176 | * Type is GNUNET_MESSAGE_TYPE_STREAM_ACK |
176 | * its buffer without any missing packets | ||
177 | */ | 177 | */ |
178 | uint32_t base_seq; | 178 | struct GNUNET_STREAM_MessageHeader header; |
179 | 179 | ||
180 | /** | 180 | /** |
181 | * The Selective Acknowledgement Bitmap. Computed relative to the base_seq | 181 | * The Selective Acknowledgement Bitmap. Computed relative to the base_seq |
182 | * (bit n corresponds to the Data message with sequence number base_seq+n) | 182 | * (bit n corresponds to the Data message with sequence number base_seq+n) |
183 | */ | 183 | */ |
184 | GNUNET_STREAM_AckBitmap bitmap; | 184 | GNUNET_STREAM_AckBitmap bitmap; |
185 | |||
186 | /** | ||
187 | * The sequence number of the Data Message upto which the receiver has filled | ||
188 | * its buffer without any missing packets | ||
189 | */ | ||
190 | uint32_t base_sequence_number; | ||
191 | |||
192 | /** | ||
193 | * Available buffer space past the last acknowledged buffer (for flow control), | ||
194 | * in bytes. | ||
195 | */ | ||
196 | uint32_t receive_window_remaining; | ||
185 | }; | 197 | }; |
186 | 198 | ||
187 | 199 | ||