Tuesday, February 21, 2006

Protocol Design by Committee

3M's Standard Interchange Protocol (SIP, not to be confused with the "Session Initiation Protocol" used in internet telephony) is the protocol that library self-check units use to talk to the circulation module of a library's Integrated Library System. It's a small, focused protocol that was designed by people who: knew what they were trying to accomplish, had to implement it, and had to make it work on the low-end computers that get stuffed into the self-checkout units, and over the (potentially slow and crappy) communication lines that a small library system might have.

NCIP is the NISO Circulation Interchange Protocol. This protocol was designed as a "vendor-neutral" replacement for the 3M SIP. The standards committee allowed themselves to be seduced by both new technologies and mission creep that encouraged them to attempt to design a system that could handle all circulation activities, including not just patron self-check, but also inter-library borrowing and the accounting that goes with it. What they produced was... larger than one might expect, given the size of the documents.

For example, when a self-checkout unit wants to verify that a user is valid with SIP, it sends this message:


2300020060221 211723AOLochalsh Public\ Library|AAdjfiander|AC|AD|AY1AZEA14

When a self-checkout unit is using NCIP, it sends this XML:

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE NCIPMessage PUBLIC "-//NISO//NCIP DTD Version 1//EN"
     "http://www.niso.org/ncip/v1_0/imp1/dtd/ncip_v1_0.dtd">
<NCIPMessage version="http://www.niso.org/ncip/v1_0/imp1/dtd/ncip_v1_0.dtd">
    <AuthenticateUser>
        <IntiationHeader>
        <FromAgencyId>
            <UniqueAgencyId>
            <Scheme>local-name</Scheme><Value>Taylor-SC-1</Value>
        </UniqueAgencyId>
        </FromAgencyId>
        <FromAgencyAuthentication>xyzzy</FromAgencyAuthentication>
         <ToAgencyId>
            <UniqueAgencyId>
            <Scheme>local-name</Scheme><Value>UWOLS</Value>
        </UniqueAgencyId>
        </ToAgencyId>
       </IntiationHeader>
       <AuthenticationInput>
           <AuthenticationInputData>djfiander</AuthenticationInputData>
       <AuthenticationDataFormatType>
           <Scheme>http://www.iana.org/assignments/media-types</Scheme>
           <Value>text/plain</Value>
       </AuthenticationDataFormatType>
       <AuthenticationInputType>
           <Scheme>http://www.niso.org/ncip/v1_0/imp1/schemes/authenticationinputtype/authenticationinputtype.scm</Scheme>
           <Value>User ID</Value>
       </AuthenticationInputType>
       </AuthenticationInput>
    </AuthenticateUser>
</NCIPMessage>


Need I say more?

2 comments:

Unknown said...

I am working on a very small project for a local library that requires I access the library system using the SIP protocal... however I am getting weird results:

I built a small script to connect to the system and request message 17 "Item information request":

It seems that if I process more than one message between fsockopen and fclose I get inconsisten results from fread...
-How can I be sure that I clear the buffer before sending a new request.
-How can I read the entire SIP response at once
-Why do I have to sleep when logging on to get any reponse from the system

---Thanks... George

Anonymous said...

George,

In general, your questions aren't SIP questions, but general network programming questions. The first thing to do is to make sure that you're not using buffered I/O on the socket. In Perl, this is controlled by setting the variable "$|".

I can't really be more specific than that, given what you've told me.