> > Hi,
> > 
> > GtkG's current TODO file states that horizon size estimation is to be
> > implemented into GtkG 0.94.
> > 
> > Luckily, I have already implemented the HSEP 0.2 core functionality
> > for GtkG. 
> 
> OK, I'll 'assign' the task to you then. This should avoid others doing 
> this task.

I'm not familiar with the GUI stuff, though. Perhaps someone else
could add a "horizon" panel to the GUI, which displays the reachable
hosts/files/KiB in a table? For testing purposes, we might be happy
with the console output for a while, so that would be a lower
priority.

> > Integration into GtkG is still incomplete (and GUI
> > integration for displaying HSEP data is completely missing), but
> > integration is probably not a big problem for the main developers. The
> > to-do parts are marked with "TODO:". Additionally, the handshaking
> > checks for HSEP compatibility need to be added (it seems that
> > "X-Features:" is not yet used for Gnet connection handshaking in GtkG
> > yet). The source file needs to be added to the Makefile(s), too.
> 
> I'll implement the X-Features part for GNet connection handshaking.

Great, thanks!

> > If someone could look at the patches and files and would
> > check/adapt/correct/modify them to get it running, this would be
> > great. I managed to get the stuff working on my home LAN and it seemed
> > to work correctly with a couple of nodes (but without handshaking
> > checks, little-endian-only support, etc.).
> 
> Please create your diff with the option -u for example:
> diff -uR gtk-gnutella-hep gtk-gnutella-current
> 
> This will create a universal diff

Right, sorry about that. I have attached the universal diff of my
changes.


Greetings,
Thomas.
Index: gnutella.h
===================================================================
RCS file: /cvsroot/gtk-gnutella/gtk-gnutella-current/src/gnutella.h,v
retrieving revision 1.108
diff -u -r1.108 gnutella.h
--- gnutella.h  18 Jul 2003 05:05:14 -0000      1.108
+++ gnutella.h  11 Feb 2004 16:55:58 -0000
@@ -69,6 +69,25 @@
     guint32 _v = htonl(v); memcpy(a, &_v, 4); \
 } G_STMT_END
 
+// TODO: review these 64-bit defines
+// Something seems to be wrong here
+
+#define READ_GUINT64_LE(a,v) G_STMT_START { \
+    memcpy(&v, a, 8); v = GUINT64_FROM_LE(v); \
+} G_STMT_END
+
+#define READ_GUINT64_BE(a,v) G_STMT_START { \
+    memcpy(&v, a, 8); v = (guint64)ntohl((u_long)v)<<(guint64)32 | 
(guint64)htonl((u_long)(v>>32)); \
+} G_STMT_END
+
+#define WRITE_GUINT64_LE(v,a) G_STMT_START { \
+    guint64 _v = GUINT64_TO_LE(v); memcpy(a, &_v, 8); \
+} G_STMT_END
+
+#define WRITE_GUINT64_BE(v,a) G_STMT_START { \
+    guint64 _v = (guint64)htonl((u_long)v)<<(guint64)32 | 
(guint64)htonl((u_long)(v>>32U)); memcpy(a, &_v, 8); \
+} G_STMT_END
+
 /*
  * Constants
  */
@@ -82,6 +101,7 @@
 #define GTA_MSG_PUSH_REQUEST                   0x40
 #define GTA_MSG_SEARCH                                 0x80
 #define GTA_MSG_SEARCH_RESULTS                 0x81
+#define GTA_MSG_HSEP_DATA                              0xcd
 
 #define GTA_MSGV_QRP_RESET                             0x00
 #define GTA_MSGV_QRP_PATCH                             0x01
@@ -200,6 +220,11 @@
 struct gnutella_msg_vendor {
        struct gnutella_header header;
        struct gnutella_vendor data;
+} __attribute__((__packed__));
+
+struct gnutella_msg_hsep_data {
+       struct gnutella_header header;
+       /* payload follows */
 } __attribute__((__packed__));
 
 /* main.c */
Index: main.c
===================================================================
RCS file: /cvsroot/gtk-gnutella/gtk-gnutella-current/src/main.c,v
retrieving revision 1.185
diff -u -r1.185 main.c
--- main.c      14 Jan 2004 20:52:32 -0000      1.185
+++ main.c      11 Feb 2004 16:55:59 -0000
@@ -62,6 +62,7 @@
 #include "clock.h"
 #include "eval.h"
 #include "pproxy.h"
+#include "hsep.h"
 
 #ifdef USE_REMOTE_CTRL
 #include "shell.h"
@@ -350,6 +351,7 @@
                parq_upload_timer(now);         /* PARQ upload timeouts/removal */
                upload_timer(now);                      /* Upload timeouts */
         file_info_timer();          /* Notify about changes */
