data communication networkin project

CS4445

Project 4 (Due: 11/29/2018)

In this project, you will implement the chatting program for multiple user. Upon successful

implementation of this project, all team members will get 3% of extra credit on top of the final

grade. If the team implements GUI for this application, additional 2% will be added (total of 5%).

The details of the project are described as follows.

Part 1: Server

The server provides a linking service among the clients (users); the terms “user” and “client”

are interchangeably used throughout this project. When the server gets started, it reads a file

(“account.txt”) located in the server computer, that contains users’ ids and passwords. Each

line in the file contains an account information; id and password separated by one blank

space.

account.txt Example

id1 password1

id2 password2

id3 password3

id4 password4

…..

After reading “account.txt” file, the server displays the contents of the file and waits for TCP

connection request from the client by opening server socket. At this time, server runs a thread

for TCP connection from clients. This means that, a new thread will be created and be

waiting for the next new TCP connection when one connection is made

multithreaded

server. The server can take up to 100 concurrent connections.

When the server receives a connection request from any client, it must check how many

concurrent connections/users are open/online at this moment. If it is larger than 100, the

server sends an error message (the exact string “BUSY”) to the client and doesn’t accept the

new connection. If not, it accepts the new connection and proceeds to the following steps.

When the server receives connection requests from the clients, it just follows the same rules

of Log-in Phase for Project 3.

Once the client1 is successfully connected to the server, the server sends the list of users who

are currently on-line and ready to chat. And the server waits for the client1’s message with

the user id (e.g. client2’s user id). When the server receives the user id (with which the

client1 wants to chat), it sends client2 the following message;

“CONNECTIONREQUESTED” followed by 2 port numbers, port number2 and port

number1 (unique/unused port number randomly chosen by the server between 8000 and

9999), separated by ‘*’ (“CONNECTIONREQUESTED*port number2*port number1”).

These 2 port numbers are unique and randomly chosen by the server between 8000 and 9999.

Then, the server waits for the ACK message from the client2. Once the server receives an

ACK message (“READY”) from the client2, it sends client1 the ip address of the client2

followed by port number1 and port number2; message format will be “client2’s ip

address*port number1*port number2”. After sending these 2 messages, the server waits for

other messages from both clients.

If the server receives a message “DONE”, then it means that P2P chatting has been done and

2 involved clients are ready for another connection for chatting. When the server receives a

message “DISCONNECT”, then the socket connection is closed for that user. When the

client leaves the server, the server must update the list of the users who are currently on-line

and broadcast it to all clients who are still connected to the server.

Part 2: Client1

The client1 will connect to the server using TCP connection. When the client1 gets started, it

asks server’s ip address and port number. Then the user will enter the information to connect

to the server. When the client receives an error message (the exact string “BUSY”) from the

client and the connection will be terminated.

The client1 follows the same rules of Log-in Phase for Project 3.

Once the client1 logs in to the server, it will receive the list of users who are currently on-line

and ready to chat. Then the client1 sends a user (client2’s user id) id in the received list with

whom it wants to chat and waits for the response from the server. For this, the client1

program must check if the user enters the valid user id which is in the received list. If it is not,

then the client1 program displays an error message and lets the user try again.

Once the client1 receives the client2’s ip address, port number1 and port number2 from the

server in the form of “client2’s ip address*port number1*port number2”, then the client1

creates threads (one for server and the other one for client; bidirectional communication

between users) to make the connection to the received ip address. port number1 is used

client1’s server socket and port number2 is used for client1’s client socket. Once the client1

opens server socket using port number1 and waits for the connection from client2. Then, it

uses a client socket to initiate the connection to client2’s server socket. client1 will receive a

connection from client2 through server socket and bidirectional communication channel is

established between client1 and client2.

Each team will decide how to terminate the chatting.

When client1 wants to leave the chatting system, it must send a message “DISCONNECT” to

the server. Then client1 will be removed from the list of available users in the server which

will also update “account.txt”.

Part 3: Client2

Let’s assume that client2 is already online and is waiting for server’s message. Once client2

receives a message (“CONNECTIONREQUESTED*port number2*port number1”) from the

server, it opens a server socket using port number2 and waits for the connection from client1.

In the meantime, client2 creates client socket and tries to connect to client1’s server socket

using port number1. Now, bidirectional communication channel is established between

client1 and client2.

Each team will decide how to terminate the chatting.

Submissions

You must submit the program that

compiles

and

runs

without any error to receive full

points.

The programs must

terminate

gracefully without any exceptions/crashes/errors.

Along with the source code, please include the comments describing about how and

where to run your program; the IDE used, hardware/software environment (e.g. MacBook

with i5, Windows OS, etc…), special instruction to run the code, etc.

Don’t forget to put comments in your source code so that the reader can understand your

program easily.

On the top of each source code file, please don’t forget to put your Name.

You will submit the project to Canvas.

Need your ASSIGNMENT done? Use our paper writing service to score good grades and meet your deadlines.


Order a Similar Paper Order a Different Paper