diff options
author | Bart Polot <bart@net.in.tum.de> | 2012-07-27 11:35:36 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2012-07-27 11:35:36 +0000 |
commit | 1eecfe59914c7c549e666198080b0523a4609004 (patch) | |
tree | ad44d694fcae81fdc573ba8c1d30bf66f2eeea50 | |
parent | af76ae1dbfb86fe720ca9fe2be544f89ffbc476e (diff) | |
download | gnunet-1eecfe59914c7c549e666198080b0523a4609004.tar.gz gnunet-1eecfe59914c7c549e666198080b0523a4609004.zip |
- wip flow control service<-> client
-rw-r--r-- | src/mesh/gnunet-service-mesh.c | 88 |
1 files changed, 72 insertions, 16 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c index f163bbb09..114dc8d6a 100644 --- a/src/mesh/gnunet-service-mesh.c +++ b/src/mesh/gnunet-service-mesh.c | |||
@@ -976,6 +976,18 @@ tunnel_notify_connection_broken (struct MeshTunnel *t, GNUNET_PEER_Id p1, | |||
976 | 976 | ||
977 | 977 | ||
978 | /** | 978 | /** |
979 | * Get the current ack value for a tunnel, taking in account the tunnel | ||
980 | * mode and the status of all children nodes. | ||
981 | * | ||
982 | * @param t Tunnel. | ||
983 | * | ||
984 | * @return Maximum PID allowed. | ||
985 | */ | ||
986 | static uint32_t | ||
987 | tunnel_get_ack (struct MeshTunnel *t); | ||
988 | |||
989 | |||
990 | /** | ||
979 | * Iterator over edges in a regex block retrieved from the DHT. | 991 | * Iterator over edges in a regex block retrieved from the DHT. |
980 | * | 992 | * |
981 | * @param cls Closure. | 993 | * @param cls Closure. |
@@ -1919,6 +1931,31 @@ send_client_peer_connected (const struct MeshTunnel *t, const GNUNET_PEER_Id id) | |||
1919 | 1931 | ||
1920 | 1932 | ||
1921 | /** | 1933 | /** |
1934 | * Notify a client about how many more payload packages will we accept | ||
1935 | * on a given tunnel. | ||
1936 | * | ||
1937 | * @param c Client. | ||
1938 | * @param t Tunnel. | ||
1939 | */ | ||
1940 | static void | ||
1941 | send_client_tunnel_ack (struct MeshClient *c, struct MeshTunnel *t) | ||
1942 | { | ||
1943 | struct GNUNET_MESH_LocalAck msg; | ||
1944 | uint32_t ack; | ||
1945 | |||
1946 | ack = tunnel_get_ack (t); | ||
1947 | |||
1948 | msg.header.size = htons (sizeof (msg)); | ||
1949 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_ACK); | ||
1950 | msg.tunnel_id = htonl (t->local_tid); | ||
1951 | msg.max_pid = ack; | ||
1952 | |||
1953 | GNUNET_SERVER_notification_context_unicast (nc, c->handle, | ||
1954 | &msg.header, GNUNET_NO); | ||
1955 | } | ||
1956 | |||
1957 | |||
1958 | /** | ||
1922 | * Notify all clients (not depending on registration status) that the incoming | 1959 | * Notify all clients (not depending on registration status) that the incoming |
1923 | * tunnel is no longer valid. | 1960 | * tunnel is no longer valid. |
1924 | * | 1961 | * |
@@ -3228,6 +3265,39 @@ tunnel_get_children_ack (struct MeshTunnel *t) | |||
3228 | 3265 | ||
3229 | 3266 | ||
3230 | /** | 3267 | /** |
3268 | * Get the current ack value for a tunnel, taking in account the tunnel | ||
3269 | * mode and the status of all children nodes. | ||
3270 | * | ||
3271 | * @param t Tunnel. | ||
3272 | * | ||
3273 | * @return Maximum PID allowed. | ||
3274 | */ | ||
3275 | static uint32_t | ||
3276 | tunnel_get_ack (struct MeshTunnel *t) | ||
3277 | { | ||
3278 | uint32_t count; | ||
3279 | uint32_t buffer_free; | ||
3280 | uint32_t child_ack; | ||
3281 | uint32_t ack; | ||
3282 | |||
3283 | count = t->pid - t->skip; | ||
3284 | buffer_free = t->queue_max - t->queue_n; | ||
3285 | ack = count + buffer_free; | ||
3286 | child_ack = tunnel_get_children_ack (t); | ||
3287 | |||
3288 | if (GNUNET_YES == t->speed_min) | ||
3289 | { | ||
3290 | ack = child_ack > ack ? ack : child_ack; | ||
3291 | } | ||
3292 | else | ||
3293 | { | ||
3294 | ack = child_ack > ack ? child_ack : ack; | ||
3295 | } | ||
3296 | return ack; | ||
3297 | } | ||
3298 | |||
3299 | |||
3300 | /** | ||
3231 | * Send an ACK informing the predecessor about the available buffer space. | 3301 | * Send an ACK informing the predecessor about the available buffer space. |
3232 | * If buffering is off, send only on behalf of children or self if endpoint. | 3302 | * If buffering is off, send only on behalf of children or self if endpoint. |
3233 | * If buffering is on, send when sent to children and buffer space is free. | 3303 | * If buffering is on, send when sent to children and buffer space is free. |
@@ -3239,9 +3309,6 @@ tunnel_send_ack (struct MeshTunnel *t, uint16_t type) | |||
3239 | { | 3309 | { |
3240 | struct GNUNET_MESH_ACK msg; | 3310 | struct GNUNET_MESH_ACK msg; |
3241 | struct GNUNET_PeerIdentity id; | 3311 | struct GNUNET_PeerIdentity id; |
3242 | uint32_t count; | ||
3243 | uint32_t buffer_free; | ||
3244 | uint32_t child_ack; | ||
3245 | uint32_t ack; | 3312 | uint32_t ack; |
3246 | 3313 | ||
3247 | /* Is it after unicast / multicast retransmission? */ | 3314 | /* Is it after unicast / multicast retransmission? */ |
@@ -3261,19 +3328,7 @@ tunnel_send_ack (struct MeshTunnel *t, uint16_t type) | |||
3261 | } | 3328 | } |
3262 | 3329 | ||
3263 | /* Ok, ACK might be necessary, what PID to ACK? */ | 3330 | /* Ok, ACK might be necessary, what PID to ACK? */ |
3264 | count = t->pid - t->skip; | 3331 | ack = tunnel_get_ack (t); |
3265 | buffer_free = t->queue_max - t->queue_n; | ||
3266 | ack = count + buffer_free; | ||
3267 | child_ack = tunnel_get_children_ack (t); | ||
3268 | |||
3269 | if (GNUNET_YES == t->speed_min) | ||
3270 | { | ||
3271 | ack = child_ack > ack ? ack : child_ack; | ||
3272 | } | ||
3273 | else | ||
3274 | { | ||
3275 | ack = child_ack > ack ? child_ack : ack; | ||
3276 | } | ||
3277 | 3332 | ||
3278 | /* If speed_min and not all children have ack'd, dont send yet */ | 3333 | /* If speed_min and not all children have ack'd, dont send yet */ |
3279 | if (ack == t->last_ack) | 3334 | if (ack == t->last_ack) |
@@ -6187,6 +6242,7 @@ handle_local_unicast (void *cls, struct GNUNET_SERVER_Client *client, | |||
6187 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 6242 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
6188 | " calling generic handler...\n"); | 6243 | " calling generic handler...\n"); |
6189 | handle_mesh_data_unicast (NULL, &my_full_id, ©->header, NULL, 0); | 6244 | handle_mesh_data_unicast (NULL, &my_full_id, ©->header, NULL, 0); |
6245 | send_client_tunnel_ack (t->owner, t); | ||
6190 | } | 6246 | } |
6191 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 6247 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
6192 | return; | 6248 | return; |