You are on page 1of 36

MEDIA NETWORKS

Streaming Protocols

Media Networks - Streaming Protocols


LIVE STREAMING NETWORK
Digital (DVB)
MPEG TS (IP/fiber/…)
IP (RTMP)

Encoding ISP network Set Top Box

Headend

CDN
Source

Content Providers Service Providers Network Providers Customers

Digital (DVB) Digital (DVB)


MPEG TS (IP/satellite/..) MPEG TS (IP/fiber) IP (RTMP - HTTP)
IP (RTMP)

Media Networks - Streaming Protocols


Media Networks - Streaming Protocols
SOURCE DISTRIBUTION
• Digital Video Broadcasting (DVB)
− Open standard for digital tv distribution

• MPEG Transport Stream (MPEG TS)


− Can contain single program (Single Program Transport
Stream (SPTS)) or multiple multiplexed program
channels (Multiple Program Transport Stream (MPTS))
onto a single communication channel
− Multiplexed MPEG TS stream can be transmitted over:
• RF
• Satellite
• Cable network
• IP
• …

Media Networks - Streaming Protocols


MPEG TS
1. Make packets from the elementary streams (coming
from the encoder) → Becomes Packetized Elementary
Stream (PES)
− One program is usually composed of multiple PES channels (audio
and video)
− Multiple programs can be multiplexed
− A program identifier is added to the packets to identify the
channels
− A program mapping table and synchronization information is
periodically sent
− PES Header contains
• Stream id
» 110x xxxx - MPEG-2 audio stream number x xxxx.
» 1110 yyyy - MPEG-2 video stream number yyyy.
• PES packet length
• Optional headers

Media Networks - Streaming Protocols


MPEG TS

• The PES is split


up into fixed sized
184-byte chunks
+ 4-byte header
→ Becomes a
Transport stream
− TS header contains
• Sync
• Packet identifier

Media Networks - Streaming Protocols


MPEG TS OVER IP
• MPEG TS will be encapsulated using RTP, which uses UDP on the
transport layer
• RTP/UDP/IP gives an overhead of 40 bytes
• With a common MTU of 1500, 1 to 7 TS packets of 188 bytes can
be added in a single IP packet
• Timestamp field of RTP header is based on the synchronization
information in the TS stream

Media Networks - Streaming Protocols


HEADEND

• Hardware to:
− receive and demultiplex
channels from different
sources
• Via cable or satellite
− Decode incoming streams
− Multiplex into channels for
distribution
− Encode for receiving
equipment
− transmit media

Media Networks - Streaming Protocols


REAL-TIME TRANSPORT PROTOCOL (RTP)

• In the TCP/IP protocol suite, a mechanism for providing end-


to-end network transport functions suitable for applications
transmitting real-time data, such as audio, video, or
simulation data, over multicast or unicast network services
• provides end-to-end delivery services including payload type
identification, sequence numbering, and timestamping
• widely used for IP telephony and audio and video
streaming e.g. WebRTC and MPEG TS
• Unicast or multicast transmission

Media Networks - Streaming Protocols


RTP IN OSI MODEL

• RTP typically runs on top of UDP


• audio or video chunks of data are encapsulated in RTP
packets, and each RTP packet is in turn encapsulated in a
UDP segment
• part of the application layer
• Port numbers 16384 - 32767

Media Networks - Streaming Protocols


RTP IN OSI MODEL

• Layer on top of UDP, only adding the TCP functionalities


it needs, without the extra delay of TCP

− Payload type
− Sequentie nummer
− Timestamp

Media Networks - Streaming Protocols


RTP HEADER

• Payload Type Field: seven-bits long. Thus 128 different


payload types can be supported by RTP
sender can change encoding on-the-fly

• Sequence Number Field: increments by one for each RTP


packet sent
• Timestamp Field: remove packet jitter
• Synchronization Source Identifier (SSRC): number that
the source assigns randomly when the new stream is started

Media Networks - Streaming Protocols


JITTER (DELAY VARIATION): TIMESTAMP

Packets sent

d1 d1+y
Packets received

h h-y
Packets playout

Media Networks - Streaming Protocols


OUT OF ORDER EN PACKET LOSS:
SEQUENTIE NUMMER

timeline

Sender

1 2 3 4 5 6 7
(a)
(b)

1 2 3 5 7 6
Receiver

Media Networks - Streaming Protocols


BUFFER

• Client uses buffer to


cope with packet loss
and jitter
• Buffer size depends
on application
− Live streaming can have
a larger buffer
− Interactive applications
can only have a small
buffer

Media Networks - Streaming Protocols


