220cdi
Posts: 9
Joined: Mon Sep 08, 2014 2:39 pm

Rpi as a wifi-router: low speed over wireless

Mon Sep 08, 2014 3:16 pm

Hi everyone.

I've managed to configure my raspberry pi as a wireless router using a bunch of articles over the Internet. ISP cable is inserted to the ethernet-port and my laptop is connected to the wireless network. I use a wireless dongle:

Code: Select all

Bus 001 Device 004: ID 148f:5370 Ralink Technology, Corp. RT5370 Wireless Adapter
But when i try check speed over the Rpi i face a problem: i cant go any higher than 8-10-12Mbps. I usually open some big torrent-file with a plenty of seeds and watch the downloading speed (noteable detail: when i connect my laptop directly to the isp's cable i got full speed according to my contract 50Mbps, so, it's not torrent/tracker related problem). When speed problems experienced i'm able to ssh to the Rpi and only one problem i can figure out - 2 or more processes named

Code: Select all

kworker/[some_characters_and_numbers]
become very aggressive in point of consumed cpu:

Code: Select all

top - 18:57:26 up 18 days,  1:07,  2 users,  load average: 1.85, 1.09, 0.72
Tasks:  84 total,   2 running,  82 sleeping,   0 stopped,   0 zombie
%Cpu(s):  6.8 us, 28.6 sy,  0.0 ni, 12.7 id,  0.0 wa,  0.0 hi, 51.9 si,  0.0 st
KiB Mem:    447996 total,   344376 used,   103620 free,   140676 buffers
KiB Swap:   102396 total,        0 used,   102396 free,    89200 cached

  PID USER      PR  NI  VIRT  RES  SHR S  %CPU %MEM    TIME+  COMMAND
29144 root      20   0     0    0    0 R  46.0  0.0   0:37.07 kworker/u2:3
23964 pi        20   0 46648  14m 1492 S  13.4  3.2   5766:26 transmission-da
28808 root      20   0     0    0    0 S   9.4  0.0   0:27.06 kworker/u2:0
    3 root      20   0     0    0    0 S   5.3  0.0 568:18.74 ksoftirqd/0
   21 root      20   0     0    0    0 S   2.5  0.0 130:17.80 kswapd0
29085 pi        20   0  4812 1508 1044 R   2.2  0.3   0:03.40 top
Can anyone help me? I haven't found any similar problems, or anybody experiencing this problem. If you need some information (configs and so on), i will provide it by editing this post.

