Opened 6 years ago

Closed 6 years ago

#9214 closed enhancement (implemented)

Allow alternate bw limits in k/m/g bits

Reported by: hsn Owned by:
Priority: Very Low Milestone: Tor: 0.2.5.x-final
Component: Core Tor/Tor Version:
Severity: Keywords: tor-relay easy lorax
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

Currently relay bw limits can be set in 10n based bytes per seconds. Standard in ISP industry is to use 2n bits per second.

Add alternative measurement units instead of KB/GB/MB defined:

1 Mbit = 1024*1024/8 bytes/sec
1 Kbit = 1024/8 bytes/sec
1 Gbit = (10243) /8 bytes/sec

It will make bandwidth limit settings much easier to match bw limit given to you by ISP and you can easily compare it against graphs of traffic from ISP.

Nobody is using 10 based bytes per second.

Child Tickets

Attachments (2)

bitsconf.patch (886 bytes) - added by CharlieB 6 years ago.
added constants to support bits in torrc
9214.patch (6.8 KB) - added by CharlieB 6 years ago.

Download all attachments as: .zip

Change History (16)

comment:1 Changed 6 years ago by arma

You're in luck!

static struct unit_table_t memory_units[] = {
  { "",          1 },
  { "b",         1<< 0 },
  { "byte",      1<< 0 },
  { "bytes",     1<< 0 },
  { "kb",        1<<10 },
  { "kbyte",     1<<10 },
  { "kbytes",    1<<10 },
  { "kilobyte",  1<<10 },
  { "kilobytes", 1<<10 },
  { "m",         1<<20 },
  { "mb",        1<<20 },
  { "mbyte",     1<<20 },
  { "mbytes",    1<<20 },
  { "megabyte",  1<<20 },
  { "megabytes", 1<<20 },
  { "gb",        1<<30 },
  { "gbyte",     1<<30 },
  { "gbytes",    1<<30 },
  { "gigabyte",  1<<30 },
  { "gigabytes", 1<<30 },
  { "tb",        U64_LITERAL(1)<<40 },
  { "terabyte",  U64_LITERAL(1)<<40 },
  { "terabytes", U64_LITERAL(1)<<40 },
  { NULL, 0 },
};

comment:2 Changed 6 years ago by hsn

so they are 2n based, but still in bytes/sec.

How to easily write 10 Mbits/sec? its 1310720 bytes/sec.

comment:3 in reply to:  2 Changed 6 years ago by arma

Replying to hsn:

so they are 2n based, but still in bytes/sec.

How to easily write 10 Mbits/sec? its 1310720 bytes/sec.

10/8 is 1.25, so write 1250KB

comment:4 Changed 6 years ago by hsn

1250KB is 9.7Mb/s. 2n bytes/sec makes it even more confusing then 10n bytes/sec.

Can you add few new constants to table?

comment:5 Changed 6 years ago by arma

I would be amenable to new constants in the table. Can't hurt, might help.

Is there a patch?

comment:6 Changed 6 years ago by hsn

10 Mbit = 1280 KB

add kbit, kbits, mbit, mbits, gbit, gbits

No.

comment:7 Changed 6 years ago by nickm

Keywords: tor-relay easy lorax added
Milestone: Tor: 0.2.5.x-final
Priority: normaltrivial

I wouldn't mind taking {,k,kilo,m,mega,g,giga,t,tera}{bit,bits} as allowable values in that table if somebody writes a patch.

Changed 6 years ago by CharlieB

Attachment: bitsconf.patch added

added constants to support bits in torrc

comment:8 Changed 6 years ago by CharlieB

Status: newneeds_review

Sounded simple enough. I went ahead and attached a patch

Constants added:

{ "kilobits", 1<<7 },
{ "kbits", 1<<7 },
{ "megabits", 1<<17 },
{ "mbits", 1<<17 },
{ "gigabits", 1<<27 },
{ "gbits", 1<<27 },
{ "terabits", U64_LITERAL(1)<<37 },
{ "tbits", U64_LITERAL(1)<<37 },

comment:9 Changed 6 years ago by nickm

Status: needs_reviewneeds_revision

Sounds good! It also needs a patch to the manual (in tor.1.txt) and ideally a changelog file (in the changes/ directory). Also it should probably accept units in the singular too, so that you can say "1 kbit" instead of "1 kbits"

Changed 6 years ago by CharlieB

Attachment: 9214.patch added

comment:10 Changed 6 years ago by CharlieB

Status: needs_revisionneeds_review

Thanks Nick, I went ahead and updated both, sorry I missed that the first time around.

I am not all that familiar with the code base yet, but I believe this change should apply to any parameter which accepts bandwidth rates. Thus, for the documentation, I basically did

:%s/GBytes/GBytes|KBits|MBits|GBits

This seemed to me the clearest way to document the change, and I didn't see any params where I thought it would not work. Please let me know if that's a bad assumption.

comment:11 Changed 6 years ago by hsn

manpage is wrong default bw is 1 gbit.

comment:12 in reply to:  11 Changed 6 years ago by arma

Replying to hsn:

manpage is wrong default bw is 1 gbit.

No, the man page says "1 GByte", and the code says "1 GB". They match.

comment:13 Changed 6 years ago by hsn

Bandwidth (limit: 8 Gb/s, burst: 8 Gb/s, measured: 14.4 Kb/s):

You are right, i just checked arm.

comment:14 Changed 6 years ago by nickm

Resolution: implemented
Status: needs_reviewclosed

Merged as d5a5a6a2534e114b6c. Thanks, and sorry about the delay!

Note: See TracTickets for help on using tickets.