# ncps **Repository Path**: mirrors_microsoft/ncps ## Basic Information - **Project Name**: ncps - **Description**: ncps is a multi-threaded, high-performance TCP connection stress test tool - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-11-19 - **Last Updated**: 2026-01-10 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # NCPS - Network Connection Performance Stress Tool ## Overview 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. ## Purpose 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. ## Key Features - Generates billions of unique TCP 4-tuples - Multi-threaded for high scalability - Works on Linux and Windows - Command-line interface with flexible configuration ### Building NCPS UPDATE ### - Using `make`: ``` make; make install ``` - Using `CMake`: ``` cd src mkdir build && cd build cmake .. make && make install ``` ### Windows Prerequisites - Windows 10 version 1703 or higher is required. - Enable large ephemeral port range as described below. ### Linux Prerequisites - Increase file descriptor limits in `/etc/security/limits.conf` as described below. - Adjust system parameters in `/etc/rc.local` to optimize TCP behavior and disable connection tracking as described below. --- ## Platform-Specific Configuration ### Windows Make sure to enable large ephemeral port range: ```powershell Set-NetTCPSetting -AutoReusePortRangeStartPort 10000 -AutoReusePortRangeNumberOfPorts 50000 ``` Reboot the system after applying the setting. --- ### Linux Boost your system for high connection throughput: 1. Increase file descriptor limits via `/etc/security/limits.conf`: ``` * soft nofile 1048575 * hard nofile 1048575 ``` 2. Add the following to `/etc/rc.local` (ensure rc.local has execution permission): ```sh #!/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 ``` 3. 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. --- ## Quick Start **On Server:** ```bash ncps -s ``` **On Client:** ```bash ncps -c -wt 30 -t 330 ``` --- ## Output Reference ### Periodic Output Columns ```text 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 seconds - `N`: Number of currently active connections - `Pend`: Number of in-progress connect operations - `Failed`: Cumulative number of failed connect operations so far - `IOFail`: Cumulative number of failed send/recv operations so far - `Conn/s`: Rate of successful connect operations in the current interval - `Close/s`: Rate of connection close operations in the current interval - `RXkbyte/s`: TCP payload receive rate (bytes/1000 per second) in the current interval - `TXkbyte/s`: TCP payload send rate (bytes/1000 per second) in the current interval - `RT/i`: Number of SYN retransmits in the current interval - `c0/i`: Number of connect operations completed with 0 SYN retransmits in the current interval - `c0rtt/i`: Avg SYN-RTT (µs) for connections with 0 SYN retransmits in the current interval - `cR/i`: Number of connect operations completed with one or more SYN retransmits in the current interval - `cRrtt/i`: Avg SYN-RTT (µs) for connections with one or more SYN retransmits in the current interval --- ### Final Stats Example ```text === 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.0138image ``` **Contents**: 1. Command-line used 2. CPS summary over time 3. SYN-RTT distribution 4. Retransmit statistics Parser-friendly lines prefixed with `###` to simplify automation (e.g., grep for `###CPS`). --- ## Troubleshooting - **Error 24**: Limits from `/etc/security/limits.conf` not applied. Check `ulimit -n`. - **Error 23**: System-wide FD limit insufficient. Set `sysctl -w fs.file-max=1048576`. --- ## Third-Party Code 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. ## Trademark Notice 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.