Did also not succeed on large UDP telegrams in micropython.
But did some tests with TCP socket. As TCP keeps track of sent packages, it should (best case) track packets end to end even through slow hardware in picoW.
Approach: open socket, keep it open and send chunks of about 2000 bytes. picoW is a TCP server, using socket.readinto-method to receive data.
Throughput isSend code, python on a laptopServer code, MicroPython v1.22.1 on 2024-01-05; Raspberry Pi Pico W with RP2040
But did some tests with TCP socket. As TCP keeps track of sent packages, it should (best case) track packets end to end even through slow hardware in picoW.
Approach: open socket, keep it open and send chunks of about 2000 bytes. picoW is a TCP server, using socket.readinto-method to receive data.
Throughput is
Code:
812.000 kBytes/s1094.600 kBytes/s1072.400 kBytes/s1063.000 kBytes/s1079.400 kBytes/s1073.800 kBytes/s1087.200 kBytes/s1072.800 kBytes/s1063.200 kBytes/s1078.200 kBytes/s1048.000 kBytes/s1068.400 kBytes/s1077.400 kBytes/s1031.400 kBytes/s1068.800 kBytes/s1068.200 kBytes/s1066.600 kBytes/s1085.600 kBytes/s626.600 kBytes/s1092.200 kBytes/s1069.600 kBytes/s
Code:
import socketsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)cnt = 0LENGTH = 2000pad = "0"*LENGTHsock.connect( ("192.168.2.179", 22222) )while True: message = f'test{cnt:05d}{pad}'.encode("ascii") print(message) cnt += 1 sock.send(message)
Code:
import networkimport socketimport timeimport machinessid = ''password = ''wlan = Nonedef connect(): global wlan #Connect to WLAN wlan = network.WLAN(network.STA_IF) wlan.active(True) wlan.connect(ssid, password) while wlan.isconnected() == False: print('Waiting for connection...') time.sleep(1) print(wlan.ifconfig())try: connect()except KeyboardInterrupt: time.sleep(1) machine.reset() print("Connected to network!")print("IP address:", wlan.ifconfig()[0])sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) # added allow to reuse when re-runsock.bind(('192.168.2.179', 22222)) # only required when recvfrom called before sendtosock.listen(1) c, addr = sock.accept()print ('accept, c, addr: ', c, addr)t0 = time.time()cnt = 0data = bytearray(2048)D=10while True: cnt += c.readinto(data, 2048) t1 = time.time() if t1 - t0 > D: print( f"{cnt/D /1024:.3f} kBytes/s") cnt = 0 t0 = t1
Statistics: Posted by ghp — Fri Jul 26, 2024 4:52 pm