WiFi Configuration On Ubuntu Workstation/Server

802.11g Wireless Networking

A recent change of office required some wireless networking, involving installation of TP-Link TL-WN321G USB dongles on an Ubuntu Linux 9.10 workstation, 8.04 server and a couple of Windows XP workstations. This article summarises getting the device to work on an Ubuntu Linux system.

I broadly followed the (out-of-date) Ubuntu Community Documentation Wifi How To, with a few tips from elsewhere, and a recollection that it's sometimes better to be without Gnome's Network Manager.

Kernel Driver Support

After plugging in the dongle, lsusb gave the following (snipped) information:

$ lsusb
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 002: ID 148f:2573 Ralink Technology, Corp. RT2501USB Wireless Adapter
...
The second line of output gives the vendor (148f) and product (2573) identifiers for the device. Checking a Linux wireless adapter chipset directory showed that supporting kernel drivers exist for this device's chipset.

Listing the currently loaded kernel drivers showed that both the rt73usb and rt2500usb drivers had been automatically loaded:

$ lsmod
Module                  Size  Used by
...
rt73usb                26336  0 
rt2500usb              xxxxx  0
...

Seeing that two drivers had been loaded I chose to blacklist one of them - the rt2500usb. For that I created a new, custom blacklist file in the /etc/modprobe/ directory, avoiding editing any existing blacklist file that my distribution had created. I chose to create the file /etc/modprobe/blacklist-custom.conf:

$ cat /etc/modprobe.d/blacklist-custom.conf 
blacklist rt2500usb
The rt2500usb driver may work, though I haven't tested it.

Gnome Network Manager Problems

The Ubuntu workstation default setup makes use of Gnome Network Manager to manage wired and wireless network connectivity. Inspecting the kernel message log showed that although the wireless interface was being activated, it was then very quickly deactivating:

$ dmesg
...
[ xxxx.xxxxxx] rt73usb 1-2:1.0: firmware: requesting rt73.bin
[ xxxx.xxxxxx] ADDRCONF(NETDEV_UP): wlan2: link is not ready
[ xxxx.xxxxxx] wlan2: authenticate with AP xx:xx:xx:xx:xx:xx
[ xxxx.xxxxxx] wlan2: authenticated
...
[ xxxx.xxxxxx] wlan2: deauthenticating by local choice (reason=3)
...
Suspecting that Network Manager may be trying to maintain a wired-only connection and knowing the workstation doesn't move anywhere, I decided to dispense with the network-manager package altogether:
$ sudo apt-get remove network-manager
...

Network Interface Configuration

In order to test the connection with my WAP I first disabled authentication and encryption on the WAP through its configuration interface. Here's the simple configuration details for the USB dongle in the workstation's /etc/network/interfaces file:

auto lo
iface lo inet loopback
    address            127.0.0.1
    netmask            255.0.0.0

auto wlan2
iface wlan2 inet static
    address            192.168.1.115
    netmask            255.255.255.0
    gateway            192.168.1.1
    # Wireless config
    wireless-essid     myssid
    wireless-channel   1
    wireless-mode      managed
Using iwconfig I could see that the USB dongle was connecting to the WAP.

Now that we know that we can connect to the wireless access point, we can protect our communication. I'm using WPA2 to connect to and encrypt the communication channel to my WAP. Here's the snipped /etc/network/interfaces:

auto lo
iface lo inet loopback
    address            127.0.0.1
    netmask            255.0.0.0

auto wlan2
iface wlan2 inet static
    address            192.168.1.115
    netmask            255.255.255.0
    gateway            192.168.1.1
    # WPA2 config
    wpa-psk            secretpasskey
    wpa-driver         wext
    wpa-key-mgmt       WPA-PSK
    wpa-proto          WPA2
    wpa-ssid           myssid
    pre-up sleep 5
WPA2 details can go straight into the interfaces file, though you may wish to externalise the WPA2 supplicant information into a separate file that is read-protected from anything but the root user and group.

