CS 4873 Computer Networks

Spring 2008
Instructor Dr. Turgay Korkmaz

Homework 2
Due by Feb 20, 2008 (5:30pm)

 

 

In this assignment, you will use sockets in C or Java to implement a simplified shopping system which will consists of three components as shown in the following figure.

 

 

 

 

 

 

 

 

 

 


CUSTOMER:

You don’t need to implement anything here. Save ff.html file as a local file and edit it to change the host name and port number in the FORM based on your store server name and port number. Then using any web browser, customer opens ff.html file, fills out the form and submits it.

When it is submitted, the web browser will create a http POST message and send it to the server specified in the form in ff.html.

 

STORE-SERVER

You need to implement a server program that can process http POST message sent by the customer and process it (acts like a web server). Specifically, we want this server to figure out how many items the user wants, compute the cost and then contact the bank server to check if the customer has enough credit to complete this transaction or not (acts like a client to bank-server). Based on the reply from bank-server, store-server creates a dynamic html message and sends it as http reply message to the customer.

 

BANK-SERVER

You need to implement a server program that will maintain a database of customers (name, lastname, creditno, zipcode, amount). You can specify this list by hand in the program as a static array. When store-server asks about a customer, bank-server checks if the given name, creditcard number, zipcode are valid and has enough credit or not, and sends an appropriate reply to the store-server.

 

In summary, you need to implement two programs (e.g., store.c,  bank.c) and run them on different computers. bank.c will be a simple server, store.c will act as a server to customers and a client to bank-server.

 

To run your programs, you need to first figure out the names of hosts that you will use. For this, use

> hostname

Suppose the name of one computer is ten13.cs.utsa.edu and you run bank on this computer using port number 5678 as follows

> bank ten13.cs.utsa.edu  5678

Then run store server on another computer, say ten15.cs.utsa.edu and port number 6789  and also give bank server name and port number as parameters as follows

> store ten15.cs.utsa.edu  5678        ten13.cs.utsa.edu  5678

 

Finally, modify  <form action="http://HOST:PORT" method=post>  with

<form action="http://ten15.cs.utsa.edu:5678" method=post>  in ff.html.

Then using any web browser open ff.html.

 

When implementing your programs, please include extra printf statements so that I can follow your protocol and what they do.

GRADING (Total grade will be 100 points.)

1.      (20 points) Documentation (e.g., protocol design (msg formats, order, actions,)

2.      (40 points) Implementation (your source code files)

3.      (40 points) Execution (the output of your programs for a few transactions)

Submit documentation file, source code files, and output files through WebCT. But Please after submission, DO NOT change or delete your copies, we might execute them later together for grading….