[DGD] Developing a network daemon

bart at wotf.org bart at wotf.org
Wed Sep 9 22:57:31 CEST 2009


On Wed, 9 Sep 2009 12:46:55 -0700, Shentino wrote

> * Lack of knowhow implementing a decent multiplexer

While to me this doesn't seem too difficult, I don't think trying to multiplex
connections is a good idea, at least not initially. 

<braindump>
What you do need is a control channel that is not easily snooped, provided you
have that, having the network daemon create a new connection to dgd for every
inbound/outbound connection you need seems to be much easier to implement, and
should have less trouble taking advantage of dgd-mp. Multiplexing tends to get
in the way for receiving input from multiple connections in parallel.

When a new connection is made, the network daemon can request a 'secret' over
the secure control channel, create a new connection to dgd, and use the secret
it just heard to authenticate that.

No multiplexing needed.

If you do want to use multiplexing still, you'll have to encapsulate network
traffic between the network daemon and dgd into some message format that also
contains the appropriate 'session' info so both the network daemon and dgd can
tell what connection it belongs to.

For practical reasons, I'd encapsulate the traffic in json messages,
containing a list of [ int connection_id, int sequence_number, string message ]

Both on the dgd side you'll need a mapping between connection ids and
(simulated) user objects that handle each connection. On the network daemon
side you'll need a map between connection ids and connections.

Since you'll likely be using tcp for this, you can probably do without the
sequence numbers, but I tend to find them useful when having to refer to a
specific message (for example for error reporting/logging purposes)

To me this would be a practical approach because parsers/generators for JSON
are readily available for most languages, including dgd's lpc dialect, and it
makes it very easy to extend your protocol later on without having to redesign
the message format and parsers/generators.

That said, what you need is simple enough that a very simple string based
format would do the job.
</braindump>

Bart.
--
Created with Open WebMail at http://www.bartsplace.net/
Read my weblog at http://soapbox.bartsplace.net/




More information about the DGD mailing list