Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions doc/concept/standard.md

Large diffs are not rendered by default.

13 changes: 3 additions & 10 deletions drafts/draft-lcurley-moq-ietf.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,26 +135,19 @@ A relay forwards the block to a peer of that encoding unchanged, so the block ne
Every property of the object, serialized as the track's Version serializes an object's properties, in ascending ID order.
Immutable Properties (0x0b) are in the same encoding, as the publisher sent them.
It MUST NOT be empty or longer than 65,536 bytes.
On a timed track an object with a FRAME MUST NOT carry one longer than 65,526 bytes, leaving room for the largest Timestamp a relay restates ([Timestamps](#timestamps)): a one-byte key and a value of up to nine bytes.
A relay MUST refuse a {{moqt}} object whose properties, less its mutable Timestamp, exceed that, so every object it forwards fits.
A receiver MUST treat a block the track's Version would refuse as malformed, as it MUST a block on an object that Version could not send with properties.
Only draft 14 lets a status object carry them, so a block on the END_OF_GROUP record needs a Version of draft 14.
The Version also gives each property its meaning: drafts 18 and 19 serialize a block alike, but only drafts 19 and later assign property 0x06 to SUBGROUP_DELIVERY_TIMEOUT, so a relay knows not to forward a 0x06 to a draft that would read it differently.
Other properties are opaque to this extension.

## Timestamps {#timestamps}
A relay MUST preserve a relayed track's Timescale and timestamps across a negotiated hop.
A nonzero Version identifies timestamps from MoQ Transport, which may be arrival times and need not rise with Group Sequence.
A nonzero Version identifies a track from MoQ Transport, whose objects take their time from their Group ID, in the track's Timescale.
The receiver MUST NOT apply moq-lite's group-start rewind check to such a track; a Version of zero retains that check.
Without this extension, or in a listing ({{track}}), the receiver may check them like native moq-lite timestamps and refuse a Group that rewinds.

On a timed track, the FRAME's Timestamp is the object's time, and nothing else carries it.
The Property Block MUST NOT contain a mutable Timestamp (0x10) there; a receiver MUST treat one as malformed.
A relay forwarding the object to {{moqt}} restates the time as the mutable Timestamp, unless a Timestamp inside the Immutable Properties already says it.
A sealed Timestamp is in the track's Timescale ({{moql}} TRACK_INFO), and a relay MUST NOT forward one to a peer of other units, which would change its meaning.

On an untimed track there is no FRAME Timestamp, so a mutable Timestamp stays in the Property Block as an opaque property.
Likewise, the END_OF_GROUP record has no FRAME and so no time of its own beside the block, so its mutable Timestamp stays there on any track.
The FRAME's Timestamp is the object's time.
A Timestamp property (0x10) a {{moqt}} publisher attached, mutable or sealed, is opaque like any other: it stays in the Property Block, and a relay neither reads nor restates it.


# Track Stream {#track}
Expand Down
163 changes: 46 additions & 117 deletions drafts/draft-lcurley-moq-timestamp.md

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions js/crypto/src/e2ee/transport.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,16 @@ async function active(origin: Origin.Producer, path: Path.Valid): Promise<Broadc
}
}

// Whether the wire carries the route's instance, and the track's timestamps. Neither is
// authenticated, so the frames open either way.
// Whether the wire carries the route's instance, and whether a frame's time is its group's
// key, as on moq-transport, rather than its own timestamp. Neither is authenticated, so the
// frames open either way.
const transports = [
["moq-lite-07", "moq-lite-07-wip", true, true],
["moq-lite-05", "moq-lite-05", false, true],
["moq-lite-07", "moq-lite-07-wip", true, false],
["moq-lite-05", "moq-lite-05", false, false],
["moq-transport-18", "moqt-18", false, true],
] as const;

