Created
November 12, 2016 19:21
-
-
Save alirezaomidi/1cb9c208eca8c751500344e10d0826d7 to your computer and use it in GitHub Desktop.
Minimum Distribution Time for Client-Server vs Peer-to-Peer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
# in Kbps | |
F = 10 * 10**6 | |
us = 20 * 1000 | |
dmin = 1000 | |
def client_server(n): | |
return max(n*F/us, F/dmin) | |
def peer_to_peer(n, u): | |
return max(F/us, F/dmin, n*F/(us + sum(u))) | |
if __name__ == '__main__': | |
N = [10, 100, 1000] | |
u = [200, 600, 1000] | |
cs = [client_server(n) for n in N] | |
p2p = [peer_to_peer(N[i], [u[i]] * N[i]) for i in range(len(N))] | |
plt.plot(N, cs, 'bo') | |
plt.plot(N, cs, 'b', label='Client-Server') | |
plt.plot(N, p2p, 'ro') | |
plt.plot(N, p2p, 'r', label='P2P') | |
plt.legend(loc='upper-left') | |
plt.title('Minimum Distribution Time for Client-Server vs Peer-to-Peer') | |
plt.xlabel('Number of Peers') | |
plt.ylabel('Minimum Distribution Time (Kbps)') | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
Just wanted to know is it possible to make this graph interactive by use of silders and giving dynamic input using dropdown or sliders