2 This file is part of GNUnet.
3 (C) 2012 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file stream/stream_protocol.h
23 * @brief P2P protocol for the stream connections
24 * @author Sree Harsha Totakura
27 #ifndef STREAM_PROTOCOL_H
28 #define STREAM_PROTOCOL_H
33 #if 0 /* keep Emacsens' auto-indent happy */
38 #include "gnunet_util_lib.h"
40 GNUNET_NETWORK_STRUCT_BEGIN
44 * The stream message header
45 * All messages of STREAM should commonly have this as header
47 struct GNUNET_STREAM_MessageHeader
50 * The GNUNET message header, types are from GNUNET_MESSAGE_TYPE_STREAM_*-range.
52 struct GNUNET_MessageHeader header;
57 * The Data message, should be prefixed with stream header with its type set to
60 struct GNUNET_STREAM_DataMessage
64 * Type is GNUNET_MESSAGE_TYPE_STREAM_DATA
66 struct GNUNET_STREAM_MessageHeader header;
69 * Sequence number; starts with a random value. (Just in case
70 * someone breaks mesh and is able to try to do a Sequence
71 * Prediction Attack on us.)
73 uint32_t sequence_number GNUNET_PACKED;
76 * number of milliseconds to the soft deadline for sending acknowledgement
77 * measured from the time this message is received. It is optimal for the
78 * communication to send the ack within the soft deadline
80 struct GNUNET_TIME_RelativeNBO ack_deadline;
83 * Offset of the packet in the overall stream, modulo 2^32; allows
84 * the receiver to calculate where in the destination buffer the
85 * message should be placed. In network byte order.
87 uint32_t offset GNUNET_PACKED;
90 * The data should be appended here
96 * Number of bits in GNUNET_STREAM_AckBitmap
98 #define GNUNET_STREAM_ACK_BITMAP_BIT_LENGTH 64
101 * The Selective Acknowledgement Bitmap
103 typedef uint64_t GNUNET_STREAM_AckBitmap;
107 * The Acknowledgment Message to confirm receipt of DATA.
109 struct GNUNET_STREAM_AckMessage
113 * Type is GNUNET_MESSAGE_TYPE_STREAM_ACK
115 struct GNUNET_STREAM_MessageHeader header;
118 * The sequence number of the next Data Message receiver is
119 * anticipating. Data messages less than this number are received by receiver
121 uint32_t base_sequence_number GNUNET_PACKED;
124 * The Selective Acknowledgement Bitmap. Computed relative to the base_seq
125 * (bit n corresponds to the Data message with sequence number base_seq+n)
127 GNUNET_STREAM_AckBitmap bitmap GNUNET_PACKED;
130 * Available buffer space past the last acknowledged buffer (for flow control),
133 uint32_t receive_window_remaining GNUNET_PACKED;
138 * Message for Acknowledging HELLO
140 struct GNUNET_STREAM_HelloAckMessage
143 * The stream message header
145 struct GNUNET_STREAM_MessageHeader header;
148 * The selected sequence number. Following data tranmissions from the sender
149 * start with this sequence
151 uint32_t sequence_number GNUNET_PACKED;
154 * The size(in bytes) of the receive window on the peer sending this message
156 * FIXME: Remove if not needed
158 uint32_t receiver_window_size GNUNET_PACKED;
163 * The Transmit close message(used to signal transmission is closed)
164 * FIXME: dead struct?
166 struct GNUNET_STREAM_TransmitCloseMessage
169 * The stream message header
171 struct GNUNET_STREAM_MessageHeader header;
174 * The last sequence number of the packet after which the transmission has
177 uint32_t final_sequence_number GNUNET_PACKED;
180 GNUNET_NETWORK_STRUCT_END
183 #if 0 /** keep Emacsens' auto-indent happy */
190 #endif /* STREAM_PROTOCOL_H */