Skip to content
maniacbug edited this page Aug 15, 2011 · 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

$&nbsp;cat&nbsp;/etc/network/interfaces&nbsp;<br/> #&nbsp;This&nbsp;file&nbsp;describes&nbsp;the&nbsp;network&nbsp;interfaces&nbsp;available&nbsp;on&nbsp;your&nbsp;system<br/> #&nbsp;and&nbsp;how&nbsp;to&nbsp;activate&nbsp;them.&nbsp;For&nbsp;more&nbsp;information,&nbsp;see&nbsp;interfaces(5).<br/> <br/> ##&nbsp;SNIP&nbsp;##<br/> <br/> #&nbsp;IPv6&nbsp;static&nbsp;configuration<br/> iface&nbsp;eth0&nbsp;inet6&nbsp;static<br/> address&nbsp;fec0::63<br/> netmask&nbsp;64<br/> gateway&nbsp;fec0::1<br/>

Static route

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

$&amp;nbsp;sudo&amp;nbsp;route&amp;nbsp;-A&amp;nbsp;inet6&amp;nbsp;add&amp;nbsp;fdfd::/64&amp;nbsp;gw&amp;nbsp;fec0::7&lt;br/&gt; $&amp;nbsp;sudo&nbsp;route&nbsp;-A&nbsp;inet6<br/> Kernel&nbsp;IPv6&nbsp;routing&nbsp;table<br/> Destination&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n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p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;::&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;U&nbsp;&nbsp;&nbsp;&nbsp;256&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2&nbsp;eth0<br/> ::/0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fec0::1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UG&nbsp;&nbsp;&nbsp;1&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;45&nbsp;eth0<br/>

Apache

Configure apache to listen on IPv6

$&nbsp;cat&nbsp;/etc/apache2/ports.conf&nbsp;<br/> #Listen&nbsp;80<br/> Listen&nbsp;[::]:80<br/>

Host PC

Static IP

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

$&amp;nbsp;sudo&amp;nbsp;ip&amp;nbsp;-6&amp;nbsp;addr&amp;nbsp;add&amp;nbsp;fec0::7/64&amp;nbsp;dev&amp;nbsp;eth13&lt;br/&gt; $&amp;nbsp;route&nbsp;-A&nbsp;inet6<br/> Kernel&nbsp;IPv6&nbsp;routing&nbsp;table<br/> Destination&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Next&nbsp;Hop&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Flag&nbsp;Met&nbsp;Ref&nbsp;Use&nbsp;If<br/> fec0::7/128&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;::&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Un&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;1&nbsp;&nbsp;&nbsp;&nbsp;94&nbsp;lo<br/>

Forwarding

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

$&nbsp;sudo&nbsp;sysctl&nbsp;-w&nbsp;net.ipv6.conf.default.forwarding=1<br/> net.ipv6.conf.default.forwarding&nbsp;=&nbsp;1<br/>

Test

Test that the host can ping the server.

$&nbsp;ping6&nbsp;fec0::63<br/> PING&nbsp;fec0::63(fec0::63)&nbsp;56&nbsp;data&nbsp;bytes<br/> 64&nbsp;bytes&nbsp;from&nbsp;fec0::63:&nbsp;icmp_seq=1&nbsp;ttl=64&nbsp;time=2.67&nbsp;ms<br/> 64&nbsp;bytes&nbsp;from&nbsp;fec0::63:&nbsp;icmp_seq=2&nbsp;ttl=64&nbsp;time=0.316&nbsp;ms<br/>

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

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

Border Router

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

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

Ping

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

Build

$&amp;nbsp;cd&amp;nbsp;platform/avr-zigduino/tests/shell&lt;br/&gt; $&amp;nbsp;make&nbsp;upload&nbsp;login&nbsp;AVRDUDE_PORT=/dev/ttyUSB1&nbsp;-j10<br/>

Run

Ping the border router

