Getting TURN traffic statistics

1,778 views
Skip to first unread message

Roman Ivanov

unread,
Sep 27, 2013, 9:17:43 AM9/27/13
to turn-server-project...@googlegroups.com
Hello,

is there an option to track/record traffic used by each TURN user? 
I want to measure traffic statistics and bandwidth per each authorized client.


Oleg Moskalenko

unread,
Sep 27, 2013, 12:29:51 PM9/27/13
to turn-server-project...@googlegroups.com
Roman, there is an option to direct some statistics to redis statistics database. It is described in INSTALL and in wiki, see the redis-statsdb parameter.

Regards,
Oleg

Jonathan Chan

unread,
Oct 1, 2013, 11:43:46 PM10/1/13
to turn-server-project...@googlegroups.com
Dear  all,

I have been trying this new feature of collecting stats in the redis database using sample scripts "secure_relay_secret_with_db_redis.sh" and "secure_udp_client_with_secret.sh". Using the "monitor" command in redis-cli, I can see the turn server publishing "status" messages, e.g.

1380683062.342432 "publish" "turn/user/1380683661:jchan/allocation/0x396ad2c8/status" "refreshed lifetime=600"

I could also use psubscribe command to receive "turn/user/*/allocation/*/traffic", e.g.

redis 127.0.0.1:6379> psubscribe turn/user/*/allocation/*/traffic
Reading messages... (press Ctrl-C to quit)
1) "psubscribe"
2) "turn/user/*/allocation/*/traffic"
3) (integer) 1
1) "pmessage"
2) "turn/user/*/allocation/*/traffic"
3) "turn/user/1380673614:jchan/allocation/0x39bac8ef/traffic"
4) "rcvp=1025, rcvb=224660, sentp=1023, sentb=281136"
1) "pmessage"
2) "turn/user/*/allocation/*/traffic"
3) "turn/user/1380673614:jchan/allocation/0x38c4e72f/traffic"
4) "rcvp=1025, rcvb=224672, sentp=1023, sentb=281124"

However, I could receive the above traffic information only once. Since then, I have restarted the scripts but no more traffic information is available.

Redis "monitor" command is used to look at the database activities. It seems that the turn server has published status messages but no traffic messages. e.g.

1380684952.920426 "publish" "__XXX__" "__YYY__"
1380684956.884392 "keys" "turn/secret/*"
1380684956.884476 "get" "turn/secret/test-rest-api"
1380684956.933683 "set" "turn/user/1380685556:jchan/allocation/0x34667335/status" "new lifetime=1800"
1380684956.933711 "publish" "turn/user/1380685556:jchan/allocation/0x34667335/status" "new lifetime=1800"
1380684956.933932 "set" "turn/user/1380685556:jchan/allocation/0x34667335/status" "refreshed lifetime=600"
1380684956.933952 "publish" "turn/user/1380685556:jchan/allocation/0x34667335/status" "refreshed lifetime=600"
1380684957.034311 "keys" "turn/secret/*"
1380684957.034383 "get" "turn/secret/test-rest-api"
1380684957.034610 "set" "turn/user/1380685556:jchan/allocation/0x2d0a5ed5/status" "new lifetime=1800"
1380684957.034633 "publish" "turn/user/1380685556:jchan/allocation/0x2d0a5ed5/status" "new lifetime=1800"
1380684957.034841 "set" "turn/user/1380685556:jchan/allocation/0x2d0a5ed5/status" "refreshed lifetime=600"
1380684957.034865 "publish" "turn/user/1380685556:jchan/allocation/0x2d0a5ed5/status" "refreshed lifetime=600"
1380684957.035105 "keys" "turn/secret/*"
1380684957.035171 "get" "turn/secret/test-rest-api"
1380684957.035477 "set" "turn/user/1380685556:jchan/allocation/0x2d6ad2c5/status" "new lifetime=1800"
1380684957.035499 "publish" "turn/user/1380685556:jchan/allocation/0x2d6ad2c5/status" "new lifetime=1800"
1380684957.035748 "set" "turn/user/1380685556:jchan/allocation/0x2d6ad2c5/status" "refreshed lifetime=600"
1380684957.035771 "publish" "turn/user/1380685556:jchan/allocation/0x2d6ad2c5/status" "refreshed lifetime=600"
1380684957.036364 "set" "turn/user/1380685556:jchan/allocation/0x2d0a5ed5/status" "refreshed lifetime=600"
1380684957.036387 "publish" "turn/user/1380685556:jchan/allocation/0x2d0a5ed5/status" "refreshed lifetime=600"
1380684957.238240 "set" "turn/user/1380685556:jchan/allocation/0x2d6ad2c5/status" "refreshed lifetime=600"
1380684957.238300 "publish" "turn/user/1380685556:jchan/allocation/0x2d6ad2c5/status" "refreshed lifetime=600"
1380684957.922167 "keys" "turn/secret/*"
1380684957.922280 "publish" "__XXX__" "__YYY__"
1380684962.923384 "keys" "turn/secret/*"
1380684962.923535 "publish" "__XXX__" "__YYY__"

