-
Notifications
You must be signed in to change notification settings - Fork 17
Using:HTTP
Navigation: Home | Scenarios | Installing | Using | Future
Using:Setup | Using:Troubleshooting | Using:Shell | Using:Sensors | Using:Actuation | Using:SLIP | Using:Webserver | Using:HTTP | Using:RPL
Get web pages. Post values to a server. Put values to pachube.
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.
- Client node. We'll start by using the shell, and then finish with the 'wget' test
- Border router node. Needs the rpl-border-router example running.
- Host PC. The machine that the border router is physically connected to needs the most configuration
- Server PC. Somewhere on my internal network is a web server running Apache
Statically assign FEC0::63 to the web server
$ cat /etc/network/interfaces <br/> # This file describes the network interfaces available on your system<br/> # and how to activate them. For more information, see interfaces(5).<br/> <br/> ## SNIP ##<br/> <br/> # IPv6 static configuration<br/> iface eth0 inet6 static<br/> address fec0::63<br/> netmask 64<br/> gateway fec0::1<br/>
Create a route on the server so it knows how to reach FDFD::/64 nodes.
Configure apache to listen on IPv6
$ cat /etc/apache2/ports.conf <br/> #Listen 80<br/> Listen [::]:80<br/>
Statically assign FEC0::7 to the instant contiki VM acting as host PC
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<br/> net.ipv6.conf.default.forwarding = 1<br/>
Test that the host can ping the server.
$ ping6 fec0::63<br/> PING fec0::63(fec0::63) 56 data bytes<br/> 64 bytes from fec0::63: icmp_seq=1 ttl=64 time=2.67 ms<br/> 64 bytes from fec0::63: icmp_seq=2 ttl=64 time=0.316 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.
$ curl -g "http://[fec0::63]/testbed/test.php?op=server"<br/> Array<br/> (<br/> [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<br/> [HTTP_HOST] => [fec0::63]<br/> [HTTP_ACCEPT] => */*<br/> [PATH] => /usr/local/bin:/usr/bin:/bin<br/> [SERVER_SIGNATURE] => <address>Apache/2.2.12 (Ubuntu) Server at fec0::63 Port 80</address><br/> ...snip...<br/>
Next, we bring up the border router on the node attached to the host PC.
Now we can make sure ping from the remote device works. We'll use the shell.
Ping the border router
68.1: Contiki> ping fdfd::3<br/> SEND 13 bytes<br/> Sending Echo Request to fdfd:0000:0000:0000:0000:0000:0000:0003 from fdfd:0000:0000:0000:0000:0000:0000:0001 <br/> Echo reply received.<br/>
Ping the SLIP tunnel
68.1: Contiki> ping aaaa::1<br/> SEND 13 bytes<br/> Sending Echo Request to aaaa:0000:0000:0000:0000:0000:0000:0001 from aaaa:0000:0000:0000:0011:22ff:fe33:4401 <br/> Echo reply received.<br/>
Ping the host PC
68.1: Contiki> ping fec0::7<br/> SEND 13 bytes<br/> Sending Echo Request to fec0:0000:0000:0000:0000:0000:0000:0007 from fdfd:0000:0000:0000:0000:0000:0000:0001 <br/> Echo reply received.<br/>
Ping the server
68.1: Contiki> ping fec0::63<br/> SEND 14 bytes<br/> Sending Echo Request to fec0:0000:0000:0000:0000:0000:0000:0063 from fdfd:0000:0000:0000:0000:0000:0000:0001 <br/> Echo reply received.<br/>
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...
- Enabled IPv6
- Removed cfs, so doesn't save the file, just dumps the results to stdout
- Removed input via stdin to specificy the url, it's just hard-coded.
First, edit the URL in wget.c to point to a page you know will work on your server.
Voila!
*******Booting Contiki-2.5-1356-g0ffffa2*******<br/> MAC address 2:11:22:ff:fe:33:44:1<br/> nullmac sicslowmac, channel 26<br/> Routing Enabled<br/> Autostart other processes<br/> <br/> IP addresses [4 max]<br/> fdfd::1<br/> fe80::11:22ff:fe33:4401<br/> <br/> wget http://[fec0::63]/testbed/test.php?op=server...<br/> Connecting to [fec0::63]:80 for /testbed/test.php?op=server...Request sent...<br/> Downloading (411 bytes)<br/> Array<br/> (<br/> [HTTP_HOST] => [fec0::63]<br/> [HTTP_CONNECTION] => close<br/> [HTTP_USER_AGENT] => Contiki/2.2.2 (; http://www.sics.se/contiki/)<br/> [PATH] => /usr/local/bin:/usr/bin:/bin<br/> [SERVER_SIGNATURE] => <address>Apache/2.2.12 (Ubuntu) Server at fec0::63 Port 80</address><br/> <br/> [SERVER_SOFTWARE] => Apache/2.2.12 (Ubuntu)<br/> [SERVER_NAME] => fec0::63<br/> [SERVER_ADDR] => fec0::63<br/> [SERVER_PORT] => 80<br/> Downloading (965 bytes)<br/> [REMOTE_ADDR] => fdfd::1<br/> [DOCUMENT_ROOT] => /var/www<br/> [SERVER_ADMIN] => webmaster@localhost<br/> [SCRIPT_FILENAME] => /var/www/testbed/test.php<br/> [REMOTE_PORT] => 1025<br/> [GATEWAY_INTERFACE] => CGI/1.1<br/> [SERVER_PROTOCOL] => HTTP/1.0<br/> [REQUEST_METHOD] => GET<br/> [QUERY_STRING] => op=server<br/> [REQUEST_URI] => /testbed/test.php?op=server<br/> [SCRIPT_NAME] => /testbed/test.php<br/> [PHP_SELF] => /testbed/test.php<br/> [REQUEST_TIME] => 1313300218<br/> [argv] => Array<br/> (<br/> [0] => op=server<br/> )<br/> <br/> [argc] => 1<br/> )<br/> Finished downloading 965 bytes.<br/>
The wget example also includes a POST example
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.
*******Booting Contiki-2.5-1364-g613783c*******<br/> MAC address 2:11:22:ff:fe:33:44:3<br/> nullmac sicslowmac, channel 26<br/> Routing Enabled<br/> Autostart other processes<br/> <br/> IP addresses [4 max]<br/> fdfd::3<br/> fe80::11:22ff:fe33:4403<br/> <br/> wget http://[fec0::63]/testbed/test.php...<br/> Connecting to [fec0::63]:80 for /testbed/test.php...Request sent...<br/> Downloading (48 bytes)<br/> POST OK<br/> Array<br/> (<br/> [ONE] => 1<br/> [TWO] => 2<br/> )<br/> Finished downloading 48 bytes.<br/>
- Move wget to the shell.
- Post to Pachube