HTTP State Machine in Frame Notation

https://dev.w3.org/libwww/Library/User/Architecture/HTTPFeatures.html

State machines originally caught my interest as an easy to understand approach to designing communication protocols. I remember seeing an article in Dr. Dobbs Journal (RIP) that showed a graphical model of a communication protocol (like the one above) and then the code to implement it.

I was fascinated by the ease with which I could understand both the big idea from the picture and the nitty-gritty details from the code and that they aligned so clearly.

This article will explore a machine that implements the state machine above for the client-side protocol of an HTTP connection. Although almost ancient (c. 1996) in Internet time, it serves as a worthy starting point for other investigations of communication protocols.

One of the challenges with state machines in the literature is the typical approach of representing them graphically. Although the machine we will examine in this article is simple enough to reasonably draw, many of the more complicated ones can become overwhelmingly intricate.

While Frame does define an equivalent visual representation, I believe that widespread use of automata in day-to-day coding has been hampered by this dependency on graphical representations. In contrast, the Frame Machine Notation (FMN) is a textual language for describing state machines that isn’t constrained by the size of an 8.5"x11" piece of paper. You can find other articles by me on FMN here.

Below is the FMN for the HTTP protocol state machine shown above along with its pseudocode implementation:

Conclusion

While this implementation doesn’t drive any activity, it does show how FMN can model state machines in a textual format. In the analysis, I adhered strictly to the diagram to show a 1–1 translation of the protocol as specced in FMN. It should be noted that a few improvements such as factoring out common functionality into parent states would have simplified the machine and its implementation.

Future articles will explore other protocols as well as introduce actual full implementations.