I have restarted the redis database and turn server, but problem remains. I am using a packaged turn server (rfc5766-turn-server_2.6.2.1-1_amd64.deb) and redis-server 2.4.15-1 on an ubuntu 12.10 platform.

Not sure how to proceed further with this problem. Any suggestions are much appreciated.

Cheers,
Jonathan

Oleg Moskalenko

unread,
Oct 2, 2013, 2:15:50 AM10/2/13
to Jonathan Chan, turn-server-project...@googlegroups.com
Jonathan, your test setup is not entirely clear for me. I tried the same test, on a Linux Mint 14 system (an Ubuntu derivative), with some tweaks:

1) I guess you forgot to run examples/scripts/peer.sh. Start it before the test.

2) The script secure_relay_secret_with_db_redis.sh actually does not set redis-statsdb parameter, so that script is not supposed to put any traffic info into the statistics database. The script uses redis only as a user database. I am attaching an updated script to this email, with --redis-statsdb parameter set.

3) Then I run the test with monitor command and I see plenty of traffic info. I am attaching the monitor command output to this email.

Update you test setup and run it again.

Regards,
Oleg



--
You received this message because you are subscribed to the Google Groups "TURN Server project rfc5766-turn-server" group.
To unsubscribe from this group and stop receiving emails from it, send an email to turn-server-project-rfc57...@googlegroups.com.
To post to this group, send email to turn-server-project...@googlegroups.com.
Visit this group at http://groups.google.com/group/turn-server-project-rfc5766-turn-server.
For more options, visit https://groups.google.com/groups/opt_out.

redis-cli.out.txt
secure_relay_secret_with_db_redis.sh

Roman Ivanov

unread,
Oct 2, 2013, 2:42:44 AM10/2/13
to turn-server-project...@googlegroups.com
Hi Oleg,

thanks for information. I see traffic events in Redis.
Questions:
1) How often those events are sent?
2) Bytes/packets counts shows bytes/packets during the time interval?

Oleg Moskalenko

unread,
Oct 2, 2013, 2:46:38 AM10/2/13
to Roman Ivanov, turn-server-project...@googlegroups.com
On Tue, Oct 1, 2013 at 11:42 PM, Roman Ivanov <rskv...@thevideocafe.com> wrote:

1) How often those events are sent?

the information is logged each 2048th packet on client connection (send and received combined).
 
2) Bytes/packets counts shows bytes/packets during the time interval?

yes, of course
 

Regards,
Oleg

Roman Ivanov

unread,
Oct 2, 2013, 2:48:15 AM10/2/13
to turn-server-project...@googlegroups.com
Thanks!



On Friday, September 27, 2013 5:17:43 PM UTC+4, Roman Ivanov wrote:

Jonathan Chan

unread,
Oct 2, 2013, 5:42:40 AM10/2/13
to Oleg Moskalenko, turn-server-project...@googlegroups.com
Hi Oleg,

Thank you for your prompt reply. Sorry for not clarifying my test setup in my previous email, I did have peer.sh script running and added --redis-statsdb parameter in the secure_relay_secret_with_db_redis.sh

