This example uses nping to generate multiple independent UDP traffic streams from a Linux server. Each stream uses random source and destination UDP ports and runs continuously until the script is stopped with Ctrl+C.
Install Nping
On Ubuntu, nping is included in the Nmap package:
Verify that nping is available:
Traffic Generator Script
Create the traffic generator script:
Example script:
Configure the Traffic
The main parameters are defined at the beginning of the script:
DST_IP is the destination IP address, STREAMS controls the number of independent UDP flows, PPS defines packets per second for each stream, and PAYLOAD defines the UDP payload size in bytes.
Replace the example destination address with the IP address of the system used for your authorized network test.
Traffic Rate
With a 1200-byte payload and 509 packets per second, each stream generates approximately 4.9 Mbps of payload traffic:
With 10 streams, the total payload traffic is approximately:
The actual traffic observed on the interface will be slightly higher because of Ethernet, IP and UDP protocol overhead.
Run the Traffic Generator
Make the script executable:
Start the generator:
Example output:
Stop the Traffic
Press Ctrl+C to stop the test. The cleanup function keeps the process IDs of all started nping processes and terminates them automatically:
How the Multiple Streams Work
Each nping process uses a randomly generated UDP source and destination port:
This creates multiple separate UDP flows instead of sending all traffic using the same source and destination port combination. This is useful when testing ECMP, LAG hashing, traffic distribution and network throughput in a controlled lab or authorized network environment.