UNIVERSITY    of     HOUSTON
Department of Computer Science

COSC 4377 - Introduction to Computer Networks
Section 07664
Fall 2001

Assignment 2 - Socket Programming

Due midnight, Wednesday, October 3, 2001

New deadline: 11:59:59 PM, Thursday, October 4, 2001

This programming assignment is designed to let you familiar with BSD sockets , and client-server application. This assignment weights 150 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 simple grade recording system which follows a homemade protocol to allow student to login, submit grade, query grade/average, and change password. There will be only one client and one server for this assignment.

  1. Student first has to login with proper user id and password.
  2. After authenticated, student can submit it's grade, query grades/average, or change its password.
  3. If server receives a message which is incorrect UID, or unknown/unexpected action, this would be considered as an error. Server will send a message to client and ask for re-send a new message.
  4. At any given time, server receives a good-bye (BBYE), the connection will be terminated.

The Protocol

Message format

Each message has 28 bytes which is consisted of 3 fields. For the sake of convenience, all data are stored as characters, and you can use a 28-character array to store a message (28th 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
USER
user_id
send USER's id (user_id) to server
PSWD
password
send user's PaSsWorD (passwd) to server
SBMT
asgn# grade
SuBMiT grade for assignment asgn#
QURY
AVG QUeRY AVeraGe of all assignments
GRD
QUeRY GRaDes of all assignments
CHPW
new_passwd CHange PassWord to new_password
BBYE
-
notify the end of connection (Bye-BYE)
Server
NEED
USER NEED USER's id
NEED
PSWD NEED user's PaSsWorD
OLEH
user_id
say hello (OLEH) to user (user_id) after authentication
RECV
asgn#
RECeiVe grade for assignment assgn#
RPLY
AVG avg_grade RePLY the query of average grade (avg_grade)
GRD #1 #2 #3 #4
RePLY the query of grade of all 4 assignments
PWOK
-
new PassWord has been changed
BYED
-
reply the end of connection request
EROR
messages
indicate an ERroR (incorrect UID, incorrect user_id/password, or unknown / unexpected action) with your messages

Requirements:

Discussion Questions (20 points):

Answer these questions and include them in your README file. The answers are usually short and should be less than 3-4 lines.
  1. Our homemade protocol for grade submission assumes reply from server is always correct. If client receives message from server and finds UID is different, or unknown action, what is the best way to handle this kind of problem? Write a short paragraph (less than 3 lines) to state your solution.
     
  2. Is this user id/password authentication safe? State your reason.
     
  3. If your sever allows more than one client connecting to it, what kind of problems you might encounter which is not addressed in this assignment? And which part will you change in the design and/or protocol?
     

Submit your assignment:

Reference:


Last modified: October 3, 2001.
tihuang at cs . uh . edu