The C64 Real-Time Streaming Audio Server - Software Details

Plain layout version
Printer friendly version

Site menu
TFE
Music
as64

Related sites
Contiki
Internet-enabled operating system and desktop environment for the C64

uIP
The uIP embedded TCP/IP stack

uVNC
VNC server for 8-bit microcontrollers and the C64

The C64 Real-Time Streaming Audio Server - Software Details

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.

Download

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 $

Latest News

2003-09-13
Jens Schönfeld has made another production run of the RetroReplay cartridge together with the RR-Net Ethernet cards! See his announcement for details and some pictures of the hardware. The RR-Net kits are distributed with a version of Contiki on a 5.25" disk.


2003-06-02
Jens Schönfeld have announced that he will manufacture and sell C64 Ethernet cards for the RetroReplay cartridge! The cards will be available at the end of the summer for 50 EUR. A Contiki driver is already written and have been tested with the card!