-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Econotag RPL border router with Windows
This tutorial describes how to connect the SLIP RPL border router to a Windows machine. Specifically Windows 7 using cygwin and the Redbee Econotag, although it can be adapted for other versions, serial devices, and command shells.
The border router uses a fallback interface to forward 6LowPAN traffic to the host. The Jackdaw RNDIS RPL border router uses an RNDIS interface for this purpose. Other border routers such as the Econotag use a serial connection that runs the contiki SLIP protocol. The contiki tools directory has various SLIP implementations that bridge the serial connection to a network interface. We will use contiki/tools/stm32w/wpcapslip6.exe which uses wpcap to tee into an existing network interface. Note the Econotag could also be connected to an Instant Contiki virtual machine using tunslip6, which creates a tun0 interface on Ubuntu.
For reference, A RPL network on the minimal net platform describes how to set up an internal border router using a loopback interface in Windows. It uses contiki/tools/tunslip6 to tee into two network interfaces. We only need one, so install it as described in Setting up Wireshark on a Loopback Interface.
Turn off all protocols other than ip4 and ip6, give them different ip4 and ip6 addresses, and name the interfaces correspondingly. This will make it easier to keep track of which is which! But you can disable the ip4 protocol to keep the numerous ip4 discovery packets out of the wireshark captures.
ipconfig shows the loopback address:
Ethernet adapter bbbb 10-1-10-10: Connection-specific DNS Suffix . : IPv6 Address. . . . . . . . . . . : bbbb::1 Link-local IPv6 Address . . . . . : fe80::4cff:fe4f:4f50%16 Default Gateway . . . . . . . . . :
Launch wiresharks to monitor the traffic on the loopback. The Win7 homegroup service sends a lot of ipv6 packets; stopping the service will get rid of those (it will restart when you reboot). CTL-shift-escape to bring up the task manager, go to services tab and hit services button, and stop the Peer Name Resolution Protocol service.
The contiki git repository contains a prebuilt wpcapslip6.exe that might work for you. It can be run in a DOS window if you copy cygwin1.dll and cyggcc_s-1.dll from /cygwin/bin/ into the same folder as the .exe file. This will make it portable and easier to run with administrative privileges on another machine. To build it yourself:
$cd ~/contiki/tools/stm32w/wpcapslip6 $ make rm -f wpcapslip6.o wpcap6.o ip-process.o fakeuip.o cc -Wall -Werror -I../../../core -I. -c -o wpcapslip6.o wpcapslip6.c cc -Wall -Werror -I../../../core -I. -c -o wpcap6.o wpcap6.c cc -Wall -Werror -I../../../core -I. -c -o ip-process.o ip-process.c cc -Wall -Werror -I../../../core -I. -c -o fakeuip.o fakeuip.c cc wpcapslip6.o wpcap6.o ip-process.o fakeuip.o /lib/w32api/libws2_32.a /lib/w32api/libiphlpapi.a -o wpcapslip6
You need the FTDI drivers to connect to the USB-to-serial converters on the Econotag. After installing those plug it into a USB port and go to the device manager to see which COM ports it is using. The COM port numbers will depend on which physical USB port you are using. In this example they are COM6 and COM7. If cygwin is installed you could also refer to them as ttyS5 and ttyS6, as cygwin numbering starts from zero.
You could build the binary and download the firmware in an Instant Contiki virtual machine within Windows using the tools there (see the tutorial, and then detach it back to the Windows OS. If you want to build and flash directly from Windows you need to install the Codesourcery ARM toolchain, some version of PERL (in cygwin, or a standalone Windows version, and the Device-SerialPort module (tar.gz link at upper right). Download to cygwin and install the .pm and .dll files (or copy to your PERL folder):
$ tar -xzf Device-SerialPort-1.04.tar.gz $ cd Device-SerialPort-1.04 perl Makefile.PL make make test make install
It is instructive to turn on the debug prints in /core/net/rpl/rpl-icmp6.c:
//#define DEBUG DEBUG_NONE #define DEBUG DEBUG_FULL
In a new cygwin issue the command:
alias iterate='make TARGET=redbee-econotag;~/contiki/cpu/mc1322x/tools/mc1322x-load.pl -a 0 -b 0 -t /dev/com6 -f border-router_redbee-econotag.bin'
then
cd ~/contiki/examples/ipv6/rpl-border-router iterate
This will build the binary and then hang in the PERL download script idle loop:
Cygwin detected. arm-none-eabi-objcopy -O binary border-router.elf border-router_redbee-econotag.bin rm obj_redbee-econotag/symbols.o obj_redbee-econotag/httpd-simple.o obj_redbee-econotag/slip-bridge.o border-router.elf border-router.co TIOCMBIS(21526) ioctl failed: Invalid argument at /home/dak/contiki/cpu/mc1322x/tools/mc1322x-load.pl line 74 rts_active(1) ioctl: Invalid argument ........
Ignore the ioctl error, the drivers did not respond to a flow control call. It is now waiting for an Econotag reset; push the isolated button (next to the bare pad for the buck converter coil). Then it should go on with:
CONNECT Size: 58460 bytes Sending border-router_redbee-econotag.bin done sending files. performing ring osc cal crm_status: 0xc0000 sys_cntl: 0x18 ring osc cal complete cal_count: 0x18852ff cal factor: 98 hib_wake_secs: 1960 data start, end, size =1111 0 ffffeeef bss start, end, size =0 0 0 Rime started with address 00:50:C2:FF:FE:A8:CD:1A nullmac nullrdc, channel check rate 100 Hz, radio channel 26 Tentative link-local IPv6 address fe80:0000:0000:0000:0250:c2ff:fea8:cd1a Tentative global IPv6 address bbbb:0000:0000:0000:0250:c2ff:fea8:cd1a Starting 'Border router process' RPL-Border router started ?P ?P ?P
Those ?Ps are the econotag requesting a prefix; it will put them out once every second until it gets one. Now it is time to control-c out of the perl script and move over to the wpcapslip6 window. Run wpcapslip6 to connect to the COM port. 2-0-4c-4f-4f-50 is the MAC address of the loopback interface; change that to connect to another interface. (see the mac addresses with ipconfig /all or by running e.g. ./wpcapslip6 -v -s /dev/com6 -b bbbb:: 0-0).
*** Address:bbbb:: => bbbb:0000:0000:0000
The netsh commands are not strictly necessary; they reduce the number of neighbor solicitations sent to the econotag. They do require administrative privileges, if they fail you can copy and paste them to an elevated cmd window (type "cmd" in the start menu, right click on cmd.exe and "Run as Administrator", or launch cygwin with a right click and "Run as Administrator").
The netsh neighbor commands are necessary for motes in the RPL network since there will be no response to any neighbor solicitation for them, without the link-local NS/NA interchange Windows will not go on to send prefixed packets. A problem will arise if the neighbors are already in one of the caches (you tried to load the web page in Firefox for example, and after no response the request went out through a default ipv6 connection to the web). You can safely reset the Windows cache:
netsh interface ipv6 delete destinationcache
But Firefox will continue to use it's cache, and reloading the page will again contiminate the Windows cache:
netsh interface ipv6 show destinationcache Interface 14: bbbb 10-1-10-10 PMTU Destination Address Next Hop Address ---- --------------------------------------------- ------------------------- 1500 bbbb::11:22ff:fe33:4455 2001:4979:1db::1
One way to fix that is to quit Firefox, delete the Windows cache, then restart Firefox.
To add three Ravens:
netsh interface ipv6 add neighbor "bbbb 10-1-10-10" bbbb::11:22ff:fe33:4455 02-50-C2-A8-44-55 netsh interface ipv6 add neighbor "bbbb 10-1-10-10" bbbb::11:22ff:fe33:4456 02-50-C2-A8-44-56 netsh interface ipv6 add neighbor "bbbb 10-1-10-10" bbbb::11:22ff:fe33:4457 02-50-C2-A8-44-57
All set! You should be able to ping the econotag or look at the web page:
$ ping -n 2000 -l 1200 bbbb::0250:c2ff:fea8:cd1a
Pinging bbbb::250:c2ff:fea8:cd1a with 1200 bytes of data: Reply from bbbb::250:c2ff:fea8:cd1a: time=243ms Reply from bbbb::250:c2ff:fea8:cd1a: time=237ms ...
http://[bbbb::250:c2ff:fea8:cd1a]/ (in a browser) Neighbors fe80::11:22ff:fe33:4455 bbbb::1 Routes bbbb::11:22ff:fe33:4455/128 (via fe80::11:22ff:fe33:4455)
The default baud rate for the slip connection is 115200, which could be a bottleneck for network traffic. The econotag can run up to 921600 baud by changing the setting in the platform contiki-conf.h file. To avoid a complete rebuild you can also just change it in the contiki-mc1322x-main.c file: /* uart init */
//#define BRINC 767 //115200 //#define BRINC 1535 //230400 //#define BRINC 3071 //460800 //#define BRINC 6142 //921600 // uart_init(BRINC , BRMOD, SAMP); uart_init(6142, BRMOD, SAMP);
The switch to the higher baud rate will occur after programming is complete so the startup messages will be garbled:
CONNECT Size: 58460 bytes Sending border-router_redbee-econotag.bin done sending files. (garbage)
The garbage should not cause any problem. Just give it enough time to do the startup calibrations, Control-C out and run wpcapslip with the higher baud rate:
$ ./wpcapslip6 -B921600 -s com6 -b bbbb:: 2-0-4c-4f-4f-50