Goal Research Learning Assignment Help
For this assignment, you will be asked to implement a part of the peer-to-peer (P2P) protocol Circular DHT which is described in Section 2.6 of the text Computer Networking (6th ed) and would be discussed in the lecture. A primary requirement for a P2P application is that the peers form a connected network at all time. A complication that a P2P network must be able to deal with is that peers can join and leave the network at any time.
For example, if a peer leaves the network suddenly (because it has crashed), then the remaining peers must try to keep a connected network without this peer. It is therefore necessary to design P2P networks so that they can deal with these complications. One such method has been described in Section 2.6 of the text, under the heading of Peer Churn for circular DHT. You will also learn how to implement reliable data transmission over UDP.
2.1. Learning Objectives
On completing this assignment, you will gain sufﬁcient expertise in the following
- Understanding of routing mechanism and connectivity maintenance in peer- to-peer systems, and Circular DHT in particular.
- Socket programming for both UDP and TCP transport protocols.
- Protocol and message design for applications.
- Basic understanding of creating a reliable connection.
The following is extracted from the Peer Churn section of the text:
“In P2P systems, a peer can come or go without warning. Thus, when designing a
DHT, we also must be concerned about maintaining the DHT overlay in the presence of such peer churn. To get a big-picture understanding of how this could be
accomplished, let’s once again consider the DHT in Figure 2.27(a) [Reproduced here
as Figure 1]. To handle peer churn, we will now require each peer to track (that is, know the IP address of) its ﬁrst and second successor; for example, peer 4 now tracks both peer 5 and peer 8. We also require each peer to periodically verify that its two
successors are alive (for example, by periodically sending ping messages to them and asking for responses). Let’s now consider how DHT is maintained when a peer abruptly leaves. For example, suppose peer 5 in Figure 2.27(a)[Figure 1 in this assignment spec] abruptly leaves. In this case, the two peers preceding the departed peer (4 and 3) learn that 5 has departed, since it no longer responds to ping messages.
Peers 4 and 3 thus need to update their successor state information. Let’s consider
how peer 4 updates its state:
- Peer 4 replaces its ﬁrst successor (peer 5) with its second successor (peer 8).
- Peer 4 then asks its new ﬁrst successor (peer 8) for the identiﬁer and IP
addresses of its immediate successor (peer 10). Peer 4 then makes peer 10 its second successor.
Having brieﬂy addressed what has to be done when a peer leaves, let’s now consider what happens when a peer wants to join the DHT. Let’s say a peer with identiﬁer 13 wants to join the DHT, and at the time of joining, it only knows about peer 1’s existence in the DHT. Peer 13 would ﬁrst send peer 1 a message, saying ”what will be peer 13’s predecessor and successor?” This message gets forwarded through the DHT until it reaches peer 12, who realises it will be peer 13’s predecessor and its current successor, peer 15, will become its successor. Next, peer 12 sends this predecessor and successor information to peer 13. Peer 13 can now join the DHT by making peer
15 its successor and by notifying peer 12 that it should be its immediate successor to peer 13.
- Assignment description
For this assignment, you are asked to write a Java, C, or Python program which can handle query/response and peer churn (leaving only) for circular DHT as described in Section 3. However, there are afew important points that you need to note:
- You will be running each peer in an xterm on one machine. Therefore, tracking a peer no longer means knowing the IP address but in your case, it means knowing the port numbers (we will further elaborate on this point later).
- You will not be able to use built in ping in OS to determine whether the two successors of a peer are still alive. You will need to implement your own ping mechanism.
Please make sure that your P2P program is working in the CSE laboratory as we will test (and mark) your assignment using CSE machines.
If your program does not work on CSE machine, you will get ‘0’ mark for
assignment as we cannot accept running the code on your own machine.
In the following description, we will continue to use the example in Figure 1, but a very important point that you need to note is that: you should not make any assumption regarding the number of peers and their identities in your program. The number of peers and their identities to be used for the evaluation can change from student to student. You should therefore make sure that you test that your program can deal with the general situation. You can assume that there would be no more than 10 peers and the peer identities is within the range of 0-255.
There are number of mandatory requirements:
- You must name your program cdht.c, cdht.java, or cdht.py.
- This program uses 5 input arguments. The first three input arguments are all integers in the range of [0,255]. The fourth input is an integer value. And the final input is a value in the range of [0,1]. They are used to initialise the network as discussed in section 4.1 (initialization step).
- For python programs, please indicate the version of python you used clearly in the first lines of your report.
- For c programs, please include makefile with your submission and explain the process for making the file in your report. You must also show this on your demo.
4.1. Assignment specification
In this section, we will discuss the steps that you must take to implement this assignment. Make sure your program covers all these steps to get full mark. The marking guideline is discussed in section 7.
Step 1: Initialization
The main aim of this step is to initialize the DHT. For the example in Figure 1, which has 8 peers, 8 xterms will be open to initialise 8 peers. This step will be performed by using a set-up script, of which the following is an example:
This script opens up 8 xterms and starts a peer in each xterm. The -e option asks the xterm to execute the command speciﬁed after the switch (For meaning of the other xterm options, please use man xterm).
In order to understand what the input arguments represent, let us look at the ﬁrst line
more closely. The executable part of this line is “java cdht 1 3 4 400 0.1”.
The ﬁrst input argument, i.e., 1” is the identity of the peer to be initialised. The second
and third arguments, i.e., 3 and 4, are the identities of the two successive peers. The forth argument is Maximum Segment Size (MSS) used to determine the size of the data that must be transferred in each segment (discussed more in Step 3). MSS in this example is set to 400. The last argument is the drop probability which must be between 0-1 (discussed more in Step 3). You will ﬁnd that the above ﬁle initialises the conﬁguration of the circular DHT given in Figure 1. The above conﬁguration ﬁle is available from the assignment website. There are also C and Python versions.
Given the above set-up script, each peer will know its identity and the identities of its two successors. There are a few assumptions that you can safely assume:
- We will ask you to work with at most 10 peers.
- The minimum number of peers is 4.
- The identity of a peer is always in the range of [0,255].
- The set-up script that we give you will always correctly describe a circular
You can always create more set-up scripts for testing. Although for the demo (see Section 5) you will run your code with the above configuration, but we will also test your code with another configuration that we have to ensure that you did not hardcode anything in the program. You would not know that configuration, but the configuration will follow the above rules. Thus, make sure you test your code with different configurations.
Step 2: Ping successors
After initialisation, each peer will start pinging its two successors to see whether they are alive. The ping mechanism should deﬁne two types of messages: 1) ping request, and 2) ping response. The ping messages should use UDP protocol. You can assume that a peer whose identity is i will listen to the UDP port 50000 + i for ping messages. For example, peers 4 and 12 will listen on UDP ports 50004 and 50012 respectively for ping request messages. Each peer should output a line to the terminal when a ping request message is received from any of its two predecessors. For example, peer 10 is expected to receive ping request messages from peers 5 and 8; when peer 10 receives a ping request message from peer 5, it should output the following line to the terminal:
A ping request message was received from Peer 5.
Similarly, if peer 10 receives a ping request message from peer 8, it should output the following line to the terminal:
A ping request message was received from Peer 8.
The numbers ”5” and ”8” are correct for this example, your program is of course expected to print the correct identities for the situation.
NOTE Printing ping messages to the terminal is highly important as the evaluator will mark you according to the outputs. So, if no output is printed, the evaluator will assume that the ping was unsuccessful. Even if you implement the ping correctly but there is no output, you will get 10% of the mark for that part (see Section 7).
Since the title of each xterm displays the identity of each peer, you should be able to keep track of each peer. When a peer receives a ping request message from another peer, it should send a ping response message to the sending peer so that the sending peer knows that the receiving peer is alive. When a peer receives a ping response from another peer, it should display on the terminal. For example, if peer 10 is still alive, peer 5 is expected to receive a ping response message from peer 10, and peer
5 should display:
A ping response message was received from Peer 10.
It is important to note that the messages displayed in the terminal should differentiate between ping request and ping response messages.
You will need to decide on how often you send the ping messages. You should not
send them very often, otherwise you may overwhelm the computer. Please don’t make the evaluator waiting for more than 3 minutes before it shows the output. Otherwise it will be assumed that the program does not work.
Links for Us