MoQT explained
SUBSCRIBE_NAMESPACE & track namespace prefix matching
SUBSCRIBE_NAMESPACE
is how a MoQT client discovers what a relay offers. It carries a
Track Namespace prefix — an ordered tuple such as
["sports"] —
and the relay replies with REQUEST_OK,
then announces every namespace that begins with that prefix using
NAMESPACE
messages, and sends NAMESPACE_DONE
when one of them goes away.
It is not SUBSCRIBE: it finds tracks rather than receiving them. And the
announcements are NAMESPACE messages, not PUBLISH_NAMESPACE — that is a different message, sent by a
publisher to advertise a namespace (see below). Matching is on whole
tuple components, not characters — which is exactly why a namespace is a tuple and not
a flat string.
The flow on this page is drafts 16–23 of draft-ietf-moq-transport. Drafts
07–15 use other message names; see the messages in each draft.
How prefix matching works
A Track Namespace is an ordered tuple of byte-string components. A prefix matches a namespace when the namespace’s leading components equal the prefix, component-for-component:
| SUBSCRIBE_NAMESPACE prefix | Namespace | Match? |
|---|---|---|
| ["sports"] | ["sports","live","game42"] | ✓ |
| ["sports"] | ["sports","vod","game17"] | ✓ |
| ["sports","live"] | ["sports","vod","game17"] | ✗ |
| ["sports"] | ["news","live"] | ✗ |
| [] (empty) | any namespace | ✓ |
Matching is component-wise: prefix ["sports"] does not
match a namespace ["sportsball"] — the first component must be equal,
not merely a string prefix. The empty prefix matches every namespace in drafts 16–23; drafts 08–15
close the session if the prefix is empty.
The discovery flow
TX SUBSCRIBE_NAMESPACE prefix = ["sports"]
RX REQUEST_OK (subscription accepted)
RX NAMESPACE ["live","game42"] ← suffix; prefix ["sports"] stripped
RX NAMESPACE ["vod","game17"]
…later, as namespaces come and go…
RX NAMESPACE ["live","game43"] ← a new matching namespace
RX NAMESPACE_DONE ["vod","game17"] ← this one is withdrawn
The announcements arrive as NAMESPACE messages on the SUBSCRIBE_NAMESPACE
request’s own stream: one for each matching namespace the publisher knows, then more as the set changes.
NAMESPACE_DONE withdraws a namespace that was announced earlier; it never
arrives before that namespace’s NAMESPACE. Both carry only the
suffix — the tuple components after your prefix — since the prefix is already
known from the request. The subscription stays open until you close its stream.
Don't confuse this with PUBLISH_NAMESPACE: that is a distinct message a
publisher sends on its own stream to advertise that it has tracks in a namespace. A relay turns
an authorized upstream PUBLISH_NAMESPACE into downstream
NAMESPACE messages for each subscriber whose prefix matches.
Each announced namespace can then be explored for its individual tracks. Once you know a namespace and a track name, you issue a SUBSCRIBE to actually receive its objects.
SUBSCRIBE_NAMESPACE vs SUBSCRIBE_TRACKS (drafts 18–23)
In drafts 18–23 namespace subscription has two messages:
SUBSCRIBE_NAMESPACE
"Which namespaces exist under this prefix?" You receive NAMESPACE /
NAMESPACE_DONE announcements. Pure discovery — no track data.
SUBSCRIBE_TRACKS
"Subscribe me to the tracks in namespaces under this prefix." The publisher sends a
PUBLISH for each matching track, or PUBLISH_SKIPPED
(drafts 19–23) for a track it will not publish to you.
In drafts 16–17 one SUBSCRIBE_NAMESPACE does both jobs, and its Subscribe
Options field asks for NAMESPACE messages, PUBLISH
messages, or both.
Overlapping prefixes
In draft-23 a subscriber may hold several namespace subscriptions whose prefixes overlap,
say ["sports"] and ["sports","live"]. If a
track matches more than one SUBSCRIBE_TRACKS, the publisher sends a
PUBLISH for each, and each one carries a
SUBSCRIBE_TRACKS_ID parameter naming the request it answers.
In drafts 07–22 the publisher rejects a namespace subscription whose prefix overlaps an
active one in the same session (with PREFIX_OVERLAP in drafts 15–22). In
drafts 18–22 the rule applies to SUBSCRIBE_NAMESPACE and
SUBSCRIBE_TRACKS separately, so one of each may share a prefix.
The messages in each draft
| Drafts | Request | Answer | Namespace announced by | Withdrawn by | To stop |
|---|---|---|---|---|---|
| 07–12 | SUBSCRIBE_ANNOUNCES (0x11) | SUBSCRIBE_ANNOUNCES_OK / _ERROR | ANNOUNCE (full namespace) | UNANNOUNCE | UNSUBSCRIBE_ANNOUNCES |
| 13 | SUBSCRIBE_NAMESPACE (0x11) | SUBSCRIBE_NAMESPACE_OK / _ERROR | ANNOUNCE (full namespace) | UNANNOUNCE | UNSUBSCRIBE_NAMESPACE |
| 14 | SUBSCRIBE_NAMESPACE (0x11) | SUBSCRIBE_NAMESPACE_OK / _ERROR | PUBLISH_NAMESPACE (full namespace) | PUBLISH_NAMESPACE_DONE | UNSUBSCRIBE_NAMESPACE |
| 15 | SUBSCRIBE_NAMESPACE (0x11) | REQUEST_OK / REQUEST_ERROR | PUBLISH_NAMESPACE (full namespace) | PUBLISH_NAMESPACE_DONE | UNSUBSCRIBE_NAMESPACE |
| 16–17 | SUBSCRIBE_NAMESPACE (0x11), on its own stream | REQUEST_OK / REQUEST_ERROR | NAMESPACE (suffix) | NAMESPACE_DONE | Close the stream |
| 18–23 | SUBSCRIBE_NAMESPACE (0x50), on its own stream | REQUEST_OK / REQUEST_ERROR | NAMESPACE (suffix) | NAMESPACE_DONE | Close the stream |
In drafts 07–15 the announcements are the messages a publisher uses to advertise a namespace, and they
carry the full namespace. In drafts 13–15 the publisher also sends matching PUBLISH
messages. In draft-23 a namespace whose parameters change is announced again with a new
NAMESPACE.
Frequently asked questions
What is SUBSCRIBE_NAMESPACE in MoQT?
How does track namespace prefix matching work?
What is the difference between SUBSCRIBE_NAMESPACE and SUBSCRIBE?
What is SUBSCRIBE_TRACKS and how does it relate to SUBSCRIBE_NAMESPACE?
Can I have two namespace subscriptions whose prefixes overlap?
How do I stop a namespace subscription?
Related
- Track Namespace vs Track Name
- The MoQT SUBSCRIBE message, field by field
- Namespace discovery — hands-on moqtap guide
- MoQT control messages overview
- MoQT spec — SUBSCRIBE_NAMESPACE (draft-23, normative text)
- MoQT spec — Subscribing to Namespaces (draft-23)
- MoQT spec — Subscribing to Tracks by Prefix (draft-23)
Discover namespaces on any relay
moqtap peek auto-detects the draft and runs the right discovery
mechanism, listing every namespace and track a relay publishes.