-help seaspider some more
[oweals/gnunet.git] / src / fs / gnunet-service-fs_cp.h
index c9485f23b80ea4052f9397715964452150c73329..e3c7cd2278259a8525aece2f1dfc30c062483bfd 100644 (file)
 #include "gnunet-service-fs.h"
 
 
+/**
+ * Maximum number of outgoing messages we queue per peer.
+ *
+ * Performance measurements for 2 peer setup for 50 MB file
+ * (with MAX_DATASTORE_QUEUE = 1 and RETRY_PROBABILITY_INV = 1):
+ *
+ *   2: 1700 kb/s, 1372 kb/s
+ *   8: 2117 kb/s, 1284 kb/s, 1112 kb/s
+ *  16: 3500 kb/s, 3200 kb/s, 3388 kb/s
+ *  32: 3441 kb/s, 3163 kb/s, 3277 kb/s
+ * 128: 1700 kb/s; 2010 kb/s, 3383 kb/s, 1156 kb/s
+ *
+ * Conclusion: 16 seems to be a pretty good value (stable
+ * and high performance, no excessive memory use).
+ */
+#define MAX_QUEUE_PER_PEER 16
+
+/**
+ * Length of the P2P success tracker.  Note that having a very long
+ * list can also hurt performance.
+ */
+#define P2P_SUCCESS_LIST_SIZE 8
+
+/**
+ * Length of the CS-2-P success tracker.  Note that
+ * having a very long list can also hurt performance.
+ */
+#define CS2P_SUCCESS_LIST_SIZE 8
+
+
 /**
  * Performance data kept for a peer.
  */
@@ -39,7 +69,7 @@ struct GSF_PeerPerformanceData
   /**
    * Transport performance data.
    */
-  struct GNUNET_TRANSPORT_ATS_Information *atsi;
+  struct GNUNET_ATS_Information *atsi;
 
   /**
    * List of the last clients for which this peer successfully
@@ -62,6 +92,13 @@ struct GSF_PeerPerformanceData
    */
   struct GNUNET_TIME_Relative avg_reply_delay;
 
+  /**
+   * If we get content we already have from this peer, for how
+   * long do we block him?  Adjusted based on the fraction of
+   * redundant data we receive, between 1s and 1h.
+   */
+  struct GNUNET_TIME_Relative migration_delay;
+
   /**
    * Point in time until which this peer does not want us to migrate content
    * to it.
@@ -110,10 +147,6 @@ struct GSF_PeerPerformanceData
    */
   unsigned int pending_replies;
 
-  /**
-   * How many of the last blocks from migration were duplicates?
-   */
-  unsigned int migration_duplication;
 };
 
 
