Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Using:HTTP

maniacbug edited this page · 6 revisions

Navigation: Home | Scenarios | Installing | Using | Future

Using:Setup | Using:Troubleshooting | Using:Shell | Using:Sensors | Using:Actuation | Using:SLIP | Using:Webserver | Using:HTTP | Using:RPL

Table of Contents

Goal

Get web pages. Post values to a server. Put values to pachube.

Prepare the Network

In this example, I am going to get a web page from an internal server on my network using a remote Zigduino node. All my machines are running IPv6 out of the box, BUT I do not have global unicast addresses on my network. So I'll need to configure site-local addresses.

There are 4 machines participating in this dance, and each one will need to be configured.

  1. Client node. We'll start by using the shell, and then finish with the 'wget' test
  2. Border router node. Needs the rpl-border-router example running.
  3. Host PC. The machine that the border router is physically connected to needs the most configuration
  4. Server PC. Somewhere on my internal network is a web server running Apache

Server PC

Static IP

Statically assign FEC0::63 to the web server

$ cat /etc/network/interfaces 
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

## SNIP ##

# IPv6 static configuration
iface eth0 inet6 static
address fec0::63
netmask 64
gateway fec0::1

Static route

Create a route on the server so it knows how to reach FDFD::/64 nodes.

$ sudo route -A inet6 add fdfd::/64 gw fec0::7
$ sudo route -A inet6
Kernel IPv6 routing table
Destination                    Next Hop                   Flag Met Ref Use If
fdfd::/64                      fec0::7                    UG   1   0   157 eth0
fe80::/64                      ::                         U    256 0     0 eth0
fec0::/64                      ::                         U    256 0     2 eth0
::/0                           fec0::1                    UG   1   0    45 eth0

Apache

Configure apache to listen on IPv6

$ cat /etc/apache2/ports.conf 
#Listen 80
Listen [::]:80

Host PC

Static IP

Statically assign FEC0::7 to the instant contiki VM acting as host PC

$ sudo ip -6 addr add fec0::7/64 dev eth13
$ route -A inet6
Kernel IPv6 routing table
Destination                    Next Hop                   Flag Met Ref Use If
fec0::7/128                    ::                         Un   0   1    94 lo

Forwarding

Instruct the host PC has to forward packets between networks, between FDFD::/64 and FEC0::/64.

$ sudo sysctl -w net.ipv6.conf.default.forwarding=1
net.ipv6.conf.default.forwarding = 1

Test

Test that the host can ping the server.

$ ping6 fec0::63
PING fec0::63(fec0::63) 56 data bytes
64 bytes from fec0::63: icmp_seq=1 ttl=64 time=2.67 ms
64 bytes from fec0::63: icmp_seq=2 ttl=64 time=0.316 ms

Test that the host can fetch web pages from the server. Obviously, change the URL to a page you know exists on your server.

