gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r28897 - gnunet/src/ats


From: gnunet
Subject: [GNUnet-SVN] r28897 - gnunet/src/ats
Date: Thu, 29 Aug 2013 17:34:53 +0200

Author: wachs
Date: 2013-08-29 17:34:53 +0200 (Thu, 29 Aug 2013)
New Revision: 28897

Added:
   gnunet/src/ats/test_ats_api_performance_feedback.c
Modified:
   gnunet/src/ats/Makefile.am
   gnunet/src/ats/ats.h
   gnunet/src/ats/ats_api_performance.c
   gnunet/src/ats/gnunet-service-ats.c
   gnunet/src/ats/gnunet-service-ats_addresses.c
   gnunet/src/ats/gnunet-service-ats_addresses.h
   gnunet/src/ats/gnunet-service-ats_performance.c
   gnunet/src/ats/gnunet-service-ats_performance.h
   gnunet/src/ats/perf_ats.c
   gnunet/src/ats/test_ats_change_preference.c
   gnunet/src/ats/test_ats_simplistic_change_preference.c
   gnunet/src/ats/test_ats_simplistic_pref_aging.c
Log:
implemented feedback API, but not yet calling solver


Modified: gnunet/src/ats/Makefile.am
===================================================================
--- gnunet/src/ats/Makefile.am  2013-08-29 15:14:17 UTC (rev 28896)
+++ gnunet/src/ats/Makefile.am  2013-08-29 15:34:53 UTC (rev 28897)
@@ -79,6 +79,7 @@
  test_ats_simplistic_change_preference \
  test_ats_api_performance_list_addresses \
  test_ats_api_performance_address_info \
+ test_ats_api_performance_feedback \
  perf_ats_proportional_bandwidth \
  perf_ats_proportional_delay
 endif
@@ -165,6 +166,16 @@
   $(top_builddir)/src/testing/libgnunettesting.la \
   $(top_builddir)/src/ats/libgnunetats.la
 
+
+
+test_ats_api_performance_feedback_SOURCES = \
+ test_ats_api_performance_feedback.c
+test_ats_api_performance_feedback_LDADD = \
+  $(top_builddir)/src/util/libgnunetutil.la \
+  $(top_builddir)/src/testing/libgnunettesting.la \
+  $(top_builddir)/src/hello/libgnunethello.la \
+  $(top_builddir)/src/ats/libgnunetats.la    
+
 test_ats_api_performance_list_addresses_SOURCES = \
  test_ats_api_performance_list_addresses.c
 test_ats_api_performance_list_addresses_LDADD = \

Modified: gnunet/src/ats/ats.h
===================================================================
--- gnunet/src/ats/ats.h        2013-08-29 15:14:17 UTC (rev 28896)
+++ gnunet/src/ats/ats.h        2013-08-29 15:34:53 UTC (rev 28897)
@@ -261,6 +261,19 @@
   /* followed by 'num_preferences'
    * struct PreferenceInformation values */
 };
+
+struct FeedbackPreferenceMessage
+{
+  struct GNUNET_MessageHeader header;
+
+  uint32_t num_preferences GNUNET_PACKED;
+
+  struct GNUNET_PeerIdentity peer;
+
+  /* followed by 'num_preferences'
+   * struct PreferenceInformation values */
+};
+
 GNUNET_NETWORK_STRUCT_END
 
 

Modified: gnunet/src/ats/ats_api_performance.c
===================================================================
--- gnunet/src/ats/ats_api_performance.c        2013-08-29 15:14:17 UTC (rev 
28896)
+++ gnunet/src/ats/ats_api_performance.c        2013-08-29 15:34:53 UTC (rev 
28897)
@@ -866,7 +866,7 @@
  * @param ... 0-terminated specification of the desired changes
  */
 void
