Python代写 | COMP3331/9331 Computer Networks and Applications

本次Python代写是设计的自定义应用程序层协议,并使客户端和服务器通过TCP进行通信

COMP3331/9331 Computer Networks and Applications
Assignment for Term 3, 2020

In this programming assignment, you will implement the client and server programs of a
discussion forum application, similar in many ways to the discussion forum we use for this
course. The difference being that your application is not web-based (i.e. non-HTTP) but uses a
custom application layer protocol which you will design. The client and server must
communicate over TCP. Your application will support a range of operations including create a
new user account, create or delete a new thread, post a message on a thread, edit or delete
messages, upload and download attachments to/from a thread, read a thread, list all threads and
shutting down the server. You will implement the application protocol to implement these
functions. The server will listen on a port specified as the command line argument and will wait
for a client to connect. The client program will initiate a TCP connection with the server. Upon
connection establishment, the user will initiate the authentication process. The client will interact
with the user through the command line interface. Following successful authentication, the user
will initiate one of the available commands. All commands require a simple request response
interaction between the client and server. The user may execute a series of commands (one after
the other) and eventually quit. Both the client and server MUST print meaningful messages at
the command prompt that capture the specific interactions taking place. You are free to choose
the precise text that is displayed. Examples of client server interactions are given in Section 8.
The assignment will be tested in two configurations. In the first configuration, the server will
interact with a single client at any given time. Multiple clients can connect with the server in a
serial fashion, i.e., one client connects, interacts and quits, the second client connects, interacts
and quits, and so on. The server design is significantly simplified (i.e. you won’t need to use
multi-threading) if you only wish to implement this portion of the assignment. A correct
implementation of this first part is worth 70% of the assignment marks (14 marks, see Section
7). In the second configuration, the server must interact with multiple clients concurrently. The
client design will only require minimal changes to meet this requirement. The server design,
however, would require a significant change, in that, the server would need to send and receive
messages to and from multiple clients concurrently. We strongly recommend using multithreading to achieve this. The interaction with a single client, would however be similar as in
the first configuration. Note that, a correctly implemented multi-threaded server should also be
able to interact correctly with a single client at any given time. So, if you design your client and
server to achieve all functionality expected for the second configuration, it should work as
expected in the first configuration.
3.1 File Names & Execution
The main code for the server and client should be contained in the following files: server.c,
3
or Server.java or server.py, and client.c or Client.java or client.py. You
are free to create additional files such as header files or other class files and name them as you
wish. Submission instructions are in Section 5.
The server should accept the following arguments:
• server_port: this is the port number which the server will use to communicate with
the clients. Recall that a TCP socket is NOT uniquely identified by the server port
number. It should thus be possible for multiple TCP connections to use the same serverside port number (in Part 2).
• admin_passwd: this is the admin password for the server. It is required to shut down the
server (see operation SHT later).
The server should be executed before any of the clients. It should be initiated as follows:
If you use Java:
java Server server_port admin_passwd
If you use C:
./server server_port admin_passwd
If you use Python:
python server.py server_port admin_passwd OR
python3 server.py server_port admin_passwd
The client should accept the following two arguments:
• server_IP: this is the IP address of the machine on which the server is running.
• server_port: this is the port number being used by the server. This argument should
be the same as the first argument of the server.
Note that, you do not have to specify the port to be used by the client. You should allow the OS
to pick a random available port. Each client should be initiated in a separate terminal as follows:
If you use Java:
java Client server_IP server_port
If you use C:
./client server_IP server_port
If you use Python:
python client.py server_IP server_port OR
python3 client.py server_IP server_port
Note: When you are testing your assignment, you should run the server and one or more clients
on the same machine in separate terminals. In this case, use 127.0.0.1 (local host) as the server
IP address.
3.2 Authentication
You may assume that a credentials file called credentials.txt will be available in the current
working directory of the server with the correct access permissions set (read and write). This file
will contain username and passwords of authorised users. They contain uppercase characters (A-
4
Z), lowercase characters (a-z) and digits (0-9) and special characters.
An example credentials.txt file is provided on the assignment page. We
may use a different file for testing so DO NOT hardcode this information in your program. You
may assume that each username and password will be on a separate line and that there will be
one white space between the two. There will only be one password per username. A sample
credentials file is provided on the assignment page. We may use a different file while testing.
Upon execution, a client should first attempt to setup a TCP connection with the server.
Assuming the connection is successful, the client should prompt the user to enter a username.
The username should be sent to the server. The server should check the credentials file
(credentials.txt) for a match. If the username exists, the server sends a confirmation message to
the client. The client prompts the user to enter a password. The password is sent to the server,
which checks for a match with the stored password for this user. The server sends a confirmation
if the password matches or an error message in the event of a mismatch. An appropriate message
is displayed to the user. In case, of a mismatch, the client prompts the user to enter a username.
If the username does not exist, the sever sends an appropriate message to the client. The client
prompts the user to enter a new password. The password is sent to the server. The server creates
a new username and password entry in the credentials file (appending it as the last entry in the
file). A confirmation is sent to the client. The client displays an appropriate message to the user.
You should make sure that write permissions are enabled for the credentials.txt file (type
“chmod +w credentials.txt” at a terminal in the current working directory of the
server).

When your assignment is tested with multiple concurrent clients, the server should also check
that a new client that is authenticating with the server does not attempt to login with a username
that is already being used by another active client (i.e. a username cannot be used concurrently
by two clients). The server should keep track of all active users and check that the username
provided by an authenticating client does not match with those in this list. If a match is found,
then a message to this effect should be sent to the server and displayed at the prompt for the user
and they should be prompted to enter a username.


程序代写代做C/C++/JAVA/安卓/PYTHON/留学生/PHP/APP开发/MATLAB


本网站支持淘宝 支付宝 微信支付  paypal等等交易。如果不放心可以用淘宝交易!

E-mail: [email protected]  微信:itcsdx


如果您使用手机请先保存二维码,微信识别。如果用电脑,直接掏出手机果断扫描。

blank

发表评论