Programming Assignment 3: Implement an RTSP Server and Client

Web posted: April 20, 23:45 hrs
Due: May 12, 17:00hrs

VIP/NTU students: Due 3 weeks from when you receive this assignment


The goal of this mini-project is to design an RTSP server and client. The mini-project will require you to:

A secondary goal to learn client-server programming based on sockets.

Part I: Build a skeleton client-server application

First read about socket programming from the following references.

Having understood the basics of socket programming, implement a client-server application based on TCP. Your server should listen for client requests on a well-known port (say 9000). Your client should connect to the server at this port. Once a connection between the client and server is established, your server should fork a child process and have the child handle all future communication with the client. To test your client-server application, your client should send two integers to the server, the server should add the two integers and send back the result to the client. Both the client and server should then close the connection, and the child process at the server should then exit.

Additional Notes:

  1. You are welcome to do this assignment using the WINSOCK API, rather than the BSD API, if you have a WIN95/98/NT machine and a C compiler.

  2. In writing your code, make sure to check for an error return from all system calls. Be sure to check fork for an error return. If there is an error, the system declared global variable, errno, will give you information about the type of error that occurred.

  3. The man pages for the socket-related system calls, fork(), and errno() are available here.

  4. Note that read and write might return without having read or written the full number of bytes requested. In such a case, these calls will return a positive return value indicating the number of bytes actually read or written. If the number does not correspond with the number requested, be sure to loop back until all the data has been transferred.

  5. Your processes should communicate using the reliable stream protocol (SOCK_STREAM) and the Internet domain protocols (AF_INET). If you need to know your host's IP address, you can telnet to your own machine and seeing the dotted decimal address displayed by the telnet program. You can also use the UNIX nslookup command or you can ask your local system administrator for the info.

  6. Make sure you close every socket that you use in your program. If you abort your program, the socket may still hang around and the next time you try and bind a new socket to the port ID you previously used (but never closed), you may get an error. Also, please be aware that port ID's, when bound to sockets, are system-wide values and thus other students may be using the port number you are trying to use.

    Part II: Build a RTSP client and server

    In this part, we will use the client and server application from Part I to implement the RTSP protocol. First read about the RTSP protocol. RTSP is described in RFC 2326 (you don't need to understand every single detail in the RFC, just be sure that you understand the basics). RTSP is also described in Chapter 6 of the Kurose-Ross text. A good online reference on RTSP is available here (this page also includes sample code for RTSP, you can look at the code as a reference, but do not use any of this code for your assignment---write your own code!).

    Implement an RTSP server that understands a few RTSP methods (you should at least implement four methods: DESCRIBE, PLAY, SETUP, TEARDOWN). Your server should be able to accept RTSP requests from the client, parse them and send back a valid RTSP response (read the RFC for examples of different types requests and responses). Be sure to send back the "551: option not supported" error code for the options you have not implemented. Again, you do NOT need to implement every single detail in the RTSP protocol, just be sure to implement all the basic stuff needed to support the about four methods.

    Implement an RTSP client that accepts an RTSP request from the user. Your client should connect to the RTSP server specified in the request, send the actual request and print the response received from the server.

    Note that RTSP is a control protocol. It allows a client and server to exchange control messages. The actual streaming of the data is done through a different protocol such as RTP; so you need not worry about streaming the actual data.


    What to hand in.

    When you hand in your programming assignment, you should include:


    Prashant Shenoy
    Last modified: Tue May 23 11:53:56 EDT 2000