PID and CID

Technical discussion about the NMDC and <a href="http://dcpp.net/ADC.html">ADC</A> protocol. The NMDC protocol is documented in the <a href="http://dcpp.net/wiki/">Wiki</a>, so feel free to refer to it.

Moderator: Moderators

Locked
Dolda2000
Posts: 20
Joined: 2003-11-12 20:11
Location: Täby, Sweden
Contact:

PID and CID

Post by Dolda2000 » 2006-12-20 07:31

I'm reading the ADC spec in order to implement it, and I'm just wondering: The spec doesn't appear to contain any rationale for including both a PID and a CID. I can merely guess that the purpose of the PID is for authentication -- is that correct, or is it used in other/more situations?

Furthermore, the spec appears to mandate the use of the MAC address in generating the PID. I might be guessing incorrectly, but the goal is merely it being unique, right? In that case, one should be able to just read 24 bytes from /dev/random instead (or the Windows analogy).

Also, while I'm at it, I'm wondering if there's any specific purpose of defining the SID and its base32-encoded version separately. Is there any particular reason for not just defining it as 4 arbitrary characters instead of a 20-bit number?

ivulfusbar
Posts: 506
Joined: 2003-01-03 07:33

Post by ivulfusbar » 2006-12-20 07:58

The rationale for including both PID and CID is that another client should not be able to steal another client CID. PID is only used in client-->hub communication. The PID is never broadcasted by the hub to other clients. Ofcourse, someone with access to the hub can steal a clients CID by examining the raw data. So PID is only used to create a global ID that should not be to simple to duplicate from a client.

The PID should be unique, and doesn't have to come from the MAC. It should only be an recomendation. The PID should only be created once, and then be used globaly over hubs and over sessions.

We want to use BASE32 for consistency in the SID. Any particular reason more than that? Not much. but 4 chars in base32 should be enough for most hubs.

ullner
Forum Moderator
Posts: 333
Joined: 2004-09-10 11:00
Contact:

Post by ullner » 2006-12-20 08:09

MAC-address is probably because of history;
DCTNG draft wrote:The GUID is calculated as an MD5 (128 bit) hash of the Ethernet MAC address being use plus a timestamp to ensure unicity.

FarCry
Programmer
Posts: 34
Joined: 2003-05-01 10:49

Re: PID and CID

Post by FarCry » 2006-12-20 12:55

Dolda2000 wrote:Also, while I'm at it, I'm wondering if there's any specific purpose of defining the SID and its base32-encoded version separately. Is there any particular reason for not just defining it as 4 arbitrary characters instead of a 20-bit number?
Getting a well-defined specification is unfortunately often not as simple as that. ADC uses utf8 encoding for general text and "4 arbitrary characters" wouldn't necessarily have a 4 byte representation in the stream. I'm sure you will agree that this would unnecessarily complicate the implementation. Base32 is just an alphabet limitation that is already used in other parts of the protocol and comes in handy here. On the bright side, an implementation can just handle the SID as you suggest and the size was intentionally chosen to allow that.

Dolda2000
Posts: 20
Joined: 2003-11-12 20:11
Location: Täby, Sweden
Contact:

Post by Dolda2000 » 2006-12-20 21:30

Thanks for your replies! It all makes sense. I would think they, too, ought to be part of the document, though.

Locked