Skip to content
Open
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
8 changes: 3 additions & 5 deletions doc/concept/moq-lite.md
Original file line number Diff line number Diff line change
Expand Up @@ -375,11 +375,9 @@ without a timescale, each frame stamped with its group's start.
A publisher refuses a group that starts before a lower one, and so does a
moq-lite 07 receiver. A receiver passes on the timestamps it gets over moq-lite
05 and 06 without checking them, since their send times look like media time and
an older group fetched later would look like a rewind. Timestamps received over
moq-transport, whose peers may stamp arrival times, are not checked either. A
relay serves both on over every version. Over moq-lite 07 the
[ietf extension](/draft/moq-ietf) keeps moq-transport ones unchecked; without
it, the receiver checks them and may refuse a group that rewinds.
an older group fetched later would look like a rewind. A relay serves them on
over every version. A moq-transport frame's time is its Group ID, so its
timestamps cannot rewind and are checked like any other.

A publisher may [compress](/concept/compression) a track, which pays off for
repetitive data such as JSON and not for media. Each group's frames become one
Expand Down
4 changes: 1 addition & 3 deletions drafts/draft-lcurley-moq-ietf.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,6 @@ 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 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.

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.
Expand Down Expand Up @@ -193,7 +191,7 @@ The receiver parses the keys inside the Immutable Properties from its value, whi
It SHOULD read them from the value when needed rather than hold them beside it, as a list of IDs can cost several times the value.

A TRACKS_ADD ({{moql}} Tracks Stream) embeds TRACK_INFO without TRACK_PROPERTIES, so when the extension is negotiated a subscriber MUST NOT skip the Track Stream for a track it learned from a listing.
Lacking the Version, a TRACKS_ADD cannot mark a {{moqt}} track's timestamps as unchecked ({{timestamps}}).
Lacking the Version, a TRACKS_ADD cannot say whether the track's Group Streams carry Object Records ({{group}}).


# Security Considerations
Expand Down
1 change: 0 additions & 1 deletion js/net/src/ietf/subscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1647,7 +1647,6 @@ export class Subscriber {
priority: fromWire(ok.properties.priority ?? DEFAULT_WIRE),
// No MAX_CACHE_DURATION sets no publisher limit, not the authored default.
maxAge: maxCacheDuration === undefined ? null : Duration.millis(Number(maxCacheDuration)),
// A moq-transport peer may stamp arrival times, and nothing on the wire says it didn't.
ietf: version,
});
const producer = known ?? staged?.producer;
Expand Down
4 changes: 2 additions & 2 deletions js/net/src/lite/publisher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -607,8 +607,8 @@ test.each([0, 5, 6, 7])("a fetched cached tail keeps absolute indices from %s",
}
});

