[dcc2] SIDs and connections to self.
myndzi
myndzi at gmail.com
Sun Jun 27 18:59:59 EDT 2004
I don't like the renaming the index bit every time, but I see how it
would make sense (allow you to store data you initiated or they
initiated in the same table)...
On Sun, 27 Jun 2004 15:29:59 +0200, Szymon Stefanek <pragma at kvirc.net> wrote:
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On Sunday 27 June 2004 09:17, myndzi wrote:
>
> > The other option is simply to ensure that all the required info
> > remains in the message. That way you don't have to "remember"
> > anything, merely react to incoming data. That may be the 'way to go'.
> > Sorry for the mass posting ;P
>
> I guess that the applications WILL always have some private data to remember.
>
> A "mental" schema for implementing the data structure lookup might be the
> following:
>
> You keep a hashtable keyed to the triple (<SID>,<NICK>,<MID>) where <SID> is
> the identifier of the session, <NICK> is the REMOTE nickname and <MID> is the
> lasts message counter SENT.
>
> To initiate a DCC2 handshake to <NICK>:
> - generate a <SID>
> - memorize your data keyed to (<SID>,<NICK>,1) in the hash
> - send the first handshake message by using <SID> and <MID>=1
>
> When you receive a message (<SID>,<MID>) from <NICK> you proceed as follows:
>
> - If <MID>=1 then this is a new session to handle.
> It may have been initiated by a remote party or yourself, but you shouldn't
> care about that. Memorize your data structure keyed to (<SID>,<NICK>,2)
> and continue the handshake by sending a message with that triple.
> - Search the triple <SID>,<MID> - 1 ,<nick> in the hash.
> If you have a match then this is a valid session initiated earlier. If <MID>
> is ODD then the session has been initiated by yourself , otherwise it has
> been initiated by a remote party. Remove the data structure from the hash
> and rememorize it again keyed to (<SID>,<NICK>,<MID>+1). Continue
> the handshake by sending a message with <MID>+1.
> - Error: discard the message.
>
> The bad news is that a remote party can mess up in several ways.
> For example, if it receives a message with MID=1 and sends the reply without
> increasing it (still with MID 1) then you may end up in an infinite loop.
>
> For this reason when you receive a message with (<SID>,<MID> = 1) from <NICK>
> you should perform this additional check:
>
> - If there exists a data structure keyed to (<SID>,<N>,<NICK>) with <N>
> GREATER OR EQUAL to <MID> then:
> - If <NICK> is NOT you, then the message is an error.
> - If <NICK> is you, then:
> - If <N> is EQUAL to <MID> then it is a "dcc-to-self" session.
> - If <N> is GREATER than <MID> you have a bug in your program.
>
> The rules above can be also implemented cleanly using two hashes: one for the
> locally generated sessions and one for the remotely generated. In this case
> the number of lookups increases.
>
> - --
>
> Szymon Stefanek
>
> - ------------------------------------------------------------------------------
> - -
> - - Energy of the gods, adrenaline surge
> - - Won't stop til I hit the ground, I'm on my way for sure
> - - Up here in the air, this will never hurt
> - - I'm on my way to impact, taste the high speed dirt
> - -
> - ------------------------------------------------------------------------------
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.4 (GNU/Linux)
>
> iD8DBQFA3svXRu+qkQYW8QERAnVYAKDUOL/ZYShrcqPgleV5S6NDOCD4bgCfWI2R
> Whev3+Wpuz1yk2qmCYUdndc=
> =cMSv
> -----END PGP SIGNATURE-----
>
>
> _______________________________________________
> dcc2 mailing list
> dcc2 at dcc2.org
> http://six.pairlist.net/mailman/listinfo/dcc2
>
More information about the dcc2
mailing list