gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r34161 - in gnunet/src: dht include
Date: Sun, 17 Aug 2014 14:07:41 +0200

Author: supriti
Date: 2014-08-17 14:07:41 +0200 (Sun, 17 Aug 2014)
New Revision: 34161

Modified:
   gnunet/src/dht/gnunet-service-xdht_neighbours.c
   gnunet/src/include/gnunet_protocols.h
Log:
Removed trail compression message. Checking for friend to source in trail setup.


Modified: gnunet/src/dht/gnunet-service-xdht_neighbours.c
===================================================================
--- gnunet/src/dht/gnunet-service-xdht_neighbours.c     2014-08-17 11:01:09 UTC 
(rev 34160)
+++ gnunet/src/dht/gnunet-service-xdht_neighbours.c     2014-08-17 12:07:41 UTC 
(rev 34161)
@@ -491,35 +491,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;
-};
-
-
 /**
  * P2P Trail Tear Down message.
  */
@@ -1533,56 +1505,6 @@
 
 
 /**
- * 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 (GET_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);
-
-}
-
-
-/**
  * Search my location in trail. In case I am present more than once in the
  * trail (can happen during trail setup), then return my lowest index.
  * @param trail List of peers
@@ -3107,106 +3029,6 @@
 
 
 /**
- * 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;
-}
-
-
-/**
  * Periodic task to verify current successor. There can be multiple trails to 
reach
  * to successor, choose the shortest one and send verify successor message
  * across that trail.
@@ -3473,7 +3295,7 @@
   struct FingerInfo *existing_finger;
   const struct GNUNET_PeerIdentity *closest_peer;
   struct FingerInfo *successor;
-  int updated_finger_trail_length;
+  //int updated_finger_trail_length;
   unsigned int finger_table_index;
 
   /* Get the finger_table_index corresponding to finger_value we got from 
network.*/
@@ -3521,18 +3343,18 @@
   /* No entry present in finger_table for given finger map index. */
   if (GNUNET_NO == existing_finger->is_present)
   {
-    struct GNUNET_PeerIdentity *updated_trail;
+    //struct GNUNET_PeerIdentity *updated_trail;
 
-    /* Shorten the trail if possible. */
+    /* 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,
+                                             &updated_finger_trail_length);*/
+    add_new_finger (finger_identity, finger_trail,
+                    finger_trail_length,
                     finger_trail_id, finger_table_index);
-    GNUNET_free_non_null(updated_trail);
+    //GNUNET_free_non_null(updated_trail);
     update_current_search_finger_index (finger_identity,
                                         finger_table_index);
     return;
@@ -3551,17 +3373,17 @@
     /* If the new finger is the closest peer. */
     if (0 == GNUNET_CRYPTO_cmp_peer_identity (&finger_identity, closest_peer))
     {
-      struct GNUNET_PeerIdentity *updated_trail;
-      /* Shorten the trail if possible. */
+      //struct GNUNET_PeerIdentity *updated_trail;
+      /* 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);
+                                 &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);
-      GNUNET_free_non_null((struct GNUNET_PeerIdentity *)updated_trail);
+      //GNUNET_free_non_null((struct GNUNET_PeerIdentity *)updated_trail);
     }
     else
     {
@@ -3593,21 +3415,21 @@
         GNUNET_CONTAINER_multipeermap_get (friend_peermap,
                                            &existing_finger->finger_identity))
     {
-      struct GNUNET_PeerIdentity *updated_trail;
+      //struct GNUNET_PeerIdentity *updated_trail;
 
-      /* Shorten the trail if possible. */
+      /* 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);
+                                  &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);
+        select_and_replace_trail (existing_finger, finger_trail,
+                                  finger_trail_length, finger_trail_id);
 
     }
   }
@@ -4159,17 +3981,30 @@
   {   
     trail_length = 0;
   }
-
-  /* Check if you are present in the trail seen so far? */
-  for (i = 0; i < trail_length ; i++)
+  
+  /* Check if you are friend of source. */
+  if (trail_length > 1)
   {
-    if(0 == GNUNET_CRYPTO_cmp_peer_identity(&trail_peer_list[i],&my_identity))
+    if(NULL != GNUNET_CONTAINER_multipeermap_get (friend_peermap, &source))
     {
-      trail_length = i; /* Check that you add yourself again */
-      break;
+      /* If I am a friend, then I can be the first contact, so make
+       trail length 0. We are going to add ourself later in the code.*/
+      trail_length = 0;
     }
   }
-
+  else
+  {
+    /* Check if you are present in the trail seen so far? */
+    for (i = 0; i < trail_length ; i++)
+    {
+      if(0 == 
GNUNET_CRYPTO_cmp_peer_identity(&trail_peer_list[i],&my_identity))
+      {
+        trail_length = i; /* Check that you add yourself again */
+        break;
+      }
+    }
+  }
+  
   /* Is my routing table full?  */
   if (GNUNET_YES == GDS_ROUTING_threshold_reached())
   {
@@ -4225,7 +4060,6 @@
                                             trail_peer_list,
                                             is_predecessor,
                                             final_dest_finger_val,trail_id);
-    
   }
   else /* I'm not the final destination. */
   {
@@ -4249,7 +4083,6 @@
                                        target_friend, trail_length + 1, 
peer_list,
                                        is_predecessor, trail_id,
                                        next_peer.trail_id);
-      GNUNET_free_non_null (peer_list);
     }
     else
         GDS_NEIGHBOURS_send_trail_setup (source,
@@ -5428,88 +5261,6 @@
 }
 
 
-/*
- * 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;
-}
-
-
 /**
  * Core handler for trail teardown message.
  * @param cls closure
@@ -6002,8 +5753,6 @@
     {&handle_dht_p2p_verify_successor_result, 
GNUNET_MESSAGE_TYPE_XDHT_P2P_VERIFY_SUCCESSOR_RESULT, 0},
     {&handle_dht_p2p_notify_new_successor, 
GNUNET_MESSAGE_TYPE_XDHT_P2P_NOTIFY_NEW_SUCCESSOR, 0},
     {&handle_dht_p2p_trail_setup_rejection, 
GNUNET_MESSAGE_TYPE_XDHT_P2P_TRAIL_SETUP_REJECTION, 0},
-    {&handle_dht_p2p_trail_compression, 
GNUNET_MESSAGE_TYPE_XDHT_P2P_TRAIL_COMPRESSION,
-                                        sizeof (struct 
PeerTrailCompressionMessage)},
     {&handle_dht_p2p_trail_teardown, 
GNUNET_MESSAGE_TYPE_XDHT_P2P_TRAIL_TEARDOWN,
                                      sizeof (struct PeerTrailTearDownMessage)},
     {&handle_dht_p2p_add_trail, GNUNET_MESSAGE_TYPE_XDHT_P2P_ADD_TRAIL, 0},

Modified: gnunet/src/include/gnunet_protocols.h
===================================================================
--- gnunet/src/include/gnunet_protocols.h       2014-08-17 11:01:09 UTC (rev 
34160)
+++ gnunet/src/include/gnunet_protocols.h       2014-08-17 12:07:41 UTC (rev 
34161)
@@ -2584,11 +2584,6 @@
 #define GNUNET_MESSAGE_TYPE_XDHT_P2P_ADD_TRAIL 888
 
 /**
- * Trail compression message.
- */
-#define GNUNET_MESSAGE_TYPE_XDHT_P2P_TRAIL_COMPRESSION 889
-
-/**
  * Peer is storing the data in DHT.
  */
 #define GNUNET_MESSAGE_TYPE_XDHT_P2P_PUT 890




reply via email to

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