// An unchecked track's frames go out with their own timestamps, which may be moq-transport
// arrival times, rather than their send time.
// An unchecked (lite-05/06) track's frames go out with their own timestamps, which may be an
// untimed origin's send times, rather than this hop's send time.
test("lite draft-06: an unchecked track's fetched frames carry their own timestamp", async () => {
const pair = createMockTransportPair(ALPN_06);
const origin = new OriginProducer();
Expand Down
29 changes: 23 additions & 6 deletions js/net/src/track.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1053,6 +1053,18 @@ test("an untimed track reads time anchors as keys", () => {
expect(readable(reader)).toEqual([5n, 10n]);
});

// A moq-transport frame's time is its Group ID, so its starts never rewind and index like any.
test("a moq-transport copy resolves a time anchor", () => {
const producer = new TrackProducer("test");
producer.accept({ timescale: Timescale.MILLI, maxAge: null, ietf: IetfVersion.DRAFT_18 });
for (const key of [0n, 1000n, 2000n]) stampGroup(producer, key, Number(key));
const reader = producer.subscribe({
delay: { max: null },
ranges: [{ start: { time: 1500n } }],
});
expect(readable(reader)).toEqual([1000n, 2000n]);
});

test("only unstated minimums aggregate to an unstated one", () => {
const producer = new TrackProducer("test");
producer.subscribe({ delay: { min: null } });
Expand Down Expand Up @@ -4280,11 +4292,12 @@ test("an endless track with gaps remembers only those within the budget", () =>
}
});

for (const [name, extra] of [
["unchecked", { unchecked: true }],
["IETF provenance", { ietf: IetfVersion.DRAFT_22 }],
for (const [name, extra, checked] of [
["unchecked", { unchecked: true }, false],
// A moq-transport frame's time is its Group ID, so it cannot rewind and is checked.
["IETF provenance", { ietf: IetfVersion.DRAFT_22 }, true],
] as const) {
test(`${name} survives normalization and skips the rewind check`, () => {
test(`${name} survives normalization and ${checked ? "keeps" : "skips"} the rewind check`, () => {
for (const timescale of [null, Timescale.MILLI]) {
const info = authoredInfo({ ...extra, timescale });
expect(info).toMatchObject(extra);
Expand All @@ -4293,8 +4306,12 @@ for (const [name, extra] of [
const producer = new TrackProducer("rewind").accept({ timescale: Timescale.MILLI, ...extra });
try {
stampGroup(producer, 0n, 1000);
stampGroup(producer, 1n, 500);
producer.writeFrame({ payload: enc.encode("arrival"), timestamp: Timestamp.fromMillis(250) });
if (checked) {
expect(() => stampGroup(producer, 1n, 500)).toThrow(TimestampMismatch);
} else {
stampGroup(producer, 1n, 500);
producer.writeFrame({ payload: enc.encode("arrival"), timestamp: Timestamp.fromMillis(250) });
}
} finally {
producer.finish();
producer.close();
Expand Down
9 changes: 4 additions & 5 deletions js/net/src/track.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,11 @@ export interface Info {
* one is pending. `0` asks on any join after a delta. An integer in `0..2^32`.
*/
refresh: number | null;
/** The original moq-transport publisher's draft, whose timestamps may rewind. @internal */
/** The original moq-transport publisher's draft. @internal */
ietf?: IetfVersion;
/**
* Whether this copy's groups skip the rewind check, since its timestamps may be lite-05/06 send
* times. An {@link Info.ietf} track skips it too. Mirrors the Rust `track::Info::unchecked`.
* times. Mirrors the Rust `track::Info::unchecked`.
* @internal
*/
unchecked?: boolean;
Expand Down Expand Up @@ -2289,10 +2289,9 @@ export class Producer {
return group;
}

// Whether this track's timestamps may rewind (see {@link Info.unchecked} and {@link Info.ietf}).
// Whether this track's timestamps may rewind (see {@link Info.unchecked}).
#unchecked(): boolean {
const info = this.#state.info.peek();
return info?.unchecked === true || info?.ietf !== undefined;
return this.#state.info.peek()?.unchecked === true;
}

/**
Expand Down
22 changes: 0 additions & 22 deletions quest/m2/ietf-rewind-check.md

This file was deleted.

14 changes: 8 additions & 6 deletions rs/moq-net/src/ietf/subscriber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16917,10 +16917,10 @@ mod stitch_tests {
assert!(h.session.log.closes().is_empty());
}

/// A received group whose first object rewinds past the group before it is accepted: a
/// moq-transport peer may stamp arrival times, so its timed tracks are unchecked.
/// A received group whose first object rewinds past the group before it is refused: a
/// moq-transport frame's time is its Group ID, so its timed tracks are checked like any.
#[kio::test]
async fn a_received_rewind_is_accepted() {
async fn a_received_rewind_is_refused() {
use futures::FutureExt;

let mut h = Harness::new(Fill::Done, vec![draft18_subgroup(KEY, true, 0, &[b"rewound"])]);
Expand All @@ -16935,16 +16935,18 @@ mod stitch_tests {

let mut stream = read_draft18(&h.session).await;
h.subscriber.clone().recv_group(&mut stream).await.unwrap();
// The stream was read to its end, so the group is already delivered.
let mut group = consumer
.recv_group()
.now_or_never()
.expect("delivered")
.unwrap()
.unwrap();
assert_eq!(group.start, KEY);
let frame = group.read_frame().now_or_never().unwrap().unwrap().unwrap();
assert_eq!(frame.payload.as_ref(), b"rewound");
// The group fails, but the track stays open for the groups after it.
assert!(matches!(
group.read_frame().now_or_never().unwrap(),
Err(Error::TimestampMismatch)
));
assert!(h.track.closed().now_or_never().is_none());
}

Expand Down
20 changes: 11 additions & 9 deletions rs/moq-net/src/lite/ietf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1127,9 +1127,9 @@ mod hop_tests {
drop(sessions);
}

/// Every hop carries IETF times, and provenance keeps them unchecked after a hop that
/// negotiated the extension. A peer declining it checks them like native moq-lite, as a
/// listing's copy does. SUBSCRIBE and FETCH must agree with TRACK_INFO.
/// Every hop carries IETF times, and provenance survives a hop that negotiated the
/// extension. A peer declining it, like a listing, sees a native moq-lite track.
/// SUBSCRIBE and FETCH must agree with TRACK_INFO.
#[kio::test]
async fn ietf_timestamps_keep_their_provenance_across_a_hop() {
for offer in [[true, true], [true, false], [false, true]] {
Expand Down Expand Up @@ -1184,19 +1184,21 @@ mod hop_tests {
.await
.unwrap()
.unwrap();
// A peer may have stamped arrival times. The second group's rewind must not
// acquire native moq-lite checks merely because it crossed a negotiated hop;
// without the extension, the copy is checked, so it advances instead.
let start = if negotiated { ts(50) } else { ts(150) };
let mut group = track.create_group(1u64.into()).unwrap();
group.write_frame(start, b"frame".to_vec()).unwrap();
group.write_frame(ts(150), b"frame".to_vec()).unwrap();
group.finish().unwrap();
let mut received = recv(&mut subscriber).await;
assert_eq!(received.start, 1);
let frame = next(&mut received).await.unwrap();
assert_eq!(frame.timestamp, start, "{offer:?}");
assert_eq!(frame.timestamp, ts(150), "{offer:?}");
assert_eq!(&frame.payload.contiguous(0)[..], b"frame");
assert!(next(&mut received).await.is_none());
// Provenance exempts nothing from the rewind check.
let mut rewound = track.create_group(2u64.into()).unwrap();
assert!(matches!(
rewound.write_frame(ts(50), b"frame".to_vec()),
Err(crate::Error::TimestampMismatch)
));
drop(sessions);
}
}
Expand Down
7 changes: 2 additions & 5 deletions rs/moq-net/src/model/resume.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7706,15 +7706,12 @@ mod test {
let mut group = recv(&mut sub);
assert_eq!(read(&mut group), Some(b"held".to_vec()));

// A moq-transport route's copy, whose timestamps are never checked for a rewind.
// A lite-05/06 route's copy, whose timestamps are never checked for a rewind.
let b = track::Producer::new(
Arc::new(broadcast::Info::default()),
"video",
crate::track::Info {
properties: Some(Arc::new(crate::model::object::TrackProperties {
version: crate::ietf::Version::Draft22,
values: Vec::new(),
})),
unchecked: true,
..crate::track::Info::timed()
},
);
Expand Down
10 changes: 2 additions & 8 deletions rs/moq-net/src/model/track.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ pub struct Info {
pub(crate) properties: Option<Arc<crate::model::object::TrackProperties>>,
/// Whether this copy's groups skip the rewind check: set on a lite-05/06 copy, whose
/// untimed origin stamps send times, so an older group fetched later looks like a rewind.
/// A track with moq-transport provenance ([`Self::ietf`]) skips it too.
#[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))]
pub(crate) unchecked: bool,
}
Expand Down Expand Up @@ -305,8 +304,7 @@ impl Info {
}
}

/// The original moq-transport publisher's draft, whose timestamps may rewind, or
/// `None` for a native moq-lite track.
/// The original moq-transport publisher's draft, or `None` for a native moq-lite track.
pub(crate) fn ietf(&self) -> Option<crate::ietf::Version> {
self.properties.as_ref().map(|properties| properties.version)
}
Expand Down Expand Up @@ -1226,11 +1224,7 @@ impl TrackState {
/// Usually one group lookup each way; only unstarted or partial neighbors are skipped.
/// `None` on an [unchecked](Info::unchecked) track, whose timestamps may rewind.
pub(super) fn neighbors(&self, key: u64) -> Option<Neighbors> {
if self
.info
.as_ref()
.is_some_and(|info| info.unchecked || info.ietf().is_some())
{
if self.info.as_ref().is_some_and(|info| info.unchecked) {
return None;
}
let bounds = self.bounds.lock().unwrap_or_else(PoisonError::into_inner);
Expand Down