aboutsummaryrefslogtreecommitdiff
path: root/src/ats
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-08-30 11:41:26 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-08-30 11:41:26 +0000
commit3df2832fdf4bd38c1c766fe1b3f2a97c9fe1fe4d (patch)
treeb34ba8ceabb3b0b709148daf634eb94e8123db4f /src/ats
parent75bb2cabda18a4105f518fcebf7fe95dde3132d6 (diff)
downloadgnunet-3df2832fdf4bd38c1c766fe1b3f2a97c9fe1fe4d.tar.gz
gnunet-3df2832fdf4bd38c1c766fe1b3f2a97c9fe1fe4d.zip
updated experimentation tests
added scope time for feedback api
Diffstat (limited to 'src/ats')
-rw-r--r--src/ats/ats.h19
-rw-r--r--src/ats/ats_api_performance.c11
-rw-r--r--src/ats/gnunet-service-ats-solver_mlp.c2
-rw-r--r--src/ats/gnunet-service-ats-solver_mlp.h2
-rw-r--r--src/ats/gnunet-service-ats-solver_proportional.c2
-rw-r--r--src/ats/gnunet-service-ats-solver_proportional.h2
-rw-r--r--src/ats/gnunet-service-ats_addresses.c5
-rw-r--r--src/ats/gnunet-service-ats_addresses.h8
-rw-r--r--src/ats/gnunet-service-ats_performance.c3
-rw-r--r--src/ats/test_ats_api_performance_feedback.c8
10 files changed, 50 insertions, 12 deletions
diff --git a/src/ats/ats.h b/src/ats/ats.h
index d202ddc24..4f8ab1b81 100644
--- a/src/ats/ats.h
+++ b/src/ats/ats.h
@@ -262,15 +262,30 @@ struct ChangePreferenceMessage
262 * struct PreferenceInformation values */ 262 * struct PreferenceInformation values */
263}; 263};
264 264
265
266/**
267 * Message containing application feedback for a peer
268 */
265struct FeedbackPreferenceMessage 269struct FeedbackPreferenceMessage
266{ 270{
267 struct GNUNET_MessageHeader header; 271 struct GNUNET_MessageHeader header;
268 272
269 uint32_t num_preferences GNUNET_PACKED; 273 /**
274 * Number of feedback values included
275 */
276 uint32_t num_feedback GNUNET_PACKED;
270 277
278 /**
279 * Relative time describing for which time interval this feedback is
280 */
281 struct GNUNET_TIME_RelativeNBO scope;
282
283 /**
284 * Peer this feedback is for
285 */
271 struct GNUNET_PeerIdentity peer; 286 struct GNUNET_PeerIdentity peer;
272 287
273 /* followed by 'num_preferences' 288 /* followed by 'num_feedback'
274 * struct PreferenceInformation values */ 289 * struct PreferenceInformation values */
275}; 290};
276 291
diff --git a/src/ats/ats_api_performance.c b/src/ats/ats_api_performance.c
index b7c24aa53..8d8df6474 100644
--- a/src/ats/ats_api_performance.c
+++ b/src/ats/ats_api_performance.c
@@ -943,12 +943,14 @@ GNUNET_ATS_performance_change_preference (struct GNUNET_ATS_PerformanceHandle *p
943 * preference is satisfied by ATS 943 * preference is satisfied by ATS
944 * 944 *
945 * @param ph performance handle 945 * @param ph performance handle
946 * @param scope the time interval this valid for: [now - scope .. now]
946 * @param peer identifies the peer 947 * @param peer identifies the peer
947 * @param ... 0-terminated specification of the desired changes 948 * @param ... 0-terminated specification of the desired changes
948 */ 949 */
949void 950void
950GNUNET_ATS_performance_give_feedback (struct GNUNET_ATS_PerformanceHandle *ph, 951GNUNET_ATS_performance_give_feedback (struct GNUNET_ATS_PerformanceHandle *ph,
951 const struct GNUNET_PeerIdentity *peer, ...) 952 const struct GNUNET_PeerIdentity *peer,
953 const struct GNUNET_TIME_Relative scope, ...)
952{ 954{
953 struct PendingMessage *p; 955 struct PendingMessage *p;
954 struct FeedbackPreferenceMessage *m; 956 struct FeedbackPreferenceMessage *m;
@@ -959,7 +961,7 @@ GNUNET_ATS_performance_give_feedback (struct GNUNET_ATS_PerformanceHandle *ph,
959 enum GNUNET_ATS_PreferenceKind kind; 961 enum GNUNET_ATS_PreferenceKind kind;
960 962
961 count = 0; 963 count = 0;
962 va_start (ap, peer); 964 va_start (ap, scope);
963 while (GNUNET_ATS_PREFERENCE_END != 965 while (GNUNET_ATS_PREFERENCE_END !=
964 (kind = va_arg (ap, enum GNUNET_ATS_PreferenceKind))) 966 (kind = va_arg (ap, enum GNUNET_ATS_PreferenceKind)))
965 { 967 {
@@ -989,11 +991,12 @@ GNUNET_ATS_performance_give_feedback (struct GNUNET_ATS_PerformanceHandle *ph,
989 m = (struct FeedbackPreferenceMessage *) &p[1]; 991 m = (struct FeedbackPreferenceMessage *) &p[1];
990 m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_FEEDBACK); 992 m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_FEEDBACK);
991 m->header.size = htons (msize); 993 m->header.size = htons (msize);
992 m->num_preferences = htonl (count); 994 m->scope = GNUNET_TIME_relative_hton (scope);
995 m->num_feedback = htonl (count);
993 m->peer = *peer; 996 m->peer = *peer;
994 pi = (struct PreferenceInformation *) &m[1]; 997 pi = (struct PreferenceInformation *) &m[1];
995 count = 0; 998 count = 0;
996 va_start (ap, peer); 999 va_start (ap, scope);
997 while (GNUNET_ATS_PREFERENCE_END != 1000 while (GNUNET_ATS_PREFERENCE_END !=
998 (kind = va_arg (ap, enum GNUNET_ATS_PreferenceKind))) 1001 (kind = va_arg (ap, enum GNUNET_ATS_PreferenceKind)))
999 { 1002 {
diff --git a/src/ats/gnunet-service-ats-solver_mlp.c b/src/ats/gnunet-service-ats-solver_mlp.c
index 9c1cb10b6..c2873a4f6 100644
--- a/src/ats/gnunet-service-ats-solver_mlp.c
+++ b/src/ats/gnunet-service-ats-solver_mlp.c
@@ -1657,6 +1657,7 @@ GAS_mlp_address_change_preference (void *solver,
1657 * @param solver the solver handle 1657 * @param solver the solver handle
1658 * @param application the application 1658 * @param application the application
1659 * @param peer the peer to change the preference for 1659 * @param peer the peer to change the preference for
1660 * @param scope the time interval for this feedback: [now - scope .. now]
1660 * @param kind the kind to change the preference 1661 * @param kind the kind to change the preference
1661 * @param score the score 1662 * @param score the score
1662 */ 1663 */
@@ -1664,6 +1665,7 @@ void
1664GAS_mlp_address_preference_feedback (void *solver, 1665GAS_mlp_address_preference_feedback (void *solver,
1665 void *application, 1666 void *application,
1666 const struct GNUNET_PeerIdentity *peer, 1667 const struct GNUNET_PeerIdentity *peer,
1668 const struct GNUNET_TIME_Relative scope,
1667 enum GNUNET_ATS_PreferenceKind kind, 1669 enum GNUNET_ATS_PreferenceKind kind,
1668 double score) 1670 double score)
1669{ 1671{
diff --git a/src/ats/gnunet-service-ats-solver_mlp.h b/src/ats/gnunet-service-ats-solver_mlp.h
index 647ab8b30..d1a65c002 100644
--- a/src/ats/gnunet-service-ats-solver_mlp.h
+++ b/src/ats/gnunet-service-ats-solver_mlp.h
@@ -506,6 +506,7 @@ GAS_mlp_address_change_preference (void *solver,
506 * @param solver the solver handle 506 * @param solver the solver handle
507 * @param application the application 507 * @param application the application
508 * @param peer the peer to change the preference for 508 * @param peer the peer to change the preference for
509 * @param scope the time interval for this feedback: [now - scope .. now]
509 * @param kind the kind to change the preference 510 * @param kind the kind to change the preference
510 * @param score the score 511 * @param score the score
511 */ 512 */
@@ -513,6 +514,7 @@ void
513GAS_mlp_address_preference_feedback (void *solver, 514GAS_mlp_address_preference_feedback (void *solver,
514 void *application, 515 void *application,
515 const struct GNUNET_PeerIdentity *peer, 516 const struct GNUNET_PeerIdentity *peer,
517 const struct GNUNET_TIME_Relative scope,
516 enum GNUNET_ATS_PreferenceKind kind, 518 enum GNUNET_ATS_PreferenceKind kind,
517 double score); 519 double score);
518 520
diff --git a/src/ats/gnunet-service-ats-solver_proportional.c b/src/ats/gnunet-service-ats-solver_proportional.c
index d62cface9..e36f04b5e 100644
--- a/src/ats/gnunet-service-ats-solver_proportional.c
+++ b/src/ats/gnunet-service-ats-solver_proportional.c
@@ -892,6 +892,7 @@ GAS_proportional_address_change_preference (void *solver,
892 * @param solver the solver handle 892 * @param solver the solver handle
893 * @param application the application 893 * @param application the application
894 * @param peer the peer to change the preference for 894 * @param peer the peer to change the preference for
895 * @param scope the time interval for this feedback: [now - scope .. now]
895 * @param kind the kind to change the preference 896 * @param kind the kind to change the preference
896 * @param score the score 897 * @param score the score
897 */ 898 */
@@ -899,6 +900,7 @@ void
899GAS_proportional_address_preference_feedback (void *solver, 900GAS_proportional_address_preference_feedback (void *solver,
900 void *application, 901 void *application,
901 const struct GNUNET_PeerIdentity *peer, 902 const struct GNUNET_PeerIdentity *peer,
903 const struct GNUNET_TIME_Relative scope,
902 enum GNUNET_ATS_PreferenceKind kind, 904 enum GNUNET_ATS_PreferenceKind kind,
903 double score) 905 double score)
904{ 906{
diff --git a/src/ats/gnunet-service-ats-solver_proportional.h b/src/ats/gnunet-service-ats-solver_proportional.h
index 0f950eb94..94612b736 100644
--- a/src/ats/gnunet-service-ats-solver_proportional.h
+++ b/src/ats/gnunet-service-ats-solver_proportional.h
@@ -55,6 +55,7 @@ GAS_proportional_address_change_preference (void *solver,
55 * @param solver the solver handle 55 * @param solver the solver handle
56 * @param application the application 56 * @param application the application
57 * @param peer the peer to change the preference for 57 * @param peer the peer to change the preference for
58 * @param scope the time interval for this feedback: [now - scope .. now]
58 * @param kind the kind to change the preference 59 * @param kind the kind to change the preference
59 * @param score the score 60 * @param score the score
60 */ 61 */
@@ -62,6 +63,7 @@ void
62GAS_proportional_address_preference_feedback (void *solver, 63GAS_proportional_address_preference_feedback (void *solver,
63 void *application, 64 void *application,
64 const struct GNUNET_PeerIdentity *peer, 65 const struct GNUNET_PeerIdentity *peer,
66 const struct GNUNET_TIME_Relative scope,
65 enum GNUNET_ATS_PreferenceKind kind, 67 enum GNUNET_ATS_PreferenceKind kind,
66 double score); 68 double score);
67 69
diff --git a/src/ats/gnunet-service-ats_addresses.c b/src/ats/gnunet-service-ats_addresses.c
index 76489d129..a6351e343 100644
--- a/src/ats/gnunet-service-ats_addresses.c
+++ b/src/ats/gnunet-service-ats_addresses.c
@@ -1486,12 +1486,14 @@ GAS_addresses_change_preference (struct GAS_Addresses_Handle *handle,
1486 handle->s_bulk_stop (handle->solver); 1486 handle->s_bulk_stop (handle->solver);
1487} 1487}
1488 1488
1489
1489/** 1490/**
1490 * Change the preference for a peer 1491 * Change the preference for a peer
1491 * 1492 *
1492 * @param handle the address handle 1493 * @param handle the address handle
1493 * @param application the client sending this request 1494 * @param application the client sending this request
1494 * @param peer the peer id 1495 * @param peer the peer id
1496 * @param scope the time interval for this feedback: [now - scope .. now]
1495 * @param kind the preference kind to change 1497 * @param kind the preference kind to change
1496 * @param score_abs the new preference score 1498 * @param score_abs the new preference score
1497 */ 1499 */
@@ -1499,6 +1501,7 @@ void
1499GAS_addresses_preference_feedback (struct GAS_Addresses_Handle *handle, 1501GAS_addresses_preference_feedback (struct GAS_Addresses_Handle *handle,
1500 void *application, 1502 void *application,
1501 const struct GNUNET_PeerIdentity *peer, 1503 const struct GNUNET_PeerIdentity *peer,
1504 const struct GNUNET_TIME_Relative scope,
1502 enum GNUNET_ATS_PreferenceKind kind, 1505 enum GNUNET_ATS_PreferenceKind kind,
1503 float score_abs) 1506 float score_abs)
1504{ 1507{
@@ -1520,7 +1523,7 @@ GAS_addresses_preference_feedback (struct GAS_Addresses_Handle *handle,
1520 return; 1523 return;
1521 } 1524 }
1522 1525
1523 handle->s_feedback (handle->solver, application, peer, kind, score_abs); 1526 handle->s_feedback (handle->solver, application, peer, scope, kind, score_abs);
1524} 1527}
1525 1528
1526 1529
diff --git a/src/ats/gnunet-service-ats_addresses.h b/src/ats/gnunet-service-ats_addresses.h
index a50234361..5fa8a4906 100644
--- a/src/ats/gnunet-service-ats_addresses.h
+++ b/src/ats/gnunet-service-ats_addresses.h
@@ -455,6 +455,7 @@ typedef void
455 * @param handle the solver handle 455 * @param handle the solver handle
456 * @param application the application sending this request 456 * @param application the application sending this request
457 * @param peer the peer id 457 * @param peer the peer id
458 * @param scope the time interval for this feedback: [now - scope .. now]
458 * @param kind the preference kind for this feedback 459 * @param kind the preference kind for this feedback
459 * @param score the feedback score 460 * @param score the feedback score
460 */ 461 */
@@ -462,6 +463,7 @@ typedef void
462(*GAS_solver_address_feedback_preference) (void *solver, 463(*GAS_solver_address_feedback_preference) (void *solver,
463 void *application, 464 void *application,
464 const struct GNUNET_PeerIdentity *peer, 465 const struct GNUNET_PeerIdentity *peer,
466 const struct GNUNET_TIME_Relative scope,
465 enum GNUNET_ATS_PreferenceKind kind, 467 enum GNUNET_ATS_PreferenceKind kind,
466 double score); 468 double score);
467 469
@@ -796,15 +798,17 @@ GAS_addresses_change_preference (struct GAS_Addresses_Handle *handle,
796 * Change the preference for a peer 798 * Change the preference for a peer
797 * 799 *
798 * @param handle the address handle 800 * @param handle the address handle
799 * @param client the client sending this request 801 * @param application the client sending this request
800 * @param peer the peer id 802 * @param peer the peer id
803 * @param scope the time interval this valid for: [now - scope .. now]
801 * @param kind the preference kind to change 804 * @param kind the preference kind to change
802 * @param score_abs the new preference score 805 * @param score_abs the new preference score
803 */ 806 */
804void 807void
805GAS_addresses_preference_feedback (struct GAS_Addresses_Handle *handle, 808GAS_addresses_preference_feedback (struct GAS_Addresses_Handle *handle,
806 void *client, 809 void *application,
807 const struct GNUNET_PeerIdentity *peer, 810 const struct GNUNET_PeerIdentity *peer,
811 const struct GNUNET_TIME_Relative scope,
808 enum GNUNET_ATS_PreferenceKind kind, 812 enum GNUNET_ATS_PreferenceKind kind,
809 float score_abs); 813 float score_abs);
810 814
diff --git a/src/ats/gnunet-service-ats_performance.c b/src/ats/gnunet-service-ats_performance.c
index bb7ed7934..9447691e1 100644
--- a/src/ats/gnunet-service-ats_performance.c
+++ b/src/ats/gnunet-service-ats_performance.c
@@ -676,7 +676,7 @@ GAS_handle_preference_feedback (void *cls,
676 return; 676 return;
677 } 677 }
678 msg = (const struct FeedbackPreferenceMessage *) message; 678 msg = (const struct FeedbackPreferenceMessage *) message;
679 nump = ntohl (msg->num_preferences); 679 nump = ntohl (msg->num_feedback);
680 if (msize != 680 if (msize !=
681 sizeof (struct FeedbackPreferenceMessage) + 681 sizeof (struct FeedbackPreferenceMessage) +
682 nump * sizeof (struct PreferenceInformation)) 682 nump * sizeof (struct PreferenceInformation))
@@ -692,6 +692,7 @@ GAS_handle_preference_feedback (void *cls,
692 GAS_addresses_preference_feedback (GSA_addresses, 692 GAS_addresses_preference_feedback (GSA_addresses,
693 client, 693 client,
694 &msg->peer, 694 &msg->peer,
695 GNUNET_TIME_relative_ntoh(msg->scope),
695 (enum GNUNET_ATS_PreferenceKind) 696 (enum GNUNET_ATS_PreferenceKind)
696 ntohl (pi[i].preference_kind), 697 ntohl (pi[i].preference_kind),
697 pi[i].preference_value); 698 pi[i].preference_value);
diff --git a/src/ats/test_ats_api_performance_feedback.c b/src/ats/test_ats_api_performance_feedback.c
index 39cc5136f..35d31c495 100644
--- a/src/ats/test_ats_api_performance_feedback.c
+++ b/src/ats/test_ats_api_performance_feedback.c
@@ -167,11 +167,15 @@ void ats_suggest_cb (void *cls,
167 res_suggest_cb_p0 = GNUNET_YES; 167 res_suggest_cb_p0 = GNUNET_YES;
168 stage = 1; 168 stage = 1;
169 GNUNET_ATS_address_update (sh, &addr[1], NULL, atsi, ATS_COUNT); 169 GNUNET_ATS_address_update (sh, &addr[1], NULL, atsi, ATS_COUNT);
170 GNUNET_ATS_performance_give_feedback (ph, &addr[0].peer, GNUNET_ATS_PREFERENCE_BANDWIDTH,(double) 1000, GNUNET_ATS_PREFERENCE_END); 170 GNUNET_ATS_performance_give_feedback (ph, &addr[0].peer,
171 GNUNET_TIME_UNIT_SECONDS, GNUNET_ATS_PREFERENCE_BANDWIDTH,
172 (double) 1000, GNUNET_ATS_PREFERENCE_END);
171 } 173 }
172 if (0 == memcmp (&addr[1].peer, &address->peer, sizeof (address->peer))) 174 if (0 == memcmp (&addr[1].peer, &address->peer, sizeof (address->peer)))
173 { 175 {
174 GNUNET_ATS_performance_give_feedback (ph, &addr[1].peer, GNUNET_ATS_PREFERENCE_BANDWIDTH,(double) 1000, GNUNET_ATS_PREFERENCE_END); 176 GNUNET_ATS_performance_give_feedback (ph, &addr[1].peer,
177 GNUNET_TIME_UNIT_SECONDS, GNUNET_ATS_PREFERENCE_BANDWIDTH,
178 GNUNET_ATS_PREFERENCE_END);
175 res_suggest_cb_p1 = GNUNET_YES; 179 res_suggest_cb_p1 = GNUNET_YES;
176 } 180 }
177} 181}