aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/gnunet-service-core.c127
-rw-r--r--src/include/gnunet_transport_service.h12
-rwxr-xr-xsrc/peerinfo/perf_peerinfo_api.c6
-rw-r--r--src/transport/transport_api.c15
4 files changed, 123 insertions, 37 deletions
diff --git a/src/core/gnunet-service-core.c b/src/core/gnunet-service-core.c
index 1576eac01..e6f0a1eed 100644
--- a/src/core/gnunet-service-core.c
+++ b/src/core/gnunet-service-core.c
@@ -474,6 +474,11 @@ struct Neighbour
474 struct SetKeyMessage *skm; 474 struct SetKeyMessage *skm;
475 475
476 /** 476 /**
477 * Performance data for the peer.
478 */
479 struct GNUNET_TRANSPORT_ATS_Information *ats;
480
481 /**
477 * Identity of the neighbour. 482 * Identity of the neighbour.
478 */ 483 */
479 struct GNUNET_PeerIdentity peer; 484 struct GNUNET_PeerIdentity peer;
@@ -558,6 +563,11 @@ struct Neighbour
558 unsigned long long current_preference; 563 unsigned long long current_preference;
559 564
560 /** 565 /**
566 * Number of entries in 'ats'.
567 */
568 unsigned int ats_count;
569
570 /**
561 * Bit map indicating which of the 32 sequence numbers before the last 571 * Bit map indicating which of the 32 sequence numbers before the last
562 * were received (good for accepting out-of-order packets and 572 * were received (good for accepting out-of-order packets and
563 * estimating reliability of the connection) 573 * estimating reliability of the connection)
@@ -1344,8 +1354,8 @@ handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client)
1344 */ 1354 */
1345static void 1355static void
1346handle_client_iterate_peers (void *cls, 1356handle_client_iterate_peers (void *cls,
1347 struct GNUNET_SERVER_Client *client, 1357 struct GNUNET_SERVER_Client *client,
1348 const struct GNUNET_MessageHeader *message) 1358 const struct GNUNET_MessageHeader *message)
1349 1359
1350{ 1360{
1351 struct Neighbour *n; 1361 struct Neighbour *n;
@@ -1555,6 +1565,7 @@ free_neighbour (struct Neighbour *n)
1555 GNUNET_SCHEDULER_cancel (n->keep_alive_task); 1565 GNUNET_SCHEDULER_cancel (n->keep_alive_task);
1556 if (n->status == PEER_STATE_KEY_CONFIRMED) 1566 if (n->status == PEER_STATE_KEY_CONFIRMED)
1557 GNUNET_STATISTICS_update (stats, gettext_noop ("# established sessions"), -1, GNUNET_NO); 1567 GNUNET_STATISTICS_update (stats, gettext_noop ("# established sessions"), -1, GNUNET_NO);
1568 GNUNET_array_grow (n->ats, n->ats_count, 0);
1558 GNUNET_free_non_null (n->public_key); 1569 GNUNET_free_non_null (n->public_key);
1559 GNUNET_free_non_null (n->pending_ping); 1570 GNUNET_free_non_null (n->pending_ping);
1560 GNUNET_free_non_null (n->pending_pong); 1571 GNUNET_free_non_null (n->pending_pong);
@@ -3134,10 +3145,15 @@ send_key (struct Neighbour *n)
3134 * 3145 *
3135 * @param n the neighbour from which we received message m 3146 * @param n the neighbour from which we received message m
3136 * @param m the set key message we received 3147 * @param m the set key message we received
3148 * @param ats performance data
3149 * @param ats_count number of entries in ats (excluding 0-termination)
3137 */ 3150 */
3138static void 3151static void
3139handle_set_key (struct Neighbour *n, 3152handle_set_key (struct Neighbour *n,
3140 const struct SetKeyMessage *m); 3153 const struct SetKeyMessage *m,
3154 const struct GNUNET_TRANSPORT_ATS_Information *ats,
3155 uint32_t ats_count);
3156
3141 3157
3142 3158
3143/** 3159/**
@@ -3170,7 +3186,7 @@ process_hello_retry_handle_set_key (void *cls,
3170 GNUNET_i2s (&n->peer), 3186 GNUNET_i2s (&n->peer),
3171 "SET_KEY"); 3187 "SET_KEY");
3172#endif 3188#endif
3173 handle_set_key (n, sm); 3189 handle_set_key (n, sm, NULL, 0);
3174 } 3190 }
3175 else 3191 else
3176 { 3192 {
@@ -3196,14 +3212,55 @@ process_hello_retry_handle_set_key (void *cls,
3196 3212
3197 3213
3198/** 3214/**
3215 * Merge the given performance data with the data we currently
3216 * track for the given neighbour.
3217 *
3218 * @param n neighbour
3219 * @param ats new performance data
3220 * @param ats_count number of records in ats
3221 */
3222static void
3223update_neighbour_performance (struct Neighbour *n,
3224 const struct GNUNET_TRANSPORT_ATS_Information *ats,
3225 uint32_t ats_count)
3226{
3227 uint32_t i;
3228 unsigned int j;
3229
3230 if (ats_count == 0)
3231 return;
3232 for (i=0;i<ats_count;i++)
3233 {
3234 for (j=0;j<n->ats_count;j++)
3235 {
3236 if (n->ats[j].type == ats[i].type)
3237 {
3238 n->ats[j].value = ats[i].value;
3239 break;
3240 }
3241 }
3242 if (j == n->ats_count)
3243 GNUNET_array_append (n->ats,
3244 n->ats_count,
3245 *ats);
3246 }
3247}
3248
3249
3250/**
3199 * We received a PING message. Validate and transmit 3251 * We received a PING message. Validate and transmit
3200 * PONG. 3252 * PONG.
3201 * 3253 *
3202 * @param n sender of the PING 3254 * @param n sender of the PING
3203 * @param m the encrypted PING message itself 3255 * @param m the encrypted PING message itself
3256 * @param ats performance data
3257 * @param ats_count number of entries in ats (excluding 0-termination)
3204 */ 3258 */
3205static void 3259static void
3206handle_ping (struct Neighbour *n, const struct PingMessage *m) 3260handle_ping (struct Neighbour *n,
3261 const struct PingMessage *m,
3262 const struct GNUNET_TRANSPORT_ATS_Information *ats,
3263 uint32_t ats_count)
3207{ 3264{
3208 struct PingMessage t; 3265 struct PingMessage t;
3209 struct PongMessage tx; 3266 struct PongMessage tx;
@@ -3245,6 +3302,7 @@ handle_ping (struct Neighbour *n, const struct PingMessage *m)
3245 GNUNET_break_op (0); 3302 GNUNET_break_op (0);
3246 return; 3303 return;
3247 } 3304 }
3305 update_neighbour_performance (n, ats, ats_count);
3248 me = GNUNET_malloc (sizeof (struct MessageEntry) + 3306 me = GNUNET_malloc (sizeof (struct MessageEntry) +
3249 sizeof (struct PongMessage)); 3307 sizeof (struct PongMessage));
3250 GNUNET_CONTAINER_DLL_insert_after (n->encrypted_head, 3308 GNUNET_CONTAINER_DLL_insert_after (n->encrypted_head,
@@ -3291,10 +3349,14 @@ handle_ping (struct Neighbour *n, const struct PingMessage *m)
3291 * 3349 *
3292 * @param n sender of the PONG 3350 * @param n sender of the PONG
3293 * @param m the encrypted PONG message itself 3351 * @param m the encrypted PONG message itself
3352 * @param ats performance data
3353 * @param ats_count number of entries in ats (excluding 0-termination)
3294 */ 3354 */
3295static void 3355static void
3296handle_pong (struct Neighbour *n, 3356handle_pong (struct Neighbour *n,
3297 const struct PongMessage *m) 3357 const struct PongMessage *m,
3358 const struct GNUNET_TRANSPORT_ATS_Information *ats,
3359 uint32_t ats_count)
3298{ 3360{
3299 struct PongMessage t; 3361 struct PongMessage t;
3300 struct ConnectNotifyMessage cnm; 3362 struct ConnectNotifyMessage cnm;
@@ -3409,6 +3471,7 @@ handle_pong (struct Neighbour *n,
3409 = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_divide (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 2), 3471 = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_divide (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 2),
3410 &send_keep_alive, 3472 &send_keep_alive,
3411 n); 3473 n);
3474 update_neighbour_performance (n, ats, ats_count);
3412 handle_peer_status_change (n); 3475 handle_peer_status_change (n);
3413 break; 3476 break;
3414 default: 3477 default:
@@ -3424,9 +3487,14 @@ handle_pong (struct Neighbour *n,
3424 * 3487 *
3425 * @param n the neighbour from which we received message m 3488 * @param n the neighbour from which we received message m
3426 * @param m the set key message we received 3489 * @param m the set key message we received
3490 * @param ats performance data
3491 * @param ats_count number of entries in ats (excluding 0-termination)
3427 */ 3492 */
3428static void 3493static void
3429handle_set_key (struct Neighbour *n, const struct SetKeyMessage *m) 3494handle_set_key (struct Neighbour *n,
3495 const struct SetKeyMessage *m,
3496 const struct GNUNET_TRANSPORT_ATS_Information *ats,
3497 uint32_t ats_count)
3430{ 3498{
3431 struct SetKeyMessage *m_cpy; 3499 struct SetKeyMessage *m_cpy;
3432 struct GNUNET_TIME_Absolute t; 3500 struct GNUNET_TIME_Absolute t;
@@ -3531,6 +3599,7 @@ handle_set_key (struct Neighbour *n, const struct SetKeyMessage *m)
3531 n->last_packets_bitmap = 0; 3599 n->last_packets_bitmap = 0;
3532 n->decrypt_key_created = t; 3600 n->decrypt_key_created = t;
3533 } 3601 }
3602 update_neighbour_performance (n, ats, ats_count);
3534 sender_status = (enum PeerStateMachine) ntohl (m->sender_status); 3603 sender_status = (enum PeerStateMachine) ntohl (m->sender_status);
3535 switch (n->status) 3604 switch (n->status)
3536 { 3605 {
@@ -3578,14 +3647,14 @@ handle_set_key (struct Neighbour *n, const struct SetKeyMessage *m)
3578 { 3647 {
3579 ping = n->pending_ping; 3648 ping = n->pending_ping;
3580 n->pending_ping = NULL; 3649 n->pending_ping = NULL;
3581 handle_ping (n, ping); 3650 handle_ping (n, ping, NULL, 0);
3582 GNUNET_free (ping); 3651 GNUNET_free (ping);
3583 } 3652 }
3584 if (n->pending_pong != NULL) 3653 if (n->pending_pong != NULL)
3585 { 3654 {
3586 pong = n->pending_pong; 3655 pong = n->pending_pong;
3587 n->pending_pong = NULL; 3656 n->pending_pong = NULL;
3588 handle_pong (n, pong); 3657 handle_pong (n, pong, NULL, 0);
3589 GNUNET_free (pong); 3658 GNUNET_free (pong);
3590 } 3659 }
3591} 3660}
@@ -3709,10 +3778,17 @@ deliver_message (void *cls,
3709/** 3778/**
3710 * We received an encrypted message. Decrypt, validate and 3779 * We received an encrypted message. Decrypt, validate and
3711 * pass on to the appropriate clients. 3780 * pass on to the appropriate clients.
3781 *
3782 * @param n target of the message
3783 * @param m encrypted message
3784 * @param ats performance data
3785 * @param ats_count number of entries in ats (excluding 0-termination)
3712 */ 3786 */
3713static void 3787static void
3714handle_encrypted_message (struct Neighbour *n, 3788handle_encrypted_message (struct Neighbour *n,
3715 const struct EncryptedMessage *m) 3789 const struct EncryptedMessage *m,
3790 const struct GNUNET_TRANSPORT_ATS_Information *ats,
3791 uint32_t ats_count)
3716{ 3792{
3717 size_t size = ntohs (m->header.size); 3793 size_t size = ntohs (m->header.size);
3718 char buf[size]; 3794 char buf[size];
@@ -3864,6 +3940,7 @@ handle_encrypted_message (struct Neighbour *n,
3864 size - sizeof (struct EncryptedMessage), 3940 size - sizeof (struct EncryptedMessage),
3865 GNUNET_NO); 3941 GNUNET_NO);
3866 handle_peer_status_change (n); 3942 handle_peer_status_change (n);
3943 update_neighbour_performance (n, ats, ats_count);
3867 if (GNUNET_OK != GNUNET_SERVER_mst_receive (mst, 3944 if (GNUNET_OK != GNUNET_SERVER_mst_receive (mst,
3868 n, 3945 n,
3869 &buf[sizeof (struct EncryptedMessage)], 3946 &buf[sizeof (struct EncryptedMessage)],
@@ -3879,15 +3956,15 @@ handle_encrypted_message (struct Neighbour *n,
3879 * @param cls closure 3956 * @param cls closure
3880 * @param peer (claimed) identity of the other peer 3957 * @param peer (claimed) identity of the other peer
3881 * @param message the message 3958 * @param message the message
3882 * @param latency estimated latency for communicating with the 3959 * @param ats performance data
3883 * given peer (round-trip) 3960 * @param ats_count number of entries in ats (excluding 0-termination)
3884 * @param distance in overlay hops, as given by transport plugin
3885 */ 3961 */
3886static void 3962static void
3887handle_transport_receive (void *cls, 3963handle_transport_receive (void *cls,
3888 const struct GNUNET_PeerIdentity *peer, 3964 const struct GNUNET_PeerIdentity *peer,
3889 const struct GNUNET_MessageHeader *message, 3965 const struct GNUNET_MessageHeader *message,
3890 const struct GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count) 3966 const struct GNUNET_TRANSPORT_ATS_Information *ats,
3967 uint32_t ats_count)
3891{ 3968{
3892 struct Neighbour *n; 3969 struct Neighbour *n;
3893 struct GNUNET_TIME_Absolute now; 3970 struct GNUNET_TIME_Absolute now;
@@ -3923,7 +4000,9 @@ handle_transport_receive (void *cls,
3923 return; 4000 return;
3924 } 4001 }
3925 GNUNET_STATISTICS_update (stats, gettext_noop ("# session keys received"), 1, GNUNET_NO); 4002 GNUNET_STATISTICS_update (stats, gettext_noop ("# session keys received"), 1, GNUNET_NO);
3926 handle_set_key (n, (const struct SetKeyMessage *) message); 4003 handle_set_key (n,
4004 (const struct SetKeyMessage *) message,
4005 ats, ats_count);
3927 break; 4006 break;
3928 case GNUNET_MESSAGE_TYPE_CORE_ENCRYPTED_MESSAGE: 4007 case GNUNET_MESSAGE_TYPE_CORE_ENCRYPTED_MESSAGE:
3929 if (size < sizeof (struct EncryptedMessage) + 4008 if (size < sizeof (struct EncryptedMessage) +
@@ -3938,7 +4017,9 @@ handle_transport_receive (void *cls,
3938 GNUNET_break_op (0); 4017 GNUNET_break_op (0);
3939 return; 4018 return;
3940 } 4019 }
3941 handle_encrypted_message (n, (const struct EncryptedMessage *) message); 4020 handle_encrypted_message (n,
4021 (const struct EncryptedMessage *) message,
4022 ats, ats_count);
3942 break; 4023 break;
3943 case GNUNET_MESSAGE_TYPE_CORE_PING: 4024 case GNUNET_MESSAGE_TYPE_CORE_PING:
3944 if (size != sizeof (struct PingMessage)) 4025 if (size != sizeof (struct PingMessage))
@@ -3960,7 +4041,8 @@ handle_transport_receive (void *cls,
3960 memcpy (n->pending_ping, message, sizeof (struct PingMessage)); 4041 memcpy (n->pending_ping, message, sizeof (struct PingMessage));
3961 return; 4042 return;
3962 } 4043 }
3963 handle_ping (n, (const struct PingMessage *) message); 4044 handle_ping (n, (const struct PingMessage *) message,
4045 ats, ats_count);
3964 break; 4046 break;
3965 case GNUNET_MESSAGE_TYPE_CORE_PONG: 4047 case GNUNET_MESSAGE_TYPE_CORE_PONG:
3966 if (size != sizeof (struct PongMessage)) 4048 if (size != sizeof (struct PongMessage))
@@ -3982,7 +4064,8 @@ handle_transport_receive (void *cls,
3982 memcpy (n->pending_pong, message, sizeof (struct PongMessage)); 4064 memcpy (n->pending_pong, message, sizeof (struct PongMessage));
3983 return; 4065 return;
3984 } 4066 }
3985 handle_pong (n, (const struct PongMessage *) message); 4067 handle_pong (n, (const struct PongMessage *) message,
4068 ats, ats_count);
3986 break; 4069 break;
3987 default: 4070 default:
3988 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 4071 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -4125,13 +4208,14 @@ neighbour_quota_update (void *cls,
4125 * 4208 *
4126 * @param cls closure 4209 * @param cls closure
4127 * @param peer the peer that connected 4210 * @param peer the peer that connected
4128 * @param latency current latency of the connection 4211 * @param ats performance data
4129 * @param distance in overlay hops, as given by transport plugin 4212 * @param ats_count number of entries in ats (excluding 0-termination)
4130 */ 4213 */
4131static void 4214static void
4132handle_transport_notify_connect (void *cls, 4215handle_transport_notify_connect (void *cls,
4133 const struct GNUNET_PeerIdentity *peer, 4216 const struct GNUNET_PeerIdentity *peer,
4134 const struct GNUNET_TRANSPORT_ATS_Information *ats, uint32_t ats_count) 4217 const struct GNUNET_TRANSPORT_ATS_Information *ats,
4218 uint32_t ats_count)
4135{ 4219{
4136 struct Neighbour *n; 4220 struct Neighbour *n;
4137 4221
@@ -4159,6 +4243,7 @@ handle_transport_notify_connect (void *cls,
4159 1, 4243 1,
4160 GNUNET_NO); 4244 GNUNET_NO);
4161 n->is_connected = GNUNET_YES; 4245 n->is_connected = GNUNET_YES;
4246 update_neighbour_performance (n, ats, ats_count);
4162 GNUNET_BANDWIDTH_tracker_init (&n->available_send_window, 4247 GNUNET_BANDWIDTH_tracker_init (&n->available_send_window,
4163 n->bw_out, 4248 n->bw_out,
4164 MAX_WINDOW_TIME_S); 4249 MAX_WINDOW_TIME_S);
diff --git a/src/include/gnunet_transport_service.h b/src/include/gnunet_transport_service.h
index 196946173..af09f02ce 100644
--- a/src/include/gnunet_transport_service.h
+++ b/src/include/gnunet_transport_service.h
@@ -391,9 +391,8 @@ struct GNUNET_TRANSPORT_ATS_Information
391 * @param cls closure 391 * @param cls closure
392 * @param peer (claimed) identity of the other peer 392 * @param peer (claimed) identity of the other peer
393 * @param message the message 393 * @param message the message
394 * @param latency estimated latency for communicating with the 394 * @param ats performance data
395 * given peer (round-trip) 395 * @param ats_count number of entries in ats (excluding 0-termination)
396 * @param distance in overlay hops, as given by transport plugin
397 */ 396 */
398typedef void (*GNUNET_TRANSPORT_ReceiveCallback) (void *cls, 397typedef void (*GNUNET_TRANSPORT_ReceiveCallback) (void *cls,
399 const struct 398 const struct
@@ -401,7 +400,7 @@ typedef void (*GNUNET_TRANSPORT_ReceiveCallback) (void *cls,
401 const struct 400 const struct
402 GNUNET_MessageHeader * 401 GNUNET_MessageHeader *
403 message, 402 message,
404 const struct GNUNET_TRANSPORT_ATS_Information *ats, 403 const struct GNUNET_TRANSPORT_ATS_Information *ats,
405 uint32_t ats_count); 404 uint32_t ats_count);
406 405
407 406
@@ -417,9 +416,8 @@ struct GNUNET_TRANSPORT_Handle;
417 * 416 *
418 * @param cls closure 417 * @param cls closure
419 * @param peer the peer that connected 418 * @param peer the peer that connected
420 * @param latency estimated latency for communicating with the 419 * @param ats performance data
421 * given peer (round-trip) 420 * @param ats_count number of entries in ats (excluding 0-termination)
422 * @param distance in overlay hops, as given by transport plugin
423 */ 421 */
424typedef void 422typedef void
425 (*GNUNET_TRANSPORT_NotifyConnect) (void *cls, 423 (*GNUNET_TRANSPORT_NotifyConnect) (void *cls,
diff --git a/src/peerinfo/perf_peerinfo_api.c b/src/peerinfo/perf_peerinfo_api.c
index 1c2f81d76..fe1851a7f 100755
--- a/src/peerinfo/perf_peerinfo_api.c
+++ b/src/peerinfo/perf_peerinfo_api.c
@@ -153,11 +153,13 @@ static int
153check () 153check ()
154{ 154{
155 int ok = 0; 155 int ok = 0;
156 char *const argv[] = { "test-peerinfo-hammer", 156 char *const argv[] = { "perf-peerinfo-api",
157 "-c", 157 "-c",
158 "test_peerinfo_api_data.conf", 158 "test_peerinfo_api_data.conf",
159#if DEBUG_PEERINFO 159#if DEBUG_PEERINFO
160 "-L", "DEBUG", 160 "-L", "DEBUG",
161#else
162 "-L", "ERROR",
161#endif 163#endif
162 NULL 164 NULL
163 }; 165 };
@@ -170,6 +172,8 @@ check ()
170 "gnunet-service-peerinfo", 172 "gnunet-service-peerinfo",
171#if DEBUG_PEERINFO 173#if DEBUG_PEERINFO
172 "-L", "DEBUG", 174 "-L", "DEBUG",
175#else
176 "-L", "ERROR",
173#endif 177#endif
174 "-c", "test_peerinfo_api_data.conf", NULL); 178 "-c", "test_peerinfo_api_data.conf", NULL);
175#endif 179#endif
diff --git a/src/transport/transport_api.c b/src/transport/transport_api.c
index 30294de92..10a023dcf 100644
--- a/src/transport/transport_api.c
+++ b/src/transport/transport_api.c
@@ -1591,12 +1591,9 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg)
1591 GNUNET_break (n->is_connected == GNUNET_NO); 1591 GNUNET_break (n->is_connected == GNUNET_NO);
1592 n->is_connected = GNUNET_YES; 1592 n->is_connected = GNUNET_YES;
1593 if (h->nc_cb != NULL) 1593 if (h->nc_cb != NULL)
1594 h->nc_cb (h->cls, &n->id, &(cim->ats), cim->ats_count); 1594 h->nc_cb (h->cls, &n->id,
1595/* 1595 &(cim->ats),
1596 h->nc_cb (h->cls, &n->id, 1596 cim->ats_count);
1597 GNUNET_TIME_relative_ntoh (cim->latency),
1598 ntohl (cim->distance));
1599*/
1600 break; 1597 break;
1601 case GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT: 1598 case GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT:
1602 if (size != sizeof (struct DisconnectInfoMessage)) 1599 if (size != sizeof (struct DisconnectInfoMessage))
@@ -1688,8 +1685,10 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg)
1688 break; 1685 break;
1689 } 1686 }
1690 if (h->rec != NULL) 1687 if (h->rec != NULL)
1691 h->rec (h->cls, &im->peer, imm, &im->ats, im->ats_count); 1688 h->rec (h->cls, &im->peer,
1692 //h->rec (h->cls, &im->peer, imm, GNUNET_TIME_relative_ntoh (im->latency), ntohl(im->distance)); 1689 imm,
1690 &im->ats,
1691 im->ats_count);
1693 break; 1692 break;
1694 default: 1693 default:
1695 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1694 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,