Astro~/0.3
** Conformance / Time Code Formats * PAGE 21 / 23
** Astro * Conformance
** /conformance/tcf

Time Code Formats

Coverage matrix: what pkg/tcf implements from CCSDS 301.0-B-4, and what it does not.

Coverage matrix for pkg/tcf, CCSDS 301.0-B-4

CCSDS 301.0-B-4 ships no PICS proforma. It is a format definition standard, not a protocol with a conformance annex, so there is no official table to fill in. What follows is a coverage matrix written against the normative text: each row names a feature, the clause that defines it, and what this package does with it.

Rows marked derived were checked against the standard's text rather than a published test vector, because the standard publishes none for that item. The distinction matters: a derived row is one implementer's reading, and a round-trip test cannot tell you it is wrong.


A. General information

Implementationgithub.com/ravisuhag/astro/pkg/tcf
StandardCCSDS 301.0-B-4, Time Code Formats
ScopeEncoding and decoding of the four time code formats, with the P-field and bare T-field forms
Not in scopeTime correlation, clock discipline, and onboard time management, none of which this standard defines

B. P-field

FeatureClauseStatusNotes
First octet: extension flag, 3-bit ID, 4 detail bitsclause 3.2.2 and per-formatYPField
Second octet when the extension flag is setclause 3.2.2Y7 detail bits
Implicit P-field (bare T-field):YEncodeTField, DecodeCUCTField, DecodeCDSTField, DecodeCCSTField. The standard permits an agreed format without a preamble; the octet counts, variant, and epoch are then caller-supplied.
Time code ID 001, CUC Level 1clause 3.2YTimeCodeCUCLevel1
Time code ID 010, CUC Level 2clause 3.2YTimeCodeCUCLevel2
Time code ID 100, CDSclause 3.3YTimeCodeCDS; level from detail bit 4
Time code ID 101, CCSclause 3.4YTimeCodeCCS; Level 1 only
Unrecognised time code ID-YErrInvalidTimeCodeID
Implicit P-field (bare T-field)-YEncodeTField, DecodeCUCTField, DecodeCDSTField, DecodeCCSTField. The standard permits an agreed format without a preamble; the octet counts, variant, and epoch are then caller-supplied.

C. CUC, Unsegmented Time Code (clause 3.2)

FeatureClauseStatusNotes
Coarse time, 1-4 basic octetsclause 3.2.2YWithCUCCoarseBytes
Fine time, 0-3 basic octetsclause 3.2.2YWithCUCFineBytes
Extension octet: additional coarse (2 bits), additional fine (3 bits)clause 3.2.2YCoarse to 7 octets, fine to 10
Reserved bits 6-7 of the extension octetclause 3.2.2YA non-zero value is rejected
Out-of-range octet countsclause 3.2.2YErrInvalidCoarseOctets, ErrInvalidFineOctets
Level 1, CCSDS epoch, 1958-01-01 TAIclause 3.2YCoarse count is true TAI seconds: the offset in effect at the encoded instant is added on encode and removed on decode
Level 2, agency-defined epochclause 3.2YPurely arithmetic, no leap-second correction. WithCUCEpoch; ErrEpochRequired if omitted
Coarse value exceeding the configured widthclause 3.2.2YErrOverflow
Fine-time wire fidelity across an encode/decode cycleclause 3.2.2YFine octets are preserved as transmitted, not re-derived from a rounded duration

D. CDS, Day Segmented Time Code (clause 3.3)

FeatureClauseStatusNotes
Day segment, 16-bitclause 3.3.2YWithCDSDayBytes(2)
Day segment, 24-bitclause 3.3.2YWithCDSDayBytes(3)
Milliseconds of day, 0-86399999clause 3.3.2YErrInvalidMilliseconds outside range
Sub-millisecond absent (code 00)clause 3.3.2YWithCDSSubmsBytes(0)
Sub-millisecond microseconds (code 01, 2 octets)clause 3.3.2YWithCDSSubmsBytes(2)
Sub-millisecond picoseconds (code 10, 4 octets)clause 3.3.2YWithCDSSubmsBytes(4)
Reserved sub-millisecond code 11clause 3.3.2YRejected with ErrReservedSubmsCode
Sub-millisecond value outside the declared resolutionclause 3.3.2YErrInvalidSubmilliseconds
Extension flag on a CDS P-fieldclause 3.3.2YThe CDS P-field is a single octet; a set extension flag is rejected
Level 1 and Level 2 epochsclause 3.3YWithCDSEpoch
Leap secondsclause 3.3N/ADay and millisecond counting is purely arithmetic. The fields act as a UTC day and time-of-day label; no leap-second table is applied.

