Practicum in Trading Systems Development: Lab 6

Due:           Thursday, August 2, 2012, by 5:00 PM


PURPOSE AND RATIONALE

The purpose of this lab is to let students gain specific experience with basic message queue manipulation in C (called from C++).  The goal of this lab is to provide students with the foundations necessary to understand the dynamics of the adding and removing messages from a Linux Message Queue.

NB:  If you are not a CSPP student and are in need of a CS Cluster login ID (if you don't know what this is you are in need of one), contact the TAs immediately so you can get set up with a cluster login ID for the labs.  This course cannot be conducted without a CS Cluster login ID.  If you already have a UofC CNET ID, you can (and should) manually apply for a CS cluster ID here.


PRIMARY RESOURCES:

You should refer to relevant sections of the man pages for assistance for this lab, in addition to materials in the assigned chapters from the primary texts for this week (per the syllabus).

You should ssh into the cluster to perform all lab activities.

Make sure you have read this week's assigned reading. 

README

  1. If you are not in our course email list, please subscribe to the cspp51025 email list here:  http://mailman.cs.uchicago.edu/mailman/listinfo/cspp51025

  2. Turn the lab assignment as a tarball in by email to the TA (cc'ing the instructor) by the due date above.

  3. For printing out your documents, you might find the following commands useful during your year(s) in this department:

    1. lpr -  off line print. Note that this command is called when you print from acroread  (for .pdf files) or gv (for .ps files)
    2. lpq - shows the printer queue
    3. lprm - removes jobs from the printer queue
    4. enscript - converts text files to PostScript (useful when you want to print out text files)

  4. Make sure you have read the Submission Guidelines for submission.

LAB 6

In Lab 2, you were asked to create a simple client and server program where the client was a trading application that talked to a simple connection manager.  To wit (to repeat the Lab 2 assignment):

You are to write a client and server program in C++ with a makefile to build your client and server applications.  The client will be a simple trading client, and the server will be essentially a simple connection manager.  The client will use this header file for the protocol for sending an order, specifically, using the ORDER structure.  The client must be launched with an argument that represents the unique "name" of the client, which will be delivered to the client at runtime via a command line argument.  When the client places an ORDER to the server, it will use the ORDER structure to pass in its name (received on the command line), using the char account field.  The server will then create space to manage that client's state via state management in the server, organized by client name.  You will need to define the class to manage client state.  You might want to use an associative STL map with unique keys to manage the client name with the value being a pointer to the client's state structure (all of which you will need to design and implement). 

When the server receives an order (via an ORDER message type from the MESSAGE_TYPE enum), it will do two things:  it will send a ORDER_ACK message type back to the trader client, and it will then print out the details of the order to the screen.  The server is responsible for handling multiple clients via select() and maintaining the state of each client.  The server is also responsible for maintaining state information about each client connection, including:  the time of initial connection, the time of connection termination, the total number of BUY ORDERS and the total number of SELL ORDERS received for each client (and by calculated derivation, the total number of ORDERS received).

In Lab 6, you are to leverage the code you wrote for Lab 2 and have the Connection Manager create a message queue, and write an ACK message (you will define the message struct...more below) for every ORDER that it receives onto the message queue.  In doing so, the Connection Manager will extract the unique order_id (you must make sure that your Client is sending the order_id as a unique number (as opposed to text) from the order received from the client, and will create a message containing that (numeric) order_id and the text "ORDERACK" in the message it adds to the queue.  You may simply wish to define the message struct to contain a long message type that may simply be populated with the char order_id[] converted to a long, with an additional char[] which will contain the ORDERACK text.

As you will be writing this and running it on the same machine (a requirement), you will further modify the trading Client to periodically TRY to read an ACK message off the queue for each order it sends.  You should run this in an additional thread that will periodically poll the message queue for ACK messages.  The client should contain code that will verify that it has extracted an ACK message for each and every ORDER it has sent.

You will need to imbed C Language message queue code inside your C++ program code.  Please refer to the sample program offered in Lab 1 for an example on how to do this.  If you wish, you may use the current header file instead of then older one linked above.




More information:

Spencer's Socket Site
Beej's Guide to Network Programming
Developerweb Unix Socket FAQ
Richard Steven's Home Page
BOOST Sockets
 

Mark Shacklette