I should also mention, that i measured speed by using iperf. Measuring topology is "PC - ethernet cable - Rpi". When i install an endpoint (let's call it an endpoint, no matter who acts as a server and who is iperf -c). With this topology i got almost wire-speed. But when i modify topology to the following: "PC - ethernet cable - Rpi - wireless waves - laptop with iperf" speed measurements fall down to 10-12-15Mbps (varying tcp window size) and doesn't go any higher. The main reason i described this topologies and iperf-related stuff is the following conclusion: once you get wireless connection, speed dramatically falls down. I beleive that something is wrong with the wireless adapter.

Thanks a lot and sorry for my english, it's not my native language.

220cdi
Posts: 9
Joined: Mon Sep 08, 2014 2:39 pm

Re: Rpi as a wifi-router: low speed over wireless

Wed Sep 10, 2014 10:00 am

I searched hard and found that RT5370-chipset-based wireless dongles have issues with power management. It can also result in low wireless speeds. I tried to turn off power management like it said here: http://www.raspberrypi.org/forums/viewt ... 45&t=46569
But the result was the same:

Code: Select all

pi@raspberrypi ~ $ iwconfig
mon.wlan0  IEEE 802.11bgn  Mode:Monitor  Tx-Power=20 dBm
          Retry  long limit:7   RTS thr:off   Fragment thr:off
          Power Management:on

wlan0     IEEE 802.11bgn  Mode:Master  Tx-Power=20 dBm
          Retry  long limit:7   RTS thr:off   Fragment thr:off
          Power Management:on
My /etc/network/interfaces

Code: Select all

pi@raspberrypi ~ $ cat /etc/network/interfaces
auto lo
iface lo inet loopback

iface eth0 inet static
        address 172.21.13.150
        netmask 255.255.255.0
        gateway 172.21.13.1

wireless-power off
allow-hotplug wlan0
iface wlan0 inet static
        address 192.168.42.1
        netmask 255.255.255.0

up iptables-restore < /etc/iptables.ipv4.nat
I've reloaded the box after editing the file.
Or i am doing something wrong? Or it's impossible to turn off power management when dongle is used in master mode?

220cdi
Posts: 9
Joined: Mon Sep 08, 2014 2:39 pm

Re: Rpi as a wifi-router: low speed over wireless

Mon Sep 15, 2014 9:04 am

I've updated my Raspbian by using

Code: Select all

rpi-update
And now it's up to date:

Code: Select all

pi@raspberrypi ~ $ uname -a
Linux raspberrypi 3.12.28+ #710 PREEMPT Wed Sep 10 15:23:42 BST 2014 armv6l GNU/Linux
But it didn't solve the problem, i still have no more 15Mbps on wireless clients and experiencing kworker problem again:

Code: Select all

pi@raspberrypi ~ $ top
top - 13:02:53 up 10 min,  3 users,  load average: 2.26, 2.24, 1.21
Tasks:  76 total,   2 running,  74 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.6 us, 33.0 sy,  0.0 ni,  3.2 id,  0.0 wa,  0.0 hi, 63.1 si,  0.0 st
KiB Mem:    447864 total,   146876 used,   300988 free,    23828 buffers
KiB Swap:   102396 total,        0 used,   102396 free,    75184 cached

  PID USER      PR  NI  VIRT  RES  SHR S  %CPU %MEM    TIME+  COMMAND
   38 root      20   0     0    0    0 S  84.6  0.0   0:16.52 kworker/u2:2
    3 root      20   0     0    0    0 R   4.5  0.0   0:17.52 ksoftirqd/0
   36 root      20   0     0    0    0 S   2.5  0.0   1:48.64 kworker/u2:1
 3499 pi        20   0  4684 1460 1044 R   2.2  0.3   0:10.17 top
    7 root      20   0     0    0    0 S   0.6  0.0   0:04.03 rcu_preempt
    6 root      20   0     0    0    0 S   0.3  0.0   1:19.32 kworker/u2:0
   18 root      20   0     0    0    0 S   0.3  0.0   0:00.85 kworker/0:1
 1763 root      20   0  1752  540  456 S   0.3  0.1   0:00.24 ifplugd

User avatar
abishur
Posts: 4477
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
Contact: Website

Re: Rpi as a wifi-router: low speed over wireless

Thu Sep 18, 2014 3:27 pm

I'm trying to understand your network setup here.

Are you saying it goes ISP->Rpi->WiFi dongle->Laptop?
Dear forum: Play nice ;-)

User avatar
Jessie
Posts: 1754
Joined: Fri Nov 04, 2011 7:40 pm
Location: C/S CO USA

Re: Rpi as a wifi-router: low speed over wireless

Thu Sep 18, 2014 3:58 pm

How much bandwidth is transmission taking away? The Ralink chipset is natoriosly slow with the pi, but it is also the easiest to configure as a router.

220cdi
Posts: 9
Joined: Mon Sep 08, 2014 2:39 pm

Re: Rpi as a wifi-router: low speed over wireless

Fri Sep 19, 2014 5:49 am

abishur wrote:I'm trying to understand your network setup here.
Are you saying it goes ISP->Rpi->WiFi dongle->Laptop?
I'm using this exact topology.
I just started (actually started to recall some unix-like skills and knowledge from college) to learn linux. And all i want to do is to replace my home router with the Rpi and since i'm replacing a dumb router with a linux-box i decided to start cacti (mysql and apache as a dependency), transmission and couple other things. As i said, when i'm stopping all additional services, like transmission-daemon, mysqld, apache - speed increases, but not significantly. I barely can reach 16, maybe 18Mbps (megabits per sec) on my laptop with all the services off.

220cdi
Posts: 9
Joined: Mon Sep 08, 2014 2:39 pm

Re: Rpi as a wifi-router: low speed over wireless

Fri Sep 19, 2014 8:35 am

Jessie wrote:How much bandwidth is transmission taking away? The Ralink chipset is natoriosly slow with the pi, but it is also the easiest to configure as a router.
Well, i have another one USB stick:

Code: Select all

Bus 001 Device 004: ID 0b05:1791 ASUSTek Computer, Inc. WL-167G v3 802.11n Adapter [Realtek RTL8188SU]
It's claimed that it should work out of the box, but it doesn't... I'm now trying to start it couple of hours, but no success yet.

220cdi
Posts: 9
Joined: Mon Sep 08, 2014 2:39 pm

Re: Rpi as a wifi-router: low speed over wireless

Fri Sep 19, 2014 2:25 pm

