17def cli(address, port):
18 console.log(f
"Preparing to send WIB packets to {address}:{port} in a loop.")
19 sock = socket.socket(socket.AF_INET,
22 wf = fddetdataformats.WIBEthFrame()
23 wf.get_daqheader().det_id = 3
24 wf.get_daqheader().stream_id = 0
25 wf.get_daqheader().seq_id = 1
26 wf.get_daqheader().block_length = 0x382
27 wf.get_daqheader().timestamp = 0
33 start_time_orig = time.time();
34 start_time = time.time();
38 wf.get_daqheader().stream_id = i
39 sock.sendto(wf.get_bytes(), (address, port))
42 sent_bytes += len(wf.get_bytes())
43 sent_bytes_tot += len(wf.get_bytes())
44 if sent_pkts_tot % 100000 == 0:
45 stop_time = time.time()
46 interval = stop_time - start_time
47 console.log(f
"Received {sent_pkts} packets: throughput is {sent_bytes*8/(interval*1000000000.):.2f} Gb/s")
50 start_time = stop_time
52 wf.get_daqheader().timestamp += (32*64)
53 if wf.get_daqheader().seq_id == 4095:
54 wf.get_daqheader().seq_id = 0
56 wf.get_daqheader().seq_id +=1
58 except KeyboardInterrupt:
63 stop_time = time.time();
64 time_seconds = stop_time - start_time_orig
65 console.log(f
"Sent {sent_pkts_tot} WIB packets in {time_seconds:.2f} seconds. Throughput = {(sent_bytes_tot*8)/(time_seconds*1000000000.):2f} Gb/s")