E. CCS, Calendar Segmented Time Code (clause 3.4)

FeatureClauseStatusNotes
Month/Day variant (detail bit 4 = 0)clause 3.4.2YWithCCSMonthDay
Day-of-Year variant (detail bit 4 = 1)clause 3.4.2YDefault
BCD encoding of every segmentclause 3.4.1Y
Upper 4 bits of the year's first octet are zeroclause 3.4.1.2YEnforced on encode and decode
Non-BCD nibble (value above 9)clause 3.4.1YErrInvalidBCD
Sub-second octets, 0-6clause 3.4.2YWithCCSSubSecBytes; each octet holds two decimal digits
Second value 60 (the leap second)clause 3.4YAccepted and flagged; Time() normalizes it, because Go's time.Time cannot represent second 60
Calendar field range checksclause 3.4.1YMonth 1-12, day of month 1-31, day of year 1-366, hour 0-23, minute 0-59; ErrInvalidCalendarTime
Cross-checks between calendar fieldsclause 3.4.1YDerived: the standard gives per-field ranges; consistency between them is checked here as a decoder safeguard
Level 2clause 3.4N/ACCS is Level 1 UTC only, by definition

F. ASCII time codes (clause 3.5)

FeatureClauseStatusNotes
Type A, YYYY-MM-DDThh:mm:ss.d...dZclause 3.5.1.1YASCIITypeA
Type B, YYYY-DDDThh:mm:ss.d...dZclause 3.5YASCIITypeB
Fractional seconds, 1-9 digitsclause 3.5YWithASCIIPrecision; default 3
Optional Z terminatorclause 3.5YAccepted on decode, written on encode
Fixed field widths and mandatory separatorsclause 3.5YDecode enforces the subset strictly and rejects anything ISO 8601 allows but clause 3.5 does not
Second 60clause 3.5YAccepted only at 23:59:60
P-fieldclause 3.5N/AASCII codes carry no P-field

G. Time scales and leap seconds

FeatureStatusNotes
Integer TAI-UTC offset tableYEmbedded in leapseconds.go; TAIUTCOffsetAt(t) returns the offset in effect at any instant. The values are historical facts and cannot change.
Current offsetY37 s from 2017-01-01. No leap second has been announced since.
Pre-1972 eraPartialUTC used fractional "rubber second" adjustments with no integer representation. TAI and UTC are treated as identical (offset 0). TAI counts falling inside the 10-second step at 1972-01-01 do not round-trip exactly. Documented limitation.
An instant inside a leap secondPartialA CUC Level 1 count landing on UTC 23:59:60 decodes to the following 00:00:00. Go's time.Time cannot represent second 60. Documented limitation.
Future leap secondsNNot predictable. A new IERS announcement needs a one-line addition to leapseconds.go.

H. Not implemented

ItemReason
Time correlation and clock disciplineNot defined by this standard
Agency-specific epoch registriesA mission supplies its own epoch through WithCUCEpoch or WithCDSEpoch
P-field octets beyond the secondNone are defined by CCSDS 301.0-B-4

I. Verification

The conformance regressions live in pkg/tcf/audit_test.go, tagged TCF-n per defect. They cover the TAI-UTC table against its historical values, CUC Level 1 leap-second handling, CUC Level 2 arithmetic behaviour, fine-time wire fidelity, the rejected P-field extension bit, the reserved CDS sub-millisecond code, CCS BCD and calendar validation, strict ASCII decoding, bare T-field round trips, and overflow guards on large coarse and day values.

pkg/tcf/fuzz_test.go fuzzes the decoders: arbitrary bytes must never panic and never allocate from a length field an attacker controls.

Reference