+               hsep_timer();                           /* HSEP notify message timer */
                pproxy_timer(now);                      /* Push-proxy requests */
        }
        socket_timer(now);                              /* Expire inactive sockets */
@@ -535,6 +537,7 @@
        crc_init();
        hostiles_init();
        parq_init();
+       hsep_init();
        clock_init();
 
     main_gui_init();
Index: nodes.c
===================================================================
RCS file: /cvsroot/gtk-gnutella/gtk-gnutella-current/src/nodes.c,v
retrieving revision 1.317
diff -u -r1.317 nodes.c
--- nodes.c     18 Jan 2004 19:15:55 -0000      1.317
+++ nodes.c     11 Feb 2004 16:56:02 -0000
@@ -63,6 +63,7 @@
 #include "token.h"
 #include "hostiles.h"
 #include "clock.h"
+#include "hsep.h"
 
 #include "settings.h"
 #include "override.h"          /* Must be the last header included */
@@ -1065,6 +1066,10 @@
                        n->n_ping_sent, n->n_pong_received, n->n_pong_sent);
        }
 
+    // TODO: only do the following if node is HSEP-capable
+    
+    hsep_connection_deinit(n);
+
        if (n->routing_data)
                routing_node_remove(n);
 
@@ -2451,6 +2456,14 @@
        }
 
        /*
+        * Initialize connection's HSEP data and
+        * send first HSEP message.
+        * TODO: only do the following if node is HSEP-capable
+        */
+
+       hsep_connection_init(n);
+
+       /*
         * If we're an Ultranode, we're going to monitor the queries sent by
         * our leaves and by our neighbours.
         */
@@ -4335,6 +4348,10 @@
                        n->n_bad++;
                }
                break;
+       case GTA_MSG_HSEP_DATA:
+               // TODO: check HSEP capability of peer servent
+               // log HSEP msgs from non-HSEP servents
+               break;
        default:                                        /* Unknown message type - we 
drop it */
                drop = TRUE;
         gnet_stats_count_dropped(n, MSG_DROP_UNKNOWN_TYPE);
@@ -4427,6 +4444,9 @@
                        node_extract_host(n, &ip, &port);
                        host_add_semi_pong(ip, port);
                }
+               break;
+       case GTA_MSG_HSEP_DATA:
+               hsep_process_msg(n);
                break;
        default:
                break;
Index: nodes.h
===================================================================
RCS file: /cvsroot/gtk-gnutella/gtk-gnutella-current/src/nodes.h,v
retrieving revision 1.95
diff -u -r1.95 nodes.h
--- nodes.h     12 Jan 2004 21:48:35 -0000      1.95
+++ nodes.h     11 Feb 2004 16:56:02 -0000
@@ -31,6 +31,7 @@
 #include "sq.h"
 #include "rx.h"
 #include "qrp.h"
+#include "hsep.h"
 
 /*
  * This structure keeps tracks of remote flow-control indications and
@@ -202,6 +203,14 @@
        guint32 tx_queries;                     /* Total amount of queries sent */
        guint32 rx_qhits;                       /* Total amount of hits received */
        guint32 tx_qhits;                       /* Total amount of hits sent */
+
+       /*
+        * Horizon size estimation (HSEP) -- TSC, 11/02/2004.
+        */
+
+        hsep_triple hsep_table[HSEP_N_MAX+1];
+        time_t hsep_last_received;
+        time_t hsep_last_sent;
 } gnutella_node_t;
 
 /*
@@ -240,6 +249,7 @@
 #define NODE_A_ULTRA           0x00000040      /* Node wants to be an Ultrapeer */
 #define NODE_A_NO_ULTRA                0x00000080      /* Node is NOT ultra capable */
 
+#define NODE_A_CAN_HSEP                0x04000000      /* Node supports HSEP */
 #define NODE_A_CAN_QRP         0x08000000      /* Node supports query routing */
 #define NODE_A_CAN_VENDOR      0x10000000      /* Node supports vendor messages */
 #define NODE_A_CAN_GGEP                0x20000000      /* Node supports big pongs, 
etc.. */
Index: routing.c
===================================================================
RCS file: /cvsroot/gtk-gnutella/gtk-gnutella-current/src/routing.c,v
retrieving revision 1.72
diff -u -r1.72 routing.c
--- routing.c   20 Jan 2004 08:38:15 -0000      1.72
+++ routing.c   11 Feb 2004 16:56:03 -0000
@@ -330,6 +330,7 @@
        case GTA_MSG_PUSH_REQUEST:
        case GTA_MSG_BYE:
        case GTA_MSG_QRP:
+       case GTA_MSG_HSEP_DATA:
        case GTA_MSG_STANDARD:
        case GTA_MSG_VENDOR:            /* When a non-blank random GUID is needed */
                guid_random_muid(header->muid);

Reply via email to