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

Ari Keranen <ari.keranen@nomadiclab.com> Mon, 06 September 2010 20:44 UTC

Return-Path: <ari.keranen@nomadiclab.com>
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 4D8AA3A6981 for <mmusic@core3.amsl.com>; Mon, 6 Sep 2010 13:44:51 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -1.616
X-Spam-Level:
X-Spam-Status: No, score=-1.616 tagged_above=-999 required=5 tests=[AWL=-0.817, BAYES_00=-2.599, J_CHICKENPOX_61=0.6, J_CHICKENPOX_63=0.6, J_CHICKENPOX_65=0.6]
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 vigLOdKHY0vU for <mmusic@core3.amsl.com>; Mon, 6 Sep 2010 13:44:50 -0700 (PDT)
Received: from gw.nomadiclab.com (unknown [IPv6:2001:14b8:400:101::2]) by core3.amsl.com (Postfix) with ESMTP id 6EDDE3A6976 for <mmusic@ietf.org>; Mon, 6 Sep 2010 13:44:49 -0700 (PDT)
Received: from localhost (localhost [127.0.0.1]) by gw.nomadiclab.com (Postfix) with ESMTP id A98CC4E6E0; Mon, 6 Sep 2010 23:45:16 +0300 (EEST)
X-Virus-Scanned: amavisd-new at nomadiclab.com
Received: from gw.nomadiclab.com ([127.0.0.1]) by localhost (inside.nomadiclab.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id pBvCGtXHghdl; Mon, 6 Sep 2010 23:45:15 +0300 (EEST)
Received: from [127.0.0.1] (localhost [IPv6:::1]) by gw.nomadiclab.com (Postfix) with ESMTP id C991F4E6DF; Mon, 6 Sep 2010 23:45:11 +0300 (EEST)
Message-ID: <4C8552D8.6020503@nomadiclab.com>
Date: Mon, 06 Sep 2010 23:45:12 +0300
From: Ari Keranen <ari.keranen@nomadiclab.com>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; fi; rv:1.9.2.8) Gecko/20100802 Lightning/1.0b2 Thunderbird/3.1.2
MIME-Version: 1.0
To: Marc Petit-Huguenin <petithug@acm.org>
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> <4C817937.1080605@acm.org>
In-Reply-To: <4C817937.1080605@acm.org>
Content-Type: text/plain; charset="UTF-8"; format="flowed"
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: Mon, 06 Sep 2010 20:44:51 -0000

4.9.2010 1:39, Marc Petit-Huguenin wrote:
> 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.

I agree that implementers should not rely on examples, but they can make 
understanding the specs much easier too and can be therefore really 
useful. That said, given how easily errors creep into examples, I'm 
usually a bit reluctant on having really specific examples in something 
as immutable as an RFC.
  > 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.

Nice tool chain you got! Something like that would be good also for the 
examples of ICE TCP if we end up having such in the nat-scenarios draft.


Cheers,
Ari

> [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>