-GNUNET_ATS_change_preference (struct GNUNET_ATS_PerformanceHandle *ph,
+GNUNET_ATS_performance_change_preference (struct GNUNET_ATS_PerformanceHandle 
*ph,
                               const struct GNUNET_PeerIdentity *peer, ...)
 {
   struct PendingMessage *p;
@@ -938,4 +938,85 @@
   do_transmit (ph);
 }
 
+/**
+ * Send feedback to ATS on how good a the requirements for a peer and a
+ * preference is satisfied by ATS
+ *
+ * @param ph performance handle
+ * @param peer identifies the peer
+ * @param ... 0-terminated specification of the desired changes
+ */
+void
+GNUNET_ATS_performance_give_feedback (struct GNUNET_ATS_PerformanceHandle *ph,
+                                                                               
                                                                        const 
struct GNUNET_PeerIdentity *peer, ...)
+{
+  struct PendingMessage *p;
+  struct FeedbackPreferenceMessage *m;
+  size_t msize;
+  uint32_t count;
+  struct PreferenceInformation *pi;
+  va_list ap;
+  enum GNUNET_ATS_PreferenceKind kind;
+
+  count = 0;
+  va_start (ap, peer);
+  while (GNUNET_ATS_PREFERENCE_END !=
+         (kind = va_arg (ap, enum GNUNET_ATS_PreferenceKind)))
+  {
+    switch (kind)
+    {
+    case GNUNET_ATS_PREFERENCE_BANDWIDTH:
+      count++;
+      (void) va_arg (ap, double);
+
+      break;
+    case GNUNET_ATS_PREFERENCE_LATENCY:
+      count++;
+      (void) va_arg (ap, double);
+
+      break;
+    default:
+      GNUNET_assert (0);
+    }
+  }
+  va_end (ap);
+  msize =
+      count * sizeof (struct PreferenceInformation) +
+      sizeof (struct FeedbackPreferenceMessage);
+  p = GNUNET_malloc (sizeof (struct PendingMessage) + msize);
+  p->size = msize;
+  p->is_init = GNUNET_NO;
+  m = (struct FeedbackPreferenceMessage *) &p[1];
+  m->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_FEEDBACK);
+  m->header.size = htons (msize);
+  m->num_preferences = htonl (count);
+  m->peer = *peer;
+  pi = (struct PreferenceInformation *) &m[1];
+  count = 0;
+  va_start (ap, peer);
+  while (GNUNET_ATS_PREFERENCE_END !=
+         (kind = va_arg (ap, enum GNUNET_ATS_PreferenceKind)))
+  {
+    pi[count].preference_kind = htonl (kind);
+    switch (kind)
+    {
+    case GNUNET_ATS_PREFERENCE_BANDWIDTH:
+      pi[count].preference_value = (float) va_arg (ap, double);
+
+      count++;
+      break;
+    case GNUNET_ATS_PREFERENCE_LATENCY:
+      pi[count].preference_value = (float) va_arg (ap, double);
+
+      count++;
+      break;
+    default:
+      GNUNET_assert (0);
+    }
+  }
+  va_end (ap);
+  GNUNET_CONTAINER_DLL_insert_tail (ph->pending_head, ph->pending_tail, p);
+  do_transmit (ph);
+}
+
 /* end of ats_api_performance.c */

Modified: gnunet/src/ats/gnunet-service-ats.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats.c 2013-08-29 15:14:17 UTC (rev 28896)
+++ gnunet/src/ats/gnunet-service-ats.c 2013-08-29 15:34:53 UTC (rev 28897)
@@ -159,6 +159,8 @@
      sizeof (struct ReservationRequestMessage)},
     {&GAS_handle_preference_change, NULL,
      GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_CHANGE, 0},
+    {&GAS_handle_preference_feedback, NULL,
+     GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_FEEDBACK, 0},
     {&GAS_handle_reset_backoff, NULL,
      GNUNET_MESSAGE_TYPE_ATS_RESET_BACKOFF,
      sizeof (struct ResetBackoffMessage)},

Modified: gnunet/src/ats/gnunet-service-ats_addresses.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses.c       2013-08-29 15:14:17 UTC 
(rev 28896)
+++ gnunet/src/ats/gnunet-service-ats_addresses.c       2013-08-29 15:34:53 UTC 
(rev 28897)
@@ -368,6 +368,11 @@
   GAS_solver_address_change_preference s_pref;
 
   /**
+   * Give feedback about the current assignment
+   */
+  GAS_solver_address_feedback_preference s_feedback;
+
+  /**
    * Start a bulk operation
    */
   GAS_solver_bulk_start s_bulk_start;
