gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r34296 - in gnunet/src: dht include


From: gnunet
Subject: [GNUnet-SVN] r34296 - in gnunet/src: dht include
Date: Wed, 17 Sep 2014 23:51:42 +0200

Author: supriti
Date: 2014-09-17 23:51:42 +0200 (Wed, 17 Sep 2014)
New Revision: 34296

Modified:
   gnunet/src/dht/gnunet-service-xdht_neighbours.c
   gnunet/src/dht/gnunet_dht_profiler.c
   gnunet/src/include/gnunet_protocols.h
Log:
Removing trail compression message


Modified: gnunet/src/dht/gnunet-service-xdht_neighbours.c
===================================================================
--- gnunet/src/dht/gnunet-service-xdht_neighbours.c     2014-09-17 19:28:17 UTC 
(rev 34295)
+++ gnunet/src/dht/gnunet-service-xdht_neighbours.c     2014-09-17 21:51:42 UTC 
(rev 34296)
@@ -52,13 +52,6 @@
  * hashing.
  */
 
-
-/**
- * FIXME: URGENT
- * We should have a message type like notify successor result. only when 
- * this message is being recvied by the new successor. we should schedule
- * another round of verify successor. 
- */
 #define DEBUG(...)                                           \
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__)
 
@@ -630,34 +623,7 @@
    */
 };
 