Wondering if these changes might contribute to my problem:
  • The requirepass value in redis.conf has been changed from "turn" to my own password, and I modified the secure_relay_secret_with_db_redis.sh according (see my attached relay script)
  • I used my own username instead of "ninefingers" in the REST API (see my udp client script)

Compare my monitor log (see attachment) with yours, it seems that my turn server setup did not publish any traffic messages after "publish" "__XXX__" "__YYY__", even though I did receive traffic messages once in my platform earlier.

Thanks again for your help.

Cheers,
Jonathan


my_secure_relay_secret_with_db_redis.sh
my_secure_udp_client_with_secret.sh
my_monitor_log.txt

Roman Ivanov

unread,
Oct 2, 2013, 5:54:04 AM10/2/13
to turn-server-project...@googlegroups.com
Hi Jonathan,

here is example:

1) "pmessage"
2) "turn/user/*/allocation/*/traffic"
3) "turn/user/c4c5de16-efc7-42c9-8a33-f94b29c0ffa5/allocation/0xe2f0a1da/traffic"
4) "rcvp=267, rcvb=63499, sentp=1781, sentb=1391340"
1) "pmessage"
2) "turn/user/*/allocation/*/traffic"
3) "turn/user/c4c5de16-efc7-42c9-8a33-f94b29c0ffa5/allocation/0xe2f0a1da/traffic"
4) "rcvp=376, rcvb=88462, sentp=1672, sentb=1197338"
1) "pmessage"
2) "turn/user/*/allocation/*/traffic"
3) "turn/user/c4c5de16-efc7-42c9-8a33-f94b29c0ffa5/allocation/0xe35d146a/traffic"
4) "rcvp=563, rcvb=118334, sentp=1485, sentb=618920"
1) "pmessage"
2) "turn/user/*/allocation/*/traffic"
3) "turn/user/c4c5de16-efc7-42c9-8a33-f94b29c0ffa5/allocation/0xe2f0a1da/traffic"
4) "rcvp=653, rcvb=126373, sentp=1395, sentb=204283"
1) "pmessage"
2) "turn/user/*/allocation/*/traffic"
3) "turn/user/c4c5de16-efc7-42c9-8a33-f94b29c0ffa5/allocation/0xb93258ea/traffic"
4) "rcvp=541, rcvb=402591, sentp=1507, sentb=711833"
1) "pmessage"
2) "turn/user/*/allocation/*/traffic"
3) "turn/user/c4c5de16-efc7-42c9-8a33-f94b29c0ffa5/allocation/0xe35d146a/traffic"
4) "rcvp=669, rcvb=139027, sentp=1379, sentb=254100"
1) "pmessage"
2) "turn/user/*/allocation/*/traffic"
3) "turn/user/c4c5de16-efc7-42c9-8a33-f94b29c0ffa5/allocation/0xb93258ea/traffic"
4) "rcvp=511, rcvb=310899, sentp=1537, sentb=764906"



On Friday, September 27, 2013 5:17:43 PM UTC+4, Roman Ivanov wrote:

Jonathan Chan

unread,
Oct 2, 2013, 6:07:12 AM10/2/13
to Roman Ivanov, turn-server-project...@googlegroups.com
Hi Roman and Oleg,

I have found the problem. I reduced the number of emulated client in the udp client script and hence the generated traffic was not sufficient to trigger an traffic event (i.e. the 2048th packet).

Thanks for your assistance.

Cheers,
Jonathan


Oleg Moskalenko

unread,
Oct 2, 2013, 12:43:10 PM10/2/13
to Jonathan Chan, Roman Ivanov, turn-server-project...@googlegroups.com
Jonathan, the statistics is counted and reported independently per user, so the number of users does not affect the statistics reporting. You probably changed the number of packets, not the number of users.

Regards,
Oleg

Jonathan Chan

unread,
Oct 2, 2013, 3:37:05 PM10/2/13
to Oleg Moskalenko, Roman Ivanov, turn-server-project...@googlegroups.com
Hi Oleg,

You are correct. I reduced both the number of clients and the number of packets. Sorry about the mix up.

Cheers,
Jonathan
Reply all
Reply to author
Forward
0 new messages