Two weeks ago Philipp Hancke, lead WebRTC developer of Talky and part of the &yet‘s WebRTC consulting team, started a series of posts about detailed examinations he is doing on several major VoIP deployments to see if and how they may be using WebRTC. Please see that post on WhatsApp for some background on the series and below for another great analysis – this time on Facebook Messenger. {“editor”: “chad hart“}
Last week, Facebook announced support for video chats in their Messenger app. Given that Messenger claims to account for 10% of global mobile VoIP traffic, this made in a very interesting target for further investigation. As part of the series of deconstructions, the full analysis (another fifteen pages, using the full range of analysis techniques demonstrated earlier) is available for download here, including the wireshark dumps.
Facebook Messenger is an extremely popular messaging and communications app. It works in Chrome / Firefox and Opera as well as Android and iOS. The mobile versions use the WebRTC.org library and Messenger is optimized heavily for mobile use cases:
- Instead of DTLS, the older SDES encryption scheme is used between mobile clients. While not offering features such as perfect forward secrecy, it provides faster call setup time.
- The audio codec depends on platform and peer. Opus, iSAC and iSAC Low Complexity (LC) are used, with a packetization that prefers fewer, larger packets.
- VP8 is used as video codec on web, iOS and Android. Interestingly, Facebook chose VP8 over H.264 for iOS, even though VP8 has no hardware acceleration capability on Apple iOS devices.
Comparison with WebRTC
Feature | WebRTC/RTCWeb Specifications | Messenger |
SDES | MUST NOT offer SDES | uses SDES between mobile clients, DTLS with browsers |
ICE | RFC 5245 | RFC 5245 with some old google quirks |
TURN usage | used as last resort | TURN and old Google relay |
Audio codec | Opus or G.711 | Opus, iSAC, ISAC Low Complexity |
Video codec | VP8 or H264 | VP8 |
WebRTC fulfilling its promise: No plugins required
Back in 2011, Facebook launched Skype-powered video calling. It used a plugin. The need for a plugin is now gone, probably along with other parts of the integration as described in this announcement. Most platforms are supported without requiring users to install something. WebRTC is starting to fulfill its promise: no plugins needed.
The WebRTC rollout at Facebook has been done gradually, starting in early 2015. Chad Hart was one of the first people to notice in mid-January. I took a quick look and was not very impressed by what I found. Basically it was a simple 1-1 webchat akin to Google’s apprtc sample.
Recently, there has been a lot of news on Facebook’s Messenger. They launched messenger.com as a standalone website with support for voice and video between browsers. As Tsahi Levent-Levi pointed out already, it is using WebRTC.
On the mobile side, the Messenger client had been voice only. Video calling is available in the apps as well. All of this warrants a closer look. With WhatsApp and Messenger coming from the same company, we were expecting similarities, making this report easy. Well… that’s not how it ended up.
It turns out that unlike WhatsApp:
- Messenger uses the webrtc.org library provided by Google
- VP8 video codec is used for video calls
- Choice of the audio codec, which includes ISAC and Opus, varies based on the devices used and the other party in the call
- DTLS is used for encrypting the media between the app and the browsers
- DTLS is not used in calls between two mobile devices (surprisingly)
Mobile
While Messenger looks pretty standard, there are quite a number of optimizations here. Some gems are hidden to anyone glancing through the details. Chrome’s webrtc-internals are easily available and were used in the first scenarios tested. It allows looking at the implementation from a number of different angles, all the way from the captured packets, via the signaling protocol and up to the WebRTC API calls.
The iOS application offers a number of non-standardized codecs. In particular, when calling Chrome the iSAC audio codec will be used. Opus is used with Firefox, which does not implement iSAC. In both cases, the app tweaks the codec usage by sending larger frames than the browser. That is quite an interesting hack reminiscent of the WhatsApp behaviour of switching to a larger packetization. I can only speculate that this may show larger packets to be more robust on wireless networks?
Calls between two mobile devices turn out to be more interesting. Here, the optimizations for calling a browser come to bear fully.
Currently, video calls are only supported between either mobile devices or browsers, which will surely change soon. VP8 is used as the codec.
Unlike WhatsApp, Messenger can be run on multiple devices. So when calling someone who is logged in on multiple devices, all devices ring. This is nice behavior, as it allows the called user to choose where to take the call. This makes a lot more sense than previous approaches, e.g. Google Talk attempting to let the caller determine the recipients “most available device” from a UX point of view. In a world where mobile devices are disconnected frequently and need to be woken up via push messages, this is even more important than it was a decade ago.
Security
The most important takeaway is that instead of using DTLS, Messenger uses the older SDES encryption scheme between two mobile clients. This means media can flow as soon as ICE is done, eliminating a round-trip for the DTLS handshake. This shows a desire to reduce the session startup time, similar to what we saw with WhatsApp.
The widely known downside of that is that the encryption keys are sent via the signaling servers and can be used to retroactively decrypt traffic. Government agencies will surely rejoice at the news of this being applicable to 10% of the mobile VoIP traffic…
{“author”: “Philipp Hancke“}
Art Matsak says
Great analysis. A couple of points:
ISAC. AppRTCDemo for iOS has been preferring ISAC as well up until late November last year. Could there simply be inertia on the part of the Facebook team where they just copied the ISAC preference a while ago?
H.264 on iOS. If the Messenger uses the WebRTC.org library, it should come at no surprise that the video codec is still VP8 because support for H.264 hardware acceleration on iOS is still work in progress.
Steven says
What about the millions that use IE and Safari? Do they have a fallback for them?