COSC 6377 - Computer Networks

Fall 2011

MW 2:30-4:00pm at AH301

Instructor Omprakash Gnawali

Project - 1

Due: October 5, 2011

Webpage Update Notification Service

In this project, we will build a network service that provides notification whenever a webpage is updated. This is much like RSS, but our update service will notify us whenever any webpage changes.

You will need to program two components in this project. First, the server that keeps track of the webpages and sends the notification whenever a webpage is updated. Second, a client that can subscribe and unsubscribe to updates about a webpage, and receives the notifications when the webpage changes.

The server

The server listens on a well-known port. The server accepts SUBSCRIBE and UNSUBSCRIBE messages in a standardized JSON format.

SUBSCRIBE. Arguments: client IP address, client port, webpage URL. The server adds this information to its database. The server returns a SUCCESS return value if the request was successful. Otherwise, the server returns FAIL.

UNSUBSCRIBE. Arguments: client IP address, client port, webpage URL. The server deletes this information from its database. The server returns a SUCCESS return value if the request was successful. Otherwise, the server returns FAIL.

The server periodically downloads all the webpages in this database and if it has changed since the last time it downloaded the webpage, it will send notification to all the clients subscribed for updates for that webpage. The notification is also sent using JSON. Your server may store the webpages in the filesystem or in the memory. If you decide to use the filesystem, please create a directory called cache and put all the downloaded files inside that directory.

NOTIFY. Arguments: webpage URL.

The server is launched by using this command:

p1-server port

The server will listen on the specified port.

The client

Write two client programs, client-configure and client-callback.

client-configure subscribe/unsubscribe server-ipaddr server-port callback-ipaddr callback-port url

server-ipaddr and server-port tells the client how to connect to the server. callback-ipaddr and callback-port tells the server the machine and port on which a client will listen for updates regarding the URL. The client sends a SUBSCRIBE or UNSUBSCRIBE message to the server with the provided URL.

client-callback port listens on a port and whenever it receives a NOTIFY from the server displays which URL has changed.

Subscription Database

Subscription database is a text file, that is, it should be human readable. It should be called subs.txt and should be located in the same directory as your server. You are welcome to come up with your own format for the subscription database.

Robustness

The server must not lose subscription information even when it crashes or the user terminates the server. When you restart the server, it should still remember all the registered clients and webpages.

If the client is no longer listening (due to crashes, etc.), the server should detect that within 30 seconds and flush that subscription.

Message format

All the messages between the client and the server will be in JSON. JSON is now becoming a standard way of exchanging information on the web. You can read more about JSON on this page:
http://en.wikipedia.org/wiki/JSON

We have standardized the messages between the client and the server across the projects so that we can mix and match client and server implementations from different project submissions. When we grade the project, we will also test if your server implementation can operate with another standard compliant implementation of the client and your client can work with another standard compliant implementation of the server.

The fields in the subscription and unsubscription message are:

FieldDescription
actionSpecifies the action desired by the client. Valid values are subscribe and unsubscribe
ipThe IP address of the client that is listening for updates from the server.
portThe TCP port at which the client is listening for updates from the server. Use port greater than 10000
urlThe URL the client wishes to monitor for updates.

When the server receives the subscribe or unsubscribe message, the server returns a message with the following field:

FieldDescription
returnvalueTells the client if the request to subscribe was successful. Valid values are success and fail.

The fields in the notify message are:

FieldDescription
actionTells the client the monitored url is updated. The only valid value is notify.
urlThe URL for which the action should be taken by the client.

If you are not certain if your message is a valid JSON, you can use the validator at this URL: http://jsonlint.com/. You can copy and paste your message and the script there will tell you if your message is a valid JSON. If your message is not a valid JSON, it will not be possible to inter-operate your client and server with the client and server written by other students -- their JSON parsing routine might raise a flag and terminate.

Simple Test Webpage

You can use this URL as a simple example of a webpage that changes over time:
http://www2.cs.uh.edu/~gnawali/courses/cosc6377-f11/p1/changepage.php?change=1

The argument n at the end of the URL (change=n) tells the page how frequently it should change. If you use 1 for n, the page will change every second. If you find this page convenient for testing simple cases, feel free to use it. You are not required to use this page as a test case and we expect your system to work with more complex pages.

Project Submission

Create a tarball of your code and submit HW through Moodle. Don't forget to delete the subscription database because you zip your directory. Please include README.txt in your tarball that will tell us how to compile your code. If your code requires any external libraries, you should mention them in README and include the library in the tarball. In the README, explain how frequently your server checks for updates and why. Also explain how your server handles multiple subscriptions for the same page.