Skip to content

Commit

Permalink
clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
danghoangnhan committed Mar 4, 2023
1 parent 8682f4e commit 5b1284b
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions Computer Networks_Homework 1_M11115013/Iperfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ def Error_messege():

def servermode():
data_volume = 0
start_time = 0
Finish_time = 0
Time_period = 0
test = sys.argv
if sys.argv[2] == "-p":

listen_port = eval(sys.argv[4])
Expand All @@ -47,7 +43,6 @@ def servermode():
s.bind(('', listen_port))
s.listen(1)
print("server is stand by")
test2 = 0
while True:
conn, (host, Remote_port) = s.accept()
while True:
Expand All @@ -56,15 +51,15 @@ def servermode():
if not data:
break
data_volume += len(data)
test2 += 1
del data

conn.close()
Finish_time = time.time()

print('host_name', host, 'port_number', Remote_port)
Time_period = Finish_time - start_time
print("received=", data_volume / 1024, "KB", "rate=",(((data_volume * 8) / 1024) / 1024) / Time_period, "Mbps")
print("received=", data_volume / 1024, "KB", "rate=", (((data_volume * 8) / 1024) / 1024) / Time_period,
"Mbps")


def clientmode():
Expand Down Expand Up @@ -94,12 +89,10 @@ def clientmode():
s.send(testdata.encode())
s.shutdown(1) # Send EOF

data = s.recv(BUFSIZE)

Finish_time = time.time()

# print('sent:=', (BUFSIZE * count * 0.001), 'KB')
print('sent:=', (total_sent/1024), 'KB')
print('sent:=', (total_sent / 1024), 'KB')
print("rate:=", (BUFSIZE * count * 8 * 0.001 * 0.001) / (Finish_time - Start_Time), 'Mbps.')


Expand Down

0 comments on commit 5b1284b

Please sign in to comment.