The C64 Real-Time Streaming Audio Server - Software Details

[ TFE Homepage | FAQ | News | Press | Pictures | Hardware | Software | Links ]

The software for the C64 real-time streaming audio server runs on an unexpanded 1 MHz 6510 CPU with 64k RAM. The software is based around an extended version of the uIP TCP/IP stack that previously has been used for another C64 webserver, TCP/IP enabled Lego Mindstorms as well as various other projects. The software is freely avaliable for download and use.

Web server

The web server is a simple HTTP server running on top of uIP, but with a small twist that protects from memory overload. The web server includes a simple virtual file system which stores the web pages in RAM. We have the web server running at TCP port 6510 and have devoted ports 80, 81, 82, 83, and 84 to the overload protection optimized web server described below.

Overload protection

Because of the limitations in processing speed and memory resources, the regular web server application is not able to handle heavy load. Each web client uses a small amount of memory, and each TCP packet sent by the web clients has to be processed and parsed. With many simultaneous web clients browsing the server, memory and CPU cycles run out quickly. When the memory is exhausted any attempts to connect to the server are discarded, thus making it hard to reach the web pages on the server.

In order to prevent service degradation under heavy load, we have employed a TCP optimization for TCP ports 80-84, while we keep port 6510 open for the normal web server application. The optimization encodes connection state information in the TCP sequence numbers and keeps no connection state in the server, thus requiring no per-connection memory. This only works in cases where the web pages are small enough to fit into one TCP segment, and it is used only for the frame-set, the menu frame (including the pictures), and the main page. All other pages are server by the regular web server application running on top of uIP.

RTSP/RTP server

The RTSP (Real-Time Streaming Protocol) is a standard (RFC2326) session initiation/maintenance protocol that is used by RealPlayer, QuickTime, and many other real-time audio and video players. RTP (Real-Time Protocol) is a standard (RFC1889) protocol used for transmission of real-time data such as audio and video. RTSP uses TCP as its primary transport layer, and RTP runs over UDP.

The RTSP server

The RTSP server is extremely simple and basically follows the steps outlined in Appendix D.2 in RFC2326. The server only supports the OPTIONS, DESCRIBE, SETUP, PLAY, and TEARDOWN commands. The implementation has not been extensively tested or verified and there may be incompatibilities with RTSP clients other than RealPlayer 8 Basic.

The RTP sender

RTP packets are sent in UDP datagrams which has the checksum turned off. While the 1 MHz 6510 CPU probably could support as many as four or five simultaneous listeners, there would not be many cycles left for the web server. Therefore, we only allow one listener at a time.

The audio sampler

A timer IRQ fires 2000 times every second and samples the input pin of the casette interface. The 1-bit value is written into two buffers that are used circularly. Once a buffer is full, an UDP/RTP header is prepended and the packet is sent out. The IP header for each listener is preconstructed and sent directly to the Ethernet interface without modifications.


The full source code for the C64 real-time streaming audio server can be downloaded here. The code is written in C with the most CPU intensive parts such as the CS8900a device driver and the sampling IRQ written in 6502 assembler.

$Date: 2004/05/01 20:37:51 $

[ TFE Homepage | FAQ | News | Press | Pictures | Hardware | Software | Links ]

Main menu
TFE | Music | as64 ]
Table layout version
Printer friendly version

© Copyright Adam Dunkels 2001-2003