@@ -1481,7 +1486,49 @@
   handle->s_bulk_stop (handle->solver);
 }
 
+/**
+ * Change the preference for a peer
+ *
+ * @param handle the address handle
+ * @param application the client sending this request
+ * @param peer the peer id
+ * @param kind the preference kind to change
+ * @param score_abs the new preference score
+ */
+void
+GAS_addresses_preference_feedback (struct GAS_Addresses_Handle *handle,
+                                                                               
                                                                void 
*application,
+                                                                               
                                                                const struct 
GNUNET_PeerIdentity *peer,
+                                                                               
                                                                enum 
GNUNET_ATS_PreferenceKind kind,
+                                                                               
                                                                float score_abs)
+{
+       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Received `%s' for peer `%s' for client %p\n",
+              "PREFERENCE FEEDBACK",
+              GNUNET_i2s (peer), application);
 
+  if (GNUNET_NO == handle->running)
+    return;
+
+  if (GNUNET_NO == GNUNET_CONTAINER_multihashmap_contains (handle->addresses,
+                                                          &peer->hashPubKey))
+  {
+      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                  "Received `%s' for unknown peer `%s' from client %p\n",
+                  "PREFERENCE FEEDBACK",
+                  GNUNET_i2s (peer), application);
+      return;
+  }
+
+  GNUNET_break (0);
+
+  //handle->s_bulk_start (handle->solver);
+  /* Tell normalization about change, normalization will call callback if 
preference changed */
+  //GAS_normalization_normalize_preference (client, peer, kind, score_abs);
+  //handle->s_bulk_stop (handle->solver);
+}
+
+
 /**
  * Load quotas for networks from configuration
  *
@@ -1733,6 +1780,7 @@
       ah->s_get = &GAS_proportional_get_preferred_address;
       ah->s_get_stop = &GAS_proportional_stop_get_preferred_address;
       ah->s_pref = &GAS_proportional_address_change_preference;
+      ah->s_pref = &GAS_proportional_address_change_preference;
       ah->s_del  = &GAS_proportional_address_delete;
       ah->s_bulk_start = &GAS_proportional_bulk_start;
       ah->s_bulk_stop = &GAS_proportional_bulk_stop;

Modified: gnunet/src/ats/gnunet-service-ats_addresses.h
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses.h       2013-08-29 15:14:17 UTC 
(rev 28896)
+++ gnunet/src/ats/gnunet-service-ats_addresses.h       2013-08-29 15:34:53 UTC 
(rev 28897)
@@ -448,7 +448,24 @@
                                                                                
                                                                                
 enum GNUNET_ATS_PreferenceKind kind,
                                                                                
                                                                                
 double pref_rel);
 
+
 /**
+ * Give feedback about the current assignment
+ *
+ * @param handle the solver handle
+ * @param application the application sending this request
+ * @param peer the peer id
+ * @param kind the preference kind for this feedback
+ * @param score the feedback score
+ */
+typedef void
+(*GAS_solver_address_feedback_preference) (void *solver,
+                                                                               
                                                                                
 void *application,
+                                                                               
                                                                                
 const struct GNUNET_PeerIdentity *peer,
+                                                                               
                                                                                
 enum GNUNET_ATS_PreferenceKind kind,
+                                                                               
                                                                                
 double score);
