1

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 230.250.5.1 12340>

# start mnc to capture packets:

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

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

 $netcat -c -w 1 -u -s 10.20.30.40 230.250.5.1 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.

2

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:230.250.5.1:12345 <capturefile

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

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.