Coder Social home page Coder Social logo

turnhammer's Introduction

TURN_Hammer

A tool to stress-test TURN (RFC 5766) servers and measure resulting packet loss and RTT.

There are pre-built versions on Github Releases

Usage

Usage: turnhammer <server> <username> <password> [-j <parallel-connections>] [-s <pkt-size>] [--pps <pps>] [-d <duration>] [--delay-after-stopping-sender <delay-after-stopping-sender>] [--delay-between-allocations <delay-between-allocations>] [--calc] [-f] [--video] [--audio] [-J] [-C]


Options:
  -j, --parallel-connections
                    number of simultaneous connections
  -s, --pkt-size    packet size
  --pps             packets per second
  -d, --duration    experiment duration, seconds
  --delay-after-stopping-sender
                    seconds to wait and receive after stopping sender
  --delay-between-allocations
                    microseconds to wait between TURN allocations
  --calc            don't actually run, only calculate bandwidth and traffic
  -f, --force       override bandwidth or traffic limitation
  --video           set pps to 90 and pktsize to 960
  --audio           set pps to 16 and pktsize to 192
  -J, --json        output as JSON instead of plain text
  -C, --no-channels do not use chanels
  --help            display usage information

Output sample:

The test would do approx 11.878 Mbit/s and consume 158.379 megabytes of traffic
My external address: 178.122.56.8:40475
Allocated 200 TURN clients
Received the first datagram
Received 365652 packets from 384000 window of total 384000 || Loss: 04.7781%   bad loss: 00.0000%
RTT4 brackets: 0-49ms: 00.0000%   180-399ms: 50.7474%  1000-1999ms: 00.0000%
             50-179ms: 44.4745%   500-999ms: 00.0000%      2000+ms: 00.0000%
 <<<  Overall score:  8.2 / 10.0  >>>
Stopping TURN clients

JSON output sample:

$ turnhammer  -J --video -j 3 104.131.203.210:3478  u153   p1994421   2> /dev/null
{"status":"ok"
,"received_packets":1350 ,"min_max_window":1350 ,"sent_packets":1350
,"loss":0 ,"bad_loss":0
,"rtt4":{"0_49":0 ,"50_179":0 ,"180_399":100 ,"400_999":0 ,"1000_1999":0 ,"2000+":0}
,"score":9.5
}

Algorithm

  1. Create a UDP socket bound to 0.0.0.0:0.
  2. Get external address the socket
  3. Create K other UDP sockets bound to 0.0.0.0:0 and obtain K allocations from specified TURN server
  4. Add permission to address from "2." to each of that TURN allocations
  5. In each of TURN client instance, send back each data message back to sender. This effectively makes K instances of UDP echo server at TURN side.
  6. From the first UDP socket, send specified number of packets at specified rate to all those "echo servers".
  7. Analyse replies from those "echo servers" and measure packet loss and round-trip times.

diagram

Stress testing guideline

