TOPIC: Wireless Networking 101

Wireless Networking 101 3 years 2 months ago #1

  • chewitt
  • chewitt's Avatar
  • OFFLINE
  • Moderator
  • Posts: 5028
  • Thank you received: 857
  • Karma: 213
Below are some observations and things to understand about how WIFI (and networkIng) works in the OpenELEC OS:

A. The /storage/config/network.conf file has not been used since RC4. The OpenELEC configuration addon was released and integrated into the OS as part of RC5. If you still have this file hanging around, you can delete it.

B. Wireless networks with a hidden SSID (network name) are NOT SUPPORTED. Hiding the network name is pointless for security READ THIS. Yes we know it might work in Ubuntu, but OE IS NOT UBUNTU so any comparison you make is irrelevant. For WIFI security, as long as you are using WPA2 (not WEP) with a decent length of passphrase the chances of some neighbour or local kid running a brute-froce attack to steal your WIFI is exceedingly slim. XKCD has a great cartoon to educate you on PASSWORD SECURITY

C. The # $ characters and <spaces> in the SSID name or passphrase will cause problems. It is possible to use them, but you need to \escape them when you enter details in the OE configuration plugin. As an example; to use "Password$" (no quotes) as your WIFI passphrase you need to input "Password\$" via the plugin. This is will be fixed eventually, but it's not a high priority right now.

D. If you change network settings in the OS plugin YOU MUST REBOOT. If you don't the changes will not take effect!

E. OpenELEC is designed to use a single network connection and it automatically uses an Ethernet/LAN connection if one is available EVEN IF YOU CONFIGURED WIFI. This is a hard-coded behaviour and it cannot be changed. This also means trying to debug a wireless connection issue with an ethernet cable connected is not going to work..

F. Your network connection is configured via the following files:
/storage/.xbmc/userdata/addon_data/os.openelec.settings/settings.xml
/var/lib/connman/default.profile
The settings you entered into the OE plugin are saved in settings.xml. During boot the /etc/init.d/21_network shell script is run. This script reads data from settings.xml and creates default.profile which is used to configure the OS's connection manager; /usr/sbin/connmand.

G. The network does not start as fast as XBMC does! OE boots fast (really fast) and a typical system shows the XBMC home screen in 7-10 seconds once POST has completed. However, many network cards (particularly USB ones) will take 15-20 seconds to load the kernel driver and become active, then see/join your wireless network, then get an IP address (unless your DHCP server is broken a static IP does not make things any quicker). This means things like the RSS news feed and Weather feed will fail the first time XBMC tries to refresh them and by default it will be ~30 minutes before XBMC tries again. Also affected are "on boot" library updates. If you experience this problem it is possible to add a startup script to /storage/.config called autostart.sh with the following content to force a refresh of the RSS feed (after 30 seconds) and update the libraries. Please note the Weather refresh line will only work in XBMC "Eden" based versions of OpenELEC, there is no equivalent command in XBMC "Dharma" releases:
(
sleep 30
xbmc-send --host=127.0.0.1 -a "RefreshRSS"
xbmc-send --host=127.0.0.1 -a "Weather.Refresh"
xbmc-send --host=127.0.0.1 -a "UpdateLibrary(music)"
xbmc-send --host=127.0.0.1 -a "UpdateLibrary(video)"
)&
H. XBMC shows 127.0.0.1 as the DNS server! This is because the OE connection manager implements a local DNS proxy, so XBMC is correctly (it is not a bug in either OE or XBMC) showing localhost as the DNS server. You may have other DNS issues but THIS IS NOT THE PROBLEM.

I. If you see "wlan0 runs an unsupported 802.11 driver" in /var/log/messages this means the driver is not currently supported by the kernel maintenance team. In laymans terms; the driver is still being tested by the Linux kernel dev team before becoming officially supported and it has "staging" status. This message can be ignored; it DOES NOT mean the driver isn't working or isn't supported by your hardware.

J. Things to check if wireless does not work:

- You do not have an Ethernet cable plugged in!
- You set network to WLAN (not LAN)
- You set the right network interface (normally wlan0)
- Check there are no spaces and strange characters in the network name or passphrase in settings.xml
- Check there are no spaces and strange characters in the network name or passphrase in default.profile
- Check that the network name and passphrase in default.profile matches settings.xml
- Check your network is not hidden
- Check your network does not have MAC address control active (if it does, make sure the wlan0 MAC is listed)

K. If the steps above don't achieve anything, check that a wireless driver is being loaded:

- Check 'ifconfig' and make sure you have wlan0
- Check 'dmesg' and /var/log/messages to check for any mention of wlan0
- Check 'lsmod', 'lsusb' or 'lspci' (for USB and PCI cards respectively) for mentions of wireless drivers
- Check in the BIOS to ensure Wireless is set to be active on boot

If there is no mention of wlan0 (or wlan1) anywhere the kernel is not loading a wireless driver. To assist with us with understanding why, it helps to boot the system from an Ubuntu LiveCD and run the same commands; this will tell the OE devs which wireless driver is being used in Ubuntu. If the equivalent driver is not already present in the OpenELEC OS it can be added easily by the dev team. Please post a request to the 'requests' section of the forum and/or speak to the dev team on the IRC support channel. If the driver is already in the OS please join the IRC channel for assistance.

L. How do I found out what driver I need to look for? The first thing to understand is that Linux is more concerned about the chipset inside the device than the brand-name on it. There are approximately 4-5 primary vendors who make all the chipsets that used by the 30,000+ hardware manufacturers, so knowing the chipset is much more useful than knowing the brand. So how do you find out what chipset is in your device? This is easily found by running some Google searches on the model number of your wireless device and "chipset" or "chipset linux", e.g. for my Sitecom W352 USB NIC I ran a search on "sitecom w352 chipset linux" and within the first few links I discovered that it has a realtek RTL8188SE chipset. The term "linux" is good to include in the search as for any device many other Linux users have probably searched or blogged looking for the same info. Once I know the chipset I can run another search on "RTL8188SE linux driver" or "RTL8188SE ubuntu" (the Ubunto forums have lots of posts on this kind of thing) and within a few postings I can figure out that the Linux driver for my wireless card uses the "r8172u" driver. Now I can look in lsmod, lsusb or dmesg output for any mention of "r8172u" to see if the driver is being loaded.

M. How do I get information off a system with no network connection?

- Connect Ethernet and SSH to the console
- Run the command "mount -o remount,rw /flash" (no quotes) to make /flash re-writable
- Change to the /flash directory
- Edit and add "debugging" (no quotes) to the kernel boot parameters line (in extlinux.cfg or patchstick.sh depending on your bootloader)
- Save and reboot

Once the system has restarted you will have local console access on CTRL+ALT+F3 to run commands and dump/save the contents of any logs you are being asked for to a text file. Once you reconnect an Ethernet cable you can "cat <filename> | paste" the files to pastebin.com to share the info the the dev team - please post pastebin.com URLs to the forum instead of ~800 line log output. Please also check/validate the pastebin URLs - if you make several pastes in quick succession you will probably trip spam filters on pastebin.com and you need to complete a captcha to validate the paste. If you don't validate the paste will be deleted which isn't so helpful. To ensure useful data on your wireless problem is collected, boot the system without Ethernet connected and then wait 60 seconds after the XBMC home screen appears before running commands to save/dump the files. Then (and only then) connect Ethernet to share the data.

N. To restart connmand without rebooting:

- Run "ps -ef | grep connmand" (no quotes) to find the Process ID (PID) for connmand. The PID is the 3-5 digit number at the start of the line that contains /usr/sbin/connmand.
- Kill the process using "kill -9 <PID>" (no quotes)
- Restart connmand by running "/usr/sbin/connmand" (no quotes)

This is useful if you need to change/test settings in default.profile from the console.

======
Comments and feedback welcomed..
Last Edit: 2 years 9 months ago by chewitt.
The administrator has disabled public write access.
The following user(s) said Thank You: ilya, vitalizm, kisho, sdb, xaro, gruby102

Re: Wireless Networking 101 3 years 2 months ago #2

  • trinybwoy
  • trinybwoy's Avatar
thank you!

this was an excellent post.
i learned a lot!
The administrator has disabled public write access.

Re: Wireless Networking 101 2 years 10 months ago #3

  • YoYo25
  • YoYo25's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 18
  • Karma: 0
Hi...

Thanks for the post....but I still didn't get what I should do in order to setup my WiFi on openELEC (used on Xtreamer Ultra). Can anyone refer me or send me explanation of what I should do...

Thanks:)
The administrator has disabled public write access.

Re: Wireless Networking 101 2 years 10 months ago #4

  • chewitt
  • chewitt's Avatar
  • OFFLINE
  • Moderator
  • Posts: 5028
  • Thank you received: 857
  • Karma: 213
From the XBMC home screen: SYSTEM > ADD-ONS > ENABLED ADD-ONS > PROGRAM ADD-ONS > OPENELEC OS SETTINGS > CONFIGURE > NETWORK. Set Network Technology to "WLAN" and Network Interface to "wlan0" ..then scroll down to set the Network Name (WLAN SSID) and security type and passphrase (password) if you use them.
The administrator has disabled public write access.

