Re: [MMUSIC] Coding from examples [was Re: I-D Action:draft-ietf-mmusic-ice-tcp-09.txt]

Marc Petit-Huguenin <petithug@acm.org> Fri, 03 September 2010 22:39 UTC

Return-Path: <petithug@acm.org>
X-Original-To: mmusic@core3.amsl.com
Delivered-To: mmusic@core3.amsl.com
Received: from localhost (localhost [127.0.0.1]) by core3.amsl.com (Postfix) with ESMTP id DB0D23A694E for <mmusic@core3.amsl.com>; Fri, 3 Sep 2010 15:39:24 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -100.499
X-Spam-Level:
X-Spam-Status: No, score=-100.499 tagged_above=-999 required=5 tests=[AWL=-0.034, BAYES_00=-2.599, IP_NOT_FRIENDLY=0.334, J_CHICKENPOX_61=0.6, J_CHICKENPOX_63=0.6, J_CHICKENPOX_65=0.6, USER_IN_WHITELIST=-100]
Received: from mail.ietf.org ([64.170.98.32]) by localhost (core3.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id pgInyp9eF+ox for <mmusic@core3.amsl.com>; Fri, 3 Sep 2010 15:39:23 -0700 (PDT)
Received: from server.implementers.org (server.implementers.org [69.55.225.91]) by core3.amsl.com (Postfix) with ESMTP id 63E103A6850 for <mmusic@ietf.org>; Fri, 3 Sep 2010 15:39:23 -0700 (PDT)
Received: by server.implementers.org (Postfix, from userid 1001) id 9C2AEDBCC046; Fri, 3 Sep 2010 22:39:52 +0000 (UTC)
Received: from [192.168.2.3] (server.implementers.org [127.0.0.1]) by server.implementers.org (Postfix) with ESMTPA id C1DCDDBCC044; Fri, 3 Sep 2010 22:39:51 +0000 (UTC)
Message-ID: <4C817937.1080605@acm.org>
Date: Fri, 03 Sep 2010 15:39:51 -0700
From: Marc Petit-Huguenin <petithug@acm.org>
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.11) Gecko/20100805 Iceowl/1.0b1 Icedove/3.0.6
MIME-Version: 1.0
To: Ari Keranen <ari.keranen@nomadiclab.com>
References: <20100902110001.7AC493A68EF@core3.amsl.com> <4C7F8451.8050502@nomadiclab.com> <4C7F97E1.9080704@viagenie.ca> <028201cb4af7$1cc4d3f0$564e7bd0$@com> <4C80EB20.4040007@viagenie.ca> <4C812C2B.5040306@acm.org> <4C815A82.6080405@nomadiclab.com>
In-Reply-To: <4C815A82.6080405@nomadiclab.com>
X-Enigmail-Version: 1.0.1
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
Cc: mmusic@ietf.org
Subject: Re: [MMUSIC] Coding from examples [was Re: I-D Action:draft-ietf-mmusic-ice-tcp-09.txt]
X-BeenThere: mmusic@ietf.org
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: Multiparty Multimedia Session Control Working Group <mmusic.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/listinfo/mmusic>, <mailto:mmusic-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/mmusic>
List-Post: <mailto:mmusic@ietf.org>
List-Help: <mailto:mmusic-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/mmusic>, <mailto:mmusic-request@ietf.org?subject=subscribe>
X-List-Received-Date: Fri, 03 Sep 2010 22:39:25 -0000

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 09/03/2010 01:28 PM, Ari Keranen wrote:
> 3.9.2010 20:11, Marc Petit-Huguenin wrote:
>> On 09/03/2010 05:33 AM, Simon Perreault wrote:
>>> On 2010-09-02 19:32, Dan Wing wrote:
>>>> In any event, if we're going to do a big example, how about
>>>> a real example in draft-ietf-sipping-nat-scenarios, if it
>>>> doesn't have it already?
>>>
>>> I don't care where it is, but we need one. When you're implementing
>>> something, you end up looking longer at examples than at the actual
>>> spec. It really is extremely useful.
>>
>> And, in my opinion, terribly wrong.  I personally would ban all
>> examples from
>> RFC, because at best they are exposing only a subset of what the RFC
>> describe
>> and at worst there is bugs in it, bugs[1] that you will then find in
>> implementations.
> 
> I agree with Simon that an example would be really useful, but I think
> also Marc is right that having it wrong is likely worse than not having
> it at all.
> 
> Since we have a draft (the nat-scenarions one) that is already
> documenting this kind of things, I'd say that would be a better place
> for the example and we can add an informative reference so that
> implementors know where to look at.
> 
> Also, the examples in the nat-scenarios draft should probably be run
> through multiple real implementations and still would need disclaimers
> saying "there are probably errors in the examples, so take a look at the
> errata, etc.", but that's a whole other story..

The way I managed the examples in my recently published RFC[1] is twofold:

