NCPS is a cross-platform tool designed to stress test and measure TCP connection setup performance.
It runs on both Linux and Windows (x64 and ARM64), and supports generating TCP connections at a high rate.
This repository contains the NCPS source code and associated binaries for performance testing in high-connection rate environments.
It is primarily used for validating TCP connection performance at scale and diagnosing networking bottlenecks.
- Generates billions of unique TCP 4-tuples
- Multi-threaded for high scalability
- Works on Linux and Windows
- Command-line interface with flexible configuration
- Using
make:
make; make install
- Using
CMake:
cd src
mkdir build && cd build
cmake ..
make && make install
- Windows 10 version 1703 or higher is required.
- Enable large ephemeral port range as described below.
- Increase file descriptor limits in
/etc/security/limits.confas described below. - Adjust system parameters in
/etc/rc.localto optimize TCP behavior and disable connection tracking as described below.
Make sure to enable large ephemeral port range:
Set-NetTCPSetting -AutoReusePortRangeStartPort 10000 -AutoReusePortRangeNumberOfPorts 50000Reboot the system after applying the setting.
Boost your system for high connection throughput:
-
Increase file descriptor limits via
/etc/security/limits.conf:* soft nofile 1048575 * hard nofile 1048575 -
Add the following to
/etc/rc.local(ensure rc.local has execution permission):#!/bin/sh sysctl -w net.ipv4.tcp_tw_reuse=1 sysctl -w net.ipv4.ip_local_port_range="10000 60000" iptables -t raw -I OUTPUT -j NOTRACK iptables -t raw -I PREROUTING -j NOTRACK sysctl -w net.netfilter.nf_conntrack_max=0 sysctl -w net.ipv4.tcp_syncookies=0 sysctl -w net.ipv4.tcp_max_syn_backlog=2048 sysctl -w net.ipv4.conf.all.rp_filter=0 sysctl -w fs.file-max=1048576
-
Re-login or reboot for changes to take effect.
Note: If you encounter error 24 in NCPS, verify that the increased FD limits are applied (ulimit -n). Error 23 indicates OS-level limits may still be restrictive.
On Server:
ncps -sOn Client:
ncps -c <serverIP> -wt 30 -t 330 T(sec) N Pend Failed IOFail Conn/s Close/s RXkbyte/s TXkbyte/s RT/i c0/i c0rtt/i cR/i cRrtt/i
1.002 7 1593 0 0 69065.9 69058.9 69062.9 69065.9 0 69204 12888 0 0
2.002 14 1586 0 0 69987.0 69980.0 69978.0 69984.0 606 69381 12962 606 161224
Fields:
T(sec): Elapsed time in secondsN: Number of currently active connectionsPend: Number of in-progress connect operationsFailed: Cumulative number of failed connect operations so farIOFail: Cumulative number of failed send/recv operations so farConn/s: Rate of successful connect operations in the current intervalClose/s: Rate of connection close operations in the current intervalRXkbyte/s: TCP payload receive rate (bytes/1000 per second) in the current intervalTXkbyte/s: TCP payload send rate (bytes/1000 per second) in the current intervalRT/i: Number of SYN retransmits in the current intervalc0/i: Number of connect operations completed with 0 SYN retransmits in the current intervalc0rtt/i: Avg SYN-RTT (µs) for connections with 0 SYN retransmits in the current intervalcR/i: Number of connect operations completed with one or more SYN retransmits in the current intervalcRrtt/i: Avg SYN-RTT (µs) for connections with one or more SYN retransmits in the current interval
=== CMDLINE: ./ncps2 -c 10.1.0.5 -wt 5 -t 15
=== VERSION 1.5
###RXGBPS 0.45
###TXGBPS 0.45
=== Time (ms) to Nth connection establishment for first 556947 connections:
=== N T(ms) CPS
=== 100000 1678 59594
=== 200000 3467 57686
=== 300000 5248 57164
=== 400000 7093 56393
=== 500000 8919 56060
=== 556947 10002 55683
###ENDCPS 55683
###CPS,100000:1678,200000:3467,300000:5248,400000:7093,500000:8919,556947:10002
=== SYN RTT (us) stats for first 556947 connections:
=== P25 Median Mean P75 P90 P95 P99 P99.9 P99.99
=== 2342 4441 15996 13249 24443 38198 79657 1038000 1057000
###SYNRTT,25:2342,Median:4441,Mean:15996,75:13249,90:24443,95:38198,99:79657,99.9:1038000,99.99:1057000
=== Percentage of connections with retransmits in the first 556947 connections: 1.7278%
=== Average retransmit count per connection (excluding 0-retransmit cases): 1.0138
###REXMIT,rtconnpercentage:1.7278,rtperconn:1.0138<img width="762" height="751" alt="image" src="https://github.com/user-attachments/assets/43061930-90c5-4780-90b6-173172f59ca4" />
Contents:
- Command-line used
- CPS summary over time
- SYN-RTT distribution
- Retransmit statistics
Parser-friendly lines prefixed with ### to simplify automation (e.g., grep for ###CPS).
- Error 24: Limits from
/etc/security/limits.confnot applied. Checkulimit -n. - Error 23: System-wide FD limit insufficient. Set
sysctl -w fs.file-max=1048576.
This repository may contain third-party open-source libraries used for:
- Command-line parsing
- Cross-platform networking compatibility
All third-party components are listed with their licenses in the THIRD_PARTY_NOTICES.md file.
This project may contain trademarks or logos for projects, products, or services.
Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft’s Trademark & Brand Guidelines.
Use of Microsoft trademarks or logos in modified versions must not cause confusion or imply sponsorship.
Any use of third-party trademarks or logos is subject to those third parties’ policies.