Oh man...
I tried to fix things with new wifi-stick and it's all went wrong. Now hostapd is not starting...
Well, i should confess, i can't understand what module or subsystem is aimed for. What does wpa_supplicant do? How it differs from hostapd? Why in some configuration examples we state wireless-related configs in /etc/network/interfaces, but some examples contain this wireless-related configs in hostapd.conf? Can anyone explain this in plain text?

I'm frustrated. Just trying to get things together, but all i do is trying different approaches without any idea and understanding what i actually do...

User avatar
abishur
Posts: 4477
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
Contact: Website

Re: Rpi as a wifi-router: low speed over wireless

Tue Sep 23, 2014 3:13 pm

Wow, sorry for not responding any sooner, work is busy.

Anyway, I asked about the setup because the Ethernet port on the Pi goes through the USB 2.0 Bus, meaning that you have a max (theoretical) speed of 35 MB/s (or 480 Mb/s if you like things in bits instead of bytes). Now I suspect (hope) that when you say you're getting 10-12-15 mbps, you actually mean 10-12-15 MB/s, which when you consider that a portion of your USB bus is already consumed with the incoming connection from your ISP, is about half the max theoretical speed of the USB bus anyway so it isn't all that bad.

If you want to increase the speed here's a couple things you can try going from easiest to hardest with a random cost variable thrown in:

1) Make sure you don't have anything else connected to the USB bus (i.e. a USB stick or hard drive). If you can get away with making the Pi headless with only the WiFi dongle and ethernet cord attached, go for it, anything that creates an interrupt can potentially affect the speed. If you want to hit the max possible speed, make the pi lean and mean!

2) Play with the overclocking settings through the rpi-setup script. The pi provides some official, safe overclocking presets, giving the pi an extra bit off kick can help your speeds. You'll want to bump your pi up one speed setting at a time until it becomes unstable. When it starts having problems lower the overclocking one notch and you'll be at the max overclock your pi can handle.

3) Buy a true wireless router. You can get a cheap one off ebay for a handful of bucks, it will obviously cost more if you want wireless N, but a true wireless router will be able to give you the speed you need.

4) You can free up speed for the USB bus if you get an SPI Ethernet adapter for the Pi. I've heard that the ENC28J60 Ethernet Module with SPI bus works with the Pi, but I've never used it. Not only is this a pricey option ~20-30 USB, it's a hard option that will require compiling the kernel and some soldering I think.
Dear forum: Play nice ;-)

220cdi
Posts: 9
Joined: Mon Sep 08, 2014 2:39 pm

Re: Rpi as a wifi-router: low speed over wireless

Wed Sep 24, 2014 8:05 am

abishur wrote:Anyway, I asked about the setup because the Ethernet port on the Pi goes through the USB 2.0 Bus, meaning that you have a max (theoretical) speed of 35 MB/s (or 480 Mb/s if you like things in bits instead of bytes). Now I suspect (hope) that when you say you're getting 10-12-15 mbps, you actually mean 10-12-15 MB/s, which when you consider that a portion of your USB bus is already consumed with the incoming connection from your ISP, is about half the max theoretical speed of the USB bus anyway so it isn't all that bad.
Thanks for reply, especially this detailed.
I described my topology and speed-rates in one of my previous posts are precise - i get no more 2Mbytes/sec download speed on wireless hosts. Transmission-daemon also has a peak download speed near this value. I use Rpi as a wifi-router, wifi is provided by usb-stick (dongle). More than that, i've got 2Tb external USB-drive, that is used to seed my torrents by transmission. As a conclusion: USB bus is getting overloaded - it's got 3 devices - USB HDD, USB wifi dongle and Ehternet port. I think this is the reason why i get low download speed and high cpu when wireless clients or transmission-daemon is downloading something.

220cdi
Posts: 9
Joined: Mon Sep 08, 2014 2:39 pm

Re: Rpi as a wifi-router: low speed over wireless

Thu Mar 12, 2015 6:16 am

Is this problem fixed in Raspberry Pi 2?
I mean Ethernet port is still on the USB-bus or they've managed to make it standalone?

User avatar
DougieLawson
Posts: 39121
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Rpi as a wifi-router: low speed over wireless

Thu Mar 12, 2015 8:27 am

220cdi wrote:Is this problem fixed in Raspberry Pi 2?
I mean Ethernet port is still on the USB-bus or they've managed to make it standalone?
That part is identical between a B+ and 2B (and some of the later rev2 Bs which got the SMSC9514 but only had one double USB socket).

Cross your fingers and hope that the RPi3 or RPi4 will have USB 3.0 and gigabit ethernet.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Return to “General discussion”