-/**
- * P2P Trail Compression Message.
- */
-struct PeerTrailCompressionMessage
-{
-  /**
-   * Type: #GNUNET_MESSAGE_TYPE_XDHT_P2P_TRAIL_COMPRESSION
-   */
-  struct GNUNET_MessageHeader header;
 
-  /**
-   * Source peer of this trail.
-   */
-  struct GNUNET_PeerIdentity source_peer;
-
-  /**
-   * Trail from source_peer to destination_peer compressed such that
-   * new_first_friend is the first hop in the trail from source to
-   * destination.
-   */
-  struct GNUNET_PeerIdentity new_first_friend;
-
-  /**
-   * Unique identifier of trail.
-   */
-  struct GNUNET_HashCode trail_id;
-};
-
 GNUNET_NETWORK_STRUCT_END
 
 /**
@@ -1480,56 +1446,7 @@
   process_friend_queue (target_friend);
 }
 
-/**
- * Construct a trail compression message and send it to target_friend.
- * @param source_peer Source of the trail.
- * @param trail_id Unique identifier of trail.
- * @param first_friend First hop in compressed trail to reach from source to 
finger
- * @param target_friend Next friend to get this message.
- */
-void
-GDS_NEIGHBOURS_send_trail_compression (struct GNUNET_PeerIdentity source_peer,
-                                       struct GNUNET_HashCode trail_id,
-                                       struct GNUNET_PeerIdentity first_friend,
-                                       struct FriendInfo *target_friend)
-{
-  struct P2PPendingMessage *pending;
-  struct PeerTrailCompressionMessage *tcm;
-  size_t msize;
 
-  msize = sizeof (struct PeerTrailCompressionMessage);
-
-  if (msize >= GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE)
-  {
-    GNUNET_break (0);
-    return;
-  }
-
-  if (target_friend->pending_count >= MAXIMUM_PENDING_PER_FRIEND)
-  {
-    GNUNET_STATISTICS_update (GDS_stats,
-                              gettext_noop ("# P2P messages dropped due to 
full queue"),
-                                                     1, GNUNET_NO);
-  }
-
-  pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize);
-  pending->importance = 0;    /* FIXME */
-  pending->timeout = GNUNET_TIME_relative_to_absolute 
(PENDING_MESSAGE_TIMEOUT);
-  tcm = (struct PeerTrailCompressionMessage *) &pending[1];
-  pending->msg = &tcm->header;
-  tcm->header.size = htons (msize);
-  tcm->header.type = htons (GNUNET_MESSAGE_TYPE_XDHT_P2P_TRAIL_COMPRESSION);
-  tcm->source_peer = source_peer;
-  tcm->new_first_friend = first_friend;
-  tcm->trail_id = trail_id;
-
-  GNUNET_CONTAINER_DLL_insert_tail (target_friend->head, target_friend->tail, 
pending);
-  target_friend->pending_count++;
-  process_friend_queue (target_friend);
-
-}
-
-
 /**
  * Construct a verify successor result message and send it to target_friend
  * @param querying_peer Peer which sent the verify successor message.
@@ -3528,189 +3445,8 @@
   return;
 }
 
-/*
- * Core handle for p2p trail tear compression messages.
- * @param cls closure
- * @param message message
- * @param peer peer identity this notification is about
- * @return #GNUNET_OK on success, #GNUNET_SYSERR on error
- */
-static int
-handle_dht_p2p_trail_compression (void *cls, const struct GNUNET_PeerIdentity 
*peer,
-                                  const struct GNUNET_MessageHeader *message)
-{
-  const struct PeerTrailCompressionMessage *trail_compression;
-  struct GNUNET_PeerIdentity *next_hop;
-  struct FriendInfo *target_friend;
-  struct GNUNET_HashCode trail_id;
-  size_t msize;
 
-  msize = ntohs (message->size);
-
-  if (msize != sizeof (struct PeerTrailCompressionMessage))
-  {
-    GNUNET_break_op (0);
-    return GNUNET_OK;
-  }
-
-  GNUNET_STATISTICS_update (GDS_stats,
-                            gettext_noop
-                            ("# Bytes received from other peers"), msize,
-                            GNUNET_NO);
-  
-  trail_compression = (const struct PeerTrailCompressionMessage *) message;
-  trail_id = trail_compression->trail_id;
-
-  /* Am I the new first friend to reach to finger of this trail. */
-  if (0 == (GNUNET_CRYPTO_cmp_peer_identity 
(&trail_compression->new_first_friend,
-                                             &my_identity)))
-  {
-    if (NULL ==
-         (GNUNET_CONTAINER_multipeermap_get (friend_peermap,
-                                             &trail_compression->source_peer)))
-    {
-      GNUNET_break_op(0);
-      return GNUNET_OK;
-    }
-
-    /* Update your prev hop to source of this message. */
-    if(GNUNET_SYSERR ==
-                  (GDS_ROUTING_update_trail_prev_hop (trail_id,
-                                                      
trail_compression->source_peer)))
-    {
-      GNUNET_break(0);
-      return GNUNET_OK;
-    }
-    return GNUNET_OK;
-  }
-
-  /* Pass the message to next hop to finally reach to new_first_friend. */
-  next_hop = GDS_ROUTING_get_next_hop (trail_id, GDS_ROUTING_SRC_TO_DEST);
-
-  if (NULL == next_hop)
-  {
-    GNUNET_break (0);
-    return GNUNET_OK;
-  }
-
-  if( NULL == (target_friend =
-                 GNUNET_CONTAINER_multipeermap_get (friend_peermap, next_hop)))
-  {
-    GNUNET_break_op(0);
-    return GNUNET_OK;
-  }
-
-  GDS_ROUTING_remove_trail (trail_id);
-
-  GDS_NEIGHBOURS_send_trail_compression (trail_compression->source_peer,
-                                         trail_id,
-                                         trail_compression->new_first_friend,
-                                         target_friend);
-  return GNUNET_OK;
-}
-
-
 /**
- * Scan the trail to check if there is any other friend in the trail other than
- * first hop. If yes then shortcut the trail, send trail compression message to
- * peers which are no longer part of trail and send back the updated trail
- * and trail_length to calling function.
- * @param finger_identity Finger whose trail we will scan.
- * @param finger_trail [in, out] Trail to reach from source to finger,
- * @param finger_trail_length  Total number of peers in original finger_trail.
- * @param finger_trail_id Unique identifier of the finger trail.
- * @return updated trail length in case we shortcut the trail, else original
- *         trail length.
- */
-static struct GNUNET_PeerIdentity *
-scan_and_compress_trail (struct GNUNET_PeerIdentity finger_identity,
-                         const struct GNUNET_PeerIdentity *trail,
-                         unsigned int trail_length,
-                         struct GNUNET_HashCode trail_id,
-                         int *new_trail_length)
-{
-  struct FriendInfo *target_friend;
-  struct GNUNET_PeerIdentity *new_trail;
-  unsigned int i;
-
-  /* I am my own finger. */
-  if (0 == GNUNET_CRYPTO_cmp_peer_identity (&my_identity, &finger_identity))
-  {
-    *new_trail_length = 0;
-    return NULL;
-  }
-
-  if (0 == trail_length)
-  {
-    *new_trail_length = 0;
-    return NULL;
-  }
-
-  /* If finger identity is a friend. */
-  if (NULL != GNUNET_CONTAINER_multipeermap_get (friend_peermap, 
&finger_identity))
-  {
-    *new_trail_length = 0;
-
-    /* If there is trail to reach this finger/friend */
-    if (trail_length > 0)
-    {
-      /* Finger is your first friend. */
-      GDS_ROUTING_update_trail_next_hop (trail_id, finger_identity);
-      GNUNET_assert (NULL !=
-                    (target_friend =
-                     GNUNET_CONTAINER_multipeermap_get (friend_peermap,
-                                                        &trail[0])));
-
-
-      GDS_NEIGHBOURS_send_trail_compression (my_identity,
-                                             trail_id, finger_identity,
-                                             target_friend);
-    }
-    return NULL;
-  }
-
-  /*  For other cases, when its neither a friend nor my own identity.*/
-  for (i = trail_length - 1; i > 0; i--)
-  {
-    /* If the element at this index in trail is a friend. */
-    if (NULL != GNUNET_CONTAINER_multipeermap_get (friend_peermap, &trail[i]))
-    {
-      struct FriendInfo *target_friend;
-      int j = 0;
-
-      GNUNET_assert (NULL !=
-                    (target_friend =
-                     GNUNET_CONTAINER_multipeermap_get (friend_peermap,
-                                                        &trail[0])));
-      GDS_ROUTING_update_trail_next_hop (trail_id, trail[i]);
-      GDS_NEIGHBOURS_send_trail_compression (my_identity,
-                                             trail_id, trail[i],
-                                             target_friend);
-
-
-      /* Copy the trail from index i to index (trail_length -1) into a new 
trail
-       *  and update new trail length */
-      *new_trail_length = trail_length - i;
-      new_trail = GNUNET_malloc (sizeof (struct GNUNET_PeerIdentity) * 
(*new_trail_length));
-      while (i < trail_length)
-      {
-        memcpy (&new_trail[j], &trail[i], sizeof(struct GNUNET_PeerIdentity));
-        j++;
-        i++;
-      }
-      return new_trail;
-    }
-  }
-
-  /* If we did not compress the trail, return the original trail back.*/
-  *new_trail_length = trail_length;
-  new_trail = GNUNET_malloc (sizeof (struct GNUNET_PeerIdentity) * 
trail_length);  
-  memcpy (new_trail, trail, trail_length * sizeof (struct 
GNUNET_PeerIdentity));
-  return new_trail;
-}
-
-
-/**
  * Check if there is already an entry in finger_table at finger_table_index.
  * We get the finger_table_index from 64bit finger value we got from the 
network.
  * -- If yes, then select the closest finger.
@@ -3802,13 +3538,8 @@
   if (GNUNET_NO == existing_finger->is_present)
   {
      /* Shorten the trail if possible. */
