Author

Topic: [SOLVED] Limiting bandwidth on Raspbian (Read 223 times)

legendary
Activity: 2870
Merit: 7490
Crypto Swap Exchange
November 01, 2020, 05:16:17 AM
#20
Okay I just got TrafficToll running with no errors -
on https://github.com/cryzed/TrafficToll it says that to install it that you have to run "pip3 install traffictoll" which I did, but it gave errors when I tried to run it, so I tried "sudo pip3 install traffictoll" and now it works when I run it.  Tongue

Even though i understand monitoring/limiting network usually require superuser access (unless you bother change groups for your user), it's bad practice to use sudo pip install.
It could break your OS if the library require newer version of dependency (which isn't backward compatible) which also used by the OS.
member
Activity: 131
Merit: 29
November 01, 2020, 05:25:27 AM
#19
Okay I just got TrafficToll running with no errors -
on https://github.com/cryzed/TrafficToll it says that to install it that you have to run "pip3 install traffictoll" which I did, but it gave errors when I tried to run it, so I tried "sudo pip3 install traffictoll" and now it works when I run it.  Tongue

Even though i understand monitoring/limiting network usually require superuser access (unless you bother change groups for your user), it's bad practice to use sudo pip install.
It could break your OS if the library require newer version of dependency (which isn't backward compatible) which also used by the OS.

I'm not sure how it would have worked without doing so.
member
Activity: 131
Merit: 29
November 01, 2020, 02:14:36 AM
#18
Okay I just got TrafficToll running with no errors -
on https://github.com/cryzed/TrafficToll it says that to install it that you have to run "pip3 install traffictoll" which I did, but it gave errors when I tried to run it, so I tried "sudo pip3 install traffictoll" and now it works when I run it.  Tongue
member
Activity: 131
Merit: 29
November 01, 2020, 01:54:25 AM
#17
Well it'd be great if it had its own built in bandwidth shaper nonetheless.

I tried using traffictoll but got a couple of errors that I didn't have any luck finding out how to fix.

Tried trickle but it crashes after a few mins and I didn't have any luck finding out why that was happening either.
legendary
Activity: 2618
Merit: 6452
Self-proclaimed Genius
November 01, 2020, 12:57:30 AM
#16
So I launched bitcoin-qt with the following command:
Code:
pi@watcher:~/Downloads/bitcoin-0.20.1/bin $ ./bitcoin-qt -maxuploadtarget=10
expecting it to upload no more than 10 mbtyte/24 hours. 13 hours since launched, it's already uploaded 470 mbytes.
470mb for 13 hours isn't bad, you might also need to reduce the number of connections in order to save some upload bandwidth.

Read this to find more options to reduce traffic: https://github.com/bitcoin/bitcoin/blob/master/doc/reduce-traffic.md
Info for -maxuploadtarget is included in that list with the reason why it reached higher than your set value:

Quote from: reduce-traffic.md
1. Use -maxuploadtarget=
This is not a hard limit; only a threshold to minimize the outbound traffic. When the limit is about to be reached, the uploaded data is cut by no longer serving historic blocks (blocks older than one week).
member
Activity: 131
Merit: 29
November 01, 2020, 12:05:16 AM
#15
So I launched bitcoin-qt with the following command:
Code:
pi@watcher:~/Downloads/bitcoin-0.20.1/bin $ ./bitcoin-qt -maxuploadtarget=10
expecting it to upload no more than 10 mbtyte/24 hours. 13 hours since launched, it's already uploaded 470 mbytes.

I put "maxuploadtarget=10" in Bitcoin-Qt.conf, and will now restart bitcoin-qt to see if it makes any difference.
member
Activity: 131
Merit: 29
October 30, 2020, 07:54:03 AM
#14
I tried launching bitcoin-qt with "trickle -d 100 -u 5 ./bitcoin-qt" and it ran for a few minutes before crashing out, saying "Segmentation fault" in the console. Didn't have any luck searching for this error to find out what happened.

So I just ran "./bitcoin-qt -maxuploadtarget=432" and hopefully when I come back in 24 hours it won't have uploaded more than 432 mbytes.
legendary
Activity: 3612
Merit: 5297
https://merel.mobi => buy facemasks with BTC/LTC
October 30, 2020, 04:39:49 AM
#13
try executing from your home dir (~)
Code:
which bitcoin-cli

If you see an output like:
which: no bitcoin-cli in
bitcoin-cli is not in your path...

In that case you either have to put ~/Downloads/bitcoin-0.20.1/bin in your PATH, or you have to cd to ~/Downloads/bitcoin-0.20.1/bin and execute
./bitcoin-cli [function]
You didn't do this in the code you pasted => the [dot][slash] NEEDS to be there if ~/Downloads/bitcoin-0.20.1/bin is not in your path!!!

And, as being discussed before, getinfo is depreciated, i'm not running the latest release, i'm not sure if it's even still there...

As for your second problem:
  • is bitcoind running under the same user you're executing bitcoin-cli with?
  • is bitcoind running?

could you execute
Code:
ps -ef |grep bitcoind
member
Activity: 131
Merit: 29
October 30, 2020, 04:27:32 AM
#12
Even when I'm in bitcoin-qt's directory, it still won't work:

Quote
pi@watcher:~/Downloads/bitcoin-0.20.1 $ cd bin
pi@watcher:~/Downloads/bitcoin-0.20.1/bin $ ls
bitcoin-cli  bitcoind  bitcoin-qt  bitcoin-tx  bitcoin-wallet  test_bitcoin
pi@watcher:~/Downloads/bitcoin-0.20.1/bin $ bitcoin-cli getinfo
-bash: bitcoin-cli: command not found
pi@watcher:~/Downloads/bitcoin-0.20.1/bin $

No idea why it's acting like bitcoin-qt's not there.
On the old bitcoin core (0.16 I think) I could execute that regardless of what directory I was in.

--

Okay, one step closer:


Quote
pi@watcher:~/Downloads/bitcoin-0.20.1/bin $ ./bitcoin-cli getblockchaininfo
error: Could not locate RPC credentials. No authentication cookie could be found, and RPC password is not set.  See -rpcpassword and -stdinrpcpass.  Configuration file: (/home/pi/.bitcoin/bitcoin.conf)
pi@watcher:~/Downloads/bitcoin-0.20.1/bin $

(/home/pi/.bitcoin/bitcoin.conf) doesn't exist. Also did a search for it and nothing was found.

legendary
Activity: 3612
Merit: 5297
https://merel.mobi => buy facemasks with BTC/LTC
October 29, 2020, 12:41:48 PM
#11
Also, when I type in "bitcoin-cli -getinfo", I get:
Quote
bitcoin-cli -getinfo
-bash: bitcoin-cli: command not found

even though I'm in bitcoin-cli's directory.

Likewise, when I type in "./bitcoin-cli -getinfo", I get:
Quote
error: Could not locate RPC credentials. No authentication cookie could be found, and RPC password is not set.  See -rpcpassword and -stdinrpcpass.  Configuration file: (/home/pi/.bitcoin/bitcoin.conf)

whereas this worked fine on the last version that I was using (18 dot something)

This would never have worked, even if the function wasn't depreciated:
Code:
bitcoin-cli -getinfo

This could have worked tough...
Code:
bitcoin-cli getinfo

no dash in front of the function in when invoking bitcoin-cli Wink

Make sure bitcoin-cli is either in your path, or if it's not in your path make sure you're in the dir where the binary is located and start with ./bitcoin-cli getinfo

Good luck!
legendary
Activity: 3472
Merit: 3217
Playbet.io - Crypto Casino and Sportsbook
October 29, 2020, 10:40:22 AM
#10
Also, when I type in "bitcoin-cli -getinfo", I get:
Quote
bitcoin-cli -getinfo
-bash: bitcoin-cli: command not found

even though I'm in bitcoin-cli's directory.

Likewise, when I type in "./bitcoin-cli -getinfo", I get:
Quote
error: Could not locate RPC credentials. No authentication cookie could be found, and RPC password is not set.  See -rpcpassword and -stdinrpcpass.  Configuration file: (/home/pi/.bitcoin/bitcoin.conf)

whereas this worked fine on the last version that I was using (18 dot something)

It seems this "-getinfo" command was removed last 2017 according to this post from Bitcoin github below.

- https://github.com/bitcoin/bitcoin/issues/11671

And they replace it with this commands below.

Code:
getblockchaininfo
getmempoolinfo
gettxoutsetinfo
getmemoryinfo ("mode")
getmininginfo
getaddednodeinfo ( "node" )
getnetworkinfo
getpeerinfo
getwalletinfo

I don't see any reason of removing it but according to them keeping it is messy and they just want to cleanup the RPC codes.
Look at this post below as it gives you more insight why they removed this command.
- https://github.com/bitcoin/bitcoin/issues/11382
member
Activity: 131
Merit: 29
October 29, 2020, 08:24:41 AM
#9
Also, when I type in "bitcoin-cli -getinfo", I get:
Quote
bitcoin-cli -getinfo
-bash: bitcoin-cli: command not found

even though I'm in bitcoin-cli's directory.

Likewise, when I type in "./bitcoin-cli -getinfo", I get:
Quote
error: Could not locate RPC credentials. No authentication cookie could be found, and RPC password is not set.  See -rpcpassword and -stdinrpcpass.  Configuration file: (/home/pi/.bitcoin/bitcoin.conf)

whereas this worked fine on the last version that I was using (18 dot something)
member
Activity: 131
Merit: 29
October 29, 2020, 08:19:50 AM
#8
I must ask why the maxuploadtarget is based on a 24 hour scope instead of 1 second?

It would be nice to throttle its upload to the second rather than day..
member
Activity: 131
Merit: 29
October 29, 2020, 08:15:17 AM
#7
I reset the pi and wondershaper worked thereafter.

Trickle still returning the same error for some reason, none to my concern though, admittedly; as wondershaper is good enough to be honest.
legendary
Activity: 1624
Merit: 2481
October 29, 2020, 07:58:43 AM
#6
By the way, is that megabits?

It is MiB per day (24 hours).
If you need to make sure that core never exceeds a specific upload rate, you need to limit it using external software (e.g. trickle).



I tried "trickle -u 99999 -d 99999 bitcoin-qt" which returned:

Quote
trickle: Could not reach trickled, working independently: No such file or directory
trickle: exec(): No such file or directory

The first message might indicate an error, but did you check your bandwidth?
This message often appears without any error. You might want to double check this.
member
Activity: 131
Merit: 29
October 29, 2020, 07:55:38 AM
#5
I tried "trickle -u 99999 -d 99999 bitcoin-qt" which returned:

Quote
trickle: Could not reach trickled, working independently: No such file or directory
trickle: exec(): No such file or directory

even though trickle is installed, because when I run "trickle", it returns:
Quote
Usage: trickle [-hvVs] [-d ] [-u ] [-w ] [-t ]
               [-l ] [-n ] command ...
        -h           Help (this)
        -v           Increase verbosity level
        -V           Print trickle version
        -s           Run trickle in standalone mode independent of trickled
        -d     Set maximum cumulative download rate to KB/s
        -u     Set maximum cumulative upload rate to KB/s
        -w   Set window length to KB
        -t Set default smoothing time to s
        -l   Set default smoothing length to KB
        -n     Use trickled socket name
        -L       Set latency to milliseconds
        -P     Preload the specified .so instead of the default one
member
Activity: 131
Merit: 29
October 29, 2020, 07:52:44 AM
#4
Nothing like a nice mocacinno! Or wine. Owe ya one Wink

I wish I'd come across that command from the help command.
Too bad it isn't suggested when you start typing it in, either.


Okay.. so with bitcoin-qt running, on the command line I ran "./bitcoind -maxuploadtarget=1000", which returned:
Quote
2020-10-29T12:48:15Z Bitcoin Core version v0.20.1 (release build)
2020-10-29T12:48:15Z Assuming ancestors of block 0000000000000000000f2adce67e49b0b6bdeb9de8b7c3d7e93b21e7fc1e819d have valid signatures.
2020-10-29T12:48:15Z Setting nMinimumChainWork=00000000000000000000000000000000000000000e1ab5ec9348e9f4b8eb8154
2020-10-29T12:48:15Z Using the 'standard' SHA256 implementation
2020-10-29T12:48:15Z Default data directory /home/pi/.bitcoin
2020-10-29T12:48:15Z Using data directory /home/pi/.bitcoin
2020-10-29T12:48:15Z Config file: /home/pi/.bitcoin/bitcoin.conf (not found, skipping)
2020-10-29T12:48:15Z Command-line arg: maxuploadtarget="1000"
2020-10-29T12:48:15Z Using at most 125 automatic connections (1024 file descriptors available)
2020-10-29T12:48:15Z Using 16 MiB out of 32/2 requested for signature cache, able to store 524288 elements
2020-10-29T12:48:15Z Using 16 MiB out of 32/2 requested for script execution cache, able to store 524288 elements
2020-10-29T12:48:15Z Script verification uses 3 additional threads
2020-10-29T12:48:15Z scheduler thread start
2020-10-29T12:48:15Z Binding RPC on address ::1 port 8332 failed.
2020-10-29T12:48:15Z Binding RPC on address 127.0.0.1 port 8332 failed.
2020-10-29T12:48:15Z Unable to bind any endpoint for RPC server
2020-10-29T12:48:15Z Error: Unable to start HTTP server. See debug log for details.
Error: Unable to start HTTP server. See debug log for details.
2020-10-29T12:48:15Z Shutdown: In progress...
2020-10-29T12:48:15Z scheduler thread exit
2020-10-29T12:48:15Z Shutdown: done

Did this work?

It's pretty annoying that I can't do this from qt's built-in Console.

By the way, is that megabits?
legendary
Activity: 1624
Merit: 2481
October 29, 2020, 07:44:57 AM
#3
Ideally, I'd prefer to limit the bandwith specifically of bitcoin-qt. Is there an apt-get listed app that can do that?

Besides using the built in function as mentioned by mocacinno, you can use trickle to limit the bandwith of a specific application:
Code:
trickle -u UPLOAD_BANDWIDTH -d DOWNLOAD_BANDWIDTH APPLICATION

You obviously need to replace UPLOAD_BANDWIDTH with the maximum allowed upload bandwidth, DOWNLOAD_BANDWIDTH with the maximum allowed download bandwidth and APPLICATION with the name of the application you want to limit.


You might want to try the method mentioned by mocacinno (editing the core config file) first and afterwards trickle.
If nothing works, feel free to report back and we can further debug your problem.
legendary
Activity: 3612
Merit: 5297
https://merel.mobi => buy facemasks with BTC/LTC
October 29, 2020, 07:34:19 AM
#2
I wonder if you're not trying to reinvent the wheel...

There's a parameter you can use for bitcoind instead:
maxuploadtarget

Code:
 -maxuploadtarget=
       Tries to keep outbound traffic under the given target (in MiB per 24h),
       0 = no limit (default: 0)

You can even combine this with:
connect

if you only connect to one or two nodes, you have bigger odds for a sybil attack, but if you connect to nodes you trust, the network traffic should be significantly lower
Code:
 -connect=
       Connect only to the specified node(s); -connect=0 disables automatic
       connections (the rules for this peer are the same as for
       -addnode)

oh, and last but not least, make sure your node isn't pruned... If you run a pruned node and something goes wrong, you'll need to redownload all those blocks...
member
Activity: 131
Merit: 29
October 29, 2020, 07:27:43 AM
#1
UPDATE: Problem solved! Used TrafficToll (https://github.com/cryzed/TrafficToll) to limit the bandwidth of bitcoin specifically.
Use sudo for install and running it, otherwise it won't work.
Create a text file called 1.yaml in /home/pi/.local/bin
Code:
# A list of processes you want to match and their respective settings
processes:
  # You can name the process what you want, it is only used to identify it on the CLI
  # output
  "Bitcoin":
    #download-priority: 0
    #upload-priority: 0
    download: 1000kbps
    upload: 50kbps
    recursive: True
    match:
      - exe: /home/pi/Downloads/bitcoin-0.20.1/bin/bitcoin-qt
https://www.howtogeek.com/658904/how-to-add-a-directory-to-your-path-in-linux/
export PATH=/home/pi/.local/bin/tt:$PATH
Restart the raspberry pi after installing traffictoll.
To run traffictoll, open command line, go to ~/.local/bin and run "sudo tt eth0 1.yaml"


-----------
Hi All
So for some reason wondershaper and trickle aren't working.
I need to limit the bandwidth to the Pi I use because we have very limited upload bandwidth.
I know from "ifconfig" and "show ip addr show" that the connected lan chip is called eth0, but "sudo wondershaper eth0 99999 99999" returns:


Quote
Error: Specified qdisc not found.
RTNETLINK answers: No such file or directory
RTNETLINK answers: No such file or directory
RTNETLINK answers: No such file or directory
RTNETLINK answers: No such file or directory
Error: Failed to find specified qdisc.
Error: Failed to find specified qdisc.
Error: Failed to find specified qdisc.
Error: Parent Qdisc doesn't exists.
We have an error talking to the kernel, -1
Error: Parent Qdisc doesn't exists.
We have an error talking to the kernel, -1
Error: Parent Qdisc doesn't exists.
We have an error talking to the kernel, -1
Error: Parent Qdisc doesn't exists.
We have an error talking to the kernel, -1
Error: Parent Qdisc doesn't exists.
We have an error talking to the kernel, -1
Error: Specified qdisc not found.
Error: Parent Qdisc doesn't exists.
We have an error talking to the kernel, -1

and "sudo trickle eth0 -d 9999 -u 9999" returns

Quote
trickle: Could not reach trickled, working independently: No such file or directory
trickle: exec(): No such file or directory
even though it's installed.
No idea why it's not working.

Ideally, I'd prefer to limit the bandwith specifically of bitcoin-qt. Is there an apt-get listed app that can do that?

By the way, the new Information tab on Bitcoin Core is lovely (and Network Traffic and Peers tabs too for that matter) Smiley

Thanks
Jump to: