Small Network Speed Testing Web Server

So I wanted to test the internal LAN speeds of our wireless bridge, switches, and cables in between – from one end of the network to the other. There’s an older iMac running on one side of the bridge and I didn’t want the speed test to slow down due to disk I/O reasons. I wrote a small python based web server which pre-initializes a memory buffer with random data and then sends random chunks inside of it throughout the fake “download” process (jumping around from index to index).
This is just a single stream test but there are other tools available if you want a more advance multi-stream performance testing (tools like iperf and what not). This will give you at least the real world output/speeds of your network setup (not just theoretical, I was able to get 111MB/s through a CAT-6 gigabit TP-Link Archer C7 V5 and nearly 75MB/s over a dedicated Linksys 802.11ac-3×3 WiFi bridge).

curl 'http://192.168.X.Y:8080/download' > /dev/null ; echo

Edit: Trying to maintain a stable and consistent WFH WiFi network setup! (the bridge is limiting clients to 13MBps ~ 104mbps via a iptables hashlimit rule set). It also has a good quality backchannel connection to carry all of the WiFi traffic:


import random,socket

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sock.bind(("", 8080))
sock.listen(1)

rr = [chr(x) for x in range(0, 256)] * 2048
random.shuffle(rr)
rs = "".join(rr)
rl = len(rs)
rb = (8 * 1024)
az = (rl - (rb + 1))
sz = (800 * 1024 * 1024)
print("size:",rl,rb,sz)

while True:
	print("loop")
	(conn, addr) = sock.accept()
	data = conn.recv(1024)
	print("[",data,"]")
	if ("get / " in data.lower()):
		d = "HTTP/1.1 200 OK\r\ncontent-type: text/html\r\n\r\n hi : "+str(random.randint(0,az))+" : <a href='/download'>link</a>"
		try:
			conn.sendall(d)
		except:
			pass
		try:
			conn.close()
		except:
			pass
	if ("get /download " in data.lower()):
		d = "HTTP/1.1 200 OK\r\ncontent-type: application/octet-stream\r\n\r\n"
		try:
			conn.send(d)
		except:
			pass
		sl = 0
		while (sl < sz):
			i = random.randint(0,az)
			d = rs[i:i+rb]
			try:
				conn.send(d)
			except:
				break
			sl += rb
		try:
			conn.close()
		except:
			pass
Small Network Speed Testing Web Server

One thought on “Small Network Speed Testing Web Server

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s