Starting from:
$35

$29

Introduction to Network Programming Final Exam Solution


Problems:

    1) (50%) Implement a UDP Server and UDP Client. Your client should be able to send a file to the server and your server should be able to receive multiple files simultaneously.

Command format:

    • Server

        ◦ ./server {number-of-client-connections} {port}

    • Client

        ◦ ./client {server-ip} {server-port} {file-name}



Notes:

    • The specified file will locate on the same directory as client program

    • Clients will use ordered port to send multiple files:

        ◦ ./client {server-ip} {server-port} {file-name}

        ◦ ./client {server-ip} {server-port + 1} {file-name}

        ◦ ./client {server-ip} {server-port + 2} {file-name}

        ◦ ./client {server-ip} {server-port + 3} {file-name}

        ◦ ./client {server-ip} {server-port + 4} {file-name}
    2) (50%) Implement a TCP server. The server does the following functions:

        ◦ Server will give client a name by connection order. For example, the first client connects to the server, it will be named user1, the second client will be user2, the third client will be user3. When user2 disconnect and connect to the server again, it will be named user4.

        ◦ When client connect/disconnect to the server, server should output message: New connection from ip:port (user#) / (user#) ip:port disconnected

The client does the following functions:

    • Every user has his own group and only the user himself can manage his group.

    • The service accepts the following commands and at least 10 clients:

When client enter command incompletely E.g., missing parameters, the server should show command format for client.

Command
Description

Output







user1
list-users
List all online users.
Success
user2



...





Add <username>
Success
Add <username> successfully.
group-add <username>




into a group.




Fail
<username> does not exist.













Remove <username>
Success
Remove <username> successfully.
group-remove <username>
from the group.




Fail
<username> does not exist.









Send<message>to the user’s

Online group members received
group-send <message>
group, only the group
Success


members can see the message.

the message.








exit
Disconnect from the server.






Set up:

Download np_final_exam.zip from new E3. After extracting this file, you will see the following directory structure:

np_final_exam/

└── setup.sh --- This script is used to set up directories of your submission.



Submission:

Change directory to np_final_exam. Type ./setup.sh <your_student_id> to set up the directories. Then, you will see the following directories.

<your_student_id>/

├── P1/ --- This directory is for storing your answer to the problem 1.

├── server/

Put your server codes and a readme file that describes how to compile your program (Makefile is better) here.

└── client/

Put your client codes and a readme file that describes how to compile your program (Makefile is better) here.

└── P2/ --- This directory is for storing your answer to the problem 2.

Put your codes here and a readme file that describes how to compile your program (Makefile is better) here.



Type zip –r <your_student_id> <your_student_id> and upload the <your_student_id>.zip to new E3.

More products