Data Stream Interface


The Data Stream Interface is a session layer used to carry Apple Filing Protocol traffic over Transmission Control Protocol.

Overview

When Apple introduced TCP with MacTCP and Open Transport in System 7 in the 1990s, they needed their file sharing protocol to run on both TCP and AppleTalk. They introduced AppleTalk Session Protocol and DSI for TCP coincidentally with AFP 2.x.
DSI is implemented directly into AFP clients such as in Mac OS and afpfs-ng.

Protocol

DSI is spoken between a client and an AFP server. All DSI communication contains the following DSI header:

Packet structure

The fields are:
There are seven possible commands:
NameCodeDirectionDescription
DSICloseSession1BothCloses an established session
DSICommand2From clientAttached payload contains an AFP command
DSIGetStatus3From clientGet information about the server
DSIOpenSession4From clientEstablish a new session
DSITickle5BothEnsure the connection is active
DSIWrite6From clientWrite data to the server
DSIAttention8From serverGet the attention of the client

Requests and replies

Upon receiving most DSI requests, the client or server sends a reply message. This reply contains:
The DSITickle and DSICloseSession commands do not trigger a reply.

Session creation, maintenance and teardown

A session is set up by the client sending a DSIOpenSession, which will include the size of the receive buffer the client has for packets. The server acknowledges the request and returns the size of its data receive buffer.
Session closure can be initiated by either side by sending DSICloseSession. The sender does not need to wait for a reply and should immediately close the session after sending the message.
Maintaining the connection is done by tickling. DSI provides a mechanism for ensuring that client and server know that the other is still active. Every 30 seconds of inactivity, the server sends a tickle request to the client. Similarly, the client also sends its own tickle. Either the client or server can terminate the DSI session if they fail to hear from the other for 120 seconds. The client may also disconnect if a request is in flight and neither a response nor tickle is received within 60 seconds.

Getting server information with GetStatus

This DSI command encapsulates an FPGetSrvrInfo packet. It is used by a client to get information from a server it isn't logged into.
The data elements are organized in the packet with a catalog of indices pointing to structured data.
The request to a DSIGetStatus request will cause the server to respond with the following information:
DSIGetStatus reply format is identical to AFP's FPGetSrvrInfo and is used for ASPGetStatus.

Error codes

The error codes returned are AFP result codes.

Further research

DSI is never documented separately, and is sufficiently simple and static that older references are suitable for modern implementations. The concepts of DSI are identical to AppleTalk Session Protocol, and the overview in Inside AppleTalk, Second Edition can be helpful.
The most succinct guide is the chapter of .
A significant source of information in understanding DSI can be found by analyzing communication between AFP clients and servers using a packet sniffer.

Footnotes