@@ -140,8 +173,8 @@ typedef void (*GSF_ConnectedPeerIterator) (void *cls,
  * @param buf where to copy the message, NULL on error (peer disconnect)
  * @return number of bytes copied to 'buf', can be 0 (without indicating an error)
  */
-typedef size_t (*GSF_GetMessageCallback) (void *cls,
-                                          size_t buf_size, void *buf);
+typedef size_t (*GSF_GetMessageCallback) (void *cls, size_t buf_size,
+                                          void *buf);
 
 
 /**
@@ -168,13 +201,13 @@ struct GSF_PeerTransmitHandle;
  *
  * @param peer identity of peer that connected
  * @param atsi performance data for the connection
+ * @param atsi_count number of records in 'atsi'
  * @return handle to connected peer entry
  */
-struct GSF_ConnectedPeer *GSF_peer_connect_handler_ (const struct
-                                                     GNUNET_PeerIdentity *peer,
-                                                     const struct
-                                                     GNUNET_TRANSPORT_ATS_Information
-                                                     *atsi);
+struct GSF_ConnectedPeer *
+GSF_peer_connect_handler_ (const struct GNUNET_PeerIdentity *peer,
+                           const struct GNUNET_ATS_Information *atsi,
+                           unsigned int atsi_count);
 
 
 /**
@@ -183,8 +216,8 @@ struct GSF_ConnectedPeer *GSF_peer_connect_handler_ (const struct
  * @param peer peer's identity
  * @return NULL if this peer is not currently connected
  */
-struct GSF_ConnectedPeer *GSF_peer_get_ (const struct GNUNET_PeerIdentity
-                                         *peer);
+struct GSF_ConnectedPeer *
+GSF_peer_get_ (const struct GNUNET_PeerIdentity *peer);
 
 
 /**
@@ -201,13 +234,10 @@ struct GSF_ConnectedPeer *GSF_peer_get_ (const struct GNUNET_PeerIdentity
  * @param gmc_cls closure for gmc
  * @return handle to cancel request
  */
-struct GSF_PeerTransmitHandle *GSF_peer_transmit_ (struct GSF_ConnectedPeer *cp,
-                                                   int is_query,
-                                                   uint32_t priority,
-                                                   struct GNUNET_TIME_Relative
-                                                   timeout, size_t size,
-                                                   GSF_GetMessageCallback gmc,
-                                                   void *gmc_cls);
+struct GSF_PeerTransmitHandle *
+GSF_peer_transmit_ (struct GSF_ConnectedPeer *cp, int is_query,
+                    uint32_t priority, struct GNUNET_TIME_Relative timeout,
+                    size_t size, GSF_GetMessageCallback gmc, void *gmc_cls);
 
 
 /**
@@ -215,7 +245,8 @@ struct GSF_PeerTransmitHandle *GSF_peer_transmit_ (struct GSF_ConnectedPeer *cp,
  *
  * @param pth request to cancel
  */
-void GSF_peer_transmit_cancel_ (struct GSF_PeerTransmitHandle *pth);
+void
+GSF_peer_transmit_cancel_ (struct GSF_PeerTransmitHandle *pth);
 
 
 /**
@@ -256,26 +287,6 @@ GSF_peer_update_responder_peer_ (struct GSF_ConnectedPeer *cp,
                                  *initiator_peer);
 
 
-/**
- * Method called whenever a given peer has a status change.
- *
- * @param cls closure
- * @param peer peer identity this notification is about
- * @param bandwidth_in available amount of inbound bandwidth
- * @param bandwidth_out available amount of outbound bandwidth
- * @param timeout absolute time when this peer will time out
- *        unless we see some further activity from it
- * @param atsi status information
- */
-void
-GSF_peer_status_handler_ (void *cls,
-                          const struct GNUNET_PeerIdentity *peer,
-                          struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
-                          struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
-                          struct GNUNET_TIME_Absolute timeout,
-                          const struct GNUNET_TRANSPORT_ATS_Information *atsi);
-
-
 /**
  * Handle P2P "MIGRATION_STOP" message.
  *
@@ -284,6 +295,7 @@ GSF_peer_status_handler_ (void *cls,
  *        for loopback messages where we are both sender and receiver)
  * @param message the actual message
  * @param atsi performance information
+ * @param atsi_count number of records in 'atsi'
  * @return GNUNET_OK to keep the connection open,
  *         GNUNET_SYSERR to close it (signal serious error)
  */
@@ -291,8 +303,8 @@ int
 GSF_handle_p2p_migration_stop_ (void *cls,
                                 const struct GNUNET_PeerIdentity *other,
                                 const struct GNUNET_MessageHeader *message,
-                                const struct GNUNET_TRANSPORT_ATS_Information
-                                *atsi);
+                                const struct GNUNET_ATS_Information *atsi,
+                                unsigned int atsi_count);
 
 
 /**
@@ -306,34 +318,31 @@ GSF_handle_p2p_migration_stop_ (void *cls,
  * @param message the actual message
  * @return pending request handle, NULL on error
  */
-struct GSF_PendingRequest *GSF_handle_p2p_query_ (const struct
-                                                  GNUNET_PeerIdentity *other,
-                                                  const struct
-                                                  GNUNET_MessageHeader
-                                                  *message);
+struct GSF_PendingRequest *
+GSF_handle_p2p_query_ (const struct GNUNET_PeerIdentity *other,
+                       const struct GNUNET_MessageHeader *message);
 
 
 /**
  * Return the performance data record for the given peer
- * 
+ *
  * @param cp peer to query
  * @return performance data record for the peer
  */
-struct GSF_PeerPerformanceData *GSF_get_peer_performance_data_ (struct
-                                                                GSF_ConnectedPeer
-                                                                *cp);
+struct GSF_PeerPerformanceData *
+GSF_get_peer_performance_data_ (struct GSF_ConnectedPeer *cp);
 
 
 /**
  * Ask a peer to stop migrating data to us until the given point
  * in time.
- * 
+ *
  * @param cp peer to ask
  * @param block_time until when to block
  */
 void
 GSF_block_peer_migration_ (struct GSF_ConnectedPeer *cp,
-                           struct GNUNET_TIME_Relative block_time);
+                           struct GNUNET_TIME_Absolute block_time);
 
 
 /**
@@ -354,7 +363,8 @@ GSF_peer_disconnect_handler_ (void *cls,
  *
  * @param lc handle to the local client (henceforth invalid)
  */
-void GSF_handle_local_client_disconnect_ (const struct GSF_LocalClient *lc);
+void
+GSF_handle_local_client_disconnect_ (const struct GSF_LocalClient *lc);
 
 
 /**
@@ -388,19 +398,22 @@ GSF_connected_peer_get_identity_ (const struct GSF_ConnectedPeer *cp,
  * @param it function to call for each peer
  * @param it_cls closure for it
  */
-void GSF_iterate_connected_peers_ (GSF_ConnectedPeerIterator it, void *it_cls);
+void
+GSF_iterate_connected_peers_ (GSF_ConnectedPeerIterator it, void *it_cls);
 
 
 /**
  * Initialize peer management subsystem.
  */
-void GSF_connected_peer_init_ (void);
+void
+GSF_connected_peer_init_ (void);
 
 
 /**
  * Shutdown peer management subsystem.
  */
-void GSF_connected_peer_done_ (void);
+void
+GSF_connected_peer_done_ (void);
 
 
 #endif