UNIVERSITY    of     HOUSTON
Department of Computer Science

COSC 4377 - Introduction to Computer Networks
Section 07662
Spring 2001

Assignment 2 - Socket Programming

Due midnight, Wednesday, February 14, 2001

This programming assignment is designed to let you familiar with BSD sockets , and client-server application. This assignment weights 200 points.

The usual note:

Latest Hint:

Overview:

You will write two C/C++ programs using BSD sockets (using AF_INET and SOCK_STREAM) to implement a simplified banking system which follows a homemade protocol to exchange messages and perform withdraw, deposit, and query for customer's account. There will be only one client and one server for this assignment.

  1. Greeting message (HELO/OLEH) will be exchanged before sending account info.
  2. After verifying account is valid, withdraw, deposit, or query can be performed.
  3. Each message includes a checksum which can be used to verify correctness of a message.
  4. If server receives a message which is incorrect UID, unknown/unexpected action, or checksum error, this would be considered as an error. Server will send a message to client and ask for resend a new message.
  5. At any given time, server receives a good-bye (BBYE), the connection will be terminated.

The Protocol

Message format

Each message has 15 bytes which is consisted of 4 fields. For the sake of convenience, all data are stored as characters, and you can use a 16-charater array to store a message (16th byte would be an end-of-string, "\0"). So you can use string functions (strcat, strncat, strcpy, strncpy, etc.) to construct messages or extract individual field.

Messages exchanged between client and server

The following state diagram describes messages exchanged between a client and a server.

Here is a list of actions with detail explanations.

Sent from
Actions
Data
Explanation
Client
HELO
-
send an connection request to server
ACCN
acc number
send ACCount Number (acc number)
WTHD
amount
WiTHDraw amount of money
DPST
amount
DePoSiT amount of money
QURY
-
QUeRY account status
BBYE
-
notify the end of connection (Bye-BYE)
Server
OLEH
-
response to client's connection request
NOAC
-
NO such Account number
GDAC
-
valid (GooD) Account number
NEMN
-
Not Enough MoNey
DONE
amount
requested withdraw/deposit/query is DONE (amount reflects new status of account)
BYED
-
reply the end of connection request
EROR
-
indicate an ERroR (incorrect UID, unknown / unexpected action, or checksum error)

 

Requirements:

Discussion Questions (20 points):

Answer these questions and include them in your README file.
  1. Our homemade protocol for banking assumes reply from server is always correct. If client receives message from server and finds UID is different, unknown action, or checksum error, what is the best way to handle this kind of problem? Write a short paragraph (less than 3 lines) to state your solution.
     
  2. Our checksum function is not robust in term of error checking. Identify two better checksum functions/algorithms which are commonly used.

Submit your assignment:

Reference:


Last modified: February 12, 2001.
tihuang at cs . uh . edu