If you want to use turnhammer to measure maximum performance of your TURN server, approximately follow these steps:

  1. On a separate node (not in the system that hosts the TURN server itself) start a turnhammer instance and ensure lightweight load produces good score.
  2. Ramp up sinlge node's load until the score starts to drop.
  3. Assume that this level of load is a client (i.e. turnhammer's) limitation. Roll back the load somewhat (e.g. by 30%), so that score is good again.
  4. Add more instances turnhammer (not within the same operating system, e.g. more VPS or physical nodes) and start them all simultaneously, with the same settings as "3.".
  5. As more and more turnhammer instances get simultaneously active, scores reported by individual turnhammer instances would eventually slump. This time assume it was caused by server overload (not client overload like in "2."). But if, for example, all turnhammer nodes were located in the same network segment then it can be still probing issue.

Note that there are currently some bugs in score calculation - if you see unrealisting values and large negative scores then it is a bug in turnhammer. But that bug should not happen when TURN server connection is working well.

Measuring CPU load may be helpful in the research, but do not get to 100% client or server CPU loads during tests.

Old version

There is old Tokio 0.1-based version of turnhammer, tagged v0.1.0 that can be built with older Rust and may support more old systems. It should work with rustc 1.34.2.

turnhammer's People

Contributors

vi avatar

Stargazers

Yoshiki Kadoshita avatar Stefan Junker avatar Chai-Shi avatar Varun Chitre avatar Trịnh Xuân Hải avatar  avatar muji avatar ik5 avatar GAURAV avatar Vint Sanghyeok Lee avatar V avatar  avatar  avatar

Watchers

 avatar James Cloos avatar  avatar  avatar

Forkers

braam quentusrex

turnhammer's Issues

How to test coturn server with this cofiguration file ?

Hi, i can't test my server, i think there are something to do with my configure file (i installed turnserver-4.5.2) to make this work. Can you check my config file ? Thank you very much.

Here is how i test and the output:

$ ./turnhammer {my public ip}:3478 test test123 -J

The test would do approx 0.011 Mbit/s and consume 0.006 megabytes of traffic
My external address: 1.55.210.102:38194
Allocated 1 TURN clients
{"status":"no_packets_received"}
Stopping TURN clients

Here my config file:

realm={MYDOMAIN}

listening-port=3478

tls-listening-port=5349

listening-ip=0.0.0.0

external-ip={MY PUBLIC IP}/172.31.16.1

min-port=49152
max-port=65535

verbose

lt-cred-mech
user=test:test123

log-file=/var/tmp/turn.log
log-binding
syslog

Here is my turnserver log

Jun 20 03:13:07 turnserver[81188]: 1444: : session 001000000000000010: closed (2nd stage), user <> realm > origin <>, local 0.0.0.0:3478, remote 1.55.210.102:38194, reason: allocation watchdog determined stale session state
Jun 20 03:17:04 turnserver[81188]: 1681: : handle_udp_packet: New UDP endpoint: local addr 0.0.0.0:3478, remote addr 1.55.210.102:51328
Jun 20 03:17:04 turnserver[81188]: 1681: : session 001000000000000012: realm > user <>: incoming packet BINDING processed, success
Jun 20 03:17:04 turnserver[81188]: 1681: : handle_udp_packet: New UDP endpoint: local addr 0.0.0.0:3478, remote addr 1.55.210.102:11424
Jun 20 03:17:04 turnserver[81188]: 1681: : session 001000000000000013: realm > user <>: incoming packet message processed, error 401: Unauthorized
Jun 20 03:17:04 turnserver[81188]: 1681: : IPv4. Local relay addr: 172.31.16.75:62442
Jun 20 03:17:04 turnserver[81188]: 1681: : session 001000000000000013: new, realm=>, username=, lifetime=600
Jun 20 03:17:04 turnserver[81188]: 1681: : session 001000000000000013: realm > user : incoming packet ALLOCATE processed, success
Jun 20 03:17:04 turnserver[81188]: 1681: : session 001000000000000013: peer 1.55.210.102:51328 lifetime updated: 600
Jun 20 03:17:04 turnserver[81188]: 1681: : session 001000000000000013: realm > user : incoming packet CHANNEL_BIND processed, success
Jun 20 03:17:04 turnserver[81188]: 1681: : session 001000000000000013: peer 1.55.210.102:51328 lifetime updated: 600
Jun 20 03:17:04 turnserver[81188]: 1681: : session 001000000000000013: realm > user : incoming packet CHANNEL_BIND processed, success
Jun 20 03:17:13 turnserver[81188]: 1690: : session 001000000000000013: refreshed, realm=>, username=, lifetime=0
Jun 20 03:17:13 turnserver[81188]: 1690: : session 001000000000000013: realm > user : incoming packet REFRESH processed, success
Jun 20 03:17:14 turnserver[81188]: 1691: : session 001000000000000013: usage: realm=>, username=, rp=5, rb=540, sp=5, sb=436
Jun 20 03:17:14 turnserver[81188]: 1691: : session 001000000000000013: peer usage: realm=>, username=, rp=0, rb=0, sp=0, sb=0
Jun 20 03:17:14 turnserver[81188]: 1691: : session 001000000000000013: closed (2nd stage), user realm > origin <>, local 0.0.0.0:3478, remote 1.55.210.102:11424, reason: allocation timeout
Jun 20 03:17:14 turnserver[81188]: 1691: : session 001000000000000013: delete: realm=>, username=
Jun 20 03:17:14 turnserver[81188]: 1691: : session 001000000000000013: peer 1.55.210.102:51328 deleted

Load Testing

I am unable to test my turn server for more than 40 parallel connections.

What does the value "bad_loss" in the output mean?

I did the test below and got a high value of bad loss. With --video option, it gets worse even more 18092.21 %.

My questions are:

  • What does the value "bad loss" in the output mean?

  • How can the value be more than 100%?

  • How can I improve the "bad loss" value?

Thank you very much !

Here is my test's output:

./turnhammer {my server ip}:3478 test test123 --audio -j 200 -d 60 --force

The test would do approx 11.878 Mbit/s and consume 79.189 megabytes of traffic
My external address: 42.113.144.74:52419
Allocated 200 TURN clients
Received the first datagram
Received 190682 packets from 192000 window of total 192000 || Loss: 00.6865%   bad loss: 49.6276%
RTT4 brackets: 0-49ms: 00.0000%   180-399ms: 09.8271%  1000-1999ms: 00.0828%
             50-179ms: 87.1000%   400-999ms: 02.3036%      2000+ms: 00.0000%
 <<<  Overall score:  -39.9 / 10.0  >>>
Stopping TURN clients

thread 'main' panicked at 'Can't bind UDP anymore

Hi. I'm testing my server and I'm trying to increase -j 800 to -j 1600 then the program stop and show up this. What can I do to be able to do the test ?. Thanks you very much.

$ sudo ./turnhammer {my server's IP}:3478 test test123 --pkt-size 275 --pps 24 -j 1600 -d 960 --force
The test would do approx 193.536 Mbit/s and consume 20643.840 megabytes of traffic
My external address: {My IP}:42627

thread 'main' panicked at 'Can't bind UDP anymore: Os { code: 24, kind: Uncategorized, message: "Too many open files" }', src/main.rs:426:66
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.