Skip to content

Latest commit

 

History

History
136 lines (107 loc) · 5.75 KB

proj.org

File metadata and controls

136 lines (107 loc) · 5.75 KB

First meeting

  • ask for motes available At least two motes to attach to the usb ports and two virtual machines are needed (or one with two modules)
  • ask for what code is already available in the testbed

Links

Useful libraries

Creating TUN device to communicate

One way is to create a rule with udev, like here:

I have this in my /etc/udev/rules.d/10-udev-rules 

# N.B.: Using := prevents later rules modifying parameters, 
# 50-dev-rules will reset device permissions to 600. 

KERNEL=="tun", NAME="net/%k",MODE:="666" 

Another way is to use openvpn to generate it

openvpn --mktun --dev tunX

Hints

  • try to use TUN/TAP drivers
  • see how to send packets over the network, see 6lowpan for examples
  • check the routing protocols already present in tinyos evaluating what’s best to do
  • try out the IPBaseStation and see how it’s implemented

Reading from the device

read on the TUN device can read only one packet at a time, and is also blocking. It’s only needed to allocate a buffer with the maximum length of the IPv6 header.

Using TUN/TAP?

Using a tap device we would have directly the ethernet packet, while using the tun device we’re one layer upper. One possible advantage in using directly ethernet is that the packets can be much smaller and then we could have less problems in splitting them.

Dimensions

ProtoHeaderPayload Max
IPv665k
ethernet

IPv6

Routing

Routing must be done bidirectionally, in tinyos is already present CTP, one idea is to use it twice in both directions.

Implementation

  • Using TUN to send messsages to the application instead of the
  • change the routing table
  • enable the low-power mode for the mote in cc2420

Instructions to create a simple network with a base station and a UDP echo mote

# On one mote we have to program the IPBaseStation
# After having compiled the necessary
cd $TOSROOT/apps/IPBaseStation
make telosb blip install /dev/ttyUSB0 # for example
# then we need to start the ip-driver
sudo driver/ip-driver /dev/ttyUSB0 telosb

# on the other mote we program the UDP server
cd $TOSROOT/apps/UDPEcho
make telosb  blip install.ID
  
# where the ID will be the address of the client

# to check that everything is working just
ping6 fec0::<ID>

# and as soon as there is communication it should work fine

Tun/Tap

We can use those interfaces in user-land mode also.

Userland application can write IP frame to /dev/tunX and kernel will receive this frame from tunX interface. In the same time every frame that kernel writes to tunX interface can be read by userland application from /dev/tunX device.

Main purpose of TUN/TAP driver is tunneling. Here is the tun tap driver for OSX for example.

Tun

The TUN is Virtual Point-to-Point network device. TUN driver was designed as low level kernel support for IP tunneling. It provides to userland application two interfaces:

  • /dev/tunX - character device;
  • tunX - virtual Point-to-Point interface.

Tap

The TAP is a Virtual Ethernet network device. TAP driver was designed as low level kernel support for Ethernet tunneling. It provides to userland application two interfaces:

  • /dev/tapX - character device;
  • tapX - virtual Ethernet interface.

Differences Unix/Linux

In the Linux/Unix/Solaris world, the TUN/TAP driver presents a single character device in the /dev directory (either /dev/tun or /dev/tap). Opening this creates a NEW device (/dev/tun0, tun1, etc) using the next available name, and returns a filehandle to it. An associated pseudo-network device is created at the time of the open.

In the OSX TUN/TAP driver, a preset number of tun and tap char devices (/dev/tun0 - /dev/tun15 and /dev/tap0 - /dev/tap15) are PRECREATED when the driver is installed. You must open the specific char device you want in order to get a filehandle to it. An associated pseudo-network device is created at the time of the open.