-    updated_finger_trail_length = finger_trail_length;
-    updated_trail = scan_and_compress_trail (finger_identity, finger_trail,
-                                             finger_trail_length,
-                                             finger_trail_id,
-                                             &updated_finger_trail_length);
-    add_new_finger (finger_identity, updated_trail,
-                    updated_finger_trail_length,
+    add_new_finger (finger_identity, finger_trail,
+                    finger_trail_length,
                     finger_trail_id, finger_table_index);
     update_current_search_finger_index (finger_table_index);
     return;
@@ -3826,13 +3557,8 @@
     /* If the new finger is the closest peer. */
     if (0 == GNUNET_CRYPTO_cmp_peer_identity (&finger_identity, &closest_peer))
     {
-      updated_finger_trail_length = finger_trail_length;
-      updated_trail = scan_and_compress_trail (finger_identity, finger_trail,
-                                             updated_finger_trail_length,
-                                             finger_trail_id,
-                                             &updated_finger_trail_length);
       remove_existing_finger (existing_finger, finger_table_index);
-      add_new_finger (finger_identity, updated_trail, 
updated_finger_trail_length,
+      add_new_finger (finger_identity, finger_trail, finger_trail_length,
                       finger_trail_id, finger_table_index);
     }
     else
@@ -3860,15 +3586,11 @@
     {
       return;
     }
-    updated_finger_trail_length = finger_trail_length;
-    updated_trail = scan_and_compress_trail (finger_identity, finger_trail,
-                                             finger_trail_length,
-                                             finger_trail_id,
-                                             &updated_finger_trail_length);
+    
     /* If there is space to store more trails. */
     if (existing_finger->trails_count < MAXIMUM_TRAILS_PER_FINGER)
-        add_new_trail (existing_finger, updated_trail,
-                       updated_finger_trail_length, finger_trail_id);
+        add_new_trail (existing_finger, finger_trail,
+                       finger_trail_length, finger_trail_id);
     else
         select_and_replace_trail (existing_finger, updated_trail,
                                   updated_finger_trail_length, 
finger_trail_id);
@@ -6336,8 +6058,6 @@
     {&handle_dht_p2p_trail_setup_rejection, 
GNUNET_MESSAGE_TYPE_XDHT_P2P_TRAIL_SETUP_REJECTION, 0},
     {&handle_dht_p2p_trail_teardown, 
GNUNET_MESSAGE_TYPE_XDHT_P2P_TRAIL_TEARDOWN,
                                      sizeof (struct PeerTrailTearDownMessage)},
-    {&handle_dht_p2p_trail_compression, 
GNUNET_MESSAGE_TYPE_XDHT_P2P_TRAIL_COMPRESSION,
-                                        sizeof (struct 
PeerTrailCompressionMessage)},
     {&handle_dht_p2p_add_trail, GNUNET_MESSAGE_TYPE_XDHT_P2P_ADD_TRAIL, 0},
     {&handle_dht_p2p_notify_succ_confirmation, 
GNUNET_MESSAGE_TYPE_XDHT_P2P_NOTIFY_SUCCESSOR_CONFIRMATION, 
                                       sizeof (struct 
PeerNotifyConfirmationMessage)},

Modified: gnunet/src/dht/gnunet_dht_profiler.c
===================================================================
--- gnunet/src/dht/gnunet_dht_profiler.c        2014-09-17 19:28:17 UTC (rev 
34295)
+++ gnunet/src/dht/gnunet_dht_profiler.c        2014-09-17 21:51:42 UTC (rev 
34296)
@@ -38,9 +38,16 @@
 /**
  * Number of peers which should perform a PUT out of 100 peers
  */
-#define PUT_PROBABILITY 100
+#define PUT_PROBABILITY 20
 
+#if ENABLE_MALICIOUS
 /**
+ * Number of peers which should act as malicious peers
+ */
+#define MALICIOUS_PROBABILITY 50
+
+#endif
+/**
  * Percentage of peers that should act maliciously.
  * These peers will never start PUT/GET request.
  * n_active and n_malicious should not intersect.
@@ -175,9 +182,28 @@
    * The number of peers currently doing GET on our data
    */
   uint16_t nrefs;
+  
+  /**
+   * If set this peer will act maliciously.
+   */
+  unsigned int malicious;
 };
 
+#if ENABLE_MALICIOUS
+struct Malicious_Context
+{
+  /**
+   * The linked peer context
+   */
+  struct Context *ctx;
 
+  /**
+   * Handler to the DHT service
+   */
+  struct GNUNET_DHT_Handle *dht;
+};
+#endif
+
 /**
  * An array of contexts.  The size of this array should be equal to @a 
num_peers
  */
@@ -188,7 +214,14 @@
  */
 static struct ActiveContext *a_ac;
 
+#if ENABLE_MALICIOUS
 /**
+ * Array of malicious peers.
+ */
+static struct MaliciousContext *a_mc;
+#endif
+
+/**
  * The delay between rounds for collecting statistics
  */
 static struct GNUNET_TIME_Relative delay_stats;
@@ -1074,6 +1107,7 @@
 
 
 #if ENABLE_MALICIOUS
+#if 0
 /**
  * Set the malicious variable in peer malicious context.
  */
@@ -1096,6 +1130,7 @@
   }
 }
 #endif
