tcpreplay is primarily designed for replaying packets at the network level and may not be suitable for replaying UDP packets. Thus bit of work is needed to replay this data.
update the input.pcap to us your desired MAC id's
tcprewrite --enet-dmac=destinationMAC --enet-smac=sourceMAC -i input.pcap -o output.pcap
Replace destinationMAC with the MAC address of the destination machine or network interface you wish to send the UDP packets to. Replace sourceMAC with the MAC address of the network interface you plan to send the packets from.
Now you would be able to replay this packets
sudo tcpreplay -i input.pcap -o output.pcap
test script to read this packets ( Python3 script is provided to read data on port 9999 )
import socket
UDP_IP = "0.0.0.0"
UDP_PORT = 9999
sock = socket.socket(socket.AF_INET, # Internet
socket.SOCK_DGRAM) # UDP
sock.bind((UDP_IP, UDP_PORT))
while True:
data, addr = sock.recvfrom(1024) # buffer size is 1024 bytes
print("received message: %s" % data)