+
+/**
  * Notify the solver about a bulk operation changing possibly a lot of values
  * Solver will not resolve until all bulk operations are marked as done
  *
@@ -776,6 +793,23 @@
 
 
 /**
+ * Change the preference for a peer
+ *
+ * @param handle the address handle
+ * @param client the client sending this request
+ * @param peer the peer id
+ * @param kind the preference kind to change
+ * @param score_abs the new preference score
+ */
+void
+GAS_addresses_preference_feedback (struct GAS_Addresses_Handle *handle,
+                                                                               
                                                                void *client,
+                                                                               
                                                                const struct 
GNUNET_PeerIdentity *peer,
+                                                                               
                                                                enum 
GNUNET_ATS_PreferenceKind kind,
+                                                                               
                                                                float 
score_abs);
+
+
+/**
  * Iterator for GAS_addresses_iterate_peers
  *
  * @param p_it_cls closure

Modified: gnunet/src/ats/gnunet-service-ats_performance.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_performance.c     2013-08-29 15:14:17 UTC 
(rev 28896)
+++ gnunet/src/ats/gnunet-service-ats_performance.c     2013-08-29 15:34:53 UTC 
(rev 28897)
@@ -649,6 +649,58 @@
 
 
 /**
+ * Handle 'preference feedback' messages from clients.
+ *
+ * @param cls unused, NULL
+ * @param client client that sent the request
+ * @param message the request message
+ */
+void
+GAS_handle_preference_feedback (void *cls,
+                              struct GNUNET_SERVER_Client *client,
+                              const struct GNUNET_MessageHeader *message)
+{
+  const struct FeedbackPreferenceMessage *msg;
+  const struct PreferenceInformation *pi;
+  uint16_t msize;
+  uint32_t nump;
+  uint32_t i;
+
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n",
+              "PREFERENCE_FEEDBACK");
+  msize = ntohs (message->size);
+  if (msize < sizeof (struct FeedbackPreferenceMessage))
+  {
+    GNUNET_break (0);
+    GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+    return;
+  }
+  msg = (const struct FeedbackPreferenceMessage *) message;
+  nump = ntohl (msg->num_preferences);
+  if (msize !=
+      sizeof (struct FeedbackPreferenceMessage) +
+      nump * sizeof (struct PreferenceInformation))
+  {
+    GNUNET_break (0);
+    GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+    return;
+  }
+  GNUNET_STATISTICS_update (GSA_stats, "# preference feedbacks requests 
processed",
+                            1, GNUNET_NO);
+  pi = (const struct PreferenceInformation *) &msg[1];
+  for (i = 0; i < nump; i++)
+    GAS_addresses_preference_feedback (GSA_addresses,
+                                     client,
+                                     &msg->peer,
+                                     (enum GNUNET_ATS_PreferenceKind)
+                                     ntohl (pi[i].preference_kind),
+                                     pi[i].preference_value);
+  GNUNET_SERVER_receive_done (client, GNUNET_OK);
+}
+
+
+
+/**
  * Initialize performance subsystem.
  *
  * @param server handle to our server

Modified: gnunet/src/ats/gnunet-service-ats_performance.h
===================================================================
--- gnunet/src/ats/gnunet-service-ats_performance.h     2013-08-29 15:14:17 UTC 
(rev 28896)
+++ gnunet/src/ats/gnunet-service-ats_performance.h     2013-08-29 15:34:53 UTC 
(rev 28897)
@@ -132,7 +132,20 @@
                               const struct GNUNET_MessageHeader *message);
 
 
+/**
+ * Handle 'preference feedback' messages from clients.
+ *
+ * @param cls unused, NULL
+ * @param client client that sent the request
+ * @param message the request message
+ */
 void
+GAS_handle_preference_feedback (void *cls,
+                              struct GNUNET_SERVER_Client *client,
+                              const struct GNUNET_MessageHeader *message);
+
+
+void
 GAS_handle_monitor (void *cls,
                                                                                
                        struct GNUNET_SERVER_Client *client,
                           const struct GNUNET_MessageHeader *message);

Modified: gnunet/src/ats/perf_ats.c
===================================================================
--- gnunet/src/ats/perf_ats.c   2013-08-29 15:14:17 UTC (rev 28896)
+++ gnunet/src/ats/perf_ats.c   2013-08-29 15:34:53 UTC (rev 28897)
@@ -518,7 +518,7 @@
 
        GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Set preference for master %u: 
%f\n",
                        bp->no, last);
