<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7652.24">
<TITLE>Erlang RPC over Diameter</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->
<BR>

<P><FONT SIZE=2 FACE="Arial">Given that a number (> 1) of Erlang people are hacking away at </FONT>

<BR><FONT SIZE=2 FACE="Arial">Diameter stacks, what would you think about agreeing on some</FONT>

<BR><FONT SIZE=2 FACE="Arial">derived types for carrying erlang information?</FONT>
</P>

<P><A HREF="http://www.ietf.org/rfc/rfc3588.txt"><U><FONT COLOR="#0000FF" SIZE=2 FACE="Arial">http://www.ietf.org/rfc/rfc3588.txt</FONT></U></A>
</P>

<P><FONT SIZE=2 FACE="Arial">Diameter is an RPC protocol, in that all communication consists</FONT>

<BR><FONT SIZE=2 FACE="Arial">of request-response pairs. Authentication is being standardized,</FONT>

<BR><FONT SIZE=2 FACE="Arial">and the Base Protocol supports end-to-end security via S-MIME.</FONT>

<BR><FONT SIZE=2 FACE="Arial">It can run on TCP or SCTP, it can be proxied, and it's a pretty </FONT>

<BR><FONT SIZE=2 FACE="Arial">efficient byte-coded protocol (a rare treat nowadays.)</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">What's more? It has support for robust client-server communication,</FONT>

<BR><FONT SIZE=2 FACE="Arial">in that the client will resend a request to a standby server if the </FONT>

<BR><FONT SIZE=2 FACE="Arial">first one goes down. And the encoding supports nested data </FONT>

<BR><FONT SIZE=2 FACE="Arial">structures. It also allows for load-balancing.</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">This could be used for loosely connecting Erlang-based nodes </FONT>

<BR><FONT SIZE=2 FACE="Arial">across an open network, but it would probably be wise to agree</FONT>

<BR><FONT SIZE=2 FACE="Arial">on how Erlang data types should be encoded.</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">Different stacks will implement encode/decode differently.</FONT>

<BR><FONT SIZE=2 FACE="Arial">In my stack, a callback module can be designated for </FONT>

<BR><FONT SIZE=2 FACE="Arial">custom types, and are expected to provide a function</FONT>

<BR><FONT SIZE=2 FACE="Arial">for encode & decode respectively:</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">'ETerm'(encode, Term) -> term_to_binary(Term);</FONT>

<BR><FONT SIZE=2 FACE="Arial">'ETerm'(decode, Bin)   -> binary_to_term(Bin).</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">'EInteger'(encode, I) when is_integer(I) -> <<I:32/integer>>;</FONT>

<BR><FONT SIZE=2 FACE="Arial">'EInteger'(decode, <<I:32/integer>>) -> I.</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">... etc.</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">I haven't written a callback for Erlang types yet.</FONT>

<BR><FONT SIZE=2 FACE="Arial">Diameter uses 32-bit aligned objects.</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">One could make it really easy, and encode/decode all</FONT>

<BR><FONT SIZE=2 FACE="Arial">types as ETerm, and have specific types, EInteger, etc.</FONT>

<BR><FONT SIZE=2 FACE="Arial">coded the same way, but restricted to the corresponding</FONT>

<BR><FONT SIZE=2 FACE="Arial">Erlang types.</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">In Diameter parlance, ETerm would be a derived type </FONT>

<BR><FONT SIZE=2 FACE="Arial">based on the base type OctetString, but we would then</FONT>

<BR><FONT SIZE=2 FACE="Arial">add the restriction that it conform to the Erlang Term format.</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">Tuples and lists should perhaps be grouped AVPs:</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">EList ::= < AVP Header : ??? ></FONT>

<BR><FONT SIZE=2 FACE="Arial">              * [ ETerm ]</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">ETuple ::= < AVP Header : ??? ></FONT>

<BR><FONT SIZE=2 FACE="Arial">               { Arity }</FONT>

<BR><FONT SIZE=2 FACE="Arial">             * [ ETerm ]</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">where </FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">Arity would be an AVP of type Unsigned32 (a base type)</FONT>

<BR><FONT SIZE=2 FACE="Arial">and ETerm would be an AVP of type ETerm.</FONT>
</P>
<BR>

<P><FONT SIZE=2 FACE="Arial">... Of course, you could do the same thing with CORBA,</FONT>

<BR><FONT SIZE=2 FACE="Arial">but what would be the point of using something tried and </FONT>

<BR><FONT SIZE=2 FACE="Arial">true?  ;-)</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">At least, Diameter is much more efficient than SOAP.</FONT>
</P>
<BR>

<P><FONT SIZE=2 FACE="Arial">BR,</FONT>

<BR><FONT SIZE=2 FACE="Arial">Ulf W</FONT>
</P>

</BODY>
</HTML>