示例#1
0
def main():
    
    peerPort = getFreePort()[1]
    obj = DirClient(DirServerIp, DirServerPort, peerPort)
    obj.informAndUpdate(dirPath)
    hostname = socket.gethostname()
    IP = socket.gethostbyname(hostname)
    httpd = ThreadedHTTPServer((IP, peerPort), Handler)
    threading.Thread(target=httpd.serve_forever).start()

    obj.queryForContent()
    while True:
        i = raw_input("Enter y to download (or n to quit): ")
        if i != "y":
            obj.gracefulExit()
            httpd.shutdown()
            break
        file = raw_input("Enter file Name:")
        peer = raw_input("Enter Peer:")
        port = input("Enter port:")
        httpObj = lightShareHttpClient(peer, port)
        httpObj.downloadFile(file , "tx.txt")




    httpd.shutdown()
示例#2
0
def main():


    peerPort = getFreePort()[1]
    obj = DirClient(DirServerIp, DirServerPort, peerPort)
    obj.informAndUpdate(dirPath)

    hostname = socket.gethostname()
    IP = socket.gethostbyname(hostname)
    httpd = ThreadedHTTPServer((IP, peerPort), Handler)
    threading.Thread(target=httpd.serve_forever).start()
    print "HTTP SERVER Started ..."

    while True :

        file = raw_input("Enter File name to search **** Press Enter for Directory Listing *** Press N to exit:")
        obj.queryForContent(file)

        if file == "n" or file=="N":
            obj.gracefulExit()
            httpd.shutdown()
            break

        while True:
            i = raw_input("Enter y to download (or n to quit): ")
            if i != "y":
                break
            file = raw_input("Enter file Name:")
            peer = raw_input("Enter Peer:")
            port = input("Enter port:")
            httpObj = lightShareHttpClient(peer, port)
            httpObj.downloadFile(file , "tx.txt")




    httpd.shutdown()
示例#3
0
from Config import *
import time
from DirClient import *
import math
import matplotlib.pyplot as plt

peerPort = getFreePort()[1]
obj = DirClient(DirServerIp, DirServerPort, "123")
EstimatedRTT=0.1

beta=0.25
alpha=0.125
DevRTT=0

rttList = []
eRttList = []
for x in xrange(0, 100):
    start = time.time()
    obj.informAndUpdate("/Users/yugarsi/git-local/cenProjects/project2/lib/sampleRTTFile/") #sends one segment to server
    end = time.time()
    SampleRTT=end-start
    print("SampleRTT \n", SampleRTT)
    rttList.append(SampleRTT)
    EstimatedRTT = alpha*SampleRTT + (1 - alpha)*EstimatedRTT

    eRttList.append(EstimatedRTT)
    print("EstimatedRTT \n", EstimatedRTT)
    DevRTT = (1-beta)*DevRTT + abs(beta*(EstimatedRTT-SampleRTT))
    print("DevRTT \n", DevRTT)