首页
网站开发
桌面应用
管理软件
微信开发
App开发
嵌入式软件
工具软件
数据采集与分析
其他
首页
>
> 详细
辅导program留学生程序、JAVA,c++,Python编程讲解 讲解SPSS|解析Java程序
项目预算:
开发周期:
发布时间:
要求地区:
Abdelkader Ouda page 1 Winter 2021
WESTERN UNIVERSITY - CANADA
FACULTY OF ENGINEERING
DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING
SE 3314B – COMPUTER NETWORKS APPLICATIONS
Assignment 3: Peer-to-Peer Search
Due Date: April 7, 2021
This assignment is to be done individually. Cheating is prohibited in this assignment, that is not to show
your code to any other student, do not look at any other student's code, and do not put your code in any
public domain. However, getting help is easy and available, just ask the instructor or the TAs. At the same
time, you are encouraged to discuss your problems (if any) with other students in general terms but the actual
program design and code must be your own.
Please note that the consequences of cheating are much, much worse than getting a low mark for that
particular item of work. The very best case is that you get a zero for the whole thing. Keep in mind that turning
in your own work would have at least gotten you a few marks, better than a zero.
1. Objectives
In this assignment you are to build a peer-to-peer (p2p) network and perform a search for one or more
images on the p2p network. In particular, you will implement a peer node similar to the one you implemented
for assignment 2. This peer node will also support client image query to search for images.
2. Task 1: A Peer Node
Your first task is to write a peer node. If you've implemented assignment 2 and have decided to build this
assignment on top of your working assignment 2, you're done with the first task of this assignment. If you
have not implemented assignment 2, no problem you still have the chance to practice socket-programming in
this assignment. Read the requirements and the specifications of task1 and task2 given in assignment 2, build
the required Peer Node program, and then move to task 2 in this assignment.
3. Task 2: Advanced Automatic Re-Direct
In this assignment we will enhance the automatic re-directed process so that, when a peer program Pc tried
to connect to peer Ps and Ps peer table is full, the following cases need to be considered. Ps will decline the
connection and send to Pc a message packet with ‘Message Type’ equal to 2, (2 means Re-Direct), along with
Ps connected peers (Ps1 , Ps2 , …, Psn ). Pc will print out “The join has been declined; the auto-join process is
performing …” and performs the following for each peer P in (Ps1 , Ps2 , …, Psn );
1. Pc sends connection request to P, if P peer table is not full, it should accept the connection and send
to Pc a message packet with ‘Message Type’ equal to 1, (1 means Welcome). The peer program Pc
Abdelkader Ouda page 2 Winter 2021
will be ready waiting for other peers to join into. This is the first case that is defined in task 1 in
assignment 2.
2. if P peer table is full, P will decline the connection and Pc will receive message packet with ‘Message
Type’ equal to 2 along with the connected peers of P. In this case we will, recursively, repeat the
process and should go down the list of returned P peers one at a time and performs the same process
in step 1.
3. Pc should not send connection request to any peer who have declined it during earlier join attempt.
4. This process continues until all join attempts have been made to all peers in (Ps1 , Ps2 , …, Psn ).
5. If all attempts are declined, the peer program Pc terminates.
Hint: to achieve step 3, you need to keep a separate "peering declined" table. Prior to attempting to join
a peer P, check against this table to make sure this peer P is not existing. Also, if the join attempt is declined
by a peer P, add the peer P in the "peering declined" table.
4. Task 3: Client Image Query
Your next task is to integrate the server functionality described in assignment 1 (that accept image query
request and then respond by sending the requested images) with the Peer Node code from assignment 2 in a
new program (server) which we will call it peer2peerDB. This new server will use two different ports: one to
handle peer-to-peer network maintenance traffic and another to handle image query traffic. You get the first
when you instantiate a peer object, which will accept peer join requests. The second comes with the
instantiation of the image object, which will accept image query requests. We will call the former the peer
socket and the latter the image socket henceforth. We will use one image socket for both client query and peer
image-search reply (next task).
When a client queries for images, the server first searches its own database (or rather, its working
directory/folder) for the requested file names. If the images are found, it is returned to the client using the ITP
response packet format (see Figure 2) and the connection is then closed. If all or subset of the requested images
are not found, the server will search for these images in the peer-to-peer network on behalf of the client. We
will discuss how to handle peer-to-peer search in the next task.
5. Task 4: P2P Search
When a peer cannot find at least one of the requested images locally, it sends out a search packet through
the peer-to-peer network using the peer socket. When a queried image is found, the peer holding the image
connects directly with the peer searching for the image (originating peer) and transfers the image to the
originating peer, who then forwards the collected images (if many were requested) to the client. As explained
in the previous section, this connection is made to the originating peer's image socket. Thus, the search packet
must carry the originating peer's address and its image socket's port number, along with the name of the
image(s) being searched for.
The query/search packet MUST follow the format shown in Figure 1.
Abdelkader Ouda page 3 Winter 2021
0
0 1 2 3 4 5 6 7 8 9
1
0 1 2 3 4 5 6 7 8 9
2
0 1 2 3 4 5 6 7 8 9
3
0 1
V=7 Message Type IC Search ID Sender ID length
Sender ID
Originating peer’s IPv4 address
Originating peer’s image socket port number
IT File name size
Image file name
Figure 1: The cPTP search request packet format
Here are the descriptions of the cPTP search request packet fields:
(V) is a 3-bit cPTP version field. You must set this to 7.
The message type is one byte to represent the message type; the value 3 means ‘Search’ type.
(IC) Image Count is a 5-bit field indicates the number of images in the packet. Note that we can have
a maximum of 31 image because a 5-bit field only allows a number between 1 and 31.
The "search ID" field is a way for you to differentiate subsequent searches for the same image name
from the same originating peer (see below).
The port number in the search message is that of the image socket, NOT the peer socket. The peer
initiating an image search sends a copy of this search packet to all the peers in its peer table.
(IT) Image Type is a 4-bit field, part of the payload, indicates the type of the images as follows: 1 -
BMP, 2 - JPEG, 3 - GIF, 4 - PNG, 5 - TIFF, and 15 – RAW.
The file name size (part of the payload) is a 12-bit field hold the number of bytes needed to store the
image file name.
The image file name, without the file extension, (part of the payload) is a field to store the name of
the requested image. The size of this field is equal to the length of the image file name.
Search packets are sent along the connections made between peers, i.e., the "links" forming the p2p
network. Once you have sent out a search packet to all your connected peers, you don't need to send it again
if new peers connect to you at a later time. When a search packet arrives at a peer, the peer must check whether
it has seen the same query previously. You don't have to keep a very long history. Just keep the last n number
of the most recent searches (in a circular way) where n = the peer table size. If the peer has seen the search in
the recent past, it simply drops the packet. Otherwise, it checks whether it has a copy of the queried image. If
it does not have a copy of the image, the peer forwards the query further to all its peers, except the peer whence
the query arrived. Your code must be able to make these determinations and not forward the search packet in
the two cases mentioned here:
(1) previously seen search, and
(2) the peer whence the search message arrived.
Note: You will be deducted points if your queries loop on your p2p network because your node doesn't
drop duplicate queries.
These three fields
(the payload) could
be repeated by the
value of the IC
Abdelkader Ouda page 4 Winter 2021
If a peer has no other peer to forward a search query, it simply drops the query. If a peer has a copy of the
queried image, it creates a new socket and connects to the query originating peer at the address and port
number listed in the search packet. Thus, the image is not transmitted on the "links" of the p2p network, but
on a separate connection directly to the query originating peer, created just to transfer the image.
Once the image transfer is completed, the connection is closed by the peer initiating the transfer. The
originating peer then forwards the collected images to the client requesting them and closes the connection to
the client. If the originating peer receives multiple copies of one image, it only collects one copy of the image.
At any one time, a peer can only perform a search on behalf of one client. Your code should enforce this.
If a reply for an old search arrives after a new client initiated a new search, the peer will return the wrong
image to the new client. Your code is not required to handle this error case.
Image transfer between peers and between a peer and its client MUST follow the same protocol as in
assignment 1, you MUST precede the image with the ITP response packet format as follows:
0
0 1 2 3 4 5 6 7 8 9
1
0 1 2 3 4 5 6 7 8 9
2
0 1 2 3 4 5 6 7 8 9
3
0 1
V=7 F Response Type IC Sequence number
Timestamp
IT File name size Image size in byte
Image file name
Image data
Figure 2: The ITP response packet format (the header and payload)
Here are the descriptions of the ITP response packet fields:
(V) is a 3-bit ITP version field. You must set this to 7.
(F) is a 1-bit field, if set to 1, indicates that the client request is fully fulfilled, i.e., all images are
loaded. If the client request is partially fulfilled, i.e., subset of the images is loaded, the value of F is
0.
The response type is one byte so that the value 0 means “Query”, 1 means “Found”, 2 means “Not
found”, and 3 means “Busy”.
(IC) Image Count is a 5-bit field indicates the number of images in the packet. Note that we can have
a maximum of 31 image because a 5-bit field only allows a number between 0 and 31.
Set the sequence number. The sequence number of the first packet is chosen randomly; it is
incremented by 1 for each subsequent packet sent out of the server. This field is 15 bits in length and
the increment will be performed mod 215
.
The timestamp is a 4-byte field has the current value of the server’s timer.
(IT) Image Type is a 4-bit field, part of the payload, indicates the type of the images as follows: 1 -
BMP, 2 - JPEG, 3 - GIF, 4 - PNG, 5 - TIFF, and 15 – RAW.
The file name size (part of the payload) is a 12-bit field hold the number of bytes needed to store the
image file name.
The image file name (part of the payload) is a field to store the name of the requested image. The size
of this field is equal to the length of the image file name, without the file extension.
These three fields
(the payload) exist
only if the IC is not
zero, and could be
repeated by the
value of the IC
Abdelkader Ouda page 5 Winter 2021
The image size (part of the payload) is a 16-bit field which we will need to extract the image data
from the packet and display it. The actual image content (part of the payload) will then follow the
image size field.
To keep things simpler for you, you always search for images that exist in the p2p network.
6. Testing your code
Below is a running scenario as an example to show the execution of the program and to summarize the
requirements of this assignment. Create four different folders in your computer and name them: peer1-2,
peer2-1, peer3-5, peer4-3, peer5-3, and peer6-3. Note that, the first part (before the dash sign) of the folder
name represent the peer ID, and the part, the number after the dash sign, indicates the peer table size. After
creating these folders, copy and paste your program in all these six folders. Open seven command line
windows, and perform the command as shown in the figure below.
Hand In
Submit the final version of your source code (Fully commented and formatted) through OWL by the due
date mentioned above. This should include one compressed achieve file (zip file) having all JS files for the peer
program including the package.json file and name it yourUWOID-SE3314b-assignment3.zip.
软件开发、广告设计客服
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-23:00
微信:codinghelp
热点项目
更多
代做ceng0013 design of a pro...
2024-11-13
代做mech4880 refrigeration a...
2024-11-13
代做mcd1350: media studies a...
2024-11-13
代写fint b338f (autumn 2024)...
2024-11-13
代做engd3000 design of tunab...
2024-11-13
代做n1611 financial economet...
2024-11-13
代做econ 2331: economic and ...
2024-11-13
代做cs770/870 assignment 8代...
2024-11-13
代写amath 481/581 autumn qua...
2024-11-13
代做ccc8013 the process of s...
2024-11-13
代写csit040 – modern comput...
2024-11-13
代写econ 2070: introduc2on t...
2024-11-13
代写cct260, project 2 person...
2024-11-13
热点标签
mktg2509
csci 2600
38170
lng302
csse3010
phas3226
77938
arch1162
engn4536/engn6536
acx5903
comp151101
phl245
cse12
comp9312
stat3016/6016
phas0038
comp2140
6qqmb312
xjco3011
rest0005
ematm0051
5qqmn219
lubs5062m
eee8155
cege0100
eap033
artd1109
mat246
etc3430
ecmm462
mis102
inft6800
ddes9903
comp6521
comp9517
comp3331/9331
comp4337
comp6008
comp9414
bu.231.790.81
man00150m
csb352h
math1041
eengm4100
isys1002
08
6057cem
mktg3504
mthm036
mtrx1701
mth3241
eeee3086
cmp-7038b
cmp-7000a
ints4010
econ2151
infs5710
fins5516
fin3309
fins5510
gsoe9340
math2007
math2036
soee5010
mark3088
infs3605
elec9714
comp2271
ma214
comp2211
infs3604
600426
sit254
acct3091
bbt405
msin0116
com107/com113
mark5826
sit120
comp9021
eco2101
eeen40700
cs253
ece3114
ecmm447
chns3000
math377
itd102
comp9444
comp(2041|9044)
econ0060
econ7230
mgt001371
ecs-323
cs6250
mgdi60012
mdia2012
comm221001
comm5000
ma1008
engl642
econ241
com333
math367
mis201
nbs-7041x
meek16104
econ2003
comm1190
mbas902
comp-1027
dpst1091
comp7315
eppd1033
m06
ee3025
msci231
bb113/bbs1063
fc709
comp3425
comp9417
econ42915
cb9101
math1102e
chme0017
fc307
mkt60104
5522usst
litr1-uc6201.200
ee1102
cosc2803
math39512
omp9727
int2067/int5051
bsb151
mgt253
fc021
babs2202
mis2002s
phya21
18-213
cege0012
mdia1002
math38032
mech5125
07
cisc102
mgx3110
cs240
11175
fin3020s
eco3420
ictten622
comp9727
cpt111
de114102d
mgm320h5s
bafi1019
math21112
efim20036
mn-3503
fins5568
110.807
bcpm000028
info6030
bma0092
bcpm0054
math20212
ce335
cs365
cenv6141
ftec5580
math2010
ec3450
comm1170
ecmt1010
csci-ua.0480-003
econ12-200
ib3960
ectb60h3f
cs247—assignment
tk3163
ics3u
ib3j80
comp20008
comp9334
eppd1063
acct2343
cct109
isys1055/3412
math350-real
math2014
eec180
stat141b
econ2101
msinm014/msing014/msing014b
fit2004
comp643
bu1002
cm2030
联系我们
- QQ: 9951568
© 2021
www.rj363.com
软件定制开发网!