Matrix just claimed to have done “the world’s first decentralised, end-to-end encrypted (E2EE), multiparty VoIP protocol” and Matthew Hodgson asked to be contradicted in his talk. It is, as usual, a bit more nuanced and requires a decade of history. Thankfully Matthew and I have been bickering in the comment section of Tsahi’s blog for about as long. After this round, we tackle the question of what a distributed SFU looks like and why a federated one is even harder.

The origins of decentralized, end-to-end encrypted calling
Before WebRTC, I was doing chat protocols, in particular XMPP. My approach to WebRTC has always been shaped by that. And keep in mind that WebRTC itself came out of Google Talk and its libjingle project and you can still find references to that name more than a decade later. We had a talk about a federated XMPP call between my application and my friend Lance’s on stage at Realtime Conference back in October of 2013. That sufficiently covers the “decentralised call” part, enabled by the Jingle/XMPP standard back in 2013 – not the “first ever”, calling from Google Talk to an external server already happened back in 2004/2005 when Google released libjingle.
That work directly led to what became Jitsi Meet, one of the most influential open source SFUs out there. I picked XMPP because it offered the infrastructure like authentication and group chats out of the box and we did not have to reinvent the wheel. The architecture remains unchanged more than a decade later even though the implementation has grown a lot more advanced. So we have “multiparty VoIP protocol” covered too, since around 2014.
End-to-end encrypted… guess what, we did that in 2020 on Jitsi Meet. We used a single server so it was not the “world’s first decentralised, end-to-end encrypted (E2EE), multiparty” call but… that is ok. We were just a couple of Jitsi HIPSters after all and even ended up with Olm for the key exchange. But the need for E2EE was not as big.
Fun fact, if you look at Matrix’s media E2EE it is based on LiveKit which in turn is based on the Jitsi implementation, dubbed “JFrame” which technically is not an “open standard” but a fork of an open-source implementation described by a vendor whitepaper. If your “open standard” has de facto a normative dependency on that you have a problem in your definition of a standard.
Distributed SFUs
So now that we have properly scoped the “world’s first decentralised, end-to-end encrypted (E2EE), multiparty VoIP protocol” let’s take a look at the SFU architecture Matrix proposes, which has historical precedent as well. The architecture constraint for MSC4195 given in the blog post is quite clear:
Users send their audio and video to their own server’s SFU. If it doesn’t have one, they use another participant’s.
So in a nutshell your client connects to my server’s SFU to get my audio and video streams over a WebRTC RTCPeerConnection, seen on slide 23 in the deck.
Federated calling is a hard problem and this design already has to acknowledge that: not everyone who runs their own messaging server can run their own SFU there as well.
Distributing SFUs like this is a bit more complicated than picking a single SFU to send to, however. In WebRTC land it means my client has to connect to my SFU and your SFU which means two (or more) RTCPeerConnection objects that then might end up competing for bandwidth (which is why for example Janus switched to making the “multistream” behavior the default).
And you need to answer a lot of questions:
- Picking simulcast layers according to the displayed resolution is a problem that can be solved by the local SFU but it means you need to have a standardized way for your client to signal it to my SFU since WebRTC does not provide that. So assuming both SFUs use LiveKit that depends on whatever protocol LiveKit uses for that.
- Since there is no single server that is calling the shots, how do you approach a problem like “Last-N” and active speaker detection?
- If my connection to your SFU fails but your connection to my SFU works you can see me but I can’t see you… how does that get signalled?
- If I need TURN/TCP or TURN/TLS (assuming you do not have ICE-TCP) who is giving me credentials for the TURN server – your server or my server? Oh and I might want to hide my IP address from your server for privacy reasons.
This looks more like a split brain than something you want your standard to do. Which is probably why the blog post also says this:
Calls can also be pinned to a chosen set of SFUs to reduce points of failure
Cascaded SFUs
For roughly the last decade the state of the art in WebRTC has been the “cascaded” SFU with regional SFUs running close to the user. The 2017 Kranky Geek talk is an early example of this (and I remember giggling and saying “yes, this is exactly how we did it”). The Janus and mediasoup’s documentation both show this as a common building block, forwarding RTP between different SFUs. Jitsi’s OCTO followed up in 2018 – but it took until 2022 to get it right:
This optimizes for a low round-trip time on the lossy network between the user and the first hop which makes many of the recovery mechanisms such as NACK work much better.
But cascaded SFUs require a large geodistributed network of SFUs to run well and deliver on their promise. This requirement is fundamentally at odds with “run your own server” because it favors large server operators that have the money to keep an enormous media infrastructure running. While I would describe this architecture as the dominant one, note that depending on your product you may not need it – for small conferences with local users picking an SFU from a pool works well enough.
Now the “cSFU” part is more extensively covered in Matthew’s “State of the Union” talk than the blog post, see slide 25 or here in the video: there it is called “Cascade” and you might suspect it is just that, Matrix discovered that cascading SFUs are the best thing since fried calamari (to stay with the octopus theme from Jitsi). But instead, in the tradition of complete makeovers, it is based on WebTransport – which still lacks the proper realtime congestion control – and WebCodecs.
Putting that detail aside and assuming this was done over WebRTC let us look at slide 26 where now my server’s SFU talks to your server’s SFU. I only connect to my server’s SFU once so we avoid multiple peer connections and my server (and its operator) is responsible for making sure I can connect, e.g. through TURN.
Getting back to the previous questions, this solves some of them. The principle here is that my server serves my interests and many of them can be solved between my server and my application.
- My server only needs to agree with my application on how it asks for a specific spatial layer.
- My server knows about all connections and media streams I receive and can make decisions like Last-N locally.
- I connect to my server’s SFU. Now my server’s SFU may fail to connect to your server’s SFU but that is rare for server-to-server.
- My server gives me TURN credentials. Whether via XEP-0215 or a “/_matrix/client/v3/voip/turnServer” endpoint is a detail.
If all this were applied to WebRTC this seems like a great and incremental improvement to the existing architecture. But cascading has been the state of the art operation mode for many years so the question here is why Matrix has not been building on it in the first place.
But even cascading does not solve the problem of my server and your server now having to operate a distributed network of media servers for low first hop latency which puts large services (who pay quite a hefty bandwidth price) at an advantage.
Federated Cascaded SFUs
So if we did invent all this in XMPP land (or as we called it at RealtimeConf back in 2013: “The Federated Island of WestRTC”) long ago why don’t we see that deployed more often in the wild, in particular on Jitsi Meet? We tried to standardize some of the things, one of the reasons I found very attractive about the Jitsi Videobridge was that it defined a protocol to let a server (the “conference focus”) control it called “COLIBRI”. We even published a XEP but maintaining both a standard and an implementation while tracking a moving target such as WebRTC is a lot of effort.
But building a product that works in a federated environment is a bit more complicated than that. Let me use simulcast as an example which is a key requirement for delivering good quality in multiparty conferences. You send three simulcast streams to your SFU. Now… what gets sent between the SFUs? The decision simply moves:
- Does my SFU subscribe only to a certain resolution / spatial layer that is displayed on my end?
- Or does my SFU subscribe to all three spatial resolution streams and switch locally?
- Does the decision depend on how many subscribers to the streams your SFU has?
- Last but not least, if it is just the two of us in the call, do we use simulcast? Or do we avoid the SFUs using a technique such as P2P4121? Oh wait, that won’t work with WebTransport which does not do P2P (yet).
Questions such as this are bread and butter but there is no universal answer which is why we have not come up with “the SFU protocol” yet. I doubt Matrix will find one either. E2EE is an orthogonal problem even though it makes trust and media security easier.
And I am not sure the Matrix folks understand the irony of presenting an architecture built on WebTransport and WebCodecs whose development, like the development of WebRTC, is largely funded and driven by “Big Tech” (or as RealtimeConf called the enemy: “the Silos”) that they hang up on in the blog post.
I still have a soft spot for federation and interop that Tsahi wrote a lot about in the early days of WebRTC. These days that topic comes up very rarely, WebRTC made “send a link” the winning model.
{“author”: “Philipp Hancke née Hornsby Cornflower, ambassador of the Federated Island of WestRTC“}








Leave a Reply