|
From: Oredope, A. <ao...@es...> - 2008-02-22 11:09:48
|
Hello Enrico,
Thanks a lot for you help on this. I have been able to play around with
the hash function in which I discovered it parameters had char
properties which is quite small, thus causing repetition. I have change
this to long and also used the system time as a seed to generate random
numbers. Although there some errors while compling (of course!), it
still worked. Please see below the revised code.
static
void hash_function(url_t *url, unsigned long *buf, void *user_data) {
unsigned long ans;
const unsigned long *ptr;
unsigned long tmp_yixuan;
srand(time());
for (ans = 0, ptr = url->url_host; *ptr != '\0'; ptr++)
tmp_yixuan=1+(100000.0*rand()/(RAND_MAX+1.0));
ans ^= (tmp_yixuan + *ptr);
if (url->url_user)
for (ptr = url->url_user; *ptr != '\0'; ptr++)
tmp_yixuan=1+(100000.0*rand()/(RAND_MAX+1.0));
ans ^= (tmp_yixuan + *ptr);
if (url->url_port)
for (ptr = url->url_port; *ptr != '\0'; ptr++)
tmp_yixuan=1+(100000.0*rand()/(RAND_MAX+1.0));
ans ^= (tmp_yixuan + *ptr);
buf[0] = ans;
}
At the moment this is working but there are like one duplicate out of
every 30, which is fair enough for now. I have already now simulate over
200 nodes
Do you think this changes may affect anytime else in the full
architecture? Or is there anything else I am missing or should what out
for?
Thanks a lot again for you help..
Kind Regards
Tola
-----Original Message-----
From: Enrico Marocco [mailto:enr...@te...]
Sent: 21 February 2008 10:34
To: Oredope, Adetola
Cc: sip...@li...
Subject: Re: [Sipdht-devel] SIPDHT Experiments -- with attachment
Oredope, Adetola wrote:
> I am using sipdht-tools-0.4.1 and libsipdht-0.7.0.
> I have actually just done a clean install using the .deb packages on
an
> Ubuntu machine but I'm still encountering the same errors.
> What are your opinions on this?
> Also can please point me to the files responsible for generating the
> nodes and creating the hash?
The hash function used by sipdht is implemented in the C function
"hash_function" in sipdht.c (sipdht-tools), and then set to the peer
through the "sipdht_peer_set_hash_cb" function. How it works is quite
well documented in the "peer" module documentation, available at
http://sipdht.sourceforge.net/api/index.html.
I'd suggest to implement a better hash function (the current one just
sums the char values and then casts the result in 8 bits) and then
replace the current one with it.
--
Ciao,
Enrico
|