68.1:&nbsp;Contiki&gt;&nbsp;ping&nbsp;fdfd::3<br/> SEND&nbsp;13&nbsp;bytes<br/> Sending&nbsp;Echo&nbsp;Request&nbsp;to&nbsp;fdfd:0000:0000:0000:0000:0000:0000:0003&nbsp;from&nbsp;fdfd:0000:0000:0000:0000:0000:0000:0001&nbsp;<br/> Echo&nbsp;reply&nbsp;received.<br/>

Ping the SLIP tunnel

68.1:&nbsp;Contiki&gt;&nbsp;ping&nbsp;aaaa::1<br/> SEND&nbsp;13&nbsp;bytes<br/> Sending&nbsp;Echo&nbsp;Request&nbsp;to&nbsp;aaaa:0000:0000:0000:0000:0000:0000:0001&nbsp;from&nbsp;aaaa:0000:0000:0000:0011:22ff:fe33:4401&nbsp;<br/> Echo&nbsp;reply&nbsp;received.<br/>

Ping the host PC

68.1:&nbsp;Contiki&gt;&nbsp;ping&nbsp;fec0::7<br/> SEND&nbsp;13&nbsp;bytes<br/> Sending&nbsp;Echo&nbsp;Request&nbsp;to&nbsp;fec0:0000:0000:0000:0000:0000:0000:0007&nbsp;from&nbsp;fdfd:0000:0000:0000:0000:0000:0000:0001&nbsp;<br/> Echo&nbsp;reply&nbsp;received.<br/>

Ping the server

68.1:&nbsp;Contiki&gt;&nbsp;ping&nbsp;fec0::63<br/> SEND&nbsp;14&nbsp;bytes<br/> Sending&nbsp;Echo&nbsp;Request&nbsp;to&nbsp;fec0:0000:0000:0000:0000:0000:0000:0063&nbsp;from&nbsp;fdfd:0000:0000:0000:0000:0000:0000:0001&nbsp;<br/> Echo&nbsp;reply&nbsp;received.<br/>

wget

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.

$&amp;nbsp;cd&amp;nbsp;platform/avr-zigduino/tests/wget&lt;br/&gt; $&amp;nbsp;make&nbsp;TARGET=avr-zigduino&nbsp;savetarget<br/> $&amp;nbsp;make&amp;nbsp;-j10&lt;br/&gt; $&amp;nbsp;make&nbsp;upload&nbsp;login&nbsp;AVRDUDE_PORT=/dev/ttyUSB1<br/>

Running

Voila!