for (const [name, protocol, routed, timed] of transports) {
for (const [name, protocol, routed, keyed] of transports) {
test(`${name}: grouped frames roundtrip encrypted`, async () => {
const { publisher, subscriber, close } = await session(protocol);
const cred = credential();
Expand Down Expand Up @@ -89,7 +90,7 @@ for (const [name, protocol, routed, timed] of transports) {
expect(received.sequence).toBe(0n);
const first = await received.readFrame();
expect(decoder.decode(first?.plaintext)).toBe("keyframe");
expect(first?.timestamp?.as(Time.Timescale.MILLI)).toBe(timed ? 1 : undefined);
expect(first?.timestamp?.as(Time.Timescale.MILLI)).toBe(keyed ? 0 : 1);
expect(decoder.decode((await received.readFrame())?.plaintext)).toBe("delta");

// Later frames on the open group, and a second group.
Expand Down
5 changes: 0 additions & 5 deletions js/net/src/connection/handshake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export async function exchangeSetup(
solicit: boolean | undefined;
declaredSolicit: boolean;
hidden: boolean;
maxAge: boolean;
activeCount: boolean;
cluster: Ietf.Cluster.Hops;
peerImplementation: string | undefined;
Expand All @@ -53,7 +52,6 @@ export async function exchangeSetup(
Ietf.implementationIntoSetup(params, implementation);
if (solicit) Ietf.solicitIntoSetup(params);
Ietf.hiddenIntoSetup(params);
Ietf.maxAgeIntoSetup(params);
Ietf.activeCountIntoSetup(params);
// Only a client presents a connection credential.
if (client && token) Ietf.tokenIntoSetup(params, { kind: Ietf.TOKEN_OUT_OF_BAND, value: token });
Expand Down Expand Up @@ -85,7 +83,6 @@ export async function exchangeSetup(
solicit: received.solicit,
declaredSolicit: solicit,
hidden: received.hidden,
maxAge: received.maxAge,
activeCount: received.activeCount,
cluster: { self, peer: received.cluster },
peerImplementation: received.implementation,
Expand Down Expand Up @@ -115,7 +112,6 @@ async function receiveSetup(
early: Reader[];
solicit: boolean | undefined;
hidden: boolean;
maxAge: boolean;
activeCount: boolean;
cluster: Hop | undefined;
implementation: string | undefined;
Expand Down Expand Up @@ -178,7 +174,6 @@ async function receiveSetup(
early,
solicit: Ietf.solicitFromSetup(setup.parameters),
hidden: Ietf.hiddenFromSetup(setup.parameters),
maxAge: Ietf.maxAgeFromSetup(setup.parameters),
activeCount: Ietf.activeCountFromSetup(setup.parameters),
cluster: Ietf.Cluster.fromSetup(setup.parameters),
implementation: Ietf.implementationFromSetup(setup.parameters),
Expand Down
4 changes: 0 additions & 4 deletions js/net/src/ietf/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ export class Connection implements Session {
solicit,
declaredSolicit = true,
hidden = false,
maxAge = false,
activeCount = false,
cluster,
handle,
Expand All @@ -147,8 +146,6 @@ export class Connection implements Session {
declaredSolicit?: boolean;
/** Whether the peer understands the HIDDEN parameter (MoQ Hidden). */
hidden?: boolean;
/** Whether the peer accepts subscriber max age. */
maxAge?: boolean;
/** Whether both SETUPs declared MoQ Active Count. */
activeCount?: boolean;
/**
Expand Down Expand Up @@ -211,7 +208,6 @@ export class Connection implements Session {
this.#declaredSolicit = declaredSolicit;
this.#cluster = cluster;
this.#subscriber = new Subscriber({
maxAge,
session: this.#session,
quic,
cluster,
Expand Down
22 changes: 19 additions & 3 deletions js/net/src/ietf/datagram.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Timescale, Timestamp } from "../time.ts";
import { Budget } from "../util/yield.ts";
import { wireOf } from "../wire.ts";
import { Connection } from "./connection.ts";
import { ObjectDatagram } from "./datagram.ts";
import { encodeDatagram, ObjectDatagram } from "./datagram.ts";
import { ALPN, type IetfVersion, Version } from "./version.ts";

const ALL: IetfVersion[] = [Version.DRAFT_18, Version.DRAFT_20, Version.DRAFT_22];
Expand Down Expand Up @@ -39,6 +39,20 @@ test("roundtrips on every draft", async () => {
}
});

test("a published datagram carries no properties, a timed one included", async () => {
for (const version of ALL) {
const bytes = await encodeDatagram(
{ sequence: 42n, timestamp: Timestamp.fromMillis(1234), payload: new TextEncoder().encode("hello") },
{ trackAlias: 3n, publisherPriority: 7 },
version,
);
expect(bytes[0]).toBe(0x06); // end of group, object 0, no properties
expect(await ObjectDatagram.decode(bytes, version)).toEqual(
new ObjectDatagram({ ...single(7), properties: undefined }),
);
}
});

test("an explicit object id and a status", async () => {
const datagram = new ObjectDatagram({
trackAlias: 1n,
Expand Down Expand Up @@ -160,7 +174,8 @@ test("a datagram track round-trips over moq-transport", async () => {
datagrams.insert({ sequence: 4n, timestamp: Timestamp.fromMillis(9), payload: new Uint8Array([7]) });
const received = await reader.recv();
expect(received?.sequence).toBe(4n);
expect(received?.timestamp?.asMillis()).toBe(9);
// No Timestamp goes out, so its time is its sequence in the track's units.
expect(received?.timestamp?.asMillis()).toBe(4);
expect(received?.payload).toEqual(new Uint8Array([7]));
datagrams.finish();
// The end waits out the grace a late datagram gets.
Expand Down Expand Up @@ -218,7 +233,8 @@ test("a relay shares one IETF subscription across stream and datagram readers",
group.finish();
const received = await reader.recv();
expect(received?.payload).toEqual(Uint8Array.of(7));
expect(received?.timestamp?.asMillis()).toBe(9);
// Its sequence in the stream track's TIMESCALE, which the datagrams share.
expect(received?.timestamp?.asMillis()).toBe(4);
const receivedGroup = await subscriber.recvGroup();
expect((await receivedGroup?.readFrame())?.payload).toEqual(Uint8Array.of(8));
receivedGroup?.close();
Expand Down
13 changes: 3 additions & 10 deletions js/net/src/ietf/datagram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
import type { Datagram } from "../datagram.ts";
import { error, ProtocolViolation, reason } from "../error.ts";
import { type Cursor, encodeVarint, Reader } from "../stream.ts";
import type { Timescale } from "../time.ts";
import { encodeObjectExtensions } from "./object.ts";
import type { IetfVersion } from "./version.ts";

// The bits of an OBJECT_DATAGRAM Type.
Expand Down Expand Up @@ -44,7 +42,7 @@ export class ObjectDatagram {
publisherPriority?: number;
/** No Object past this one exists in the group. */
endOfGroup: boolean;
/** The Object Properties block without its length prefix, which carries the Timestamp. */
/** The Object Properties block without its length prefix. */
properties?: Uint8Array;
body: DatagramBody;

Expand Down Expand Up @@ -120,23 +118,18 @@ export class ObjectDatagram {

/**
* Encode a datagram the way a publisher sends it: Object 0 of a group that has no other, so it
* ends its group, stamped in `timescale` units when the subscription declared one.
* ends its group, without properties.
*/
export async function encodeDatagram(
datagram: Datagram,
options: { trackAlias: bigint; publisherPriority: number; timescale?: Timescale },
options: { trackAlias: bigint; publisherPriority: number },
version: IetfVersion,
): Promise<Uint8Array> {
const properties =
options.timescale !== undefined
? encodeObjectExtensions(datagram.timestamp, options.timescale, version)
: undefined;
return new ObjectDatagram({
trackAlias: options.trackAlias,
groupId: datagram.sequence,
publisherPriority: options.publisherPriority,
endOfGroup: true,
properties: properties?.byteLength ? properties : undefined,
body: { payload: datagram.payload },
}).encode(version);
}
Expand Down
Loading