Re: Wireless Networking 101 2 years 9 months ago #5

  • vitalizm
  • vitalizm's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 8
  • Karma: 0
Awesome post!

Thanks!
The administrator has disabled public write access.

Some added tips now that mine is working... 2 years 7 months ago #6

  • sdb
  • sdb's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
  • Thank you received: 1
  • Karma: 0
For restarting connmand, I used killall:
killall -9 connmand

And I found that it restarts automatically (in /etc/init.d/21_network it is started inside a 'while' loop so when it stops it gets started again).


And I wanted both wired and wireless networks active (they are on separate networks) but wireless is too slow to start so the wired started first and then the wireless never started.

To get both of my multiple networks, wifi and wired, I used autostart.sh:
#!/bin/bash
(
  # fix for wireless network wlan0 being unconfigured when eth0 is active

  # sleep to let things stabilize
  sleep 5

  ETHIP=
  if ! ip addr list wlan0 | grep -q inet; then
    ETHIP=$(ip addr list eth0 | grep -o "inet [0-9./]\+ " | grep -o "[0-9./]\+")
    echo "wlan0, ETHIP=$ETHIP" >&2
    ifconfig wlan0 0.0.0.0 down
    ifconfig eth0  0.0.0.0 down
    ps xua | grep -q "[w]pa_supplicant" && killall wpa_supplicant
    ps xua | grep -q "[c]onnmand" && killall connmand
    x=0
    # give wlan0 a chance by keep eth0 down
    while [ $x -lt 30 ] && ! ip addr list wlan0 | grep -q inet; do
      x=$((x + 1))
      #echo "- $x --------------" >&2; ip addr list >&2
      ifconfig eth0 0.0.0.0 down >&2
      sleep 1
    done
    # now let eth0 get going
    ifconfig eth0 up
    sleep 5
  fi

  # manually recover eth0 if possible and needed
  if [ "$ETHIP" ] && ! ip addr list eth0 | grep -q inet; then
    echo "eth0 => $ETHIP" >&2
    ip addr add $ETHIP dev eth0
  fi

) &
The administrator has disabled public write access.

Re: Some added tips now that mine is working... 2 years 4 months ago #7

  • Bossanova808
  • Bossanova808's Avatar
  • NOW ONLINE
  • Expert Boarder
  • Posts: 358
  • Thank you received: 10
  • Karma: 7
This guide is great however the problems with USB wireless dongles taking time to start up are more than jsut firing off a weather/rss update - if you're using network shares, these don't come up either of course, and there doesn't appear to be an obvious way to tell XBMC

Also - my micronext USB-N adaptor - mn-wd152B - comes up quickly enough sometimes, but then others it doesn't come up at all.

Is there perhaps a more foolproof way of delaying XBMC's start until wlan0 is up and has an IP??
The administrator has disabled public write access.

Re: Some added tips now that mine is working... 2 years 4 months ago #8

  • chewitt
  • chewitt's Avatar
  • OFFLINE
  • Moderator
  • Posts: 5028
  • Thank you received: 857
  • Karma: 213
/storage/.config/autostart.sh is the only user-friendly way to manipulate the boot process. To do more you need to think about a custom build and tweaks to the init scripts:
(
sleep 10
echo "this runs in the background while other processes are still doing their thing"
&)
sleep 10
echo "this results in EVERYTHING stopping for 10 seconds as the sleep timer counts down"
What chipset is in the USB? (lsusb)
Last Edit: 2 years 4 months ago by chewitt.
The administrator has disabled public write access.
The following user(s) said Thank You: Bossanova808

Re: Some added tips now that mine is working... 2 years 4 months ago #9

  • Bossanova808
  • Bossanova808's Avatar
  • NOW ONLINE
  • Expert Boarder
  • Posts: 358
  • Thank you received: 10
  • Karma: 7
Not at home right now, but haven't found the chipset yet - www.bluenext.co.uk/wifi-products/wifi-ad...ireless-adapter.html

..actually I have just unzipped the driver package and it looks like Realtek RTL8818CUS

It's jsut odd that sometime is comes up before XBMC boots, other times not at all. I guess I should be looking in dmesg but it's a pain cause there's no network!
Last Edit: 2 years 4 months ago by Bossanova808.
The administrator has disabled public write access.

Re: Some added tips now that mine is working... 2 years 4 months ago #10

  • chewitt
  • chewitt's Avatar
  • OFFLINE
  • Moderator
  • Posts: 5028
  • Thank you received: 857
  • Karma: 213
