Personal Area Networking Profile (PAN) allows Bluetooth devices to form an ad-hoc network, access a remote network through a network access point.
The ad-hoc network in the PAN profile consists of a single Bluetooth piconet. The PAN profile does not cover scatternet networking - the case where multiple piconets are involved.
In simple words, the PAN profile can be understood as Ethernet emulation over Bluetooth. Ethernet packets are encapsulated into Bluetooth special packets and are sent over Bluetooth link.
Device, participating in the ad-hoc network, is assigned one of following roles:
Network Access Point (NAP): A Bluetooth device that provides some of the features of an Ethernet bridge. The NAP device forwards Ethernet packets between each of the connected Bluetooth devices, reffered to as PAN Users (PANU). In addition, NAP forwards Ethernet packets to/from a different network connected to the NAP via Layer 2 bridging or Layer 3 routing mechanism.
Group Ad-Hoc Network (GN): A Bluetooth devices acting in the same way as NAP device with the exception that it does not provide access to any additional networks.
PAN User (PANU): A bluetooth device that uses either the NAP or the GN service.
In other words, the PAN ad-hoc network consists of one NAP or GN device and several (up to 7) PANU devices.
The PAN profile in the Affix is implemented as kernel module affix_pan.o. The state of the PAN module can be seen in its proc file system entry, /proc/net/affix/pan".
To enable access from PANU device to external network the NAP must be configured to have briding or routing functionality.
Bridging functionality is supported by the Linux kernel. In order to enable it, it is necessary to compile the kernel with following option enabled: [Networking Options/802.1d Ethernet Bridging].
Configuration of the Ethernet bridge is done using brctl utility that is distributed with the bridge-utils package.
First, initialize the PAN interface: "btctl paninit nap bt0". This command will create a new network (PAN) interface called pan0, pan1, etc.
Second, set up a bridge:
add a new bridge to the system: "brctl addbr br0". This command will create a new network interface called br0. It is used with the ifconfig command in the same way as with any ethernet interface.
add Ethernet interface and PAN interface to the bridge: "brctl addif br0 eth0" and "brctl addif br0 pan0".
activate the bridge and assign an IP address. "ifconfig br0 up". It may have the same IP address as the eth0 interface.
check and fix, if necessary, the routing table. Default gateway must point to the bridge interface br0 (route add default ...). If eth0 and br0 have the same IP address then entry pointing to eth0 must be removed from the table (route del ... eth0).
Third, activate the PAN interface: ifconfig pan0 up. It's also possible to assign an IP address to the PAN interface, but as bridge has IP interface it's not really necessary.
Active NAP PAN interface waits for connection establishment.
To enable multiple clients on one NAP, the Bluetooth device on the NAP should be configured to accept role switch when connection occurs. This is done by: "btctl role allow|deny master". In this case, the NAP device becomes master when a client (PANU) connects to it.
The GN device is not need to be connected to a non-bluetooth network. Set up procedure is simpler then in NAP case.
First, initialize the PAN interface: "btctl paninit gn bt0". This command will create a new network (PAN) interface called pan0, pan1, etc.
Second, activate the PAN interface: ifconfig pan0 up. It's necessary to assign an IP address to the PAN interface.
Active GN PAN interface waits for connection establishment.
First, initialize the PAN interface: "btctl paninit panu bt0". This command will create a new network (PAN) interface called pan0, pan1, etc.
Second, activate the PAN interface: ifconfig pan0 up. It's necessary to assign an IP address to the PAN interface.
If there is at least one GN or NAP device in a range, PANU will connect to it as soon as they are both activated.
The IP address assignment for Bluetooth PAN devices SHALL be done through "Dynamic Configuration of IPv4 link-local addresses".
However, IP address assignment may be done also either manually or automatically using DHCP protocol.
For ad-hoc networking with GN, the GN device, running DHCP server, may provide an IP address to the PANU device using DHCP protocol.
Multicast filter and protocol filter for the local device can be configured with "btctl pan". By default, no protocol filters are in use.
At a PAN User, the multicast configuration of the network device is used as multicast address filter configuration.
At a Group Ad-hoc Network/Network Access Point, no multi- cast address filters are in use by default. Setting a filter at a Group Ad-hoc Network/Network Access Point also affects packets exchanged between PAN users connected to the same Group Ad-hoc Network/Network Access Point.
The Ethernet Broadcast address FF:FF:FF:FF:FF:FF is never filtered out.
If a filter setting is rejected by the remote device, the remote device keeps its previous setting according to the specification. To avoid side effects, the current implementation always resets the affected filter in this case.