RTP CONTROL PROTOCOL (RTCP)
• use in conjunction with RTP
• are sent periodically and contain sender and/or receiver
reports that announce statistics that can be useful to the
application
• statistics include number of packets sent, number of packets
lost and interarrival jitter
• up to the application developer to decide what it wants to do
with the feedback information
− Senders can use the feedback information, for example, to modify their
transmission rates
• RTCP attempts to limit its traffic to 5% of the session bandwidth
• QOS (Quality of Service) analysis and synchronization between
video
• RTP uses even port numbers, RTCP uses next odd port number

Media Networks - Streaming Protocols


RTCP PACKET TYPES
• Receiver reception packets
− receiver generates a reception report containing:
• The SSRC of the RTP stream
• The fraction of packets lost
• The last sequence number received
• The interarrival jitter

• Sender report packets


− sender creates and transmits RTCP sender-report packets containing:
• The SSRC of the RTP stream
• The timestamp and wall-clock time
• The number of packets sent in the stream
• The number of bytes sent in the stream

Media Networks - Streaming Protocols


REAL-TIME STREAMING PROTOCOL (RTSP)
• network control protocol designed for use
in entertainment and communications
systems to control streaming media
servers
• establishing and controlling media
sessions between end points
• VCR-like commands, such as play and
pause
• transmission of streaming data itself is
not a task of the RTSP protocol
• use the Real-time Transport Protocol
(RTP) in conjunction with Real-time
Control Protocol (RTCP) for media stream
delivery

Media Networks - Streaming Protocols


DESCRIBE AND SETUP PROCESS OF RTSP
• The client device sends an RTSP request to the server to determine the
available options, such as pause, play and record.
• The server returns a list of the types of requests it can accept through
RTSP.
• The client transmits a media description request to the streaming
server, and the server responds with a description of the media.
• The client sends a setup request, and the server responds with
information about the transport mechanism.
• The client initiates the streaming process by telling the server to send the
bitstream -- a binary sequence -- using the transport mechanism
specified in the setup request.

Media Networks - Streaming Protocols


RTSP DESCRIPTION FILE
<title>Twister/title>
<session>
<group language=en lipsync>
<switch>
<track type=audio
e=”PCMU/8000/1”
src= ”rtsp://audio.example.com/twister/
audio.en/lofi”>
<track type=audio
e=”DVI4/16000/2” pt=”90 DVI4/8000/1”
scr=”rtsp://audio.example.com/twister/
audio.en/hifi”>
</switch>
<track type=”video/jpeg”
scr=”rtsp://video.example.com/twister/video”>
</group>
</session>

Media Networks - Streaming Protocols


RTP AND RTSP USE CASES

Source streaming VoIP RTP WebRTC AND


to media server streaming MPEG TS over IP

Media Networks - Streaming Protocols


REAL TIME MESSAGING PROTOCOL (RTMP)

• Developed by Macromedia (initially a proprietary) for


communication between flash media server and flash media
player
• Very big in mid 2000’s
• Adobe released an incomplete version of the specification of
the protocol
• bidirectional message multiplex service over a reliable stream
transport, such as TCP, intended to carry parallel streams of
video, audio, and data messages, with associated timing
information, between a pair of communicating peers.
• Dynamically negotiated size of fragments for smooth delivery

Media Networks - Streaming Protocols


REAL TIME MESSAGING PROTOCOL (RTMP)

• TCP-based and offers therefore persistent


connections
• encapsulates MP3/AAC audio and MP4/FLV video
multimedia streams
• Instant playing of RTMP stream, does not rely on
buffers
• Very low latency for live streaming (2 or 3 seconds)

Media Networks - Streaming Protocols


RTMP USE CASES

As source for streaming As source for CDN

Media Networks - Streaming Protocols


RTP AND RTSP STREAMING

• Ffmpeg
− Ffmpeg -re -i video.mp4 –preset ultrafast –c:v libx264 -tune
zerolatency -bitrate 900k -f rtp_mpegts rtp://localhost:1234
− Ffmpeg -re -i video.mp4 –preset ultrafast –c:v libx264 -tune
zerolatency -bitrate 900k -f mpegts udp://localhost:1234

• Vlc

Media Networks - Streaming Protocols


WATCHING RTP STREAM

• FFPlay
− ffplay rtp://localhost:1234
− ffplay udp://localhost:1234

• vlc

Media Networks - Streaming Protocols


• Ffmpeg

• ffmpeg -i bbb_sunflower_1080p_30fps_normal.mp4 -
preset ultrafast -vcodec copy -tune zerolatency -b 900k
-f mpegts rtp://localhost:1234

Media Networks - Streaming Protocols


