Advanced Computer Communications (CNCO3002) Page 1 of 5 2nd Semester 2023
CRICOS Number: 00301
Advanced Computer Communications (CNCO3002)
CURTIN UNIVERSITY
School of Electrical Engineering, Computing and Mathematical Sciences
Discipline of Computing
Assignment
Simple Function Call
Due Date: 4pm (local time) on Monday 9th of October 2023
The objective of this network programming assignment is to develop two complementary programs, a
client and a server, which implement a simple application program, called Simple Function Call (SFC).
A. Requirements
The SFC server (server) has a set of functions that can be used by one or more SFC clients (client). As
shown in Figure 1, each client and the server are connected by two parallel TCP connections: requestline and reply-line. The client uses request-line to send a function name together with its necessary
parameters to the server. The server uses reply-line to transfer the result of executing the function. For
each request, each client stores every request and its reply in a file called log_file.
For request-line, the server listens (passive mode) on a port L. A client initiates request-line (active
mode) to the server on port L. On the other hand, for reply-line, the server uses port L+1 in active
mode, and the client is in a passive mode on port U. The client sends to the server its port number U
via request-line so that the server can initiate reply-line to the port. The reply-line is closed by the
server when the request-line is closed.
Figure 1: Connection between SFC server and its clients
Details of assignment requirement are as follows.
1. Write a TCP concurrent server program (server) that is waiting for some clients at its port L. Use
one of your assigned port numbers, e.g., L = 52000.
2. For each connection from a client C, the server creates a child thread S that will serve the client
C. You can create a new thread or use one available from a pool of threads that you have created
when you started your server (discussed in lecture). The child server S is waiting to receive client
C’s port number U. Use one of your assigned port numbers, e.g., U = 52002. Receiving U, child
SFC
Client
SFC
Server
Request Line
Reply Line
Port L
Port U Port L+1
An ephemeral Port
Advanced Computer Communications (CNCO3002) Page 2 of 5 2nd Semester 2023
CRICOS Number: 00301
server S initiates a reply-line at port number L+1, e.g., L+1 = 52001 to port U of the client. At
this stage, client C and server S are connected via request-line and reply-line.
3. Each child server S is waiting for its client C’s valid commands/functions/requests at request-line
and provides a service according to the request. For each valid request, server S sends the request’s
result to client C. Otherwise, server S sends an error message to client C. Server S sends the reply
or error message via reply-line.
The followings are the details of valid requests / commands from a client C to a server S. Notice
that for simplicity, each command does not contain any space.
• ADD(x,y)
When a user enters the command, client C sends it to server S, stores the request in log_file,
and waits to receive its result from server S. Receiving the command, server S sends the result
of x+y to client C. For example, receiving ADD(2,3), server S will send the result of 2+3, i.e.,
5 to client C. Receiving the result, client C shows the result on the screen, and also stores it
in log_file.
• MUL(x,y)
When a user enters the command, client C sends it to server S, stores the request in log_file,
and waits to receive its result from server S. Receiving the command, server S sends the result
of x*y to client C. For example, receiving MUL(2,3), server S will send the result of 2*3, i.e.,
6 to client C. Receiving the result, client C shows the result on the screen, and also stores it
in log_file.
• DIV(x,y)
When a user enters the command, client C sends it to server S, stores the request in log_file,
and waits to receive its result from server S. Receiving the command, server S sends the result
of x DIV y to client C. For example, receiving DIV(5,2), server S will send the result of 5
DIV 2, i.e., 2 to client C. Receiving the result, client C shows the result on the screen, and
also stores it in log_file.
• MOD(x,y)
When a user enters the command, client C sends it to server S, stores the request in log_file,
and waits to receive its result from server S. Receiving the command, server S sends the result
of x MOD y to client C. For example, receiving MOD(5,2), server S will send the result of 5
MOD 2, i.e., 1 to client C. Receiving the result, client C shows the result on the screen, and
also stores it in log_file.
• INFO
When a user enters the command, client C sends it to server S, stores the request in log_file,
and waits to receive its result from server S. Receiving the command, server S sends the list
of available functions, i.e., ADD(x,y), MUL(x,y), DIV(x,y), MOD (x,y), INFO, and QUIT
together with a short explanation of how to use each of them. The list of available functions
and their information is stored in a file, called info in server. Specifically, receiving request
Advanced Computer Communications (CNCO3002) Page 3 of 5 2nd Semester 2023
CRICOS Number: 00301
INFO, server S sends the content of file info to client C. Please create file info yourself.
Receiving the result, client C shows the result on the screen, and also stores it in log_file.
• QUIT
This command is used by client C to tell server S that it is terminating the SFC session with
server S. When a user enters the command, client C sends it to server S, stores the request in
log_file, and waits to receive its result from server S. Receiving the command, server S sends
a ‘goodbye’ message (e.g., Thank you for using SFC. Goodbye!) and terminates reply-line.
Receiving the message, client C shows it on its screen and terminates connection.
4. The concurrent server is able to accept up to max_client simultaneous clients. If a child server S
does not receive any command (from its client C) within a max_time, the child server S sends a
‘goodbye’ message, closes both request-line and reply-line and terminates. The max_client, and
max_time must be arguments passed to the SFC server when the server is started. The valid
numbers for these arguments are:
• max_client: 1 to 10.
• max_time: 1 to 120 seconds.
5. Write a TCP client program (client) with the following details.
a) The client connects to the server that is waiting at port L.
client Server_IP_address port
or
client Server_machine_name port
Note, Server_IP_address is the SFC server’s address (in dotted decimal notation).
Once the SFC client is connected to the SFC server, the SFC client waits for user command,
and a prompt “Client>” should be shown on the screen.
b) Once connected to the server, i.e., request-line is on, the client creates a passive socket at port
U, and sends the port U to the server, also via request-line. Receiving port U information, the
server connects to the client’s port U. At this stage, the reply-line is established.
c) Each time the client sends a request (e.g., ADD(2,3)) to the server, the client logs the request
in a file, named log_file, and later also writes the reply it receives from the server to the file.
For example, the following information would be stored in the log_file:
ADD(2,3); the result is: 5
d) Each valid command (including its parameter) should be shown on the client’s screen and be
forwarded to the server. Notice that both the client and the server should check for the validity
of each command.
e) Each received result should be shown on the client’s screen.
Advanced Computer Communications (CNCO3002) Page 4 of 5 2nd Semester 2023
CRICOS Number: 00301
6. Your program must be written in ‘C’ using TCP/IPv4 sockets and must run on a computer in any
lab in our discipline, e.g., Lab 219.
7. Make sure to check for error return from each system call, and to close every socket created.
8. You MAY make your own assumptions/requirements other than those already given. However,
YOU HAVE TO DOCUMENT ANY ADDITIONAL ASSUMPTIONS/LIMITATIONS FOR
YOUR IMPLEMENTATIONS.
B. Instruction for submission
1. Assignment submission is compulsory. Late submission is allowed. As stated in the unit outline,
the penalty for late submission is as follows:
• For assessment items submitted within the first 24 hours after the due date/time, students will
be penalised by a deduction of 5% of the total marks allocated for the assessment task;
• For each additional 24 hour period commenced an additional penalty of 10% of the total marks
allocated for the assessment item will be deducted; and
• Assessment items submitted more than 168 hours late (7 calendar days) will receive a mark of
zero.
Due dates and other arrangements may only be altered with the consent of the majority of
the students enrolled in the unit and with the consent of the lecturer.
2. You must
(i) put your program files, e.g., server.c, client.c, makefiles, and other required files, in your
home directory named CNCO3002/Assignment. Note that these files will be used when
marking your assignment during program demonstration.
(ii) submit a soft copy of your assignment to the unit Blackboard (in one zip file), i.e.,
YourID_Assignment.zip. The soft copy includes your assignment report and all your
assignment code in (i). Note that the assignment code submitted to Blackboard serves as a
backup copy.
3. The assignment report MUST include:
• A signed cover page (i.e., declaration of originality). The declaration form is available from the
unit Blackboard. By signing the form, among others, you agree on the following two statements:
1. The work I am submitting is entirely my own, except where clearly indicated otherwise and
correctly referenced.
2. Even with correct referencing, my submission will only be marked according to what I have
done myself, specifically for this assessment. I cannot re-use the work of others, or my own
previously submitted work, in order to fulfil the assessment requirements.
• A printout of your assignment code that MUST include (i) all source code for the programs
with proper in-line and header documentation. Use proper indentation so that your code can be
Advanced Computer Communications (CNCO3002) Page 5 of 5 2nd Semester 2023
CRICOS Number: 00301
easily read. Make sure that you use meaningful variable names and delete all unnecessary /
commented code that you created while debugging your program; and (ii) readme file that,
among others, explains how to compile your program and how to run the program.
• Detailed discussion on all shared data structures used in the server, and how any mutual exclusion
/ thread synchronization is achieved on shared resources, e.g., memory, server’s record, and what
threads access the shared resources.
• Description of any cases for which your program is not working correctly or how you test your
program that make you believe it works perfectly.
• Sample inputs and outputs from running your programs. For each sample output, you MUST
explain if the output is correct or incorrect.
Your report will be assessed (worth 20% of the overall mark for the Assignment)
4. Assignment demonstration
• You may be required to demonstrate your program. The time schedule for the demonstration
will be announced later.
• For the program demo, you MUST keep the source code of your programs in your home
directory, and the source code MUST be that you have submitted.
• The programs must run on any computer in the department labs.
Failure to meet these requirements may result in the assignment not being marked.