Forward UDP packets captured by libpcap.
This command-line tool leverages the functionality of libpcap to facilitate the forwarding of filtered UDP packets without affecting the original UDP data flow.
The third-party source code argparse.hpp is involved for the advantage of parsing arguments.
For performance, a simple pre-allocated ring-buffer is used in the program to avoid continually malloc and free memory.
makeThen udpfwd is built. See Makefile for details.
See the help message with the -h option:
$ ./udpfwd -hTerminal-1:
# Send UDP packets from 9000 to 9001.
$ ./test/test.pyTerminal-2:
# Forward UDP packets (filtered by dst port 9001) to 9002.
$ ./test/udpfwd.shTerminal-3:
# Listen to UDP port 9002 and print the content onto stdout.
$ ./test/nc.shTerminal-4 (optional):
# Use tcpdump to capture the UDP packets going to port 9002.
$ ./test/tcpdump.sh# On Ubuntu
sudo apt install libpcap-dev
# On macOS
brew install libpcapclang++is the default C++ compiler on macOS.- On Ubuntu, install clang++ with the following cmdline.
sudo apt install llvm clangThe argparse.hpp file under the top directory is simply copied from p-ranav/argparse, which is a good C++ argument parser.