UDPPacketDump is a simple C program that captures UDP packets from a network interface and prints their source and destination IP addresses and ports in real time. It uses the libpcap library for packet capturing and is intended to run on Linux systems.
- Captures UDP traffic only.
- Displays source IP, source port, destination IP, and destination port for each packet.
- Allows users to select the network interface from the command line.
- Lightweight and easy to use for monitoring and analyzing UDP traffic.
- Linux system (Ubuntu or similar).
libpcap-devlibrary installed.- Root privileges to access network interfaces.
- Install the required library:
sudo apt update
sudo apt install libpcap-dev build-essential-
Clone or copy the code into a file called
udpdump.c. -
Compile the program:
gcc udpdump.c -lpcap -o udpdumpRun the program with root privileges and specify the network interface to monitor:
sudo ./udpdump <interface>Example:
sudo ./udpdump eth0This will start capturing UDP packets on the eth0 interface and print each packet’s source and destination information.
192.168.1.10:12345 -> 192.168.1.20:80
10.0.0.5:5678 -> 10.0.0.8:53
- Make sure to run the program with
sudoto allow access to network interfaces. - The program captures only IPv4 UDP packets.
- For systems with multiple network interfaces, specify the correct interface to capture the desired traffic.
This project is free to use for learning and educational purposes.