SECURITY

• Rtp, rtcp and rtsp are plain text protocols


• Captured stream can be replayed with ex wireshark

• Secure Real-Time Transport Protocol (SRTP)


− uses encryption and authentication to minimize the risk of denial-
of-service attacks and security breaches

Media Networks - Streaming Protocols


SRTP WITH FFMPEG AND FFPLAY
• https://ffmpeg.org/ffmpeg-protocols.html#srtp
• Ffmpeg –i video.mp4 –f flv srtp://ip?srtp_out_suite=suite&srtp_out_params=masterkey+salt
• Ffplay srtp://ip?srtp_in_suite=suite&srtp_in_params=masterkey+salt

srtp_in_suite
srtp_out_suite
− Select input and output encoding suites.
− Supported values:
• ‘AES_CM_128_HMAC_SHA1_80’
• ‘SRTP_AES128_CM_HMAC_SHA1_80’
• ‘AES_CM_128_HMAC_SHA1_32’
• ‘SRTP_AES128_CM_HMAC_SHA1_32’
srtp_in_params
srtp_out_params
− Set input and output encoding parameters, which are expressed by a base64-encoded representation of a binary block. The first 16
bytes of this binary block are used as master key, the following 14 bytes are used as master salt.

Media Networks - Streaming Protocols


RTMP AND FFMPEG

• Streaming to rtmp media server

• Ffmpeg -re -i videofile.mp4 -c:a aac -c:v libx264 -f flv


rtmp://34.253.239.50/live

Media Networks - Streaming Protocols


STREAMING PROTOCOLS AND FIREWALL
• RTMP uses standard port 1935, wich will be blocked on many firewalls
• If firewall blockes this port
− make a connection attempt on port 80 using RTMP
• rtmp://your_ip_address:80/app_name

− If the connection is unsuccessful, you should move the connection to use RTMPT,
which is RTMP encapsulated over HTTP. Firewalls will not block this connection,
because it makes RTMP “hide” behind HTTP traffic on port 80.
• rtmpt://your_ip_address:80/app_name

• You should not use RTMPT at all times because there’s a performance
issue, there is an overhead on top of each packet sent.

Media Networks - Streaming Protocols


STREAM CONTROL TRANSMISSION
PROTOCOL
• transport-layer (layer 4) protocol that
can be used on top of IP networks for
end-to-end communications
• Based on TCP, but enhanced to
overcome streaming problems with TCP
• Dominant transport protocol for many
telecom applications and standards
• Not widely implemented in home and
business networks
− No changes need to be made to IP network
(Routers and Switches)
− Changes need to be made to the transport
stack on nodes (NAT-routers, applications, …)

Media Networks - Streaming Protocols


SCTP

Like TCP Unlike TCP

• unicast connection-oriented • message-oriented (like


protocol UDP)whereas TCP is stream-
• Reliable transport with seq- and oriented
ack-numbers • can handle multiple
• In order delivery simultaneous streams and
multiplexed streams (TCP is one
• Uses a Window for buffering stream)
− stream-aware connection control
• multihoming
− end points can use multiple IP
addresses for the connection

Media Networks - Streaming Protocols


Media Networks - Streaming Protocols
CREATE LIVE STREAMING NETWORK
• Media source: video, microphone, screencast, webcam, …
• Mixer
− Software: Open broadcaster software
− Hardware
• Encoding server
− Ffmpeg, open broadcaster software
• Streaming server
− Nginx, wirecast, wowza
• Delivery trough streaming protocol
− Content Delivery Network
• Nginx, public cdn
− Public delivery: Youtube, Facebook, Twitter, Instagram
− Comercial media server
• Wirecast, wowza
− Webserver
• Html5, Mpeg Dash, HLS, Smooth Streaming

Media Networks - Streaming Protocols


SOURCES
• https://erg.abdn.ac.uk/future-net/digital-video/mpeg2-trans.html
• http://ftp.enensys.com/documents/whitePapers/ENENSYS%20Technologie
s%20-%20DVB%20over%20IP.pdf
• https://headendinfo.com/digital-headend/
• https://www.iwavesystems.com/rtsp-media-streaming-server-on-
windows-embedded-compact-7-wec7
• https://tools.ietf.org/html/rfc2326#page-34
• http:/www.firewall.cx/networking-topics/general-networking/107-
network-multicast.html
• https://www.metaswitch.com/knowledge-center/reference/what-is-
internet-group-management-protocol-igmp-multicast-listener-discovery-
mld
• https://www.kurento.org/blog/rtp-i-intro-rtp-and-sdp

Media Networks - Streaming Protocols

You might also like