1. I refused to add examples to explain something until the normative text
itself was clear enough to in fact make the examples redundant.  Examples are
fine for people that are just interested in vaguely understanding what it is
about but implementers should not look at examples, or at any section titled
"Introduction", "Overview" or "Informative References".  I wish I could somehow
filter this sections automatically when my developers upload RFC from the Internet.

2. I generated automatically the examples in the spec.  I first wrote a
reference implementation[2] of the RFC.  Then I added unit tests to verify that
my reference implementation was correct.  Then finally I wrote the code listed
in [3] that automatically generates the RFC2629 fragments listed in [4],
fragments that are automatically merged in the draft using Xinclude.  Because
the examples were generated each time I built the text version of the draft, I
was sure that the examples were correct - or at least as correct as my reference
implementation.



[1] https://datatracker.ietf.org/doc/rfc5928/
[2] http://debian.implementers.org/stable/source/turnuri.tar.gz
[3]
example("turn:example.net", Arrays.asList(TLS, TCP, UDP), new MockDirContext(
  domain("example.net.",
    record(NAPTR,
      "100 10 \"\" RELAY:turn.udp \"\" datagram.example.net.",
      "200 10 \"\" RELAY:turn.tcp:turn.tls \"\" stream.example.net.")),
  domain("datagram.example.net.",
    record(NAPTR, "100 10 S RELAY:turn.udp \"\" _turn._udp.example.net.")),
  domain("stream.example.net.",
    record(NAPTR,
      "100 10 S RELAY:turn.tcp \"\" _turn._tcp.example.net.",
      "200 10 A RELAY:turn.tls \"\" a.example.net.")),
  domain("_turn._udp.example.net.",
    record(SRV, "0 0 3478 a.example.net.")),
  domain("_turn._tcp.example.net.",
    record(SRV, "0 0 5000 a.example.net.")),
  domain("a.example.net.",
    record(A, "192.0.2.1"))), 1, true);
example("turn:example.com", Arrays.asList(TLS, TCP, UDP), new MockDirContext(
  domain("example.com.",
    record(NAPTR,
      "100 10 \"\" RELAY:turn.udp:turn.tcp:turn.tls \"\" example.net."))), 2,
false);
example("turn:example.net", Arrays.asList(TLS, TCP, UDP), new MockDirContext(
  domain("_turn._udp.example.com.",
    record(SRV, "0 0 3478 a.example.net.")),
  domain("_turn._tcp.example.com.",
    record(SRV, "0 0 5000 a.example.net.")),
  domain("_turns._tcp.example.com.",
    record(SRV, "0 0 5349 a.example.net."))), 3, false);

[4]
<figure anchor="dns-rr1"><artwork><![CDATA[example.net.
IN NAPTR 100 10 "" RELAY:turn.udp "" datagram.example.net.
IN NAPTR 200 10 "" RELAY:turn.tcp:turn.tls "" stream.example.net.

datagram.example.net.
IN NAPTR 100 10 S RELAY:turn.udp "" _turn._udp.example.net.

stream.example.net.
IN NAPTR 100 10 S RELAY:turn.tcp "" _turn._tcp.example.net.
IN NAPTR 200 10 A RELAY:turn.tls "" a.example.net.

_turn._udp.example.net.
IN SRV   0 0 3478 a.example.net.

_turn._tcp.example.net.
IN SRV   0 0 5000 a.example.net.

a.example.net.
IN A     192.0.2.1

]]></artwork></figure>

<figure anchor="dns-rr2"><artwork><![CDATA[example.com.
IN NAPTR 100 10 "" RELAY:turn.udp:turn.tcp:turn.tls "" example.net.
]]></artwork></figure>

<figure anchor="dns-rr3"><artwork><![CDATA[_turn._udp.example.com.
IN SRV   0 0 3478 a.example.net.

_turn._tcp.example.com.
IN SRV   0 0 5000 a.example.net.

_turns._tcp.example.com.
IN SRV   0 0 5349 a.example.net.

]]></artwork></figure>

<texttable anchor="result1"><ttcol>Order</ttcol><ttcol>Protocol</ttcol><ttcol>IP
address</ttcol><ttcol>Port</ttcol><c>1</c><c>UDP</c><c>192.0.2.1</c><c>3478</c><c>2</c><c>TLS</c><c>192.0.2.1</c><c>5349</c><c>3</c><c>TCP</c><c>192.0.2.1</c><c>5000</c></texttable>

- -- 
Marc Petit-Huguenin
Personal email: marc@petit-huguenin.org
Professional email: petithug@acm.org
Blog: http://blog.marc.petit-huguenin.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAkyBeTUACgkQ9RoMZyVa61da/gCglgbaaNooPVm80TfXiUKeCD7P
O48An31V368eY5G4qcf5WE8Yw+xG2Z5q
=Ms1x
-----END PGP SIGNATURE-----