14

I just sniffed some traffic using wireshark and noticed, that the YouTube traffic relies on TCP. I thought, they were using UDP? But it seems like as if they would use HTTP octet streams. Is YouTube really using TCP for streams or am i missing something?

Sebastian
  • 905
  • 2
  • 9
  • 21

3 Answers3

19

Because they need everything TCP provides (slow start, transmit pacing, exponential backoff, receive windows, reordering, duplicate rejection, and so on) they would either have to use TCP or try to do all those things themselves. There's no way they could do that better than each operating system's optimized TCP implementation.

David Schwartz
  • 179,497
  • 17
  • 214
  • 278
  • That's right, but do they need all this for _streaming_ video? i believed, that streaming means "UDP, cause it doesnt matter at all whether some packets get lost or not! Hey, we try to provide you some sort of real time service". – Sebastian Oct 27 '13 at 16:30
  • 2
    @Sebastian Right, but lost packets are just one issue. The number of issues that TCP handles for you that you *do* need is enormous, and TCP is heavily optimized on every operating system and network. UDP just can't compete. – David Schwartz Oct 27 '13 at 16:33
  • I am shocked video is sent as TCP as it doesn't require reliable which slows things down considerably. – markmnl Jun 19 '15 at 02:20
  • It doesn't use TCP for video, I thought not, see my answer. – markmnl Jun 19 '15 at 02:24
  • 1
    UDP is not suported by browsers at the moment, that's why! – Ma Jerez Sep 09 '16 at 20:26
  • 2
    @Sebastian Streaming only means UDP if you don't care about lost frames (like in a voice call, you want to be as current as possible, regardless of lost audio). However, many streaming applications don't want to toss frames for video streaming (e.g., music videos on YouTube) unless it is live streaming (e.g., Facebook Live). – Greg Schmit Feb 11 '17 at 06:16
12

Obviously, Google is currently experimenting with own Protocol Implementations, like QUIC (Quick UDP Internet Connection), as one can see when examining the HTTP Response

HTTP/1.1 200 OK
...
Content-Type: video/mp4
Alternate-Protocol: 80:quic
...

However, currently, they seem to rely on TCP, just like David mentioned before.

Sebastian
  • 905
  • 2
  • 9
  • 21
2

From http://www.crazyengineers.com/threads/youtube-use-tcp-or-udp.38419/:

...of course youtube page uses http [which is over TCP]. The real thing does not happens via http page but the flash object that is embedded in that page. The flash object which appear on youtube is video flash player. The video flash player acts as iframe(technically incorrect term) for contents that would be called for streaming via flash object. For storing media contents a media sever have been installed by youtube whose contents get called when you press play button.

For streaming media to flash player Real Time Streaming Protocol(RTSP) is used. The play button on flash player acts as RTSP invoker for media being called and media is streamed via UDP packets. In fact you don't need to migrate anywhere from page because the embedded object calls for video not the http page but as the object is embedded on http page once you close it, object also get closed.

markmnl
  • 11,116
  • 8
  • 73
  • 109
  • But what about HTML5 video fallback? – Anurag Aug 29 '15 at 10:38
  • Depends on what protocol you specify e.g. ` – markmnl Sep 02 '15 at 06:01
  • 1
    Maybe it was true when Youtube used Flash, but now (and for quite some time) the majority of browsers use [MSE](https://en.wikipedia.org/wiki/Media_Source_Extensions)/[DASH](https://en.wikipedia.org/wiki/Dynamic_Adaptive_Streaming_over_HTTP) by default. Even the browsers that don't support MSE (like IE on Windows 7 and below) use HTML5 video via HTTP, which in turn uses TCP. – John29 Apr 19 '16 at 16:55
  • 3
    Flash does not use RTSP - it uses RTMP/RTMPE over TCP or RTMFP over UDP. The article quoted above is wrong. – Fotios Basagiannis Jun 08 '16 at 23:57