+#endif
 
 
 /**
@@ -1122,7 +1157,7 @@
   if (GNUNET_SCHEDULER_NO_TASK == successor_stats_task && peers_started == 
num_peers)
   {
 #if ENABLE_MALICIOUS
-    set_malicious();
+    //set_malicious();
 #endif
     
      DEBUG("successor_stats_task \n");
@@ -1156,7 +1191,7 @@
 {
   unsigned int cnt;
   unsigned int ac_cnt;
-  
+  unsigned int malicious_peers;
   testbed_handles = peers;  
   if (NULL == peers)
   {
@@ -1175,6 +1210,9 @@
     return;
   }
   
+  a_ac = GNUNET_malloc (n_active * sizeof (struct ActiveContext));
+  ac_cnt = 0;
+  
 #if ENABLE_MALICIOUS
 
   if(PUT_PROBABILITY + MALICIOUS_PEERS > 100)
@@ -1191,16 +1229,30 @@
   /* Select n_malicious peers and ensure that those are not active peers. 
      keep all malicious peer at one place, and call act malicious for all
      those peers. */
+  a_mc = GNUNET_malloc (n_malicious * sizeof (struct MaliciousContext));
+  malicious_peers = 0;
   
+  for (cnt = 0; cnt < num_peers && ac_cnt < n_active; cnt++)
+  {
+    if (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100) >=
+        MALICIOUS_PROBABILITY)
+      continue;
+    a_ac[ac_cnt].malicious = 1;
+    a_mc[ac_cnt].ctx = &a_ctx[cnt];
+    malicious_peers++;
+  } 
+  INFO ("Malicious Peers: %u\n",malicious_peers);
+  
 #endif
   
   a_ac = GNUNET_malloc (n_active * sizeof (struct ActiveContext));
   ac_cnt = 0;
   for (cnt = 0; cnt < num_peers && ac_cnt < n_active; cnt++)
   {
-    if (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100) >=
-        PUT_PROBABILITY)
+    if ((GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 100) >=
+        PUT_PROBABILITY) || (a_ac[ac_cnt].malicious == 1))
       continue;