$ curl -g "http://[fec0::63]/testbed/test.php?op=server"
Array
(
    [HTTP_USER_AGENT] => curl/7.19.7 (i486-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15
    [HTTP_HOST] => [fec0::63]
    [HTTP_ACCEPT] => */*
    [PATH] => /usr/local/bin:/usr/bin:/bin
    [SERVER_SIGNATURE] => <address>Apache/2.2.12 (Ubuntu) Server at fec0::63 Port 80</address>
...snip...

Border Router

Next, we bring up the border router on the node attached to the host PC.

$ cd examples/ipv6/rpl-border-router
$ make TARGET=avr-zigduino savetarget
$ make upload WITH_WEBSERVER=0 WITH_SLIP=1 AVRDUDE_PORT=/dev/ttyUSB0 -j10
$ sudo ../../../tools/tunslip6 aaaa::1/64 -s /dev/ttyUSB0 -B 38400 -v6
$ sudo route -A inet6 add fdfd::/64 dev tun0

Ping

Now we can make sure ping from the remote device works. We'll use the shell.

Build

$ cd platform/avr-zigduino/tests/shell
$ make upload login AVRDUDE_PORT=/dev/ttyUSB1 -j10

Run

Ping the border router

68.1: Contiki> ping fdfd::3
SEND 13 bytes
Sending Echo Request to fdfd:0000:0000:0000:0000:0000:0000:0003 from fdfd:0000:0000:0000:0000:0000:0000:0001 
Echo reply received.

Ping the SLIP tunnel

68.1: Contiki> ping aaaa::1
SEND 13 bytes
Sending Echo Request to aaaa:0000:0000:0000:0000:0000:0000:0001 from aaaa:0000:0000:0000:0011:22ff:fe33:4401 
Echo reply received.

Ping the host PC

68.1: Contiki> ping fec0::7
SEND 13 bytes
Sending Echo Request to fec0:0000:0000:0000:0000:0000:0000:0007 from fdfd:0000:0000:0000:0000:0000:0000:0001 
Echo reply received.

Ping the server

68.1: Contiki> ping fec0::63
SEND 14 bytes
Sending Echo Request to fec0:0000:0000:0000:0000:0000:0000:0063 from fdfd:0000:0000:0000:0000:0000:0000:0001 
Echo reply received.

GET

Finally, everything is ready! Time to pull that page using a remote node. This uses a version of the wget example I modified for this walk-through. It's in platform/avr-zigduino/tests/wget. Specifically, I...

  1. Enabled IPv6
  2. Removed cfs, so doesn't save the file, just dumps the results to stdout
  3. Removed input via stdin to specificy the url, it's just hard-coded.

Building

First, edit the URL in wget.c to point to a page you know will work on your server.

$ cd platform/avr-zigduino/tests/wget
$ make TARGET=avr-zigduino savetarget
$ make -j10
$ make upload login AVRDUDE_PORT=/dev/ttyUSB1

Running

Voila!

*******Booting Contiki-2.5-1356-g0ffffa2*******
MAC address 2:11:22:ff:fe:33:44:1
nullmac sicslowmac, channel 26
Routing Enabled
Autostart other processes

IP addresses [4 max]
fdfd::1
fe80::11:22ff:fe33:4401

wget http://[fec0::63]/testbed/test.php?op=server...
Connecting to [fec0::63]:80 for /testbed/test.php?op=server...Request sent...
Downloading (411 bytes)
Array
(
    [HTTP_HOST] => [fec0::63]
    [HTTP_CONNECTION] => close
    [HTTP_USER_AGENT] => Contiki/2.2.2 (; http://www.sics.se/contiki/)
    [PATH] => /usr/local/bin:/usr/bin:/bin
    [SERVER_SIGNATURE] => <address>Apache/2.2.12 (Ubuntu) Server at fec0::63 Port 80</address>

    [SERVER_SOFTWARE] => Apache/2.2.12 (Ubuntu)
    [SERVER_NAME] => fec0::63
    [SERVER_ADDR] => fec0::63
    [SERVER_PORT] => 80
Downloading (965 bytes)
    [REMOTE_ADDR] => fdfd::1
    [DOCUMENT_ROOT] => /var/www
    [SERVER_ADMIN] => webmaster@localhost
    [SCRIPT_FILENAME] => /var/www/testbed/test.php
    [REMOTE_PORT] => 1025
    [GATEWAY_INTERFACE] => CGI/1.1
    [SERVER_PROTOCOL] => HTTP/1.0
    [REQUEST_METHOD] => GET
    [QUERY_STRING] => op=server
    [REQUEST_URI] => /testbed/test.php?op=server
    [SCRIPT_NAME] => /testbed/test.php
    [PHP_SELF] => /testbed/test.php
    [REQUEST_TIME] => 1313300218
    [argv] => Array
        (
            [0] => op=server
        )

    [argc] => 1
)
Finished downloading 965 bytes.

POST

The wget example also includes a POST example

Building

Again, be sure edit the URL in wget.c to point to a page you know will work on your server. Make with the "METHOD_POST=1" option to select the POST test instead of the GET test.

$ cd platform/avr-zigduino/tests/wget
$ make TARGET=avr-zigduino savetarget
$ make METHOD_POST=1 -j10
$ make upload login AVRDUDE_PORT=/dev/ttyUSB1

Running

*******Booting Contiki-2.5-1364-g613783c*******
MAC address 2:11:22:ff:fe:33:44:3
nullmac sicslowmac, channel 26
Routing Enabled
Autostart other processes

IP addresses [4 max]
fdfd::3
fe80::11:22ff:fe33:4403

wget http://[fec0::63]/testbed/test.php...
Connecting to [fec0::63]:80 for /testbed/test.php...Request sent...
Downloading (48 bytes)
POST OK
Array
(
    [ONE] => 1
    [TWO] => 2
)
Finished downloading 48 bytes.

Next Steps

  • Move wget to the shell.
  • Post to Pachube
Getting to the outside world, e.g. posting data to pachube, requires world-routable IPv6 addresses, an IPv6-compatible router on your network, and an IPv6 connection to your ISP. I don't have those yet, so this is as far as I go. Fortunately, Pachube is ready!
Something went wrong with that request. Please try again.