Re: [dtn] BPv7 CDDL and CBOR tagging

"Burleigh, Scott C (312B)" <scott.c.burleigh@jpl.nasa.gov> Wed, 10 April 2019 15:07 UTC

Return-Path: <scott.c.burleigh@jpl.nasa.gov>
X-Original-To: dtn@ietfa.amsl.com
Delivered-To: dtn@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 999901202FE for <dtn@ietfa.amsl.com>; Wed, 10 Apr 2019 08:07:51 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.001
X-Spam-Level:
X-Spam-Status: No, score=-2.001 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=jpl.nasa.gov
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 OIv6uR8ga5_P for <dtn@ietfa.amsl.com>; Wed, 10 Apr 2019 08:07:49 -0700 (PDT)
Received: from ppa01.jpl.nasa.gov (ppa01.jpl.nasa.gov [128.149.137.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 1E45C120072 for <dtn@ietf.org>; Wed, 10 Apr 2019 08:07:49 -0700 (PDT)
Received: from pps.filterd (ppa01.jpl.nasa.gov [127.0.0.1]) by ppa01.jpl.nasa.gov (8.16.0.27/8.16.0.27) with SMTP id x3AF4t9C097501; Wed, 10 Apr 2019 08:07:48 -0700
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpl.nasa.gov; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=JPL1810; bh=yELDTRtpvOABfHx8Agh4Xoh9NYE13t2UQuSQYSwkfaE=; b=FZVE6PTLRJrVqpAjU/NxFH1ipuRf6NygMAHH5BAc+rafsrMBGID5paHKzFmaOs2r431C YQlrhq5h2d9IdoOZ0YafnKBJdw8LqKymsDomtTSagSKMYIoav6rC9Mk8Ogz/1JuBxVVV Je+6czRpOxC84HWEEg17WygpqC3pzsQp3mCylyQeLwaImB9RZ1hmNODcKcHb1JKzPOx/ H72U4gyVv2G43AAcqQsjmPia/CxquGHVR8mrZLrweCrNQZ2ppojQTE8IiwKaa05eGOHp soGftr4p+5vtVm/Vv+f69BNgBjfIxc7RaVWL/VkcItHqR/qbBCzXG2Y1qRNMbMtldb21 wA==
Received: from mail.jpl.nasa.gov (altphysenclup01.jpl.nasa.gov [128.149.137.52]) by ppa01.jpl.nasa.gov with ESMTP id 2rs605hyaw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 10 Apr 2019 08:07:47 -0700
Received: from ap-embx16-sp20.RES.AD.JPL (ap-embx16-sp20.jpl.nasa.gov [128.149.137.84]) by smtp.jpl.nasa.gov (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id x3AF7jJA001361 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128 bits) verified FAIL); Wed, 10 Apr 2019 08:07:46 -0700
Received: from ap-embx16-sp10.RES.AD.JPL (2002:8095:8953::8095:8953) by ap-embx16-sp20.RES.AD.JPL (2002:8095:8954::8095:8954) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10; Wed, 10 Apr 2019 08:07:45 -0700
Received: from ap-embx16-sp10.RES.AD.JPL ([fe80::4:f430:47b5:767b]) by ap-embx16-sp10.RES.AD.JPL ([fe80::4:f430:47b5:767b%17]) with mapi id 15.01.1591.008; Wed, 10 Apr 2019 08:07:45 -0700
From: "Burleigh, Scott C (312B)" <scott.c.burleigh@jpl.nasa.gov>
To: Brian Sipos <BSipos@rkf-eng.com>, Carsten Bormann <cabo@tzi.org>
CC: "dtn@ietf.org" <dtn@ietf.org>
Thread-Topic: [dtn] BPv7 CDDL and CBOR tagging
Thread-Index: AQHU7mgWSkg6bBAW40y+wBx08j2w+qYzBqewgAIZFACAAGBIUA==
Date: Wed, 10 Apr 2019 15:07:45 +0000
Message-ID: <77a455395d2c4495986cceeef84edd8e@jpl.nasa.gov>
References: <CY4PR1301MB20399B0DD6B59D2D566257379F570@CY4PR1301MB2039.namprd13.prod.outlook.com> <B8DF4499-2EEC-4680-B1AD-9FEF00A907D7@tzi.org> <6773e0f0e03e6e4ddb935f0f02de7ade2bc606b8.camel@rkf-eng.com> <670af7e65e8c4746947b0833690f4625@jpl.nasa.gov> <1069e920de24c960ca46b3172d99db44802a3b2b.camel@rkf-eng.com>
In-Reply-To: <1069e920de24c960ca46b3172d99db44802a3b2b.camel@rkf-eng.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
x-originating-ip: [207.151.104.72]
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: base64
MIME-Version: 1.0
X-Source-IP: ap-embx16-sp20.jpl.nasa.gov [128.149.137.84]
X-Source-Sender: scott.c.burleigh@jpl.nasa.gov
X-AUTH: Authorized
X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-04-10_06:, , signatures=0
X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 lowpriorityscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1904100107
Archived-At: <https://mailarchive.ietf.org/arch/msg/dtn/gnn7lyicJ0R1okfmXvcQS4cpW7U>
Subject: Re: [dtn] BPv7 CDDL and CBOR tagging
X-BeenThere: dtn@ietf.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: "Delay Tolerant Networking \(DTN\) discussion list at the IETF." <dtn.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/dtn>, <mailto:dtn-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/dtn/>
List-Post: <mailto:dtn@ietf.org>
List-Help: <mailto:dtn-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/dtn>, <mailto:dtn-request@ietf.org?subject=subscribe>
X-List-Received-Date: Wed, 10 Apr 2019 15:07:52 -0000

Brian, thanks, this is great!  I'll insert the revised CDDL and re-post.

I think "total application data unit length" was erroneously deleted from section 4.2.2 a couple of revs back, but it was restored as of version 13 (January).

Scott

-----Original Message-----
From: Brian Sipos <BSipos@rkf-eng.com> 
Sent: Tuesday, April 9, 2019 7:18 PM
To: Burleigh, Scott C (312B) <scott.c.burleigh@jpl.nasa.gov>; Carsten Bormann <cabo@tzi.org>
Cc: dtn@ietf.org
Subject: [EXTERNAL] Re: [dtn] BPv7 CDDL and CBOR tagging

Scott,
At the bottom of this email is a full CDDL that captures both the encodings of extension / administrative data as well as the binding between extension data types and extension block numbers.
I also added restrictions on CRC type code and CRC value data, and used the socket convention and the "-structure" convention from the pre-RFC CDDL draft.

I'll leave up to you to decide if this is an over-specialized use of CDDL. Using the reference "cddl" program to generate randomized data actually produces near-to-reasonable bundles to my eye, which is nice validation of the CDDL itself.

The reference program can be tested as in:
$ gem install cddl
$ cddl bpv7.cddl.txt generate
[[7, 17174, 0, [2, [3026, 451]], [1, 0], [2, [535, 2091]], [4044, 2891], 1070, h'FCDD'], [8, 2593, 229, 2, h'190836', h'C4F3'], [7, 2533, 177, 2, h'820100', h'0504'], [8, 3239, 179, 2, h'1850'], [8, 398, 237, 2, h'183E', h'31261138'], [1, 0, 175, 0, h'8201848481F581F481F481F51901C6820166766F6C75707482190704190CDA',
h'AFA5']]

One issue that I ran into when testing this: I used this CDDL to validate some test bundles which I had been generating separately to test the TCPCL agent. The original CDDL in the draft contains the field name "total-application-data-length" which also appears several times in the draft as "total application data unit length" in the statments.
But I don't see that field listed in Section 4.2.2. Is there a missing field in that section, or is that field no longer present and the other text is inaccurate?

Thanks,
Brian S.

On Tue, 2019-04-09 at 01:24 +0000, Burleigh, Scott C (312B) wrote:
> Guys, please feel free to send me an updated CDDL expression of Bundle 
> Protocol version 7; I will gladly include it in the document.
> 
> My one comment is that the type dtn-time is correctly defined as uint; 
> it should NOT be changed to int, as negative values are not allowed.  
> If you can spot an instance in the spec where dtn-time is 
> characterized as a signed integer, please let me know and I will 
> correct it.
> 
> Scott

start = bundle / #6.55799(bundle)

; Times before 2000 are invalid
dtn-time = uint

; CRC enumerated type
crc-type = 0 / 1 / 2
; Either 16-bit or 32-bit
crc-value = (bstr .size 2) / (bstr .size 4)

creation-timestamp = [dtn-time, sequence: uint]

eid = $eid-choice .within eid-structure
eid-structure = [
  uri-code: uint,
  SSP: any
]
$eid-choice /= [
  uri-code: 1,
  SSP: (tstr / 0)
]
$eid-choice /= [
  uri-code: 2,
  SSP: [
    nodenum: uint,
    servicenum: uint
  ]
]

bundle-control-flags = uint .bits bundleflagbits bundleflagbits = &(
  reserved: 15
  reserved: 14
  reserved: 13
  bundle-deletion-status-reports-are-requested: 12
  bundle-delivery-status-reports-are-requested: 11
  bundle-forwarding-status-reports-are-requested: 10
  reserved: 9
  bundle-reception-status-reports-are-requested: 8
  bundle-contains-a-Manifest-block: 7
  status-time-is-requested-in-all-status-reports: 6
  user-application-acknowledgement-is-requested: 5
  reserved: 4
  reserved: 3
  bundle-must-not-be-fragmented: 2
  payload-is-an-administrative-record: 1
  bundle-is-a-fragment: 0
)

block-control-flags = uint .bits blockflagbits blockflagbits = &(
  reserved: 7
  reserved: 6
  reserved: 5
  reserved: 4
  bundle-must-be-deleted-if-block-cannot-be-processed: 3
  status-report-must-be-transmitted-if-block-cannot-be-processed: 2
  block-must-be-removed-from-bundle-if-it-cannot-be-processed: 1
  block-must-be-replicated-in-every-fragment: 0
)

bundle = [primary-block, *extension-block, payload-block]

primary-block = [
  version: 7,
  bundle-control-flags,
  crc-type,
  destination: eid,
  source-node: eid,
  report-to: eid,
  creation-timestamp,
  lifetime: uint,
  ? (
    fragment-offset: uint,
;    total-application-data-length: uint,
  )
  ? crc-value,
]

; Abstract shared structure of all non-primary blocks canonical-block-structure = [
  block-type-code: uint,
  block-number: uint,
  block-control-flags,
  crc-type,
  ; Each block type defines the content within the bytestring
  block-type-specific-data,
  ? crc-value
]
block-type-specific-data = bstr / #6.24(bstr) ; Extension block type, which does not specialize any more than the code/number extension-block = $extension-block-structure .within canonical-block- structure $extension-block-structure = [
  block-type-code: (uint .gt 1),
  extension-block-number,
  block-control-flags,
  crc-type,
  ($extension-block-data .within block-type-specific-data)
  ? crc-value
]
extension-block-number = (uint .ne 0)
; Payload block type
payload-block = payload-block-structure .within canonical-block- structure payload-block-structure = [
  block-type-code: 1,
  block-number: 0,
  block-control-flags,
  crc-type,
  ($payload-block-data .within block-type-specific-data)
  ? crc-value
]

