2

I've been painfully trying to set up internet connection on my pi, but, unfortunately, without any result.

The problem is that Pi (connected via cable, running raspbian) gets an ip address and is pinging websites/lan properly, but the connection freezes on any download attempt. E.g.: When doing sudo apt-get update, it is "waiting for headers" forever. Wget stops responding at "Waiting for HTTP request". Even when I connect ethernet with a fresh copy of NOOBS on SD card, it can't download any update for it. And the list goes on...

I tried every possible solution found on the internet - static IP address, fixed DNS address, opening all ports, switching off DHCP on the router, etc.

I gave it a spin at my workplace and it worked perfectly, none of the issues were ocurring. I have also no connection problems with any other devices connected via cable or wifi to the router. I have a sky hub SR101 at home and I'm completely out of ideas what else can I check/configure to make it work.

  • Could you try reducing your MTU using sudo ip link set mtu 1400 dev eth0 or ifconfig eth0 mtu 1400 (both command do exactly the same)? Does wget or curl command work? Could you try something like wget http://google.pl/ ? – Krzysztof Adamski Dec 16 '13 at 11:48
3

The problem

You may experience the problem with too high a MTU value. In such case, small packages (like ICMP ECHO or TCP SYN) are working correctly so you can ping other hosts, and TCP sessions are opened but as soon as you try to transfer bigger packages, it stops working.

The solution

This issue is quite hard to diagnose and the easiest way to test this is to set MTUto some smaller number, like 1400. You can do this using ip command from iproute2 package:

sudo ip link set mtu 1400 dev eth0

or ifconfig command:

ifconfig eth0 mtu 1400

Both command do exactly the same - they set MTU value to 1400. You may experiment with higher values (up to default 1500) to find the biggest one that works. It will probably be 1492 or 1496

Rationale

MTU stands for Maximum Transmission Unit - it's a size of the largest packet that the network can handle. By default it is 1500 for Ethernet v2 (practically all the Ethernet networks today). If you try to send larger packet, the network will drop it.

This means that your network card need to know what is the MTU value of the network so that it wont send packages that are too large. If you are transferring some bigger amount of data, network stack will organize it in the largest packages possible to reduce the number of packages that has to be send (in order to reduce overhead).

Using ping command wont help you diagnose the problem since default packages sent by this command are couple 84 bytes large (so they will work as long as MTU of your network is at least 84).

Now, why default 1500 value may be wrong? If your network uses LLC, SNAP or PPPoE, according to RFC 1042, the MTU should be 1492. One other situation where I had to lower MTU value was using IEEE 802.1Q VLAN tagging. In such situation each packet will be amended by adding 4 bytes so if your packet already has 1500 bytes, it will be enlarged to 1504.

Consequences

MTU value has direct impact on network performance. The bigger the value is, the more data can be transferred in one network package. Since each network package has to be processed individually and much of this work is not depended on it's size (processing headers and making decisions based on them), a lot of network equipment has limits not only on bandwidth but also on number of packages per second. This means that making packages bigger makes network working faster.

There are some problems with big packages, though. If you have bigger package, chances that it will be corrupted are greater. Since the only way to handle damaged packages on Ethernet is to drop them, big packages may degrade network performance when there are some transfer problems. In addition, some connections may not be able to transport packages over a certain size, which will result in fragmentation.

That being said, reducing MTU size by a few bytes should have only marginal impact on your network performance. This should be even less visible on RaspberryPi since it's not a high performance network device.

  • Does it affect the transfer in any way or is it negligible? I mean 4 bytes sounds like nothing, I just want to know out of pure curiosity. – Koyot Dec 18 '13 at 9:26
  • @Koyot: Updated my answer with regards to your question in comment. – Krzysztof Adamski Dec 18 '13 at 9:48
0

your best bet would be to replace the router. i did this once (not for a raspi, but for another device), but the symptoms were similar -- everything works, except this one particular device.

besides that you may try to telnet/netcat/http to the router (it usually has some setup pages available) and start trouble shooting from there. if you can see the router pages, then you may procees to access the internet, if not -- again, maybe router replacement is not such a bad idea after all.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.