Re: [Spud] SPUD magic number

"Pal Martinsen (palmarti)" <palmarti@cisco.com> Fri, 10 April 2015 07:12 UTC

Return-Path: <palmarti@cisco.com>
X-Original-To: spud@ietfa.amsl.com
Delivered-To: spud@ietfa.amsl.com
Received: from localhost (ietfa.amsl.com [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 2C1E91A009E for <spud@ietfa.amsl.com>; Fri, 10 Apr 2015 00:12:50 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -14.511
X-Spam-Level:
X-Spam-Status: No, score=-14.511 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_HI=-5, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01, USER_IN_DEF_DKIM_WL=-7.5] autolearn=ham
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tLF-E9fBA_Ff for <spud@ietfa.amsl.com>; Fri, 10 Apr 2015 00:12:48 -0700 (PDT)
Received: from alln-iport-6.cisco.com (alln-iport-6.cisco.com [173.37.142.93]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 991891A009B for <spud@ietf.org>; Fri, 10 Apr 2015 00:12:48 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=2978; q=dns/txt; s=iport; t=1428649968; x=1429859568; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-id:content-transfer-encoding: mime-version; bh=8Os5DY4M9F7uHcCaBTx5IfbB0iyCuPxN0ffM8d+Jk94=; b=WUnToR2lrw0asuoqvg3cybz1zozUj/MlQUPftSlfocg81PTsrLdSckTk DIuwvufQMOWlKsnZ3sPdyE3BdVybV0xph6gMf/XkXfQqNZcAvFZVyfx/c MI762uRRc2SxpygbYRwmuT8HEUbmHtwlbullAJotAhHUuFeIrQLUleXqf 8=;
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result: A0BeBACSdidV/51dJa1cgwxSXAWDEMFBCYFECoYBAhyBKDgUAQEBAQEBAX2EHwEBAQMBAQEBIBE6CwULAgEIGAICJgICAiULFRACBA4FiCIIDbdcllcBAQEBAQEBAQEBAQEBAQEBAQEBAQETBIEhigqESTMHgmgvgRYFkQODeIYUgR2PfINMIoIDHIFQb4FEfwEBAQ
X-IronPort-AV: E=Sophos;i="5.11,555,1422921600"; d="scan'208";a="139952946"
Received: from rcdn-core-6.cisco.com ([173.37.93.157]) by alln-iport-6.cisco.com with ESMTP; 10 Apr 2015 07:12:47 +0000
Received: from xhc-aln-x10.cisco.com (xhc-aln-x10.cisco.com [173.36.12.84]) by rcdn-core-6.cisco.com (8.14.5/8.14.5) with ESMTP id t3A7ClFX024430 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=FAIL); Fri, 10 Apr 2015 07:12:47 GMT
Received: from xmb-rcd-x06.cisco.com ([169.254.6.233]) by xhc-aln-x10.cisco.com ([173.36.12.84]) with mapi id 14.03.0195.001; Fri, 10 Apr 2015 02:12:47 -0500
From: "Pal Martinsen (palmarti)" <palmarti@cisco.com>
To: Tom Herbert <tom@herbertland.com>
Thread-Topic: [Spud] SPUD magic number
Thread-Index: AQHQczcRa9I0LYd8BE2BbTGlCFnVEJ1GKN2A
Date: Fri, 10 Apr 2015 07:12:47 +0000
Message-ID: <430F4C7C-7565-48C1-833B-45F9E0D5F6B2@cisco.com>
References: <CALx6S379MDL+dtnncB7J1Xz9xSbgS3gyEyKuQ7NaRNnHvh7E6w@mail.gmail.com>
In-Reply-To: <CALx6S379MDL+dtnncB7J1Xz9xSbgS3gyEyKuQ7NaRNnHvh7E6w@mail.gmail.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
x-originating-ip: [10.61.204.130]
Content-Type: text/plain; charset="utf-8"
Content-ID: <59637933883A774BB5CD89A6C7F37F4A@emea.cisco.com>
Content-Transfer-Encoding: base64
MIME-Version: 1.0
Archived-At: <http://mailarchive.ietf.org/arch/msg/spud/ZGLuBEKIszItt5kjrT9BdQP4nCI>
Cc: "spud@ietf.org" <spud@ietf.org>
Subject: Re: [Spud] SPUD magic number
X-BeenThere: spud@ietf.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: Session Protocol Underneath Datagrams <spud.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/spud>, <mailto:spud-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/spud/>
List-Post: <mailto:spud@ietf.org>
List-Help: <mailto:spud-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/spud>, <mailto:spud-request@ietf.org?subject=subscribe>
X-List-Received-Date: Fri, 10 Apr 2015 07:12:50 -0000

> On 10 Apr 2015, at 04:35, Tom Herbert <tom@herbertland.com> wrote:
> 
> Hi,
> 
> The SPUD magic number seems like a good idea and in fact I anticipate
> that we'll want to adopt this technique in other UDP encapsulation
> protocols.
> 
+1

STUN (RFC5389) also uses this trick in section 6 (https://tools.ietf.org/html/rfc5389#section-6)

> I believe the magic number could be applied in two different ways:
> 
> 1) A middlebox must match both the UDP destination port and the magic
> number before accepting the packet is SPUD protocol. In this case ,
> the magic number is used to distinguish SPUD from other arbitrary uses
> of a SPUD assigned port.
> 2) A middlebox matches the magic number in any UDP packet regardless
> of destination port and declares it to be SPUD. This is nice because
> we would not need to configure SPUD ports on middleboxes, but
> increases the chances of misinterpreting something which is not SPUD
> at all (a larger magic number size might be warranted).
> 
> What is the intended use for this in the SPUD prototype protocol?
> 
This was actually the first bet we implemented (https://github.com/iptube/SPUDlib). Mostly due to your 2) bullet point. 

It allowed us to quickly get a linux router with netfiletr/iptables up and running with the following rule:

-A PREROUTING -p udp —match u32 --u32 "0>>22&0x3C@8=0xd80000d8" -j NFQUEUE --queue-num 0

See https://github.com/iptube/TubeNode for a quick and dirty implementation.

From a client perspective lessons learned from implementing ICE and STUN where RTP, STUN and vide variety of other packets might be multiplexed on the same port was that having a simple isSPUD function is really useful..

In the spud prototype it is defined like this:

bool spud_is_spud(const uint8_t *payload, size_t length)
{
    if (length < sizeof(spud_header)) {
        return false;
    }
    return (memcmp(payload, (void *)SpudMagicCookie, SPUD_MAGIC_COOKIE_SIZE) == 0);
}

.-.
Pål-Erik

> Thanks,
> Tom
> 
> _______________________________________________
> Spud mailing list
> Spud@ietf.org
> https://www.ietf.org/mailman/listinfo/spud