CS 9668/4438 Internet AlgorithmicsAssignment 4: Graduate and Undergraduate studentsDue date: November 281. In the consensus problem that we studied in class, initially each processor piin the systemhas an integer value vi and the goal is to ensure that at the end all processors select the samevalue v. Define the half consensus problem as above, except that now not all processors arerequired to select the same value, but at least half of them must select the same value. Forexample, assume that there are 4 processors p1, p2, p3, and p4. They initially have the valuesv1 = 2, v2 = 6, v3 = 1, and v4 = 9, respectively. In a feasible solution the processors might, forexample, pick these values: p1, and p2 select value 2, p3 selects value 6, and p4 chooses value 1.Assume that at most f processors in the system can fail (for simplicity let us assume that fis even) and that processors might only exhibit stopping failures (i.e. when a processor fails itstops sending messages for the duration of the algorithm, but a processor might not be ablefinish sending all the messages that it must send in a round). Assume also that the networkis complete, i.e., there is an edge between every pair of processors. Consider the followingalgorithm for the half consensus problem.Algorithm half consensus(id, f)Input: Processor’s id and maximum number of processors that can failOutput: Value selected by the processor to achieve half consensus.mssg ← hvidirounds ← 0vselected ← vidloop {if mssg 6= null then send mssg to all neighbours.mssg ← nullfor every message hvi received do if v rounds ← rounds+1if rounds = f2 + 1 then return vselected else mssg ← hvselectedi}(i) (25 marks) Prove that the above algorithm correctly solves the half consensus problem inthe presence of at most f crash failures, for any f (ii) (5 marks) Compute the time complexity and communication complexity of this algorithm.2. (5 marks) Consider a synchronous system in which processors can fail by clean crashes. Thismeans that in a round, a processor either sends all its messages or none. After crashing, aprocessor does not send messages in the following rounds. What is the minimum number ofrounds that the algorithm described in the previous question needs to perform to ensure thatat the end all the processors select the same value? You need to prove that your answer isindeed the minimum number of required rounds and that all processors will achieve consensus.3. (i) (30 marks) In class we studied the use of consistent hashing in Chord for finding keys in apeer-to-peer network. Assume that each processor pi has a finger table that allows it to storeits own address plus the addresses of two other processors. Which addresses must be stored inthe table so as to, both, minimize the number of messages needed to find a key (or to decidethat a key is not stored in the system), and to ensure that every key can be found?You must explain your answer and show that the number of messages is minimized.(ii) (5 marks) Prove that with your choice of fingers any key stored in the system can be found.(iii) (5 marks) Compute the maximum number of messages that need to be sent to either finda key or to determine that the key is not stored in the system.4. (25 marks) Write a synchronous algorithm in Java that a processor in a peer-to-peer systemcan use to find a given set of keys, assuming that the consistent hashing scheme described inclass is used to determine where to store the 代做CS 9668/4438作业、代写Java编程作业、代做Java作业、代写Algorithmics作业 代做Pythkeys. Your algorithm must use finger tables tofind the keys. To find a key your algorithm cannot simply send messages to the successorsuntil the key is found. The finger table must be searched to find the processor closest to theposition of the desired key; a message must then be sent to such a processor.To test your implementation we will use the simulator for distributed algorithms of DanielServos. For simplicity we will assume that only one processor, P, needs to find keys in thepeer-to-peer system. Upon termination the algorithm must return a string of the formk1 : p1 k2 : p2 · · · kr : prwhere k1, k2, . . . , kr are the keys that processor P needs to find and piis the processor storingkey kifor each i = 1, 2, . . . . , r. Before terminating, processor P will send an END message toits successor. An END message will pass from each node that receives it to its successor toensure that all processors receive it. Processors other than P upon termination will return anempty string .In class we discussed a simple search algorithm that does not use the finger tables, but in whicha processor simply sends messages to its successor. A Java implementation of the algorithmwill be posted in the course’s website. You can use this algorithm as starting point for yoursolution. Since the simulator was not really designed to emulate peer-to-peer systems, in thenetwork configuration file we will use the DataKeys command to specify the keys to store in theprocessors (these will be negative numbers), the keys that the processor P needs to find (theseare positive numbers smaller than 1000), and the processor addresses in the finger table (thesewill be positive numbers larger than 1000). If this is a bit confusing, look at the Java codeposted in the website to see how the two above sets of keys and the finger table of a processorcan be determined from the configuration file.If you cannot write a program in Java, you will be allowed to submit a solution in pseudocode.However, you are strongly encouraged to write your algorithm in Java.5. (5 marks) Optional question. You can download from the course’s website a chat clientand chat server that allow messages to be exchanged between a client and a server running ondifferent computers. There are 2 versions of these programs, one written in C and the otherwritten in Java.Study the above programs and modify them to write either in C or in Java a file server and aclient. Your file server will be executed first and it must wait for requests from clients. Aftera client establishes a connection with the server the user sitting at the client’s computer typesthe name of a file and sends it to the server. When the server receives the name of the file itchecks that the file is stored in the computer hosting the server. If the file is found a FOUNDmessage is sent to the client followed by a sequence of messages, each containing one line oftext from the file. After the file has been transmitted and END message is sent to the client.If the file is not found in the server an END message is sent to the client.The client saves the file and it closes the connection when it receives an END message. Forsimplicity you can assume that all the files are text files and all of them are stored in the samedirectory or folder where the server program is stored.You need to email me your code and provide a hard copy of it. You can write the programin another programming language if you want, as long as we can run your program on theresearch network.转自:http://ass.3daixie.com/2018112882668344.html