Download
lecture 9 multimedia transmission protocol n.
Skip this Video
Loading SlideShow in 5 Seconds..
Lecture 9: Multimedia Transmission Protocol PowerPoint Presentation
Download Presentation
Lecture 9: Multimedia Transmission Protocol

Lecture 9: Multimedia Transmission Protocol

182 Vues Download Presentation
Télécharger la présentation

Lecture 9: Multimedia Transmission Protocol

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Lecture 9: Multimedia Transmission Protocol Hongli Luo, CEIT

  2. Multimedia Transmission Protocol • RTSP • RTP • RTCP • SIP • Socket Programming

  3. HTTP does not target multimedia content no commands for fast forward, etc. RTSP: RFC 2326 Allow the media player and server to exchange playback control information Allows a media player to control the transmission of a media stream client-server application layer protocol user control: rewind, fast forward, pause, resume, repositioning, etc… What it doesn’t do: doesn’t define how audio/video is encapsulated for streaming over network doesn’t restrict how streamed media is transported (UDP or TCP possible) doesn’t specify how media player buffers audio/video User Control of Streaming Media: RTSP

  4. FTP uses an “out-of-band” control channel: file transferred over one TCP connection. control info (directory changes, file deletion, rename) sent over separate TCP connection “out-of-band”, “in-band” channels use different port numbers RTSP messages also sent out-of-band: RTSP control messages use different port numbers than media stream: out-of-band. port 554 Over TCP or UDP media stream is considered “in-band”. Adopted by RealNetworks RTSP: out of band control

  5. transfer file to/from remote host client/server model client: side that initiates transfer (either to/from remote) server: remote host ftp: RFC 959 ftp server: port 21 FTP user interface FTP client FTP server FTP: the file transfer protocol file transfer user at host remote file system local file system

  6. FTP client contacts FTP server at port 21, TCP is transport protocol client authorized over control connection client browses remote directory by sending commands over control connection. when server receives file transfer command, server opens 2ndTCP connection (for file) to client after transferring one file, server closes data connection. server opens another TCP data connection to transfer another file. TCP control connection port 21 TCP data connection port 20 FTP client FTP server FTP: separate control, data connections • The control session remains open throughout the duration of the user session • control connection: “out of band” • FTP server maintains “state”: current directory, earlier authentication

  7. RTSP Example Scenario: • metafile communicated to web browser • browser launches player • player sets up an RTSP control connection, data connection to streaming server

  8. Metafile Example <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" src="rtsp://audio.example.com/twister/audio.en/hifi"> </switch> <track type="video/jpeg" src="rtsp://video.example.com/twister/video"> </group> </session>

  9. RTSP Operation

  10. RTSP Exchange Example C: SETUP rtsp://audio.example.com/twister/audio RTSP/1.0 Transport: rtp/udp; compression; port=3056; mode=PLAY S: RTSP/1.0 200 1 OK Session 4231 C: PLAY rtsp://audio.example.com/twister/audio.en/lofi RTSP/1.0 Session: 4231 Range: npt=0- S: RTSP/1.0 200 2 OK Session 4231 C: PAUSE rtsp://audio.example.com/twister/audio.en/lofi RTSP/1.0 Session: 4231 Range: npt=37 S: RTSP/1.0 200 3 OK Session 4231 C: TEARDOWN rtsp://audio.example.com/twister/audio.en/lofi RTSP/1.0 Session: 4231 S: RTSP/1.0 200 4 OK Session 4231

  11. RTP specifies packet structure for packets carrying audio, video data Audio: PCM, GSM, MP3 Video: MPEG and h.263 Proprietary audio and video formats RTP packet provides payload type identification packet sequence numbering time stamping RFC 3550 RTP runs in end systems RTP packets encapsulated in UDP segments interoperability: if two Internet phone applications run RTP, then they may be able to work together Real-Time Protocol (RTP)

  12. RTP runs on top of UDP • RTP libraries provide transport-layer interface • that extends UDP: • port numbers, IP addresses • payload type identification • packet sequence numbering • time-stamping

  13. consider sending 64 kbps PCM-encoded voice over RTP. application collects encoded data in chunks, e.g., every 20 msec = 160 bytes in a chunk. audio chunk + RTP header form RTP packet, which is encapsulated in UDP segment RTP header indicates type of audio encoding in each packet sender can change encoding during conference. RTP header also contains sequence numbers, timestamps. RTP Example

  14. RTP and QoS • RTP does not provide any mechanism to ensure timely data delivery or other QoS guarantees. • RTP does not provide • Timely delivery of data • QoS guarantees • Guarantee delivery of packets • Prevention of out-of-order delivery of packets • RTP encapsulation is only seen at end systems (not) by intermediate routers. • routers providing best-effort service, making no special effort to ensure that RTP packets arrive at destination in timely matter.

  15. RTP Header (12 bytes) • Payload Type (7 bits): Indicates type of encoding currently being used. If sender changes encoding in middle of conference, sender • informs receiver via payload type field. • Payload type 0: PCM mu-law, 64 kbps • Payload type 3, GSM, 13 kbps • Payload type 7, LPC, 2.4 kbps • Payload type 26, Motion JPEG • Payload type 31. H.261 • Payload type 33, MPEG2 video • Sequence Number (16 bits): Increments by one for each RTP packet • sent, and may be used to detect packet loss and to restore packet • sequence.

  16. Timestamp field (32 bytes long): sampling instant of first byte in this RTP data packet Receiver can use it to remove packet jitter and to provide synchronous playout for audio, timestamp clock typically increments by one for each sampling period (for example, each 125 usecs for 8 KHz sampling clock) if application generates chunks of 160 encoded samples, then timestamp increases by 160 for each RTP packet when source is active. Timestamp clock continues to increase at constant rate when source is inactive. SSRC field (32 bits long): identifies source of RTP stream. Each stream in RTP session should have distinct SSRC. Miscellaneous fields (9 bits) RTP Header (2)

  17. Developing Software Applications with RTP • Two approaches to develop an RTP-based networked applications • Incorporate RTP by hand – • write the code that performs RTP encapsulation at the sender side and RTP decapsulation at the client side • Use existing RTP libraries (for C programmers) and Java classes (for Java programmers) • The libraries and classes perform the encapsulation and decapsulation for the application

  18. Incorporate RTP by hand - example • A server that encapsulates stored video frames into RTP packets • grab video frame, • add RTP headers to frame and generate an RTP packet • create UDP segments, send segments to UDP socket • include seq numbers and time stamps • The API is the standard UDP socket API • A client decapsulates the RTP packet and display the video frame • RTSP • Client: issue setup/play/pause/teardown commands • Server: accepts the requests and take actions

  19. RTP does not mandate a specific port number. • The application developer specifies the port number for the two sides of the application.

  20. Use existing Java RTP class to implement (or C RTP library for C programmers) to implement the RTP. • The sender application provides • media chunk, payload-type number, SSRC, timestamp, destination port number, destination IP • Java Media Framework (JMF) includes a complete RTP implementation

  21. works in conjunction with RTP. each participant in RTP session periodically transmits RTCP control packets to all other participants. each RTCP packet contains sender and/or receiver reports report statistics useful to application: # packets sent, # packets lost, interarrival jitter, etc. feedback can be used to control performance sender may modify its transmissions based on feedback Real-Time Control Protocol (RTCP)

  22. RTCP - Continued • each RTP session: typically a single multicast address; all RTP /RTCP packets belonging to session use multicast address. • RTP, RTCP packets distinguished from each other via distinct port numbers. • RTCP port number is set to be equal to the RTP port number plus one • to limit traffic, each participant reduces RTCP traffic as number of conference participants increases

  23. Receiver report packets: Receiver aggregates its reception report into a single RTCP packet The packet is sent into the multicast tree that connects all the session’s participants. Fields in reception report: SSRC of RTP stream fraction of packets lost – the sender can switch to different encoding rates last sequence number average interarrival jitter – a smoothed estimate of the variation in the interarrival time between successive packets in the RTP stream RTCP Packets

  24. Sender report packets: Sender creates and transmits RTCP sender report packets The packets include information such as SSRC of RTP stream, Time stamp, wall clock time (current time) of the most recently generated RTP packet in the stream number of packets sent, number of bytes sent Sender reports can be used to synchronize different media streams within a RTP session. RTCP Packets

  25. Source description packets: Sender also creates and transmits source description packets. Includes e-mail address of sender, sender's name, SSRC of associated RTP stream, application that generates the RTP stream provide mapping between the SSRC and the user/host name RTCP packets are stackable Receiver reception reports, sender reports, and source descriptors can be concatenated into a single packet The RTCP packet is then encapsulated into a UDP segment RTCP Packets

  26. RTCP can synchronize different media streams within a RTP session consider videoconferencing app for which each sender generates one RTP stream for video, one for audio. timestamps in RTP packets tied to the video, audio sampling clocks not tied to wall-clock time (real time) each RTCP sender-report packet contains (for most recently generated packet in associated RTP stream): timestamp of RTP packet wall-clock time for when packet was created. receivers uses association to synchronize playout of audio, video Synchronization of Streams

  27. RTCP attempts to limit its traffic to 5% of session bandwidth. Example Suppose one sender, sending video at 2 Mbps. Then RTCP attempts to limit its traffic to 100 Kbps. RTCP gives 75% of rate to receivers; remaining 25% to sender 75 kbps is equally shared among receivers: with R receivers, each receiver gets to send RTCP traffic at 75/R kbps. sender gets to send RTCP traffic at 25 kbps. participant determines RTCP packet transmission period by calculating avg RTCP packet size (across entire session) and dividing by allocated rate RTCP Bandwidth Scaling

  28. RTCP Bandwidth Scaling (2) • The period for transmitting RTCP packets for a sender is T = (number of senders ) * (avg. RTCP packet size) / (.25 * .05 * session bandwidth) • The period for transmitting RTCP packets for a receiver is T = (number of senders ) *(avg. RTCP packet size) / (.75 * .05 * session bandwidth)

  29. SIP: Session Initiation Protocol[RFC 3261] SIP long-term vision: • all telephone calls, video conference calls take place over Internet • people are identified by names or e-mail addresses, rather than by phone numbers • you can reach callee, no matter where callee roams, no matter what IP device callee is currently using – computer or PDA

  30. Setting up a call between caller and callee, SIP provides mechanisms .. for caller to let callee know she wants to establish a call so caller, callee can agree on media type, encoding to end call determine current IP address of callee: Callee has dynamic IP by DHCP or has multiple IP devices maps mnemonic identifier to current IP address call management: add new media streams during call change encoding during call invite others transfer, hold calls SIP Services

  31. Setting up a call to known IP address • Alice’s SIP invite message indicates her port number, IP address, encoding she prefers to receive (PCM ulaw) • Bob’s 200 OK message indicates his port number, IP address, preferred encoding (GSM) • SIP messages can be sent over TCP or UDP; here sent over RTP/UDP. • default SIP port number is 5060.

  32. SIP is an out-of-band protocol SIP messages are sent and received in sockets different from those for media data SIP messages are ASCII-readable and resemble HTTP messages SIP requires all messages to be acknowledged It can run over UDP or TCP media can be sent over RTP or some other protocol codec negotiation: suppose Bob doesn’t have PCM ulaw encoder. Bob will instead reply with 606 Not Acceptable Reply, listing his encoders Alice can then send new INVITE message, advertising different encoder rejecting a call Bob can reject with replies “busy,” “gone,” “payment required,” “forbidden” Setting up a call (more)

  33. SIP Addresses • Bob’s SIP address is sip:bob@193.64.210.89 • When Alice’s SIP device sends an INVITE message, the message would include this email-like address • The SIP infrastructure would then route the message to the IP advice that Bob is currently using • Other possible forms for SIP address • Phone number • First/last name • SIP address can be included in Web page

  34. Example of SIP message INVITE sip:bob@domain.com SIP/2.0 Via: SIP/2.0/UDP 167.180.112.24 From: sip:alice@hereway.com To: sip:bob@domain.com Call-ID: a2e3a@pigeon.hereway.com Content-Type: application/sdp Content-Length: 885 c=IN IP4 167.180.112.24 m=audio 38060 RTP/AVP 0 Notes: • HTTP message syntax • sdp = session description protocol • Call-ID is unique for every call. • Here we don’t know Bob’s IP address. Intermediate SIPservers needed. • Alice sends, receives SIP messages using SIP default port 506 • Alice specifies in Via: IP address of the device, header that SIP client sends, receives SIP messages over UDP

  35. caller wants to call callee, but only has callee’s name or e-mail address. need to get IP address of callee’s current host: user moves around DHCP protocol user has different IP devices (PC, PDA, car device) result can be based on: time of day (work, home) caller (don’t want boss to call you at home) status of callee (calls sent to voicemail when callee is already talking to someone) Service provided by SIP servers: SIP proxy server SIP registrar server Name translation and user locataion

  36. SIP Proxy • Alice sends invite message to her proxy server • contains address sip:bob@domain.com • proxy responsible for routing SIP messages to callee • possibly through multiple proxies. • callee sends response back through the same set of proxies. • proxy returns SIP response message to Alice • contains Bob’s IP address • proxy analogous to local DNS server

  37. SIP Registrar • when Bob starts SIP client, client sends SIP REGISTER message to Bob’s registrar server (similar function needed by Instant Messaging) • Often SIP registrars and SIP proxies are run on the same host REGISTER sip:domain.com SIP/2.0 Via: SIP/2.0/UDP 193.64.210.89 From: sip:bob@domain.com To: sip:bob@domain.com Expires: 3600 Register Message:

  38. Example Caller jim@umass.edu with places a call to keith@upenn.edu (1) Jim sends INVITEmessage to umass SIPproxy. (2) Proxy forwardsrequest to upenn registrar server. (3) upenn server returnsredirect response,indicating that it should try keith@eurecom.fr (4) umass proxy sends INVITE to eurecom registrar. (5) eurecom registrar forwards INVITE to 197.87.54.21, which is running keith’s SIP client. (6-8) SIP response sent back (9) media sent directly between clients. Note: also a SIP ack message, which is not shown.

  39. H.323 is another signaling protocol for real-time, interactive audio and video conferencing H.323 is a complete, vertically integrated suite of protocols for multimedia conferencing: signaling, registration, admission control, transport, codecs SIP is a single component. Works with RTP, but does not mandate it. Can be combined with other protocols, services H.323 comes from the ITU (telephony). SIP comes from IETF: Borrows much of its concepts from HTTP SIP has Web flavor, whereas H.323 has telephony flavor. SIP uses the KISS principle: Keep it simple stupid. Comparison with H.323

  40. Socket programming • Development of network applications • Implementation of protocol standard defined in an RFC • Client and server conform to the rules of RFC • Use the port number associated with the protocol • Allows interoperability • Proprietary network application • The application-layer protocol used by the client and the server do not necessarily conform to any existing RFC • Developer creates both client and server programs • Not interoperable with other applications • Not to use well-known port numbers defined in RFCs • TCP or UDP at the transport layer?

  41. a host-local, application-created, OS-controlled interface (a “door”) into which application process can both send and receive messages to/from another application process socket Socket programming Goal: learn how to build client/server application that communicate using sockets Socket API • introduced in BSD4.1 UNIX, 1981 • explicitly created, used, released by apps • client/server paradigm • two types of transport service via socket API: • unreliable datagram • reliable, byte stream-oriented

  42. process process TCP with buffers, variables TCP with buffers, variables socket socket Socket-programming using TCP Socket: a door between application process and end-end-transport protocol (UCP or TCP) TCP service: reliable transfer of bytesfrom one process to another controlled by application developer controlled by application developer controlled by operating system controlled by operating system internet host or server host or server

  43. Client must contact server server process must first be running server must have created socket (door) that welcomes client’s contact Client contacts server by: creating client-local TCP socket specifying IP address, port number of server process The client choses a source port number When client creates socket: client TCP establishes connection to server TCP When contacted by client, server TCP creates new socket for server process to communicate with client allows server to talk with multiple clients source port numbers used to distinguish clients TCP socket is identified by a four-tuple: (source IP address, source port number, destination IP address, destination port number) TCP provides reliable, in-order transfer of bytes (“pipe”) between client and server application viewpoint Socket programming with TCP

  44. create socket, connect to hostid, port=x create socket, port=x, for incoming request: clientSocket = Socket() welcomeSocket = ServerSocket() TCP connection setup wait for incoming connection request connectionSocket = welcomeSocket.accept() send request using clientSocket read request from connectionSocket write reply to connectionSocket read reply from clientSocket close connectionSocket close clientSocket Client/server socket interaction: TCP Server (running on hostid) Client

  45. A stream is a sequence of characters that flow into or out of a process. An input stream is attached to some input source for the process, e.g., keyboard or socket. An output stream is attached to an output source, e.g., monitor or socket. Stream jargon Client process client TCP socket

  46. Example client-server app: 1) client reads line from standard input (inFromUser stream) , sends to server via socket (outToServer stream) 2) server reads line from socket 3) server converts line to uppercase, sends back to client 4) client reads, prints modified line from socket (inFromServer stream) Socket programming with TCP

  47. Example: Java client (TCP) import java.io.*; import java.net.*; class TCPClient { public static void main(String argv[]) throws Exception { String sentence; String modifiedSentence; BufferedReader inFromUser = new BufferedReader(new InputStreamReader(System.in)); Socket clientSocket = new Socket("hostname", 6789); System.out.println(“client port: " + clientSocket.getLocalPort()); DataOutputStream outToServer = new DataOutputStream(clientSocket.getOutputStream()); Create input stream Create client socket, connect to server Create output stream attached to socket

  48. Example: Java client (TCP), cont. Create input stream attached to socket BufferedReader inFromServer = new BufferedReader(new InputStreamReader(clientSocket.getInputStream())); sentence = inFromUser.readLine(); outToServer.writeBytes(sentence + '\n'); modifiedSentence = inFromServer.readLine(); System.out.println("FROM SERVER: " + modifiedSentence); clientSocket.close(); } } Send line to server Read line from server

  49. Example: Java server (TCP) import java.io.*; import java.net.*; class TCPServer { public static void main(String argv[]) throws Exception { String clientSentence; String capitalizedSentence; ServerSocket welcomeSocket = new ServerSocket(6789); while(true) { Socket connectionSocket = welcomeSocket.accept(); BufferedReader inFromClient = new BufferedReader(new InputStreamReader(connectionSocket.getInputStream())); Create welcoming socket at port 6789 Wait, on welcoming socket for contact by client Create input stream, attached to socket