Realtek USB chipsets seem to take substantially longer than others to initialise. The couple I have take 22-25 seconds whereas the Atheros card I have takes 5-6 seconds, and "over time" there's been a persistent drip-feed of postings about this kind of thing and it's always a Realtek NIC.

If you look in /var/log/messages you'll see dmesg and info on the init scripts running at the same time. The networking init script tests once each second for 30 seconds for the NIC device to be shows as present, then it starts connman. If it's over 30 seconds connman starts with no profile for the NIC and WLAN simply won't work during that boot cycle, even when the NIC has finally initialised. I suspect your NIC is right on the 30 second boundary; hence sometimes it works, others it doesn't.

Googling that chipset turns up only 4 posts in chinese. I think when you plug it in and run lsusb the chipset will be something else (more known)
The administrator has disabled public write access.
The following user(s) said Thank You: Bossanova808

Re: Some added tips now that mine is working... 2 years 4 months ago #11

  • Bossanova808
  • Bossanova808's Avatar
  • NOW ONLINE
  • Expert Boarder
  • Posts: 358
  • Thank you received: 10
  • Karma: 7
I'll try lsusb out tonight with any luck...

I am not qutie sure you're right on the timing thouhg, in that there's a little green LED on teh dongle - sometimes it lights up almsot straight after the SYSLINUX screen, and other times not at all - pretty much nothing inbetween. I will try putting a pause in place, I don't care if it takes 10 extra seconds to boot as long as it does come up.

Eventually I will just get a cabler in to do Cat6 but it will be a tricky install so was keen to get things running at least moderately before I can organise that...
The administrator has disabled public write access.

Re: Some added tips now that mine is working... 2 years 4 months ago #12

  • Bossanova808
  • Bossanova808's Avatar
  • NOW ONLINE
  • Expert Boarder
  • Posts: 358
  • Thank you received: 10
  • Karma: 7
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 002: ID 0bda:8176 Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN
Bus 002 Device 002: ID 147a:e03e Formosa Industrial Computing, Inc. Infrared Receiver [IR605A/Q]
Bus 002 Device 003: ID 04d9:1203 Holtek Semiconductor, Inc. Keyboard

On a succesful startup:

[ 6.161131] ADDRCONF(NETDEV_UP): wlan0: link is not ready
....
[ 9.126303] wlan0: direct probe to 00:04:ed:d0:03:9a (try 1/3)
[ 9.132031] wlan0: direct probe responded
[ 9.167293] wlan0: authenticate with 00:04:ed:d0:03:9a (try 1)
[ 9.181935] wlan0: authenticated
[ 9.182377] wlan0: associate with 00:04:ed:d0:03:9a (try 1)
[ 9.201123] wlan0: RX AssocResp from 00:04:ed:d0:03:9a (capab=0x411 status=0 aid=5)
[ 9.201133] wlan0: associated
[ 9.215089] ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready

...that's 9 seconds right? So it CAN be up in that sort of time, but clearly it often isn't....

It dropped the connection while I was getting these files....I am really dubios this is ever gonna work well enough. I have tried EOP devices as well, I've never had a set last longer than 6 months....I think I have to bite the bullet and get the cabling done...
The administrator has disabled public write access.

Re: Some added tips now that mine is working... 2 years 4 months ago #13

  • chewitt
  • chewitt's Avatar
  • OFFLINE
  • Moderator
  • Posts: 5028
  • Thank you received: 857
  • Karma: 213
Yup, 9.2 secs

It should be using the r8192cu driver which has been in the OS for a while, but some Google research on this specific chipset gives a mixed bag of results that vary wildly from kernel to user to distro combination. The general synopsis seems to be that if it works OOTB it'll work really great, but if it doesn't work you're in for a visit to driver purgatory. OE uses the kernel driver not the Realtek binary driver, but there are an equal number of complaints for each so I'm not sure that would be the solution. In short; no ideas what the issue is :(

Cat6 gets a thumbs up as WLAN is always a little sucky for streaming.
The administrator has disabled public write access.

Re: Some added tips now that mine is working... 2 years 4 months ago #14

  • Bossanova808
  • Bossanova808's Avatar
  • NOW ONLINE
  • Expert Boarder
  • Posts: 358
  • Thank you received: 10
  • Karma: 7
Yeah thanks, I will call the cabler - once done it will always be right...
The administrator has disabled public write access.

Re: Wireless Networking 101 2 years 4 months ago #15

  • gruby102
  • gruby102's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 9
  • Karma: 0
Thank You very much for this post!!!
The administrator has disabled public write access.

Our Sponsors & Partners

arctic_logo