Is there a delimiter or some way of telling netcat how many bytes to send per packet from a file? Invoking netcat multiple times in a script is not acceptable as I need to send them out as fast as possible.

I have captured UDP packets with binary data into a file using mnc (multicast netcat) and attempt to play them back as follows:

# start program sending multicast packets to 12340>

# start mnc to capture packets:

 $mnc -l -i eth1 -p 12340 >capturefile

... # playback packets using netcat, sending to 12345

 $netcat -c -w 1 -u -s 12345 <capturefile

capturefile appears to have the packets I want to send.

When I play back with netcat the packets are concatenated. UDP packet size is 208 during packet capture and wireshark shows 250 as packet size, I assume that includes ethernet bytes. On replay, wireshark shows packet size of 1016.


This may not be possible for you, but if you use socat instead of netcat you can set a fixed block size quite easily with -b:

socat -b 208 - udp4: <capturefile

If you have variable length data you might look at using tcpdump and tcpreplay and the pcap file format.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.