-       GNUNET_ATS_change_preference (bp->p_handle, &bp->destination->id,
+       GNUNET_ATS_performance_change_preference (bp->p_handle, 
&bp->destination->id,
                        GNUNET_ATS_PREFERENCE_BANDWIDTH, (double) last,
                        GNUNET_ATS_PREFERENCE_END);
        last++;

Added: gnunet/src/ats/test_ats_api_performance_feedback.c
===================================================================
--- gnunet/src/ats/test_ats_api_performance_feedback.c                          
(rev 0)
+++ gnunet/src/ats/test_ats_api_performance_feedback.c  2013-08-29 15:34:53 UTC 
(rev 28897)
@@ -0,0 +1,236 @@
+/*
+     This file is part of GNUnet.
+     (C) 2010,2011 Christian Grothoff (and other contributing authors)
+
+     GNUnet is free software; you can redistribute it and/or modify
+     it under the terms of the GNU General Public License as published
+     by the Free Software Foundation; either version 3, or (at your
+     option) any later version.
+
+     GNUnet is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     General Public License for more details.
+
+     You should have received a copy of the GNU General Public License
+     along with GNUnet; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+     Boston, MA 02111-1307, USA.
+*/
+/**
+ * @file ats/test_ats_api_performance_feedback
+ * @brief Test performance API:
+ *                             Test for address feedback API
+ * @author Christian Grothoff
+ * @author Matthias Wachs
+ */
+#include "platform.h"
+#include "gnunet_ats_service.h"
+#include "gnunet_testing_lib.h"
+#include "ats.h"
+
+#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 20)
+#define SHUTDOWN_CORRECT GNUNET_TIME_relative_multiply 
(GNUNET_TIME_UNIT_SECONDS, 5)
+
+#define ATS_COUNT 2
+
+static GNUNET_SCHEDULER_TaskIdentifier die_task;
+static GNUNET_SCHEDULER_TaskIdentifier stage_task;
+
+struct GNUNET_CONFIGURATION_Handle *cfg;
+
+static struct GNUNET_ATS_SchedulingHandle *sh;
+
+static struct GNUNET_ATS_PerformanceHandle *ph;
+
+static struct GNUNET_HELLO_Address addr[2];
+
+static struct GNUNET_ATS_Information atsi[ATS_COUNT];
+
+static int ret;
+
+static int res_suggest_cb_p0;
+static int res_suggest_cb_p1;
+
+static int res_addrinfo_cb_p0;
+static int res_addrinfo_cb_p1;
+
+/**
+ * Stage 0: Init, request address and wait for peer0 suggest cb
+ * Stage 1: Got peer0 suggest cb, expect monitoring cb
+ * Stage 2: Got peer0 monitoring cb, update address and expect monitor cb
+ * Stage 3: Got 2nd peer0 monitoring cb, shutdown
+ */
+
+static int stage;
+
+
+static void cleanup_addresses ()
+{
+       GNUNET_ATS_address_destroyed (sh, &addr[0], NULL);
+       GNUNET_ATS_address_destroyed (sh, &addr[1], NULL);
+}
+
+static void
+end_now (int res)
+{
+       if (GNUNET_SCHEDULER_NO_TASK != stage_task)
+       {
+                       GNUNET_SCHEDULER_cancel (stage_task);
+                       stage_task = GNUNET_SCHEDULER_NO_TASK;
+       }
+       if (GNUNET_SCHEDULER_NO_TASK != die_task)
+       {
+                       GNUNET_SCHEDULER_cancel (die_task);
+                       die_task = GNUNET_SCHEDULER_NO_TASK;
+       }
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown\n");
+
+       cleanup_addresses ();
+
+       if (NULL != ph)
+       {
+               GNUNET_ATS_performance_done (ph);
+               ph = NULL;
+       }
+
+       if (NULL != sh)
+       {
+               GNUNET_ATS_scheduling_done (sh);
+               sh = NULL;
+       }
+       ret = res;
+}
+
+#if 0
+static void
+end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  die_task = GNUNET_SCHEDULER_NO_TASK;
+  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error!\n");
+  if (GNUNET_NO == res_addrinfo_cb_p0)
+       GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Did not get address information 
for requested peer0!\n");
+  if (GNUNET_NO == res_addrinfo_cb_p1)
+       GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Did not get address information 
for requested peer1!\n");
+  if (GNUNET_NO == res_suggest_cb_p0)
+       GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Did not get suggestion for not 
peer!\n");
+  if (GNUNET_YES == res_suggest_cb_p1)
+       GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Got suggestion for not requested 
peer!\n");
+  end_now (1);
+}
+#endif
+
+static void end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Success\n");
+  end_now (0);
+}
+
+static void
+addrinfo_cb (void *cls,
+                                               const struct 
GNUNET_HELLO_Address *address,
+                                               int address_active,
+                                               struct 
GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
+                                               struct 
GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
+                                               const struct 
GNUNET_ATS_Information *ats,
+                                               uint32_t ats_count)
+{
+       //static int shutdown = GNUNET_NO;
+       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                       "ATS has information about address for peer `%s'\n", 
GNUNET_i2s (&address->peer));
+
+       if (0 == memcmp (&addr[0].peer, &address->peer, sizeof (address->peer)))
+               res_addrinfo_cb_p0 = GNUNET_YES;
+       if (0 == memcmp (&addr[1].peer, &address->peer, sizeof (address->peer)))
+               res_addrinfo_cb_p1 = GNUNET_YES;
+}
+
+void ats_suggest_cb (void *cls,
+                                                                               
const struct GNUNET_HELLO_Address * address,
+                                                                               
struct Session * session,
+                                                                               
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
+                                                                               
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
+                                                                               
const struct GNUNET_ATS_Information *ats,
+                                                                               
uint32_t ats_count)
+{
+       static int feedbacks = 0;
+
+       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                       "ATS is suggesting address for peer `%s'\n", GNUNET_i2s 
(&address->peer));
+
+       if (feedbacks >= 2)
+               return;
+       feedbacks++;
+
+       if (0 == memcmp (&addr[0].peer, &address->peer, sizeof (address->peer)))
+       {
+               res_suggest_cb_p0 = GNUNET_YES;
+               stage = 1;
+               GNUNET_ATS_address_update (sh, &addr[1], NULL, atsi, ATS_COUNT);
+               GNUNET_ATS_performance_give_feedback (ph, &addr[0].peer, 
GNUNET_ATS_PREFERENCE_BANDWIDTH,(double) 1000, GNUNET_ATS_PREFERENCE_END);
+       }
+       if (0 == memcmp (&addr[1].peer, &address->peer, sizeof (address->peer)))
+       {
+               GNUNET_ATS_performance_give_feedback (ph, &addr[1].peer, 
GNUNET_ATS_PREFERENCE_BANDWIDTH,(double) 1000, GNUNET_ATS_PREFERENCE_END);
+               res_suggest_cb_p1 = GNUNET_YES;
+       }
+}
+
+
+static void next (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+       memset (&addr[0].peer,'\0', sizeof (addr[0].peer));
+       addr[0].transport_name = "test0";
+       addr[0].address = "test_addr0";
+       addr[0].address_length = strlen ("test_addr0") + 1;
+
+       atsi[0].type = htonl(GNUNET_ATS_QUALITY_NET_DELAY);
+       atsi[0].value = htonl(100);
+
+       atsi[1].type = htonl(GNUNET_ATS_QUALITY_NET_DISTANCE);
+       atsi[1].value = htonl(5);
+
+       GNUNET_ATS_address_add (sh, &addr[0], NULL, atsi, ATS_COUNT);
+  GNUNET_ATS_suggest_address (sh, &addr[0].peer);
+
+       memset (&addr[1].peer,'\1', sizeof (addr[1].peer));
+       addr[1].transport_name = "test1";
+       addr[1].address = "test_addr1";
+       addr[1].address_length = strlen ("test_addr1") + 1;
+
+       GNUNET_ATS_address_add (sh, &addr[1], NULL, atsi, ATS_COUNT);
+  GNUNET_ATS_suggest_address (sh, &addr[1].peer);
+  GNUNET_SCHEDULER_add_delayed (SHUTDOWN_CORRECT, &end, NULL);
+}
+
+static void
+run (void *cls, 
+     const struct GNUNET_CONFIGURATION_Handle *mycfg,
+     struct GNUNET_TESTING_Peer *peer)
+{
+  ret = 1;
+  stage = 0;
+  cfg = (struct GNUNET_CONFIGURATION_Handle *) mycfg;
+//  die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
+
+  ph = GNUNET_ATS_performance_init (cfg, &addrinfo_cb, NULL);
+  GNUNET_assert (NULL != ph);
+
+  sh = GNUNET_ATS_scheduling_init (cfg, &ats_suggest_cb, NULL);
+  GNUNET_assert (NULL != sh);
+
+  GNUNET_SCHEDULER_add_delayed (SHUTDOWN_CORRECT, &next, NULL);
+}
+
+
+int
+main (int argc, char *argv[])
+{
+  if (0 != GNUNET_TESTING_peer_run ("test_ats_api_performance_monitor",
+                                   "test_ats_api.conf",
+                                   &run, NULL))
+    return 1;
+  return ret;
+}
+
+/* end of file test_ats_api_performance_feedback.c */