+    
     a_ctx[cnt].ac = &a_ac[ac_cnt];
     a_ac[ac_cnt].ctx = &a_ctx[cnt];
     ac_cnt++;
@@ -1266,7 +1318,7 @@
      gettext_noop ("number of peers to start"),
      1, &GNUNET_GETOPT_set_uint, &num_peers},
     {'s', "searches", "COUNT",
-     gettext_noop ("maximum number of times we try to search for successor 
circle formation (default is 1)"),
+     gettext_noop ("maximum number of times we try to search for successor 
circle formation (0 for R5N)"),
      1, &GNUNET_GETOPT_set_uint, &max_searches},
     {'H', "hosts", "FILENAME",
      gettext_noop ("name of the file with the login information for the 
testbed"),

Modified: gnunet/src/include/gnunet_protocols.h
===================================================================
--- gnunet/src/include/gnunet_protocols.h       2014-09-17 19:28:17 UTC (rev 
34295)
+++ gnunet/src/include/gnunet_protocols.h       2014-09-17 21:51:42 UTC (rev 
34296)
@@ -2605,15 +2605,10 @@
  * that you got the notify successor message. 
  */
 #define GNUNET_MESSAGE_TYPE_XDHT_P2P_NOTIFY_SUCCESSOR_CONFIRMATION 893
-
-/**
- * Trail Compression
- */
-#define GNUNET_MESSAGE_TYPE_XDHT_P2P_TRAIL_COMPRESSION 894
 
/*******************************************************************************/
 
 /**
- * Next available: 904
+ * Next available: 903
  */
 
 /**




reply via email to

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