Advanced Computer Communications (CNCO3002) Page 1 of 5 2nd Semester 2023CRICOS Number: 00301Advanced Computer Communications (CNCO3002)School of Electrical Engineering, Computing and Mathematical Sciences
Discipline of ComputingAssignment

1. Simple Function Call

Due Date: 4pm (local time) on Monday 9th of October 2023The objective of this network programming assignment is to develop twocomplementary programs, aclient and a server, which implement a simpleapplicationprogram, 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). Asshown 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 necessaryparameters to the server. The server uses reply-line to transfer the result ofexecuting the function. Foreach 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 (activemode) to the server on port L. On the other hand, for reply-line, the server uses port L+1 in activemode, and the client is in a passive mode on port U. The client sends to the server its port number Uvia request-line so that the server can initiate reply-line to the port. The reply-line is closed by theserver when the request-line is closed.Figure 1: Connection between SFC server and its clientsDetails of assignment requirement are as follows.

1. Write a TCP concurrent server program (server) that is waiting for some clients at its port L. Useone 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 poolofthreads that you have createdwhen you started your server (discussed in lecture). The child server S is waiting to receiveclientC’s port number U. Use one of your assigned port numbers, e.g., U = 52002. Receiving U, childserver S initiates a reply-line at port number L+1, e.g., L+1 = 52001to port U of the client. Atthis 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-lineand provides a service according to the request. For each valid request, server S sends the request’sresult to client C. Otherwise, server S sends an error message to client C. Server S sends the replyor error message via reply-line.The followings are the details of valid requests / commands from a client C to a server S. Noticethat 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 itin 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 itin 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 resultof 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 resultof 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, andalso 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 listof available functions, i.e., ADD(x,y), MUL(x,y), DIV(x,y), MOD (x,y), INFO, and QUITtogether 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

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.
• QUITThis command is used by client C to tell server S that it is terminating the SFC session withserver S. When a user enters the command, client C sends it to server S, stores the request inlog_file, and waits to receive its result from server S. Receiving the command, server S sendsa ‘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.

  1. The concurrent server is able to accept up to max_client simultaneous clients. If a child server Sdoes 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, andmax_time must be arguments passed to the SFC server when the server is started. The validnumbers for these arguments are:
    • max_client: 1 to 10.
    • max_time: 1 to 120 seconds.
  2. 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 portorclient Server_machine_name portNote, 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 portU, and sends the port U to the server, also via request-line. Receiving port U information, theserver 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 requestin 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: 5d) Each valid command(including its parameter) should be shown on the client’s screen andbeforwarded to the server. Notice that both the client and the server should check for the validityof each command.e) Each received result should be shown on the client’s screen.Advanced Computer Communications (CNCO3002) Page 4 of 5 2nd Semester 2023CRICOS Number: 00301
  3. Your program must be written in ‘C’ using TCP/IPv4 sockets and must run on a computer in anylab in our discipline, e.g., Lab 219.
  4. Make sure to check for error return from each system call, and to close every socket created.
  5. You MAY make your own assumptions/requirements other than those already given. However,YOU HAVE TO DOCUMENT ANY ADDITIONAL ASSUMPTIONS/LIMITATIONS FORYOUR IMPLEMENTATIONS.
    B. Instruction for submission
  6. 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 willbe penalised by a deduction of 5% of the total marks allocated for the assessment task;
    • For each additional 24 hour period commenced an additional penaltyof 10% of the total marksallocated for the assessment item will be deducted; and• Assessment items submitted more than 168 hours late (7 calendardays) will receive a mark ofzero.Due dates and other arrangements may only be altered with the consentof the majority of
    the students enrolled in the unit and with the consent of thelecturer.

2. You must

(i) put your program files, e.g., server.c, client.c, makefiles, and other required files, in yourhome directory namedCNCO3002/Assignment. Note that these files will be used whenmarking 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 yourassignment code in (i). Note that the assignment code submitted to Blackboard serves as abackup copy.

3. The assignment report MUST include:

• A signed cover page (i.e., declaration of originality). Thedeclaration form is available from theunit 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 andcorrectly referenced.
  2. Even with correct referencing, my submission will only be marked according to what I havedone myself, specifically for this assessment. I cannot re-use the work of others, or my ownpreviously submitted work, in order to fulfil the assessment requirements.
    • A printout of your assignment code that MUST include (i) all source code for the programswith proper in-line and header documentation. Use proper indentation so that your code can beAdvanced Computer Communications (CNCO3002) Page 5 of 5 2nd Semester 2023CRICOS Number: 00301easily 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 testyourprogram that make you believe it works perfectly.• Sample inputs and outputs from running your programs. For each sample output, you MUSTexplain if the output is correct or incorrect.
    Your report will be assessed (worth 20% of the overall mark for theAssignment)
  3. Assignment demonstration
    • You may be required to demonstrate your program. The time schedulefor the demonstrationwill be announced later.• For the program demo, you MUST keep the source code of yourprograms in your homedirectory, 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 WX:codehelp

闷骚的单杠
1 声望0 粉丝