How does ChatRoulette work – the RTMFP protocol

Disclaimer – I’ve never used chatlroulette and have no intention of starting. But I was curious about the technology under it. Has Flash finally enabled some way of direct peer-to-peer streaming of data? And it appears that this is the case.

The RTMFP protocol is a version of Adobe’s earlier streaming protocol called RTMP. RTMFP uses UDP datagrams, which are not guaranteed to be delivered, as TCP ones are. But this is fine for live streaming apps, since data from a second ago is already outdated.. so why bother trying to guaratee delivery and all that overhead.

But the real magic with using udp is – firewall transparency. Since firewalls usually allow most outbound traffic through without much harassment (at least for home users), inbound is another story. NAT enabled routers are not even able to allow inbound connections without some finagling, since it has no idea which local machine to send the connection request to.

UDP doesnt have all the extra error checking headers etc, so it’s pretty trivial to trick it into “faking” a connection across firewalls, but having computers at both ends of the connection intiate a connection about the same time. A third-party middle server is normally used to coordinate the setup and timing of the attempt to connect in this manner. The router will see outbound packets to an ip and port, and then see packets coming back from that same ip and port… and will assume they are responses to the request, thus forwarding them on to the internal computer. This can be done from both ends at the same time, thus both ends can be behind firewalls etc. You’ll definitely get a few bad packets bouncing off the firewall until both ends get their business straigntened out, but after this everything will usually just work.

TCP, on the other hand, has headers which keep track of a bunch of things, like sequence etc., so when these headers are not correct the router will discard them as being bad.

I did some research some years ago to see if it would be possible to do this same trick of “faking” a connection (called “connection splicing”) with TCP as well. The only way it *might* be possible is to have the third party server doing some illegal packet manipulation to fool the firewalls. I never decided if was truly impossible or not, but at minimum it would be tricky. I did manage to find one other discussion about this, appears to still be around: http://www.advogato.org/article/217.html

Back on topic – the reason I dug back into this today was I was curious if Silverlight has any provisions for supporting something like the RTMFP protocol, and thus allow direct p2p connections. From what I can tell, it does not currently support anything like this.

Update- apparently chatroulette went offline recently and displayed the message “chatroulette rtmp connection failed”, so there was a spike in search traffic to this page for that phrase. Short answer: yes, this means chatroulette is offline, just wait for it to come back!

One thought on “How does ChatRoulette work – the RTMFP protocol”

Leave a Reply

Your email address will not be published. Required fields are marked *