Modified: gnunet/src/ats/test_ats_change_preference.c
===================================================================
--- gnunet/src/ats/test_ats_change_preference.c 2013-08-29 15:14:17 UTC (rev 
28896)
+++ gnunet/src/ats/test_ats_change_preference.c 2013-08-29 15:34:53 UTC (rev 
28897)
@@ -193,7 +193,7 @@
                {
                  /* Changing preference for peer 0 */
                        stage ++;
-                       GNUNET_ATS_change_preference (perf_ats, &p[0].id, 
GNUNET_ATS_PREFERENCE_BANDWIDTH,(double) 1000, GNUNET_ATS_PREFERENCE_END);
+                       GNUNET_ATS_performance_change_preference (perf_ats, 
&p[0].id, GNUNET_ATS_PREFERENCE_BANDWIDTH,(double) 1000, 
GNUNET_ATS_PREFERENCE_END);
                                sug_p0 = GNUNET_NO;
                                sug_p1 = GNUNET_NO;
                        return;

Modified: gnunet/src/ats/test_ats_simplistic_change_preference.c
===================================================================
--- gnunet/src/ats/test_ats_simplistic_change_preference.c      2013-08-29 
15:14:17 UTC (rev 28896)
+++ gnunet/src/ats/test_ats_simplistic_change_preference.c      2013-08-29 
15:34:53 UTC (rev 28897)
@@ -384,20 +384,20 @@
 
 
   /* Change bandwidth preference */
-  GNUNET_ATS_change_preference (perf_ats,
+  GNUNET_ATS_performance_change_preference (perf_ats,
       &p[0].id,
       GNUNET_ATS_PREFERENCE_BANDWIDTH,(double) 1000, 
GNUNET_ATS_PREFERENCE_END);
-  GNUNET_ATS_change_preference (perf_ats,
+  GNUNET_ATS_performance_change_preference (perf_ats,
       &p[1].id,
       GNUNET_ATS_PREFERENCE_BANDWIDTH,(double) 1000, 
GNUNET_ATS_PREFERENCE_END);
 
 
   /* Change latency preference */
 
-  GNUNET_ATS_change_preference (perf_ats,
+  GNUNET_ATS_performance_change_preference (perf_ats,
       &p[0].id,
       GNUNET_ATS_PREFERENCE_LATENCY,(double) 10, GNUNET_ATS_PREFERENCE_END);
-  GNUNET_ATS_change_preference (perf_ats,
+  GNUNET_ATS_performance_change_preference (perf_ats,
       &p[1].id,
       GNUNET_ATS_PREFERENCE_LATENCY,(double) 100, GNUNET_ATS_PREFERENCE_END);
   GNUNET_SCHEDULER_add_delayed (SLEEP, &sleep_task, NULL);

Modified: gnunet/src/ats/test_ats_simplistic_pref_aging.c
===================================================================
--- gnunet/src/ats/test_ats_simplistic_pref_aging.c     2013-08-29 15:14:17 UTC 
(rev 28896)
+++ gnunet/src/ats/test_ats_simplistic_pref_aging.c     2013-08-29 15:34:53 UTC 
(rev 28897)
@@ -193,7 +193,7 @@
                {
                  /* Changing preference for peer 0 */
                        stage ++;
-                       GNUNET_ATS_change_preference (perf_ats, &p[0].id, 
GNUNET_ATS_PREFERENCE_BANDWIDTH,(double) 1000, GNUNET_ATS_PREFERENCE_END);
+                       GNUNET_ATS_performance_change_preference (perf_ats, 
&p[0].id, GNUNET_ATS_PREFERENCE_BANDWIDTH,(double) 1000, 
GNUNET_ATS_PREFERENCE_END);
                                sug_p0 = GNUNET_NO;
                                sug_p1 = GNUNET_NO;
                        return;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]