*******Booting&nbsp;Contiki-2.5-1356-g0ffffa2*******<br/> MAC&nbsp;address&nbsp;2:11:22:ff:fe:33:44:1<br/> nullmac&nbsp;sicslowmac,&nbsp;channel&nbsp;26<br/> Routing&nbsp;Enabled<br/> Autostart&nbsp;other&nbsp;processes<br/> <br/> IP&nbsp;addresses&nbsp;[4&nbsp;max]<br/> fdfd::1<br/> fe80::11:22ff:fe33:4401<br/> <br/> wget&nbsp;http://[fec0::63]/testbed/test.php?op=server...<br/> Connecting&nbsp;to&nbsp;[fec0::63]:80&nbsp;for&nbsp;/testbed/test.php?op=server...Request&nbsp;sent...<br/> Downloading&nbsp;(411&nbsp;bytes)<br/> Array<br/> (<br/> &nbsp;&nbsp;&nbsp;&nbsp;[HTTP_HOST]&nbsp;=&gt;&nbsp;[fec0::63]<br/> &nbsp;&nbsp;&nbsp;&nbsp;[HTTP_CONNECTION]&nbsp;=&gt;&nbsp;close<br/> &nbsp;&nbsp;&nbsp;&nbsp;[HTTP_USER_AGENT]&nbsp;=&gt;&nbsp;Contiki/2.2.2&nbsp;(;&nbsp;http://www.sics.se/contiki/)<br/> &nbsp;&nbsp;&nbsp;&nbsp;[PATH]&nbsp;=&gt;&nbsp;/usr/local/bin:/usr/bin:/bin<br/> &nbsp;&nbsp;&nbsp;&nbsp;[SERVER_SIGNATURE]&nbsp;=&gt;&nbsp;&lt;address&gt;Apache/2.2.12&nbsp;(Ubuntu)&nbsp;Server&nbsp;at&nbsp;fec0::63&nbsp;Port&nbsp;80&lt;/address&gt;<br/> <br/> &nbsp;&nbsp;&nbsp;&nbsp;[SERVER_SOFTWARE]&nbsp;=&gt;&nbsp;Apache/2.2.12&nbsp;(Ubuntu)<br/> &nbsp;&nbsp;&nbsp;&nbsp;[SERVER_NAME]&nbsp;=&gt;&nbsp;fec0::63<br/> &nbsp;&nbsp;&nbsp;&nbsp;[SERVER_ADDR]&nbsp;=&gt;&nbsp;fec0::63<br/> &nbsp;&nbsp;&nbsp;&nbsp;[SERVER_PORT]&nbsp;=&gt;&nbsp;80<br/> Downloading&nbsp;(965&nbsp;bytes)<br/> &nbsp;&nbsp;&nbsp;&nbsp;[REMOTE_ADDR]&nbsp;=&gt;&nbsp;fdfd::1<br/> &nbsp;&nbsp;&nbsp;&nbsp;[DOCUMENT_ROOT]&nbsp;=&gt;&nbsp;/var/www<br/> &nbsp;&nbsp;&nbsp;&nbsp;[SERVER_ADMIN]&nbsp;=&gt;&nbsp;webmaster@localhost<br/> &nbsp;&nbsp;&nbsp;&nbsp;[SCRIPT_FILENAME]&nbsp;=&gt;&nbsp;/var/www/testbed/test.php<br/> &nbsp;&nbsp;&nbsp;&nbsp;[REMOTE_PORT]&nbsp;=&gt;&nbsp;1025<br/> &nbsp;&nbsp;&nbsp;&nbsp;[GATEWAY_INTERFACE]&nbsp;=&gt;&nbsp;CGI/1.1<br/> &nbsp;&nbsp;&nbsp;&nbsp;[SERVER_PROTOCOL]&nbsp;=&gt;&nbsp;HTTP/1.0<br/> &nbsp;&nbsp;&nbsp;&nbsp;[REQUEST_METHOD]&nbsp;=&gt;&nbsp;GET<br/> &nbsp;&nbsp;&nbsp;&nbsp;[QUERY_STRING]&nbsp;=&gt;&nbsp;op=server<br/> &nbsp;&nbsp;&nbsp;&nbsp;[REQUEST_URI]&nbsp;=&gt;&nbsp;/testbed/test.php?op=server<br/> &nbsp;&nbsp;&nbsp;&nbsp;[SCRIPT_NAME]&nbsp;=&gt;&nbsp;/testbed/test.php<br/> &nbsp;&nbsp;&nbsp;&nbsp;[PHP_SELF]&nbsp;=&gt;&nbsp;/testbed/test.php<br/> &nbsp;&nbsp;&nbsp;&nbsp;[REQUEST_TIME]&nbsp;=&gt;&nbsp;1313300218<br/> &nbsp;&nbsp;&nbsp;&nbsp;[argv]&nbsp;=&gt;&nbsp;Array<br/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(<br/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[0]&nbsp;=&gt;&nbsp;op=server<br/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br/> <br/> &nbsp;&nbsp;&nbsp;&nbsp;[argc]&nbsp;=&gt;&nbsp;1<br/> )<br/> Finished&nbsp;downloading&nbsp;965&nbsp;bytes.<br/>

Next Steps

  • Move wget to the shell.
  • Construct a post request. The best route may be to add a post flag to webclient_get. Certainly would not want to rewrite what's already there.
  • 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!
Clone this wiki locally