A check of the network interfaces shows a working wlan network interface:

$ ifconfig
lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:33 errors:0 dropped:0 overruns:0 frame:0
          TX packets:33 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:1831 (1.8 KB)  TX bytes:1831 (1.8 KB)

...

wlan2     Link encap:Ethernet  HWaddr xx:xx:xx:xx:xx:xx
          inet addr:192.168.1.115  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::227:19ff:feb7:668a/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:468550 errors:0 dropped:0 overruns:0 frame:0
          TX packets:398811 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:406451098 (406.4 MB)  TX bytes:184734469 (184.7 MB)

Checking wireless connection information with iwconfig shows the wlan interface is connected:

$ iwconfig
lo        no wireless extensions.

...

wmaster0  no wireless extensions.

wlan2     IEEE 802.11bg  ESSID:"myssid"  
          Mode:Managed  Frequency:2.462 GHz  Access Point: xx:xx:xx:xx:xx:xx
          Bit Rate=54 Mb/s   Tx-Power=9 dBm
          Retry  long limit:7   RTS thr:off   Fragment thr:off
          Power Management:on
          Link Quality=38/70  Signal level=-72 dBm
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

Labels: , , ,

Bookmark and Share

Object Oriented JavaScript - Quick Reference

Object Creation

Constructor-based Creation

function Example(attr) {
    this.attr = attr;
    // Other member attributes and methods.
}

var example = new Example();

// New instances may now also be created using the built-in constructor
// attribute:
var anotherExample = new example.constructor()

JSON-based Creation

var example = {
    attr: null
    // Other member attributes and methods.
}

Inheritance

function Example(attr) {
    this.attr = attr;
    this.foo = function() {}
    // Other member attributes and methods.
}

// Extend Example by adding the bar function to all instances.
Example.prototype.bar = function() {}

Member Attributes

Public Member Attributes

function Example(attr) {
    // Public member attribute accessible by member and non-member functions.
    this.publicAttr = attr;
}

Private Member Attributes

function Example(attr) {
    // Private member attribute only accessible by private and privileged member
    // functions.
    var publicAttr = attr;
}

Member Functions

Public Member Functions

function Example() {
}

Example.prototype.publicFoo = function() {
    // Public functions:
    // * May be called by either member or non-member functions.
    // * Can access public member attribute, but not private member attributes.
}

Private Member Functions

function Example() {
    function privateFoo() {
        // Private functions:
        // * Are only accessible to other private or privileged member functions.
        // * Can access private member attributes.
    }
}

Privileged Member Functions

function Example() {
    this.privilegedFoo = function() {
        // Privileged members:
        // * Can be accessed by either member or non-member functions.
        // * Can access public and private member attributes.
    }
}

Private Member Function Access Of Public Member Attributes

function Example(attr) {
    var that = this;
    this.publicAttr = attr;

    function privateFoo(val) {
        // Because inner functions have their own 'this' attribute, the instance
        // attribute 'this' of the parent function is obscured. Creation of a
        // private member, 'that', and pointing it to the 'this' instance
        // attribute is the convention used as a work-around.
        that.publicAttr = val;
    }

Labels: , ,

Bookmark and Share

Eclipse: An Empty 'Available Software' List

The Problem

I recently (reluctantly) installed Eclipse on my Linux development box (Ubuntu 9.10) for the first time in over a year. I quickly ran into problems when trying to view and install available plug-ins on the 'Available Software' list (available from the menu: HelpInstall New Software...). The available software list appears to be empty, however, it seems that it is actually not being painted correctly.

A quick search pulled up a bug report that suggests a problem with Eclipse's use of the GTK, and a little more searching found an explanation about mixing calls through the GTK with calls to the native windowing system.

The Solution

The solution is to make sure all Eclipse GUI calls go directly to the native windowing system, avoiding the mix of native and GTK calls. This involves setting the GDK_NATIVE_WINDOWS shell environment variable. If starting eclipse from the command line, then this can be done as follows:

$ export GDK_NATIVE_WINDOWS=1
$ eclipse
If starting from a desktop short-cut or similar, then rename the eclipse executable to, say, eclipse.bin and create the following shell script, named eclipse, in the same directory:
#!/bin/bash

export GDK_NATIVE_WINDOWS=1
$(dirname $0)/eclipse.bin

Be sure to allow users with the requisite permissions to execute this script - from the command line:
$ chmod ug+x eclipse
Ownership of the new script file may also need changing:
$ sudo chown $(ls -l eclipse.bin | awk '{OFS=":"; print $3,$4}') eclipse
(That's the long way round, but it saves a little explaining and introduces an interesting use of awk!)

Eclipse Again, sigh! - An Aside

I switched to Netbeans a while ago, having grown weary of the bugs I was encoutering in Eclipse - I find Netbeans to be extremely stable and trouble-free, by-the-way.

I installed Eclipse again recently in order to take advantage of the Android Development Tools (ADT) plug-in for Eclipse and soon faced having to deal with the bug described above. I'd like to get on with the job of developing decent software and an IDE that requires trouble-shooting, work-arounds and restarts takes me away from that and breaks concentration. That's frustrating!

I'm inclined to attribute this bug to quality issues in the Eclipse code-base. That's based upon using Eclipse for a number of years (primarily for Java and C++ development) and seeing it become increasingly unstable. The explanation regarding mixing GUI calls may also add weight to this view - Eclipse would seem to breaking Demeter's Law in an interesting way by going extra lengths to by-pass the GDK layer from within the JRE.

My recent experience with Eclipse has done nothing to bring me back to using it again, and so I'll continue to use the ever improving Netbeans where possible.

Labels: , , ,

Bookmark and Share

PHP Output to Syslog on Ubuntu

There are just a few things you need to know in order to output trace or error information to syslog on an Ubuntu system (the following is probably true for other Debian-based distributions, too) from PHP.

  1. Set error logging to syslog in php.ini (the system-wide php.ini can be found at /etc/php5/php.ini):
    error_log = syslog
  2. Restart Apache:
    $ sudo /etc/init.d/apache2 restart
  3. Use the error_log() function to output your error messages.
  4. View the output of error messages:
    $ tail -f /var/log/syslog
    The -f flag causes new messages to be appended to the output of tail.

Labels: , , ,

Bookmark and Share

Selecting A Free Software License

Motives

I've been stuck in the world of open source software licensing recently. I've written a reasonable amount of software for use by my company, getpepper™, and I would be happy to make some of that software open source. Although I'm inclined to help others, and generally hope to do things that are considered to be socially useful, my choice to open source isn't purely altruistic. Certainly I hope it benefits others as it benefits getpepper™ by its use. But I also hope that getpepper™ and maybe me, individually, will benefit from the wider exposure that open sourcing can bring.

The initial items of software that I'm considering open sourcing are plugins for WordPress and jQuery, both of which currently use the GPL version 2 license. There is a view that developing extensions for at least one of these platforms means that those extensions themselves become GPL'd. I want to understand the commercial implications of this as it effects my company when it releases its software under an open source license - and here I probably mean the GPL, or a GPL-compatible license.

Concerns

So with the above in mind here are a couple of my concerns.

  • As the original author and copyright holder of the software, can I recover that software to apply a different, non-GPL-compatible license to it?
  • Are the rights of the original author any different to the rights of any other user of the software?
Maybe I'm being overly cautious and a little edgy about committing my time and hard work to an open source license, or maybe I'm not really giving too many of my rights away. I'm not sure as I'm not a lawyer and prefer to spend my time writing software, not figuring out the intricacies of licensing law - which seems pretty dull compared to writing most, but not all, types of software. Anyway, hopefully some of my future posts will reflect a more legally aware view!

Labels: , , , ,

Bookmark and Share
Subscribe to this blog
rss news feed icon