COMP3100 S12025 Lecture02 Updated
COMP3100 S12025 Lecture02 Updated
COMP3100/COMP6105
Lecture 2: System Architectures and Models
result result
Serv er
Client
Key:
Proc ess: Computer:
• Client
1 from socket import *
2 s = socket(AF_INET, SOCK_STREAM)
3 s.connect((HOST, PORT)) #connect to server(block until accepted)
4 s.send(’Hello,world’) #send some data
5 data = s.recv(1024) #receive the response
6 print data #print the result
7 s.close() #close the connection
Serv er
Client
Serv er
Client
Serv er
Client Web
server
Prox y
server
Client Web
server
Client Web
Applet code server
Web
Client Applet server
• Searching
• Flooding: issuing node u passes request for destination node d to all neighbors. Request
is ignored when receiving node had seen it before. Otherwise, v searches locally for d
(recursively). May be limited by a Time-To-Live: a maximum number of hops.
• Random walk: issuing node u passes request for d to randomly chosen neighbor, v . If v
does not have d , it forwards request to one of its randomly chosen neighbors, and so
on.
• Random walk
• P[k ] probability that item is found after k attempts:
• Comparison
• If r /N = 0.001, then S ≈ 1000
• With flooding and d = 10, k = 4, we contact 7290 nodes.
• Random walks are more communication efficient, but might take longer before they find
the result.
• Exchange blocks
• A file is divided into equally sized pieces(typically each being 256 KB) Peers
exchange blocks of pieces, typically some 16 KB.
• A can upload a block d of piece D, only if it has piece D.
• Neighbor B belongs to the potential set PA of A, if B has a block that A
• needs.
• If B ∈PA and A ∈PB : A and B are in a position that they can trade a block.
S1, 2025 @ Macquarie University 25
BitTorrent phases
• Bootstrap phase
• A has just received its first piece (through optimistic unchoking: a node from NA
unselfishly provides the blocks of a piece to get a newly arrived node started).
• Trading phase
• |PA| > 0: there is (in principle) always a peer with whom A can trade.
Mi ddleware
Platform
• Solution
• A wrapper or adapter offers an interface acceptable to a client
application. Its functions are transformed into those available at
the component.
• Horizontal distribution
• A client or server may be physically split up into logically equivalent parts, but each part
is operating on its own share of the complete data set.
• Peer-to-peer architectures
• Processes are all equal: the functions that need to be carried out are represented by
every process ⇒ each process will act as a client and a server at the same time (i.e.,
acting as a servant).