How to Use TCP/IP over Bluetooth

TCP/IP over PAN/BNEP

PAN and BNEP are the “official” way to do networking with BlueTooth. BNEP is a simple encapsulation of Ethernet frames in a L2CAP session. PAN is the BlueTooth profile using BNEP and defining how to do networking. It includes the definition of the SDP attributes and various node roles. What are the node roles ? It’s just something to make your life more complex. In a typical Ad-Hoc scenario, the server will have the role GN, and up to 7 clients with role PANU can be connected to it. An Access Point would take a NAP (yeah, boring).

The support of BNEP in BlueZ is quite new and and not yet documented in the Official Howto, but there is an alternate Unofficial Howto.

As usual, I’ll go straight to a very simple example of setting up TCP/IP between two nodes. You can do more complex stuff by reading the Howto above.
First, you need to set up the server. The server will listen for incomming connections. In our example, it’s not an Access Point, so we do :

> modprobe bnep
> pand --listen --role GN

On the client side, we first need to know the address of the server ; the inquiry is currently done like this :

> hcitool inq
Inquiring ...
        50:C2:00:03:C4:DC       clock offset: 0x2454    class: 0x020300

Now, you just need to connect to the other side :

> modprobe bnep
> pand --connect 50:C2:00:03:C4:DC

Unfortunately, pand can fail silently, so the way to check if this succeed is to see if a new device bnep0 has been created, either using cat /proc/net/dev or ifconfig bnep0. You may notice that the interface is down, that’s perfectly normal at this point. In case of problem, you need to check the logs for details, in my case /var/log/daemon.log.

What’s left ? BNEP is only a Ethernet emulation. We need to configure TCP/IP on the new interface. This is done with :

> ifconfig bnep0 10.10.10.1 broadcast 10.10.10.255 netmask 255.255.255.0

Just remember that you need to assign an different IP address on each node, otherwise it won’t work. After that, you should be able to ping, telnet and all that jazz.

To terminate your connection on the client, just do :

> ifconfig bnep0 down
> pand --kill 50:C2:00:03:C4:DC

If you want to get more fancy, you can use HotPlug to automatically assign IP addresses to the bnep interfaces, and you can start playing with the SPD to know which node support PAN or not. And, if you want to build an Access Point, you will need to enable bridging. The HOWTO explains that in details.

This info has been extracted from http://www.hpl.hp.com/personal/Jean_Tourrilhes/bt/

Advertisements

4 thoughts on “How to Use TCP/IP over Bluetooth

  1. Pingback: bnep: rede TCP/IP sobre Bluetooth — Espaço Liberdade
  2. This is not working for me. There is no bnep0 interface created when I try to connect to the server.
    I am working with the 3.2 kernel. To get the pand daemon I have installed the bluez-compat package.
    What do I need to do to get it to work? Any help is highly appreciated.

  3. hi! , I enjoy a person’s producing therefore a great deal! promote most people be in contact extra about your posting about Yahoo? I require a specialist within this home to unravel our dilemma. Might be that is anyone! Having a look toward view you.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s