tcpkali(1)
okay so welcome to tcpkali(1), Version 1.1.1 β the fast TCP and WebSocket load generator and sink page, bestie π
β¨
π NAME π
tcpkali -- fast TCP and WebSocket load generator and sink, fr fr.
π¦ SYNOPSIS π¦
tcpkali [OPTIONS] [-l port] [host:port ...]
β¨ DESCRIPTION β¨
tcpkali is that girl for stress-testing and benching TCP and WebSocket based systems. Not me explaining the whole vibe: in the client mode, tcpkali connects to the list of specified hosts and ports and generates traffic for each of these connections. In the server mode, tcpkali accepts incoming connections and throws away any incoming data. Iconic behavior, honestly.
tcpkali can throw unlimited or bandwidth-controlled traffic to the remote destinations both in the client and in the server mode. Yes bestie, both modes get the drama.
The client mode is triggered by specifying one or more host:port arguments on the command line. The server mode is triggered by specifying -l (--listen-port port). Periodt.
π OPTIONS π
πΈ GENERAL OPTIONS πΈ
-h,--helpβ Print a help screen, then exit. Cute and useful.--versionβ Print version number, then exit. Gotta know the era you're in.-v,--verbose levelβ Increase (-v) or set (--verbose) output verbosity level[0..3]. Default is1. Spill more tea with more verbosity.-d,--dump-oneβ Dump input and output data on a single arbitrarily chosen connection. When connection gets closed, some other connection is used for dumping. One connection gets the spotlight, then the next.--dump-one-inβ Dump only the input data on a single connection. Incoming tea only.--dump-one-outβ Dump only the output data on a single connection. Outgoing tea only.--dump-{all,all-in,all-out}β Dump input and/or output data on all connections. Everyone gets looked at, no cap.--write-combine=offβ Send messages individually instead of batching writes. Implies--nagle=off, if not overriden by the command line. Default is on. Do not ask me why the original says βoverridenβ β Iβm just keeping the receipts.-w,--workers Nβ Number of parallel threads to use. Default is to use as many as needed, up to the number of cores detected in the system. Main character scheduling energy.
π§ NETWORK STACK SETTINGS π§
--nagle=on|offβ Control Nagle algorithm by settingTCP_NODELAYsocket option usingsetsockopt(). Default is not to callsetsockopt()at all, which leaves Nagle enabled on most systems. Lowkey important, bestie.--rcvbuf SizeBytesβ Set TCP receive buffers (setSO_RCVBUFsocket option usingsetsockopt()). This option has no effect on some systems with automatic receive buffer management. tcpkali will print a message if--rcvbufhas no effect. At least she tells you.--sndbuf SizeBytesβ Set TCP send buffers (setSO_SNDBUFsocket option usingsetsockopt()). This option has no effect on some systems with automatic receive buffer management. tcpkali will print a message if--sndvbufhas no effect. Yup, thatβs the spelling in the original β keeping it exactly.--source-ip IPβ By default, tcpkali automatically detects and uses all interface aliases to connect to destination hosts. This default behavior allows tcpkali to open more than64kconnections to destinations.
Use the --source-ip to override this behavior by specifying a particular source IP to use. Specifying --source-ip option multiple times builds a list of source IPs to use. Now thatβs range, honey.
π TEST RUN OPTIONS π
--ws,--websocketβ Use RFC6455 WebSocket transport. Websocket girlies rise.-H,--headerβ Add HTTP header into the WebSocket handshake. A little extra flair for the handshake.-c,--connections Nβ Number of concurrent connections to open to the destinations. Default is1. More connections = more chaos, if youβre into that.--connect-rate Rateβ Limit number of new connections per second. Default is100connections per second. Slow down, queen.--connect-timeout Timeβ Limit time spent in a connection attempt. Default is1second. No waiting around forever.--channel-lifetime Timeβ Shut down each connection afterTimeseconds. Bye bestie, your time is up.--channel-bandwidth-upstream Bandwidthβ Limit single connection bandwidth in the outgoing direction. Upstream throttle, iykyk.--channel-bandwidth-downstream Bandwidthβ Limit single connection bandwidth in the incoming direction. Downstream throttle, sheβs balancing the vibe.-l,--listen-port portβ Accept connections on the specified port. Server mode activation, slay.--listen-mode=silent|activeβ How to behave when a new client connection is received. In the silent mode we do not send data and ignore the data received. This is a default. In the active mode tcpkali sends messages to the connected clients. Silent is giving mysterious; active is giving chatty.-T,--duration Timeβ Exit and print final stats after the specified amount of time. Default is10seconds (-T10s). A whole little era.
π TRAFFIC CONTENT OPTIONS π
-e,--unescape-message-argsβ Unescape the message data specified using the-m,-fand the rest of the traffic content options on the command line. Transforms\xxxsequences into bytes with the corresponding octal values,\ninto a newline character, etc. Escape room, but make it networking.-1,--first-messageβ Send this message first, once at the beginning of each connection. This option can be specified several times to send several initial messages at the beginning of each connection. If--websocketoption is given, each message is wrapped into its own WebSocket frame. First impressions matter, bestie.--first-message-file filenameβ Read the message from a file and send it once at the beginning of each connection. This option can be specified several times. File-based opening line, cute.-m,--message stringβ Repeatedly send the specified message to each destination. This option can be specified several times. The main character message.--message-stop stringβ Terminate tcpkali if the given string is encountered in the incoming byte stream. A vibe check that ends the whole run.-f,--message-file filenameβ Repeatedly send the message read from the file to each destination. This option can be specified several times. File message spam, respectfully.-r,--message-rate Rateβ Messages per second to send in a connection. tcpkali attempts to preserve message boundaries. This setting is mutually incompatible with the--channel-bandwidth-upstreamoption, because they both control the message sending rate. Pick a lane, honestly.- *
-r,--message-rate @Latency* β Instead of specifying the message rate, attempt to figure out the maximum message rate that does not result in exceeding the given message latency. Requires--latency-markeroption to be set. Very detective of her.
EXAMPLE:
tcpkali -m "PING" --latency-marker "PONG" -r @100ms
π§ Traffic content expressions π§
tcpkali supports injecting a limited form of variability into the generated content. All message data, be it the -m or --first-message, can contain the dynamic expressions in the form of \{EXPRESSION}.
Expressions can be of the following forms:
connection.uidβ Unique number incremented for each new connection.connection.ptrβ Pointer to a connection structure. Donβt use. The original said βDonβt use,β and Iβm not gonna pretend thatβs a suggestion.connection.reβ Randomized expression, unique per connection.global.reβ Randomized expression, same across all connections.reβ Randomized expression, for each message.message.markerβ Produce a message timestamp for message rate and latency measurements.ws.continuation,ws.ping,ws.pong,ws.text,ws.binaryβ Specify WebSocket frame types. Refer to RFC 6455, section 11.8.EXPRESSION % intβ Remainder of the expression value divided byint.
Expressions can be used to provide some amount of variability to the outgoing data stream. For example, the following command line might be used to load 10 different resources from an HTTP server:
tcpkali -em 'GET /image-\{connection.uid%10}.jpg\r\n\r\n'
The following command is used to come up with random alphanumeric identifiers:
tcpkali -em 'GET /image-\{re [a-z0-9]+}.jpg\r\n\r\n' ...
Expressions are evaluated even if the -e option is not given. Sneaky but fair.
π LATENCY MEASUREMENT OPTIONS π
tcpkali can measure TCP connect latency, time to first byte, and request-response latencies. Sheβs got range.
--latency-connectβ Measure TCP connect latency. How long did the hello take?--latency-first-byteβ Measure latency to first byte. Works only for the active sockets. First byte gets the stopwatch.
tcpkali measures request-response latency by repeatedly recording the time difference between the time the message is sent (as specified by -m or -f) and the time the latency marker is observed in the downstream traffic (as set by --latency-marker). Receipts are being kept.
--latency-marker stringβ Specify a per-message sequence of characters to look for in the data stream. The little treasure map in the bytes.--latency-marker-skip Nβ Ignore the firstNobservations of a--latency-marker. Skip the warm-up drama.--latency-percentiles listβ Report latency at specified percentiles. The option takes a comma-separated list of floating point values. Mean and maximum values can be reported using--latency-percentiles 50,100. Default is95,99,99.5. Percentile queen.--message-markerβ Passive mode detection or message markers. Given this option, tcpkali will detect the\{message.marker}byte sequences and will calculate message rate (in messages per second) and message arrival latency. In the active mode, message rate calculation is implicitly enabled by using the\{message.marker}expression. Marked, measured, and minding her business.
π STATSD OPTIONS π
--statsdβ Enable StatsD output. StatsD output is disabled by default. Metrics are a choice, bestie.--statsd-host hostβ StatsD host to send metrics data to. Default islocalhost. Keep it local unless youβre feeling adventurous.--statsd-port portβ StatsD port to use. Default is8125. A very specific doorway.--statsd-namespace stringβ Metric namespace. Default is"tcpkali". Branding matters.--statsd-latency-window Timeβ By default latencies are measured across the entire duration of tcpkaliβs run (as set by--durationor-T). This option instructs tcpkali to flush latency data to StatsD everyTimeperiod and start measuring latencies anew. The latencies that are displayed in the user interface remain being collected across the whole run. So the UI keeps the whole story; StatsD gets the periodic updates.
β VARIABLE UNITS β
tcpkali recognizes a number of suffixes for numeric values. Tiny unit glossary, slay:
NandRateβk(1000, as in"5k"equals to5000),m(1000000).SizeBytesβk(1024, as in"5k"equals to5120),m(1024*1024).Bandwidthβkbps,Mbps(for bits per second),kBps,MBps(for bytes per second).Time,Latencyβms,s,m,h,d(milliseconds, seconds, etc).
Rate, Time and Latency can be fractional values, such as 0.25. Sheβs precise like that.
πΈ EXAMPLES πΈ
okay bestie, here's where it gets fun β three whole real-world scenarios, no cap π
- Throw 42 requests per second (
-r) in each of the 10,000 connections (-c) at an HTTP server (-m), replacing\nwith actual newlines (-e). this is the classic "make a website feel something" move π₯
tcpkali -c10k -r42 -em 'GET / HTTP/1.0\r\n\r\n' nonexistent.com:80
- Spin up a WebSocket (
--ws) server on a specified port (-l) that lives for an hour (-T), but block clients from actually sending any data. it's giving "the club is open but the dance floor is closed" π
tcpkali --ws -l8080 --channel-bandwidth-downstream=0 -T1h
- Show server responses (
--verbose) while we ping an SMTP server once a second (--connect-rate) and disconnect promptly (--channel-lifetime). all the tea, none of the commitment π«Ά
tcpkali --connect-rate=1 --channel-lifetime=0.1 -vvv
nonexistent.org:smtp
π SEE ALSO π
Sysctls to tune the system to be able to open more connections
like, if you're gonna be extra, be prepared to be extra. for N connections β say, 50k of them β you're gonna want these little system knobs turned:
kern.maxfiles=10000+2*N # BSD
kern.maxfilesperproc=100+2*N # BSD
kern.ipc.maxsockets=10000+2*N # BSD
fs.file-max=10000+2*N # Linux
net.ipv4.tcp_max_orphans=N # Linux
# For load-generating clients.
net.ipv4.ip_local_port_range="10000 65535" # Linux.
net.inet.ip.portrange.first=10000 # BSD/Mac.
net.inet.ip.portrange.last=65535 # (Enough for N < 55535)
net.ipv4.tcp_tw_reuse=1 # Linux
net.inet.tcp.maxtcptw=2*N # BSD
# If using netfilter on Linux:
net.netfilter.nf_conntrack_max=N
echo $((N/8)) > /sys/module/nf_conntrack/parameters/hashsize
Readings
some bedtime reading for the truly obsessed, and honestly? iconic behavior πβ¨
- On TIME-WAIT state and its reuse: http://vincent.bernat.im/en/blog/2014-tcp-time-wait-state-linux.html
- On netfliter settings: http://serverfault.com/questions/482480/
π AUTHORS π
Lev Walkin <lwalkin@machinezone.com>. yeah, that's the main character who made this whole thing happen ππ
and that's the whole manual, bestie! π this little masterpiece is the TCPKali user manual, dated 2017-01-20, and it answers to the name tcpkali(1) accordingly. go forth and flood responsibly ππ¦β¨
π¦ where this page comes from
- nixos 26.05: tcpkali 1.1.1
- nixpkgs unstable: tcpkali 1.1.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms