Creating a Bluetooth Access point (NAP) in Ubuntu 11.10

A Bluetooth NAP is similar to a Wi-Fi access point. In this case, we will be using NAP to share an Internet connection to another computer with Bluetooth. It is supposed to be able to support 7 or 8 devices connected at once in this manner. Eventually my personal goal is to use this in conjunction with a Wi-Fi connection to get slightly more speed at once or for some redundancy to help achieve a more ubiquitous/pervasive connection.

It turns out what should be a simple process is a bit tricky in Ubuntu. You would expect to be able to create an IP access point fairly easily so that you can share your Internet connection to other devices using Bluetooth. (It turns out it may be possible with Blueman – http://blog.larsstrand.org/2009/04/sharing-internet-connection-over.html, but I’ve never had any luck with setting it up this way.) Here’s some of the steps and resources I used to get it to work. I am using one laptop with a generic usb dongle and another toshiba netbook with built-in Bluetooth for this.

Before anything is started, you need to make sure the devices are paired and trusted with one another. I found the easiest way to get this to work is with blueman (it is in the Ubuntu repos). Also it seems to work better if you initiate the pairing from the client (the computer not sharing the connection).

First, you need a bridge interface. This is easy enough in Ubuntu, by editing the /etc/network/interfaces file. If the interface you wish to share is eth0 (if you want to share a Wi-Fi connection instead, you could switch this with something like wlan0 or whatever your Wi-Fi interface is), you could add something like this:

auto br1
iface br1 inet dhcp
	bridge_ports eth0
	bridge_fd 9
	bridge_hello 2
	bridge_maxage 12
	bridge_stp off

Next you need to make sure both computers can see each other via Bluetooth. This requires enabling scanning and turning the NAP into a master and the client(s) into slaves. This can be done as follows:

sudo hciconfig hci0 piscan

and

sudo hciconfig hci0 lm MASTER,ACCEPT

or

sudo hciconfig hci0 lm SLAVE,ACCEPT

You can now check to see if each of the computers can see each other on bluetooth by running:

hcitool scan

where you should be able to see the opposite computer on each.

Next you want to start the NAP server on the computer you wish to share the connection from. (This is the computer with the bridge device). This script, which is available on the git repository will allow you to start up the NAP server. (it may also be possible to use pand, but I haven’t had any luck yet with it)
This script is called test-nap. It takes a single argument, which is the name of the bridge device. So in our case we would first need to chmod +x the file (to make it executable), then run it like this:

./test-nap br1
#!/usr/bin/python

import sys
import time
import dbus
from optparse import OptionParser, make_option

bus = dbus.SystemBus()

manager = dbus.Interface(bus.get_object("org.bluez", "/"),
"org.bluez.Manager")

option_list = [
make_option("-i", "--device", action="store",
type="string", dest="dev_id"),
]
parser = OptionParser(option_list=option_list)

(options, args) = parser.parse_args()

if options.dev_id:
adapter_path = manager.FindAdapter(options.dev_id)
else:
adapter_path = manager.DefaultAdapter()

server = dbus.Interface(bus.get_object("org.bluez", adapter_path),
"org.bluez.NetworkServer")

service = "nap"

if (len(args) < 1): bridge = "tether" else: bridge = args[0] server.Register(service, bridge) print "Server for %s registered for %s" % (service, bridge) print "Press CTRL-C to disconnect" try: time.sleep(1000) print "Terminating connection" except: pass server.Unregister(service)

After this, you can search from the client to see if the NAP service can be discovered with the command:

sdptool search NAP

You should be able to see the NAP service from your server machine at this point.

The last thing to do is edit the /etc/network/interfaces file on the client side (the device which will connect to the Internet via Bluetooth. When pand connects, it uses a bnep0 interface. You need to add the following to your file:

iface bnep0 inet dhcp

Now we are ready to connect. This is how you connect:

pand -c 
sudo ifup bnep0

Links:

Aircrack suite + Ubuntu 11.10 problems with monitor mode channel

Recently I have been playing around with the aircrack suite and in particular the aireplay-ng tool. This tool may be used for ARP replay attacks, however it requires that the monitor mode interface is able to switch channels to the channel of the target device / access point. For some reason my monitor interface was stuck in channel -1. So to fix this I found a forum post on Ubuntu Forums which solves this problem: http://ubuntuforums.org/showpost.php?p=10550806&postcount=6

You can apply this to the wlan interface to put it directly into monitor mode and avoid using the airmon-ng tool altogether if you wish. You may also be able to apply this to the mon0 interface created by the airmon-ng tool as well, however I have not tried it yet.

The bulk of the problem is just the order in which monitor mode and channel are enabled, it must follow the order as follows:
ifconfig $IFACE down
iwconfig $IFACE mode managed
ifconfig $IFACE up
iwconfig $IFACE channel $@
ifconfig $IFACE down
iwconfig $IFACE mode monitor
ifconfig $IFACE up

Hope this solves some problems…

Points to consider for Usage Based Billing (UBB) in Canada

While I make no claims to understand the economics of the agreements between ISPs for forwarding traffic between each other, the point of this article is to provide a unique perspective since I am a graduate student in the networking field. I also briefly outline some potential techniques that could improve the situation (although none can really solve the problem of the alleged gap forming between revenue and expense). My personal opinion is against UBB since I believe it is against innovation and will make Canada less competitive. Charging per-byte rates will become far too expensive for many people to use the Internet in the same way as people in other countries (or those people with lots of extra money). It will result in contributing to the gap between have and have-nots where poorer people in the country are excluded from the same access to content and opportunity that others have. I try not to focus on arguing for UBB in this article because there are several existing articles which argue this quite well. (Financial Post The Globe and Mail).

In May of 2010, I attended an IEEE conference called the International Communications Conference (ICC 2010) in Capetown, South Africa. This conference is considered the one of the top conferences by the IEEE communications society and is attended by many experts in the communications field. I found one of the keynote speeches by Dr. Steven D. Gray, Head & Vice President Corporate Research, Huawei Technologies to be especially relevant to the current debate in Canada over usage based billing (UBB). The keynote is available free online from the IEEE ComSoc (please note, the keynote I am referencing here starts at about 51 minutes in the presentation).

While the key point about profitability deals with wireless carriers, it may also be relevant to wired network providers. Especially in Canada for the following reasons:

  1. The vast, sparse country which must be connected
  2. The constant upgrades to equipment required
  3. The limited capabilities of backbone and infrastructure networks & increasing speeds of user connections
  4. Steady growth in traffic from users

1. The vast, sparse country which must be connected

Compared to other countries in the world, Canada is very sparse. According to a Wikipedia article surveying population density around the world, Canada places 228 in the world. According to this figure (from Gizmodo), Canada ranks 8th in the world for average broadband speeds. Compared with the USA, which ranks 15th (and has a population density almost 10 times higher than Canada), we have less than twice the average speed for roughly the double the cost. Considering our low density and similar geographic size, one would expect we would pay much more.

Map of the Internet [http://www.opte.org/maps/]

2. The constant upgrades to equipment required

The communications industry is constantly evolving as engineers and scientists figure out how to make faster connections or find new ways to communicate (for example, 10 mbps ethernet to 100 mbps to gigabit and beyond), (example 2: Ethernet to fibre optic, or even next generation wireless networks). Every time something new comes out or improvements are made, the companies must put money into making it work with what they already have, deploy new equipment and so forth. Often because the networks are becoming more complex it requires hiring more people to manage them (which may eventually be solved by autonomous networking, but that’s a different story).

Another example of expense to keep up to date in Canada is Bell Canada. Many people with Bell Internet also have wireless access points provided by Bell. Unfortunately, these access points default to (or in some cases only support) WEP encryption. This encryption is not secure at all and can be broken by your average teenager with instruction off youtube. However it could be argued in hindsight this type of expense is the company’s fault.

Furthermore, to increase capacity in the network, it is not as simple as just adding another link between an under-supplied area. Consider a small town where a few people make use of the majority of the connection cause poor performance for the others in the town. This town may be a candidate for increased capacity, but by adding another connection the company does not stand to gain any increase in subscribers and thus may stand to lose money. Now expand this example to larger cities where higher and higher proportions of the population are using more and more of their connection to the point where almost everyone is straining the infrastructure. There are solutions to this type of problem though. Some companies in the US and other places make use of traffic shaping (which while unpopular is a cheaper alternative to the user). Perhaps two types of plans could be put in place, one with traffic shaping and unlimited usage, or one with no traffic shaping and limited usage.

3. The limited capabilities of backbone and infrastructure networks & increasing speeds of user connections

One of the problems with the increased cost to the providers is the increased speed of user connections. Allowing users to have faster connections means they can request more information at once. Imagine many people flushing their toilets at the same time where the pipe at the road isnt big enough to handle all of the water at once. This is what has been allowed to happen. The problem is further compounded because it is not as simple as water simply flowing through pipes. At each junction, decisions must be made on the direction of the flow. If too much traffic arrives at once junction, the time it takes to make a decision is slower than the rate new traffic is appearing and big problems happen.

4. Steady growth in traffic from users

As can be seen in some of the figures in the ICC keynote, traffic from users is growing exponentially. Unfortunately, the service providers’ revenue is usually growing linearly, so there is eventually a point where it is not profitable for the companies to provide Internet service (assuming the cost to provide exponential traffic grows exponentially). This is the most compelling point for usage based-billing. Unless we can somehow find a way to reduce the growth of data, the only way to retain profitable ISPs is to increase the revenue.

Internet growth [Cisco]

5. Conflicting interests between user service and shareholders profits & the disconnect between what you get and what is advertised

This is another important problem with ISPs. Perhaps this is the reason that the infrastructure managed to get into its current state (where it cannot handle everyone making full use of their advertised connections). In order to gain a competitive advantage over competing ISPs, each company often advertises their maximum potential connection speeds. There is never any mention of the network past the point where your house connects to the ISP. Sure if no one else in your neighbourhood is using the connection you might get close to the advertised speed, but as many people know, you often don’t get close. From the shareholder point of view, you want the company to spend as little as possible on infrastructure. Perhaps it may be necessary the enforce a rule that companies must be able to provide the full advertised speed, regardless of how many other people are on the network. Of course, this would make the Internet much more expensive.

6. Potential Solutions instead of UBB

There are many promising technical solutions to some of the problems that are causing the gap between cost and revenue in Internet technologies, however many of them may not make enough of an impact, or are still too premature to cause a difference yet. So in the meantime something must be done.

In the case of providing video services or other multimedia streaming services such as Netflix, LastFM etc. technologies such as multi-casting may be used to deliver common data to a group of users with one packet (in the unicast model, one packet is sent over and over again for every user, even if they are watching the same content).

To reduce the cost of human maintenance and oversight over the networks, applying autonomic computing techniques to networks so that they can self-manage, self-protect etc. may be beneficial.

Exploiting peer-to-peer, caching and other technologies that reduce communications over the large distances on the Internet may help reduce the cost of delivering traffic on the Internet.

Providing tiered Internet service, where users pay for different service levels may be another model altogether that allows companies to remain competitive without usage based billing. Make traffic that causes high strain on the networks (such as streaming video, real-time traffic etc.) more expensive than traffic that is delay tolerant and has lower requirements (web, email etc.)

Perhaps the government itself should take a more active role in providing Internet infrastructure in Canada if the Internet is seen as another piece of infrastructure like roads, bridges and electricity.

Concluding remarks

Of course, there are many assumptions to the case for UBB. The assumption that the cost for service providers is growing exponentially is the biggest and most important. Wired network access doesn’t have the same problems wireless has (the broadcast, limited bandwidth medium, interference etc.) so the comparisons may not actually be valid. The case becomes complicated by the fact that many ISPs are also in the business of providing wireless service, media services (tv, radio, newspaper etc.) that causes conflicts of interest.

The trouble I have with charging the heaviest users is that everyone seems to be trending towards using more and more traffic. In my own experience with large ISPs I feel like I’m always getting less for more money (usage caps have been getting lower and lower, yet the bill keeps going up). The advertised speeds of the networks are going up, but the capacity seems to be falling since we can get more faster, but less overall.

Howto: Custom icons for Burg (Graphical Grub2)

This is a short tutorial on how to create custom icons for Burg, since I have been trying out some new operating systems and noticed there are no icons for them. The tutorial will cover how to make the images in Gimp (although you could use Photoshop as well) as well as how to edit existing themes to add your custom icons into them.

If you would like to see how to install Burg, see my previous tutorial “Ubuntu 10.10 / 10.04 – Grub 2 with Themes” or, a more updated tutorial for installing burg on Ubuntu 11.04 (natty)

I will also make the icons I have created available for anyone who would like to use them. For this tutorial I will use Backtrack Linux, Mobiln and Chromium icons since there is nothing available for them on Burg yet (AFAIK).

Step 1: Edit the burg.cfg file to adjust the “classes”
Notice in the example below I have added the “–class moblin” argument to the entry for Moblin. We will use this later when adding the icons to our templates. You can do something similar for Chromium and Backtrack to make sure the appropriate icons appear for those entries as well.

menuentry "Moblin" --class moblin --class linux --class os --group group_/dev/sda7 {
insmod ext2
set root='(hd0,7)'
search --no-floppy --fs-uuid --set dc4dfece-206f-4d38-b35c-6aac2fb55522
linux /boot/vmlinuz-2.6.31.5-10.1.moblin2-netbook root=/dev/sda7
}

Step 2: Tell Burg the file names of your icons
Here we will edit the files in /boot/burg/themes/icons. Notice how all the files here are named. We will make our Moblin files: grey_moblin.png, large_moblin.png and small_moblin.png. We will also need to add these names into the “grey”, “hover”, “large” and “small” files.

So, we will just follow the pattern and add entries for moblin. For example, in the grey file, we add the following:

-moblin { image = "$$/grey_moblin.png" }

Continue doing this for all the icons you want to make, in all of the types of icon files (large, grey, hover etc).

Step 3: Creating the image
This part is a bit tricky, since burg is a bit picky when it comes to image format. The large images should be 128 x 128 pixels. The small should be 24 x 24 pixels. When you export the png file, make sure you flatten the image if you used layers and then uncheck all of the boxes. You can leave on compression if you like to reduce the file size. The most important thing to note, is greyscale is not supported, so make sure you save back into rgb for your grey files. Also, if you want to emulate how the gray images are smaller, reduce the size to 90×90 and then grow the canvas back to 128×128. (for more details see: http://code.google.com/p/burg/wiki/ThemeCustomization)

Step 4: Testing
If you like you can reboot each time to test out your changes, but the easiest way is with burg-emu. If you run this as root (or with sudo) and give it the “-D” option, you can change themes and view what each looks like with your icons.

The icons…
Here are the icons I made myself. Note: I don’t claim to have any skill in this area, so don’t blame me if they are ugly. I posted this tutorial so that hopefully some people with more skill can create some better ones! If you do, please send me an email and I’ll post them up here, or at least post a link.

  

Download
Here you can get the icons, there is one set for Chromium, one for Moblin and one for Backtract: icons.tar

Sources:
http://code.google.com/p/burg/wiki/ThemeCustomization