#coding: utf-8import ctypes as _ctypesfrom ctypes import wintypes as _wtypesimport threadingimport timeimport structfrom udt4py import *fd = udt_socket()ret = udt_connect(fd,"127.0.0.1",9000)if ret == 0: print("connect success")else: print("connect fail") import os os._exit(0) size = 100000data = Nonefor i in range(0,10000): for j in range(0,10): if data is None: data = struct.pack("B", j+1 ) else: data += struct.pack("B", j +1)def worker(param): global ssize print("SendRate(Mb/s)\tRTT(ms)\tCWnd\tPktSndPeriod(us)\tRecvACK\t\tRecvNAK") while True: monitor = udt_monitor(param) print("%.1f\t\t%.1f\t%.1f\t%.1f\t\t\t%d\t\t%d"%(monitor.mbpsSendRate, monitor.msRTT, monitor.pktCongestionWindow, monitor.usPktSndPeriod, monitor.pktRecvACK, monitor.pktRecvNAK )) time.sleep(1) returnt = threading.Thread(target=worker,args=(fd,))t.start() for i in range(0,size): ssize = 0 ss=0 while ssize < size: ss = udt_send(fd,data[ssize:size],size - ssize) if ss < 0: print("socket_send error") break; ssize += ss if (ssize < size): break;