I am trying to measure the speed of file transfer through sockets in python. I set up measurements on both ends (sending and receiving side) and get somewhat different results (i.e. 16 vs 17 Mbps for a 1MB file transferred via ad-hoc wifi). My question is whether this kind of difference is something I should expect, given the measurement setup following. This is all running on two Raspberry Pi models 2 B.
sender:
import socket as s
sock = s.socket(s.AF_INET, s.SOCK_STREAM)
sock.connect((addr,5000))
start = t.time()
sock.sendall(data)
finish = t.time()
receiver:
import socket as s
sock = s.socket(s.AF_INET, s.SOCK_STREAM)
sock.setsockopt(s.SOL_SOCKET, s.SO_REUSEADDR, 1)
sock.bind(("", 5000))
sock.listen(1)
conn, addr = sock.accept()
pack = []
start = t.time()
while True:
piece = conn.recv(8192)
if not piece:
finish = t.time()
break
pack.append(piece.decode())
Also very welcome, any other transfer speed measurements advices, if there is any way to do this better.