Distributed and Concurrent Systems 25.4.2008 Exercise 7 Last lectures 28.-29.4. Last exercises 6.5 10:30 - 12 T/D106. Course exam 6.5. 08:00-10:00. We shall implement the time agreement with a (overly simple) server-based TCP-protocol. The server application has a port to init agreement. The agreement is initiated by giving own applicable times and the addresses of the other requested clients. Each functioning client listens a TCP port to accept agreement requests. When the server receives a new agreement init request, it connects to all requested clients, asks for applicable times, receives them, makes the decision and announces the time to all clients (and closes connections). For simplicity, we use simple integers as applicable times. The first integer common to all will be chosen. If some client is unreachable (or gives badly formed answers), it will be ignored. Message lines are separated by a newline. The initial request by the first client to server is of form: AGREE_INIT AGREE_MY_TIMES 1 3 4 5 8 9 10 11 ... AGREE_MY_FRIENDS ip_addr1:port1 ip_addr2:port2 ... where "1 3 4 5 8 9 10 11 ..." is the applicable time for the client, and "ip_addr1:port1 ..." is the list of addresses of the other requested clients. The server replies AGREE_INIT_WAIT After this, the servers connects to each client given in AGREE_MY_FRIENDS -field, and send message AGREE_GIVE_TIMES Client should reply AGREE_MY_TIMES 3 4 5 6 ... After the server has got all replies (or a reasonable timeout), it makes the decision, and sends to all connections: AGREE_DECISION 3 where 3 is the common time. If no time is suitable to all, server replies by -1. After reply, server closes all connections. 37) What weaknesses (or defects) the protocol has? Augment the protocol to fix these weaknesses. How much the augmentations would increase programming work in client and server? The follow tasks are made using the original protocol. The following X3 exercise is obligatory for all students. The answers to X-exercises have to be unique for every student. No copies of the same answer are allowed. The answer has to be sent by Thursday 2:00 pm (the previous day). You will receive an acknowledgment upon successful processing. Answers will be graded. The answer must also contain a short self-evaluation (as a program comment) in which you describe whether the program works, nearly works, or does not probably work; how efficient it is, etc. A correct and proper self-evaluation is worth one point (in case of a proper answer). Send your answer to using cs to user sjuva with a subject HS_X3_username and the answer (with self-evaluation) as the body of the message (no attachments). At simplest using program mail at cs: /usr/ucb/mail -s HS_X3_username sjuva < username.java Where username is your cs username and username.java is a text file containing your answer. To make program compilable, the main class name must be exactly the same as your user name. No need to include AgreeProto class to your answer. X3) Implement the client for the above protocol. This consists of two parts. Firstly, the part that initiates the agreement and connects to the server. Secondly, the part that listens for new agreements and replies to the requests coming from server. Make The listening part as a separate thread. For half points, make at least one part. 40-41) Implement the server for above protocol. 42) Make the server concurrent so that it will concurrently connect each client. To help the implementation, in waw-page is AgreeProto -helper class, and skeletons of client and server. For testing purposes, there are jar-files of both client and server.