DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dpdklibs_udp_sender.py
Go to the documentation of this file.
1#!/usr/bin/env python
2
3import socket
4import argparse
5
6parser = argparse.ArgumentParser()
7parser.add_argument('ip', help='ip of the destination')
8parser.add_argument('--size', default=5, type=int, help='Size of the message to send (in bytes)')
9
10args = parser.parse_args()
11
12UDP_TARGET_IP = args.ip
13UDP_TARGET_PORT = 4444
14
15payload = 'hello' * ((args.size + 4) // 5)
16payload = payload[:args.size]
17
18sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, 0)
19ret = sock.sendto(payload.encode(), (UDP_TARGET_IP, UDP_TARGET_PORT))
20print("Sent {0} bytes".format(ret))
21
22sock.close()