12 from random
import randrange
13 USAGE =
'send host:port [count] [text file to send] [sleep time in ms]'
21 print(
'len(argv)=%d'%(len(argv),))
22 if len(argv) < 2
or len(argv) > 5:
25 node,port = argv[1].split(
':')
31 if len(argv) >= 3: count = int(argv[2])
33 f = open(argv[3],
"r")
35 if len(argv) >= 5: sleep_time = float(argv[4]) / 1000
37 print(
'node:port=%s:%d, count=%d'%(node,portint,count))
38 for ii
in range(0, count):
40 buf=
'MF: 01-Jan-1970 01:01:01'
42 buf+=
"|" + node +
"%d" % ii
43 buf+=
"|" + node +
"%d" % ii
52 buf+=
"|Test Message %d" % ii
53 buf+=
"|UDP Send MFMSG %d" % ii
54 buf+=
"|udp_send_mfmsg.py"
56 buf+=
"|Run 0, Subrun 0, Event %d" % ii
57 buf+=
"|UDP Test program"
58 buf+=
"|This is the ARTDAQ UDP test string.\n\t It contains exactly 111 characters, making for a total size of 113 bytes."
60 s = socket.socket( socket.AF_INET, socket.SOCK_DGRAM )
61 s.sendto( buf.encode(
'uft-8'), (node,portint) )
62 time.sleep(sleep_time)
66 if __name__ ==
"__main__": main(sys.argv)