I have a network that I am working with and I would like to test the round trip time of sending a packet and receiving it. Easy enough, I have a server and a client (client seen below) and I could measure the time it takes from sendall() to recv(). My issue is I want consistency in packet size so that my RTT values from each run can be adequately interpreted together. Does anyone know how I can form a request that is 64 bytes (arbitrary number I chose) in length exactly, not including the protocol overhead? Thanks!
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server_address = ('localhost', 10000) sock.connect(server_address) try: # Send data message = "This is the message. It will be repeated." sock.sendall(message) # Look for the response amount_received = 0 amount_expected = len(message) while amount_received < amount_expected: data = sock.recv(16) amount_received += len(data) finally: sock.close()
No comments:
Post a Comment