; Arbitrary payload data
$payload-block-data /= bstr


; Administrative record as a payload data specialization $payload-block-data /= block-type-specific-data .cbor admin-record admin-record = $admin-record .within admin-record-structure admin-record-structure = [
  record-type-code: uint,
  record-content: any
]
; Only one defined record type
$admin-record /= [1, status-record-content] status-record-content = [
  bundle-status-information,
  status-report-reason-code: uint,
  source-node-eid: eid,
  subject-creation-timestamp: creation-timestamp,
  ? (
    subject-payload-offset: uint,
    subject-payload-length: uint
  )
]
bundle-status-information = [
  reporting-node-received-bundle: status-info-content,
  reporting-node-forwarded-bundle: status-info-content,
  reporting-node-delivered-bundle: status-info-content,
  reporting-node-deleted-bundle: status-info-content ] status-info-content = [
  status-indicator: bool,
  ? timestamp: dtn-time
]

; Previous Node extension block
$extension-block-structure /= [
  block-type-code: 7,
  extension-block-number,
  block-control-flags,
  crc-type,
  (block-type-specific-data .cbor ext-data-previous-node)
  ? crc-value
]
ext-data-previous-node = eid

; Bundle Age extension block
$extension-block-structure /= [
  block-type-code: 8,
  extension-block-number,
  block-control-flags,
  crc-type,
  (block-type-specific-data .cbor ext-data-bundle-age)
  ? crc-value
]
ext-data-bundle-age = uint

; Hop Count extension block
$extension-block-structure /= [
  block-type-code: 9,
  extension-block-number,
  block-control-flags,
  crc-type,
  (block-type-specific-data .cbor ext-data-hop-count)
  ? crc-value
]
ext-data-hop-count = [
  hop-limit: uint,
  hop-count: uint
]