<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://anrg.usc.edu/contiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Ckapoor</id>
		<title>Contiki - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="http://anrg.usc.edu/contiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Ckapoor"/>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php/Special:Contributions/Ckapoor"/>
		<updated>2026-06-07T19:51:07Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.26.2</generator>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1425</id>
		<title>RPL Border Router</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1425"/>
				<updated>2014-11-09T06:47:32Z</updated>
		
		<summary type="html">&lt;p&gt;Ckapoor: /* Verifying Results */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction: ==&lt;br /&gt;
  &lt;br /&gt;
Border routers are routers that can be found at the edge of a network. Their function is to connect one network to another. In this tutorial we will learn how to run a simulation using the border router in Contiki 2.7. In the example which we will discuss in the rest of this tutorial the border router will be used to route data between a WSN (RPL network) and an external IP network.  &lt;br /&gt;
&lt;br /&gt;
[[File:Diagram.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Objective ==&lt;br /&gt;
  &lt;br /&gt;
The objective of this tutorial is to give you an understanding of the RPL Border Router code in Contiki 2.7 OS and learn how to simulate a network with a border router on Cooja &lt;br /&gt;
&lt;br /&gt;
At the end of the tutorial you would have learnt the following: &lt;br /&gt;
&lt;br /&gt;
1. Understanding the working of the rpl border router code &amp;lt;br&amp;gt;&lt;br /&gt;
2. Starting a simulation on Cooja simulator. &amp;lt;br&amp;gt; &lt;br /&gt;
3. Observing and validating the results &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code building blocks. ==&lt;br /&gt;
 &lt;br /&gt;
We will be using the following files &lt;br /&gt;
&lt;br /&gt;
1. border-router.c &amp;lt;br&amp;gt;&lt;br /&gt;
2. udp-server.c  (udp-client.c can also be used)&amp;lt;br&amp;gt;&lt;br /&gt;
3. slip-bridge.c (It contains callback function for processing a SLIP connection request) &amp;lt;br&amp;gt;&lt;br /&gt;
4. httpd-simple.c   (A simple web server forwarding page generation to a protothread)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
udp-server nodes will form a DAG with the border router set as the root. The border router will receive the prefix through a [SLIP][http://en.wikipedia.org/wiki/Serial_Line_Internet_Protocol] (Serial Line Interface Protocol) connection and it will be communicated to the rest of the nodes in the RPL network. &lt;br /&gt;
&lt;br /&gt;
Refer to the following code snippets in the file border-router.c In this piece of code the node configured as the border router waits for the prefix to be set. Once it receives the prefix, the border router is set as the root of the DAG after which it sets the prefix of the rest of the nodes in the network.  &lt;br /&gt;
 &lt;br /&gt;
 /* Request prefix until it has been received */ &lt;br /&gt;
  while(!prefix_set) { &lt;br /&gt;
    etimer_set(&amp;amp;et, CLOCK_SECOND); &lt;br /&gt;
    request_prefix(); &lt;br /&gt;
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&amp;amp;et)); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
  dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)dag_id); &lt;br /&gt;
  if(dag != NULL) { &lt;br /&gt;
    rpl_set_prefix(dag, &amp;amp;prefix, 64); &lt;br /&gt;
    PRINTF(&amp;quot;created a new RPL dag\n&amp;quot;); &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
By default the border router hosts a simple web page. However, this can be disabled by defining WEBSERVER as seen the code snippet below. This webpage is displayed when the IPv6 address of the border router is entered in the browser. Refer to the file httpd-simple.c for the following code snippet&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;PROCESS(border_router_process, &amp;quot;Border router process&amp;quot;);&lt;br /&gt;
#if WEBSERVER==0&lt;br /&gt;
/* No webserver */&lt;br /&gt;
AUTOSTART_PROCESSES(&amp;amp;border_router_process);&lt;br /&gt;
#elif WEBSERVER&amp;gt;1&lt;br /&gt;
/* Use an external webserver application */&lt;br /&gt;
#include &amp;quot;webserver-nogui.h&amp;quot;&lt;br /&gt;
AUTOSTART_PROCESSES(&amp;amp;border_router_process,&amp;amp;webserver_nogui_process); &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Compiling the code ==&lt;br /&gt;
 &lt;br /&gt;
The code for RPL border router can be found at /contiki-2.7/examples/ipv6/rpl-border-router. Use the following command to compile the code for the border router &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-border-router &lt;br /&gt;
make TARGET=sky. &amp;lt;/pre&amp;gt;   &lt;br /&gt;
Once this command has been successfully executed, a file named border-router.sky will be created. This file will be used to program one of the motes as the border router on Cooja.  &lt;br /&gt;
For the purpose of this tutorial we will  select  TMote Sky  as our target. &lt;br /&gt;
&lt;br /&gt;
In order to demonstrate the functionality of the border router we will create a network of nodes with the border router as the root. For creating such a network we will user the udp-server.c code.  &lt;br /&gt;
This code can be found at /contiki-2.7/examples/ipv6/rpl-udp . Use the following command to compile the code for rpl-udp &lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-udp &lt;br /&gt;
make TARGET=sky &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once this command has been successfully executed a file named udp-server.sky will be created. This file will be used to program the remaining nodes in Cooja simulator. These nodes will form a DAG with the rpl border router as the root.&lt;br /&gt;
&lt;br /&gt;
== Testing on Cooja ==&lt;br /&gt;
 &lt;br /&gt;
Upon the successful completion of the above mentioned steps we are ready to create a simulation in Cooja.  &lt;br /&gt;
Start the Cooja simulator using the following command &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd /contiki-2.7/tools/cooja &lt;br /&gt;
ant run&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
When the GUI launches execute the following steps to create a simulation. &amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
1. From &amp;#039;File&amp;#039; select &amp;#039;New Simulation&amp;#039;. Select &amp;#039;UDGM&amp;#039;, enter the name of the simulation and click on &amp;#039;create&amp;#039;. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Click on &amp;#039;Motes&amp;#039;. From the drop down menu select &amp;#039;Add New Motes&amp;#039; followed by &amp;#039;Create new motes&amp;#039; and select the mote type as &amp;#039;Sky&amp;#039;. &amp;lt;br&amp;gt;&lt;br /&gt;
3. Browse to the location &amp;#039;/contiki-2.7/examples/ipv6/rpl-border-router&amp;#039; and select the file rpl-border-router.sky. Click on &amp;#039;Create&amp;#039;. Add one mote of this type. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Repeat step 2 and 3 but this time browse to the location /contiki-2.7/examples/ipv6/rpl-udp&amp;#039;  and select the file udp-server.sky. Add 3 - 4 motes of the type udp-server &amp;lt;br&amp;gt;&lt;br /&gt;
5. Once the motes have been added you can position the motes. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Cooja_motes.png]]&lt;br /&gt;
&lt;br /&gt;
Select the options under View as shown below. These will help you creating a topology of your choice.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Motes_view.png]]&lt;br /&gt;
&lt;br /&gt;
6. Now, we need to create a bridge between the RPL network simulated on Cooja and the local machine. This can be done by right clicking on the mote which is programmed as the border router. Select &amp;#039;More tools for border router&amp;#039; and then select &amp;#039;Serial Socket (SERVER)&amp;#039;. You will get the following message on the successful completion of this step.Note that the message says &amp;#039;Listening on port 60001&amp;#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Serial_Socket.png]]&lt;br /&gt;
&lt;br /&gt;
7. Now start the simulation by clicking on Start&lt;br /&gt;
&lt;br /&gt;
== Tunslip utility ==&lt;br /&gt;
 &lt;br /&gt;
As mentioned in the introduction a border router helps in connecting one network to another. In this example the border router is used to route data between an RPL network and an external network. Till now we have only created the RPL network. Now we need to simulate the scenario in which this RPL network is connected to an external network. For this purpose we will use the Tunslip utility provided in Contiki. In this example tunslip creates a bridge between the RPL network and the local machine. &lt;br /&gt;
tunslip6.c can be found in /contiki-2.7/tools &lt;br /&gt;
Compile the tunslip6 code.&lt;br /&gt;
&amp;lt;pre&amp;gt;make tunslip6 &amp;lt;/pre&amp;gt; &lt;br /&gt;
Make a connection between the RPL network and your local machine. &lt;br /&gt;
&amp;lt;pre&amp;gt;sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64&amp;lt;/pre&amp;gt;&lt;br /&gt;
On the successful execution this command the following output will be printed on the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;slip connected to ``127.0.0.1:60001&amp;#039;&amp;#039;&lt;br /&gt;
opened tun device ``/dev/tun0&amp;#039;&amp;#039;&lt;br /&gt;
ifconfig tun0 inet `hostname` up&lt;br /&gt;
ifconfig tun0 add aaaa::1/64&lt;br /&gt;
ifconfig tun0 add fe80::0:0:0:1/64&lt;br /&gt;
ifconfig tun0&lt;br /&gt;
&lt;br /&gt;
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  &lt;br /&gt;
          inet addr:127.0.1.1  P-t-P:127.0.1.1  Mask:255.255.255.255&lt;br /&gt;
          inet6 addr: fe80::1/64 Scope:Link&lt;br /&gt;
          inet6 addr: aaaa::1/64 Scope:Global&lt;br /&gt;
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1&lt;br /&gt;
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0&lt;br /&gt;
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0&lt;br /&gt;
          collisions:0 txqueuelen:500 &lt;br /&gt;
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)&lt;br /&gt;
&lt;br /&gt;
Rime started with address 0.18.116.1.0.1.1.1&lt;br /&gt;
MAC 00:12:74:01:00:01:01:01 Contiki 2.7 started. Node id is set to 1.&lt;br /&gt;
CSMA ContikiMAC, channel check rate 8 Hz, radio channel 26&lt;br /&gt;
Tentative link-local IPv6 address fe80:0000:0000:0000:0212:7401:0001:0101&lt;br /&gt;
Starting &amp;#039;Border router process&amp;#039; &amp;#039;Web server&amp;#039;&lt;br /&gt;
*** Address:aaaa::1 =&amp;gt; aaaa:0000:0000:0000&lt;br /&gt;
Got configuration message of type P&lt;br /&gt;
Setting prefix aaaa::&lt;br /&gt;
Server IPv6 addresses:&lt;br /&gt;
 aaaa::212:7401:1:101&lt;br /&gt;
 fe80::212:7401:1:101&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Go back to the Cooja simulator GUI and look at the dialogue box. The message has now changed to &amp;#039;Client connected: /127.0.0.1&amp;#039;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Client_Connected.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Verifying Results ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can verify that the address of the border router has been set by using the ping command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7401:1:101&lt;br /&gt;
PING aaaa::212:7401:1:101(aaaa::212:7401:1:101) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=1 ttl=64 time=86.0 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=2 ttl=64 time=33.6 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=3 ttl=64 time=82.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=4 ttl=64 time=43.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=5 ttl=64 time=70.1 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7401:1:101 ping statistics ---&lt;br /&gt;
5 packets transmitted, 5 received, 0% packet loss, time 4006ms&lt;br /&gt;
rtt min/avg/max/mdev = 33.669/63.090/86.015/20.985 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also ping one of the other nodes in the network. Here we are pinging node 4&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7404:4:404&lt;br /&gt;
PING aaaa::212:7404:4:404(aaaa::212:7404:4:404) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=1 ttl=63 time=670 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=2 ttl=63 time=703 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=3 ttl=63 time=746 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=4 ttl=63 time=674 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7404:4:404 ping statistics ---&lt;br /&gt;
5 packets transmitted, 4 received, 20% packet loss, time 4001ms&lt;br /&gt;
rtt min/avg/max/mdev = 670.230/698.666/746.619/30.514 ms&lt;br /&gt;
user@instant-contiki:~/contiki-2.7$ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IPv6 address of a node can be checked from the log screen on Cooja. Filter the nodes by their ID&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Node_Address.png]]&lt;br /&gt;
&lt;br /&gt;
You can enter the address of the border router in the web browser. The border router hosts a page which will be displayed on the browser as shown below. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:RPL_Browser.png]]&lt;br /&gt;
&lt;br /&gt;
== Common Issues ==&lt;br /&gt;
&lt;br /&gt;
1. Make sure that you enter the IPv6 address properly in the command sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64 . There should be no spaces in aaaa::1/64. Otherwise the code will give unexpected behavior.&amp;lt;br&amp;gt;&lt;br /&gt;
2. When you pause the simulation the SLIP connection is lost. It might not work properly on resuming the simulation. In such cases reload the simulation. Create a fresh SLIP connection and then run the simulation again.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
[https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md]  https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md &amp;lt;br&amp;gt;&lt;br /&gt;
[http://cnds.eecs.jacobs-university.de/courses/iotlab-2013/cooja.pdf] Using the Contiki Cooja Simulator - Anuj Sehgal&lt;/div&gt;</summary>
		<author><name>Ckapoor</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1421</id>
		<title>RPL Border Router</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1421"/>
				<updated>2014-11-09T06:45:11Z</updated>
		
		<summary type="html">&lt;p&gt;Ckapoor: /* Code building blocks. */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction: ==&lt;br /&gt;
  &lt;br /&gt;
Border routers are routers that can be found at the edge of a network. Their function is to connect one network to another. In this tutorial we will learn how to run a simulation using the border router in Contiki 2.7. In the example which we will discuss in the rest of this tutorial the border router will be used to route data between a WSN (RPL network) and an external IP network.  &lt;br /&gt;
&lt;br /&gt;
[[File:Diagram.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Objective ==&lt;br /&gt;
  &lt;br /&gt;
The objective of this tutorial is to give you an understanding of the RPL Border Router code in Contiki 2.7 OS and learn how to simulate a network with a border router on Cooja &lt;br /&gt;
&lt;br /&gt;
At the end of the tutorial you would have learnt the following: &lt;br /&gt;
&lt;br /&gt;
1. Understanding the working of the rpl border router code &amp;lt;br&amp;gt;&lt;br /&gt;
2. Starting a simulation on Cooja simulator. &amp;lt;br&amp;gt; &lt;br /&gt;
3. Observing and validating the results &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code building blocks. ==&lt;br /&gt;
 &lt;br /&gt;
We will be using the following files &lt;br /&gt;
&lt;br /&gt;
1. border-router.c &amp;lt;br&amp;gt;&lt;br /&gt;
2. udp-server.c  (udp-client.c can also be used)&amp;lt;br&amp;gt;&lt;br /&gt;
3. slip-bridge.c (It contains callback function for processing a SLIP connection request) &amp;lt;br&amp;gt;&lt;br /&gt;
4. httpd-simple.c   (A simple web server forwarding page generation to a protothread)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
udp-server nodes will form a DAG with the border router set as the root. The border router will receive the prefix through a [SLIP][http://en.wikipedia.org/wiki/Serial_Line_Internet_Protocol] (Serial Line Interface Protocol) connection and it will be communicated to the rest of the nodes in the RPL network. &lt;br /&gt;
&lt;br /&gt;
Refer to the following code snippets in the file border-router.c In this piece of code the node configured as the border router waits for the prefix to be set. Once it receives the prefix, the border router is set as the root of the DAG after which it sets the prefix of the rest of the nodes in the network.  &lt;br /&gt;
 &lt;br /&gt;
 /* Request prefix until it has been received */ &lt;br /&gt;
  while(!prefix_set) { &lt;br /&gt;
    etimer_set(&amp;amp;et, CLOCK_SECOND); &lt;br /&gt;
    request_prefix(); &lt;br /&gt;
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&amp;amp;et)); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
  dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)dag_id); &lt;br /&gt;
  if(dag != NULL) { &lt;br /&gt;
    rpl_set_prefix(dag, &amp;amp;prefix, 64); &lt;br /&gt;
    PRINTF(&amp;quot;created a new RPL dag\n&amp;quot;); &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
By default the border router hosts a simple web page. However, this can be disabled by defining WEBSERVER as seen the code snippet below. This webpage is displayed when the IPv6 address of the border router is entered in the browser. Refer to the file httpd-simple.c for the following code snippet&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;PROCESS(border_router_process, &amp;quot;Border router process&amp;quot;);&lt;br /&gt;
#if WEBSERVER==0&lt;br /&gt;
/* No webserver */&lt;br /&gt;
AUTOSTART_PROCESSES(&amp;amp;border_router_process);&lt;br /&gt;
#elif WEBSERVER&amp;gt;1&lt;br /&gt;
/* Use an external webserver application */&lt;br /&gt;
#include &amp;quot;webserver-nogui.h&amp;quot;&lt;br /&gt;
AUTOSTART_PROCESSES(&amp;amp;border_router_process,&amp;amp;webserver_nogui_process); &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Compiling the code ==&lt;br /&gt;
 &lt;br /&gt;
The code for RPL border router can be found at /contiki-2.7/examples/ipv6/rpl-border-router. Use the following command to compile the code for the border router &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-border-router &lt;br /&gt;
make TARGET=sky. &amp;lt;/pre&amp;gt;   &lt;br /&gt;
Once this command has been successfully executed, a file named border-router.sky will be created. This file will be used to program one of the motes as the border router on Cooja.  &lt;br /&gt;
For the purpose of this tutorial we will  select  TMote Sky  as our target. &lt;br /&gt;
&lt;br /&gt;
In order to demonstrate the functionality of the border router we will create a network of nodes with the border router as the root. For creating such a network we will user the udp-server.c code.  &lt;br /&gt;
This code can be found at /contiki-2.7/examples/ipv6/rpl-udp . Use the following command to compile the code for rpl-udp &lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-udp &lt;br /&gt;
make TARGET=sky &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once this command has been successfully executed a file named udp-server.sky will be created. This file will be used to program the remaining nodes in Cooja simulator. These nodes will form a DAG with the rpl border router as the root.&lt;br /&gt;
&lt;br /&gt;
== Testing on Cooja ==&lt;br /&gt;
 &lt;br /&gt;
Upon the successful completion of the above mentioned steps we are ready to create a simulation in Cooja.  &lt;br /&gt;
Start the Cooja simulator using the following command &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd /contiki-2.7/tools/cooja &lt;br /&gt;
ant run&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
When the GUI launches execute the following steps to create a simulation. &amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
1. From &amp;#039;File&amp;#039; select &amp;#039;New Simulation&amp;#039;. Select &amp;#039;UDGM&amp;#039;, enter the name of the simulation and click on &amp;#039;create&amp;#039;. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Click on &amp;#039;Motes&amp;#039;. From the drop down menu select &amp;#039;Add New Motes&amp;#039; followed by &amp;#039;Create new motes&amp;#039; and select the mote type as &amp;#039;Sky&amp;#039;. &amp;lt;br&amp;gt;&lt;br /&gt;
3. Browse to the location &amp;#039;/contiki-2.7/examples/ipv6/rpl-border-router&amp;#039; and select the file rpl-border-router.sky. Click on &amp;#039;Create&amp;#039;. Add one mote of this type. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Repeat step 2 and 3 but this time browse to the location /contiki-2.7/examples/ipv6/rpl-udp&amp;#039;  and select the file udp-server.sky. Add 3 - 4 motes of the type udp-server &amp;lt;br&amp;gt;&lt;br /&gt;
5. Once the motes have been added you can position the motes. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Cooja_motes.png]]&lt;br /&gt;
&lt;br /&gt;
Select the options under View as shown below. These will help you creating a topology of your choice.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Motes_view.png]]&lt;br /&gt;
&lt;br /&gt;
6. Now, we need to create a bridge between the RPL network simulated on Cooja and the local machine. This can be done by right clicking on the mote which is programmed as the border router. Select &amp;#039;More tools for border router&amp;#039; and then select &amp;#039;Serial Socket (SERVER)&amp;#039;. You will get the following message on the successful completion of this step.Note that the message says &amp;#039;Listening on port 60001&amp;#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Serial_Socket.png]]&lt;br /&gt;
&lt;br /&gt;
7. Now start the simulation by clicking on Start&lt;br /&gt;
&lt;br /&gt;
== Tunslip utility ==&lt;br /&gt;
 &lt;br /&gt;
As mentioned in the introduction a border router helps in connecting one network to another. In this example the border router is used to route data between an RPL network and an external network. Till now we have only created the RPL network. Now we need to simulate the scenario in which this RPL network is connected to an external network. For this purpose we will use the Tunslip utility provided in Contiki. In this example tunslip creates a bridge between the RPL network and the local machine. &lt;br /&gt;
tunslip6.c can be found in /contiki-2.7/tools &lt;br /&gt;
Compile the tunslip6 code.&lt;br /&gt;
&amp;lt;pre&amp;gt;make tunslip6 &amp;lt;/pre&amp;gt; &lt;br /&gt;
Make a connection between the RPL network and your local machine. &lt;br /&gt;
&amp;lt;pre&amp;gt;sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64&amp;lt;/pre&amp;gt;&lt;br /&gt;
On the successful execution this command the following output will be printed on the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;slip connected to ``127.0.0.1:60001&amp;#039;&amp;#039;&lt;br /&gt;
opened tun device ``/dev/tun0&amp;#039;&amp;#039;&lt;br /&gt;
ifconfig tun0 inet `hostname` up&lt;br /&gt;
ifconfig tun0 add aaaa::1/64&lt;br /&gt;
ifconfig tun0 add fe80::0:0:0:1/64&lt;br /&gt;
ifconfig tun0&lt;br /&gt;
&lt;br /&gt;
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  &lt;br /&gt;
          inet addr:127.0.1.1  P-t-P:127.0.1.1  Mask:255.255.255.255&lt;br /&gt;
          inet6 addr: fe80::1/64 Scope:Link&lt;br /&gt;
          inet6 addr: aaaa::1/64 Scope:Global&lt;br /&gt;
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1&lt;br /&gt;
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0&lt;br /&gt;
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0&lt;br /&gt;
          collisions:0 txqueuelen:500 &lt;br /&gt;
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)&lt;br /&gt;
&lt;br /&gt;
Rime started with address 0.18.116.1.0.1.1.1&lt;br /&gt;
MAC 00:12:74:01:00:01:01:01 Contiki 2.7 started. Node id is set to 1.&lt;br /&gt;
CSMA ContikiMAC, channel check rate 8 Hz, radio channel 26&lt;br /&gt;
Tentative link-local IPv6 address fe80:0000:0000:0000:0212:7401:0001:0101&lt;br /&gt;
Starting &amp;#039;Border router process&amp;#039; &amp;#039;Web server&amp;#039;&lt;br /&gt;
*** Address:aaaa::1 =&amp;gt; aaaa:0000:0000:0000&lt;br /&gt;
Got configuration message of type P&lt;br /&gt;
Setting prefix aaaa::&lt;br /&gt;
Server IPv6 addresses:&lt;br /&gt;
 aaaa::212:7401:1:101&lt;br /&gt;
 fe80::212:7401:1:101&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Go back to the Cooja simulator GUI and look at the dialogue box. The message has now changed to &amp;#039;Client connected: /127.0.0.1&amp;#039;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Client_Connected.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Verifying Results ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can verify that the address of the border router has been set by using the ping command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7401:1:101&lt;br /&gt;
PING aaaa::212:7401:1:101(aaaa::212:7401:1:101) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=1 ttl=64 time=86.0 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=2 ttl=64 time=33.6 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=3 ttl=64 time=82.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=4 ttl=64 time=43.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=5 ttl=64 time=70.1 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7401:1:101 ping statistics ---&lt;br /&gt;
5 packets transmitted, 5 received, 0% packet loss, time 4006ms&lt;br /&gt;
rtt min/avg/max/mdev = 33.669/63.090/86.015/20.985 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also ping one of the other nodes in the network. Here we are pinging node 4&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7404:4:404&lt;br /&gt;
PING aaaa::212:7404:4:404(aaaa::212:7404:4:404) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=1 ttl=63 time=670 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=2 ttl=63 time=703 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=3 ttl=63 time=746 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=4 ttl=63 time=674 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7404:4:404 ping statistics ---&lt;br /&gt;
5 packets transmitted, 4 received, 20% packet loss, time 4001ms&lt;br /&gt;
rtt min/avg/max/mdev = 670.230/698.666/746.619/30.514 ms&lt;br /&gt;
user@instant-contiki:~/contiki-2.7$ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IPv6 address of a node can be checked from the log screen on Cooja. Filter the nodes by their ID&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Node_Address.png]]&lt;br /&gt;
&lt;br /&gt;
You can enter the address of the border router in the web browser. The border router host a page which will be displayed on the browser as shown below. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:RPL_Browser.png]]&lt;br /&gt;
&lt;br /&gt;
== Common Issues ==&lt;br /&gt;
&lt;br /&gt;
1. Make sure that you enter the IPv6 address properly in the command sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64 . There should be no spaces in aaaa::1/64. Otherwise the code will give unexpected behavior.&amp;lt;br&amp;gt;&lt;br /&gt;
2. When you pause the simulation the SLIP connection is lost. It might not work properly on resuming the simulation. In such cases reload the simulation. Create a fresh SLIP connection and then run the simulation again.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
[https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md]  https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md &amp;lt;br&amp;gt;&lt;br /&gt;
[http://cnds.eecs.jacobs-university.de/courses/iotlab-2013/cooja.pdf] Using the Contiki Cooja Simulator - Anuj Sehgal&lt;/div&gt;</summary>
		<author><name>Ckapoor</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1417</id>
		<title>RPL Border Router</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1417"/>
				<updated>2014-11-09T06:44:09Z</updated>
		
		<summary type="html">&lt;p&gt;Ckapoor: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction: ==&lt;br /&gt;
  &lt;br /&gt;
Border routers are routers that can be found at the edge of a network. Their function is to connect one network to another. In this tutorial we will learn how to run a simulation using the border router in Contiki 2.7. In the example which we will discuss in the rest of this tutorial the border router will be used to route data between a WSN (RPL network) and an external IP network.  &lt;br /&gt;
&lt;br /&gt;
[[File:Diagram.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Objective ==&lt;br /&gt;
  &lt;br /&gt;
The objective of this tutorial is to give you an understanding of the RPL Border Router code in Contiki 2.7 OS and learn how to simulate a network with a border router on Cooja &lt;br /&gt;
&lt;br /&gt;
At the end of the tutorial you would have learnt the following: &lt;br /&gt;
&lt;br /&gt;
1. Understanding the working of the rpl border router code &amp;lt;br&amp;gt;&lt;br /&gt;
2. Starting a simulation on Cooja simulator. &amp;lt;br&amp;gt; &lt;br /&gt;
3. Observing and validating the results &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code building blocks. ==&lt;br /&gt;
 &lt;br /&gt;
We will be using the following files &lt;br /&gt;
&lt;br /&gt;
1. border-router.c &amp;lt;br&amp;gt;&lt;br /&gt;
2. udp-server.c  (udp-client.c can also be used)&amp;lt;br&amp;gt;&lt;br /&gt;
3. slip-bridge.c (It contains callback function for processing a SLIP connection request) &amp;lt;br&amp;gt;&lt;br /&gt;
4. httpd-simple.c   (A simple web server forwarding page generation to a protothread)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
udp-server nodes will form a DAG with the border router set as the root. The border router will receive the prefix through a [SLIP][http://en.wikipedia.org/wiki/Serial_Line_Internet_Protocol] (Serial Line Interface Protocol) connection and it will be communicated to the rest of the nodes in the RPL network. &lt;br /&gt;
&lt;br /&gt;
Refer to the following code snippets in the file border-router.c In this piece of code the node configured as the border router waits for the prefix to be set. Once it receives the prefix, the border router is set as the root of the DAG after which it sets the prefix of the rest of the nodes in the network.  &lt;br /&gt;
 &lt;br /&gt;
 /* Request prefix until it has been received */ &lt;br /&gt;
  while(!prefix_set) { &lt;br /&gt;
    etimer_set(&amp;amp;et, CLOCK_SECOND); &lt;br /&gt;
    request_prefix(); &lt;br /&gt;
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&amp;amp;et)); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
  dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)dag_id); &lt;br /&gt;
  if(dag != NULL) { &lt;br /&gt;
    rpl_set_prefix(dag, &amp;amp;prefix, 64); &lt;br /&gt;
    PRINTF(&amp;quot;created a new RPL dag\n&amp;quot;); &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
By default the border router hosts a simple web page. However this can be disabled by defining WEBSERVER as seen the code snippet below. This webpage is displayed when the IPv6 address of the border router is entered in the browser. Refer to the file httpd-simple.c for the following code snippet&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;PROCESS(border_router_process, &amp;quot;Border router process&amp;quot;);&lt;br /&gt;
#if WEBSERVER==0&lt;br /&gt;
/* No webserver */&lt;br /&gt;
AUTOSTART_PROCESSES(&amp;amp;border_router_process);&lt;br /&gt;
#elif WEBSERVER&amp;gt;1&lt;br /&gt;
/* Use an external webserver application */&lt;br /&gt;
#include &amp;quot;webserver-nogui.h&amp;quot;&lt;br /&gt;
AUTOSTART_PROCESSES(&amp;amp;border_router_process,&amp;amp;webserver_nogui_process); &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Compiling the code ==&lt;br /&gt;
 &lt;br /&gt;
The code for RPL border router can be found at /contiki-2.7/examples/ipv6/rpl-border-router. Use the following command to compile the code for the border router &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-border-router &lt;br /&gt;
make TARGET=sky. &amp;lt;/pre&amp;gt;   &lt;br /&gt;
Once this command has been successfully executed, a file named border-router.sky will be created. This file will be used to program one of the motes as the border router on Cooja.  &lt;br /&gt;
For the purpose of this tutorial we will  select  TMote Sky  as our target. &lt;br /&gt;
&lt;br /&gt;
In order to demonstrate the functionality of the border router we will create a network of nodes with the border router as the root. For creating such a network we will user the udp-server.c code.  &lt;br /&gt;
This code can be found at /contiki-2.7/examples/ipv6/rpl-udp . Use the following command to compile the code for rpl-udp &lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-udp &lt;br /&gt;
make TARGET=sky &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once this command has been successfully executed a file named udp-server.sky will be created. This file will be used to program the remaining nodes in Cooja simulator. These nodes will form a DAG with the rpl border router as the root.&lt;br /&gt;
&lt;br /&gt;
== Testing on Cooja ==&lt;br /&gt;
 &lt;br /&gt;
Upon the successful completion of the above mentioned steps we are ready to create a simulation in Cooja.  &lt;br /&gt;
Start the Cooja simulator using the following command &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd /contiki-2.7/tools/cooja &lt;br /&gt;
ant run&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
When the GUI launches execute the following steps to create a simulation. &amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
1. From &amp;#039;File&amp;#039; select &amp;#039;New Simulation&amp;#039;. Select &amp;#039;UDGM&amp;#039;, enter the name of the simulation and click on &amp;#039;create&amp;#039;. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Click on &amp;#039;Motes&amp;#039;. From the drop down menu select &amp;#039;Add New Motes&amp;#039; followed by &amp;#039;Create new motes&amp;#039; and select the mote type as &amp;#039;Sky&amp;#039;. &amp;lt;br&amp;gt;&lt;br /&gt;
3. Browse to the location &amp;#039;/contiki-2.7/examples/ipv6/rpl-border-router&amp;#039; and select the file rpl-border-router.sky. Click on &amp;#039;Create&amp;#039;. Add one mote of this type. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Repeat step 2 and 3 but this time browse to the location /contiki-2.7/examples/ipv6/rpl-udp&amp;#039;  and select the file udp-server.sky. Add 3 - 4 motes of the type udp-server &amp;lt;br&amp;gt;&lt;br /&gt;
5. Once the motes have been added you can position the motes. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Cooja_motes.png]]&lt;br /&gt;
&lt;br /&gt;
Select the options under View as shown below. These will help you creating a topology of your choice.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Motes_view.png]]&lt;br /&gt;
&lt;br /&gt;
6. Now, we need to create a bridge between the RPL network simulated on Cooja and the local machine. This can be done by right clicking on the mote which is programmed as the border router. Select &amp;#039;More tools for border router&amp;#039; and then select &amp;#039;Serial Socket (SERVER)&amp;#039;. You will get the following message on the successful completion of this step.Note that the message says &amp;#039;Listening on port 60001&amp;#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Serial_Socket.png]]&lt;br /&gt;
&lt;br /&gt;
7. Now start the simulation by clicking on Start&lt;br /&gt;
&lt;br /&gt;
== Tunslip utility ==&lt;br /&gt;
 &lt;br /&gt;
As mentioned in the introduction a border router helps in connecting one network to another. In this example the border router is used to route data between an RPL network and an external network. Till now we have only created the RPL network. Now we need to simulate the scenario in which this RPL network is connected to an external network. For this purpose we will use the Tunslip utility provided in Contiki. In this example tunslip creates a bridge between the RPL network and the local machine. &lt;br /&gt;
tunslip6.c can be found in /contiki-2.7/tools &lt;br /&gt;
Compile the tunslip6 code.&lt;br /&gt;
&amp;lt;pre&amp;gt;make tunslip6 &amp;lt;/pre&amp;gt; &lt;br /&gt;
Make a connection between the RPL network and your local machine. &lt;br /&gt;
&amp;lt;pre&amp;gt;sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64&amp;lt;/pre&amp;gt;&lt;br /&gt;
On the successful execution this command the following output will be printed on the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;slip connected to ``127.0.0.1:60001&amp;#039;&amp;#039;&lt;br /&gt;
opened tun device ``/dev/tun0&amp;#039;&amp;#039;&lt;br /&gt;
ifconfig tun0 inet `hostname` up&lt;br /&gt;
ifconfig tun0 add aaaa::1/64&lt;br /&gt;
ifconfig tun0 add fe80::0:0:0:1/64&lt;br /&gt;
ifconfig tun0&lt;br /&gt;
&lt;br /&gt;
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  &lt;br /&gt;
          inet addr:127.0.1.1  P-t-P:127.0.1.1  Mask:255.255.255.255&lt;br /&gt;
          inet6 addr: fe80::1/64 Scope:Link&lt;br /&gt;
          inet6 addr: aaaa::1/64 Scope:Global&lt;br /&gt;
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1&lt;br /&gt;
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0&lt;br /&gt;
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0&lt;br /&gt;
          collisions:0 txqueuelen:500 &lt;br /&gt;
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)&lt;br /&gt;
&lt;br /&gt;
Rime started with address 0.18.116.1.0.1.1.1&lt;br /&gt;
MAC 00:12:74:01:00:01:01:01 Contiki 2.7 started. Node id is set to 1.&lt;br /&gt;
CSMA ContikiMAC, channel check rate 8 Hz, radio channel 26&lt;br /&gt;
Tentative link-local IPv6 address fe80:0000:0000:0000:0212:7401:0001:0101&lt;br /&gt;
Starting &amp;#039;Border router process&amp;#039; &amp;#039;Web server&amp;#039;&lt;br /&gt;
*** Address:aaaa::1 =&amp;gt; aaaa:0000:0000:0000&lt;br /&gt;
Got configuration message of type P&lt;br /&gt;
Setting prefix aaaa::&lt;br /&gt;
Server IPv6 addresses:&lt;br /&gt;
 aaaa::212:7401:1:101&lt;br /&gt;
 fe80::212:7401:1:101&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Go back to the Cooja simulator GUI and look at the dialogue box. The message has now changed to &amp;#039;Client connected: /127.0.0.1&amp;#039;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Client_Connected.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Verifying Results ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can verify that the address of the border router has been set by using the ping command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7401:1:101&lt;br /&gt;
PING aaaa::212:7401:1:101(aaaa::212:7401:1:101) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=1 ttl=64 time=86.0 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=2 ttl=64 time=33.6 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=3 ttl=64 time=82.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=4 ttl=64 time=43.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=5 ttl=64 time=70.1 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7401:1:101 ping statistics ---&lt;br /&gt;
5 packets transmitted, 5 received, 0% packet loss, time 4006ms&lt;br /&gt;
rtt min/avg/max/mdev = 33.669/63.090/86.015/20.985 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also ping one of the other nodes in the network. Here we are pinging node 4&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7404:4:404&lt;br /&gt;
PING aaaa::212:7404:4:404(aaaa::212:7404:4:404) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=1 ttl=63 time=670 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=2 ttl=63 time=703 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=3 ttl=63 time=746 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=4 ttl=63 time=674 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7404:4:404 ping statistics ---&lt;br /&gt;
5 packets transmitted, 4 received, 20% packet loss, time 4001ms&lt;br /&gt;
rtt min/avg/max/mdev = 670.230/698.666/746.619/30.514 ms&lt;br /&gt;
user@instant-contiki:~/contiki-2.7$ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IPv6 address of a node can be checked from the log screen on Cooja. Filter the nodes by their ID&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Node_Address.png]]&lt;br /&gt;
&lt;br /&gt;
You can enter the address of the border router in the web browser. The border router host a page which will be displayed on the browser as shown below. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:RPL_Browser.png]]&lt;br /&gt;
&lt;br /&gt;
== Common Issues ==&lt;br /&gt;
&lt;br /&gt;
1. Make sure that you enter the IPv6 address properly in the command sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64 . There should be no spaces in aaaa::1/64. Otherwise the code will give unexpected behavior.&amp;lt;br&amp;gt;&lt;br /&gt;
2. When you pause the simulation the SLIP connection is lost. It might not work properly on resuming the simulation. In such cases reload the simulation. Create a fresh SLIP connection and then run the simulation again.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
[https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md]  https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md &amp;lt;br&amp;gt;&lt;br /&gt;
[http://cnds.eecs.jacobs-university.de/courses/iotlab-2013/cooja.pdf] Using the Contiki Cooja Simulator - Anuj Sehgal&lt;/div&gt;</summary>
		<author><name>Ckapoor</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1412</id>
		<title>RPL Border Router</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1412"/>
				<updated>2014-11-09T06:41:25Z</updated>
		
		<summary type="html">&lt;p&gt;Ckapoor: /* Testing on Cooja */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction: ==&lt;br /&gt;
  &lt;br /&gt;
Border routers are routers that can be found at the edge of a network. Their function is to connect one network to another. In this tutorial we will learn how to run a simulation using the border router in Contiki 2.7. In the example which we will discuss in the rest of this tutorial the border router will be used to route data between a WSN (RPL network) and an external IP network.  &lt;br /&gt;
&lt;br /&gt;
[[File:Diagram.png]]&lt;br /&gt;
&lt;br /&gt;
Objective:  &lt;br /&gt;
The objective of this tutorial is to give you an understanding of the RPL Border Router code in Contiki 2.7 OS and learn how to simulate a network with a border router on Cooja &lt;br /&gt;
&lt;br /&gt;
At the end of the tutorial you would have learnt the following: &lt;br /&gt;
&lt;br /&gt;
1. Understanding the working of the rpl border router code &amp;lt;br&amp;gt;&lt;br /&gt;
2. Starting a simulation on Cooja simulator. &amp;lt;br&amp;gt; &lt;br /&gt;
3. Observing and validating the results &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code building blocks. ==&lt;br /&gt;
 &lt;br /&gt;
We will be using the following files &lt;br /&gt;
&lt;br /&gt;
1. border-router.c &amp;lt;br&amp;gt;&lt;br /&gt;
2. udp-server.c  (udp-client.c can also be used)&amp;lt;br&amp;gt;&lt;br /&gt;
3. slip-bridge.c (It contains callback function for processing a SLIP connection request) &amp;lt;br&amp;gt;&lt;br /&gt;
4. httpd-simple.c   (A simple web server forwarding page generation to a protothread)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
udp-server nodes will form a DAG with the border router set as the root. The border router will receive the prefix through a [SLIP][http://en.wikipedia.org/wiki/Serial_Line_Internet_Protocol] (Serial Line Interface Protocol) connection and it will be communicated to the rest of the nodes in the RPL network. &lt;br /&gt;
&lt;br /&gt;
Refer to the following code snippets in the file border-router.c In this piece of code the node configured as the border router waits for the prefix to be set. Once it receives the prefix, the border router is set as the root of the DAG after which it sets the prefix of the rest of the nodes in the network.  &lt;br /&gt;
 &lt;br /&gt;
 /* Request prefix until it has been received */ &lt;br /&gt;
  while(!prefix_set) { &lt;br /&gt;
    etimer_set(&amp;amp;et, CLOCK_SECOND); &lt;br /&gt;
    request_prefix(); &lt;br /&gt;
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&amp;amp;et)); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
  dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)dag_id); &lt;br /&gt;
  if(dag != NULL) { &lt;br /&gt;
    rpl_set_prefix(dag, &amp;amp;prefix, 64); &lt;br /&gt;
    PRINTF(&amp;quot;created a new RPL dag\n&amp;quot;); &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
By default the border router hosts a simple web page. However this can be disabled by defining WEBSERVER as seen the code snippet below. This webpage is displayed when the IPv6 address of the border router is entered in the browser. Refer to the file httpd-simple.c for the following code snippet&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;PROCESS(border_router_process, &amp;quot;Border router process&amp;quot;);&lt;br /&gt;
#if WEBSERVER==0&lt;br /&gt;
/* No webserver */&lt;br /&gt;
AUTOSTART_PROCESSES(&amp;amp;border_router_process);&lt;br /&gt;
#elif WEBSERVER&amp;gt;1&lt;br /&gt;
/* Use an external webserver application */&lt;br /&gt;
#include &amp;quot;webserver-nogui.h&amp;quot;&lt;br /&gt;
AUTOSTART_PROCESSES(&amp;amp;border_router_process,&amp;amp;webserver_nogui_process); &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Compiling the code ==&lt;br /&gt;
 &lt;br /&gt;
The code for RPL border router can be found at /contiki-2.7/examples/ipv6/rpl-border-router. Use the following command to compile the code for the border router &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-border-router &lt;br /&gt;
make TARGET=sky. &amp;lt;/pre&amp;gt;   &lt;br /&gt;
Once this command has been successfully executed, a file named border-router.sky will be created. This file will be used to program one of the motes as the border router on Cooja.  &lt;br /&gt;
For the purpose of this tutorial we will  select  TMote Sky  as our target. &lt;br /&gt;
&lt;br /&gt;
In order to demonstrate the functionality of the border router we will create a network of nodes with the border router as the root. For creating such a network we will user the udp-server.c code.  &lt;br /&gt;
This code can be found at /contiki-2.7/examples/ipv6/rpl-udp . Use the following command to compile the code for rpl-udp &lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-udp &lt;br /&gt;
make TARGET=sky &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once this command has been successfully executed a file named udp-server.sky will be created. This file will be used to program the remaining nodes in Cooja simulator. These nodes will form a DAG with the rpl border router as the root.&lt;br /&gt;
&lt;br /&gt;
== Testing on Cooja ==&lt;br /&gt;
 &lt;br /&gt;
Upon the successful completion of the above mentioned steps we are ready to create a simulation in Cooja.  &lt;br /&gt;
Start the Cooja simulator using the following command &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd /contiki-2.7/tools/cooja &lt;br /&gt;
ant run&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
When the GUI launches execute the following steps to create a simulation. &amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
1. From &amp;#039;File&amp;#039; select &amp;#039;New Simulation&amp;#039;. Select &amp;#039;UDGM&amp;#039;, enter the name of the simulation and click on &amp;#039;create&amp;#039;. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Click on &amp;#039;Motes&amp;#039;. From the drop down menu select &amp;#039;Add New Motes&amp;#039; followed by &amp;#039;Create new motes&amp;#039; and select the mote type as &amp;#039;Sky&amp;#039;. &amp;lt;br&amp;gt;&lt;br /&gt;
3. Browse to the location &amp;#039;/contiki-2.7/examples/ipv6/rpl-border-router&amp;#039; and select the file rpl-border-router.sky. Click on &amp;#039;Create&amp;#039;. Add one mote of this type. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Repeat step 2 and 3 but this time browse to the location /contiki-2.7/examples/ipv6/rpl-udp&amp;#039;  and select the file udp-server.sky. Add 3 - 4 motes of the type udp-server &amp;lt;br&amp;gt;&lt;br /&gt;
5. Once the motes have been added you can position the motes. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Cooja_motes.png]]&lt;br /&gt;
&lt;br /&gt;
Select the options under View as shown below. These will help you creating a topology of your choice.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Motes_view.png]]&lt;br /&gt;
&lt;br /&gt;
6. Now, we need to create a bridge between the RPL network simulated on Cooja and the local machine. This can be done by right clicking on the mote which is programmed as the border router. Select &amp;#039;More tools for border router&amp;#039; and then select &amp;#039;Serial Socket (SERVER)&amp;#039;. You will get the following message on the successful completion of this step.Note that the message says &amp;#039;Listening on port 60001&amp;#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Serial_Socket.png]]&lt;br /&gt;
&lt;br /&gt;
7. Now start the simulation by clicking on Start&lt;br /&gt;
&lt;br /&gt;
== Tunslip utility ==&lt;br /&gt;
 &lt;br /&gt;
As mentioned in the introduction a border router helps in connecting one network to another. In this example the border router is used to route data between an RPL network and an external network. Till now we have only created the RPL network. Now we need to simulate the scenario in which this RPL network is connected to an external network. For this purpose we will use the Tunslip utility provided in Contiki. In this example tunslip creates a bridge between the RPL network and the local machine. &lt;br /&gt;
tunslip6.c can be found in /contiki-2.7/tools &lt;br /&gt;
Compile the tunslip6 code.&lt;br /&gt;
&amp;lt;pre&amp;gt;make tunslip6 &amp;lt;/pre&amp;gt; &lt;br /&gt;
Make a connection between the RPL network and your local machine. &lt;br /&gt;
&amp;lt;pre&amp;gt;sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64&amp;lt;/pre&amp;gt;&lt;br /&gt;
On the successful execution this command the following output will be printed on the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;slip connected to ``127.0.0.1:60001&amp;#039;&amp;#039;&lt;br /&gt;
opened tun device ``/dev/tun0&amp;#039;&amp;#039;&lt;br /&gt;
ifconfig tun0 inet `hostname` up&lt;br /&gt;
ifconfig tun0 add aaaa::1/64&lt;br /&gt;
ifconfig tun0 add fe80::0:0:0:1/64&lt;br /&gt;
ifconfig tun0&lt;br /&gt;
&lt;br /&gt;
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  &lt;br /&gt;
          inet addr:127.0.1.1  P-t-P:127.0.1.1  Mask:255.255.255.255&lt;br /&gt;
          inet6 addr: fe80::1/64 Scope:Link&lt;br /&gt;
          inet6 addr: aaaa::1/64 Scope:Global&lt;br /&gt;
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1&lt;br /&gt;
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0&lt;br /&gt;
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0&lt;br /&gt;
          collisions:0 txqueuelen:500 &lt;br /&gt;
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)&lt;br /&gt;
&lt;br /&gt;
Rime started with address 0.18.116.1.0.1.1.1&lt;br /&gt;
MAC 00:12:74:01:00:01:01:01 Contiki 2.7 started. Node id is set to 1.&lt;br /&gt;
CSMA ContikiMAC, channel check rate 8 Hz, radio channel 26&lt;br /&gt;
Tentative link-local IPv6 address fe80:0000:0000:0000:0212:7401:0001:0101&lt;br /&gt;
Starting &amp;#039;Border router process&amp;#039; &amp;#039;Web server&amp;#039;&lt;br /&gt;
*** Address:aaaa::1 =&amp;gt; aaaa:0000:0000:0000&lt;br /&gt;
Got configuration message of type P&lt;br /&gt;
Setting prefix aaaa::&lt;br /&gt;
Server IPv6 addresses:&lt;br /&gt;
 aaaa::212:7401:1:101&lt;br /&gt;
 fe80::212:7401:1:101&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Go back to the Cooja simulator GUI and look at the dialogue box. The message has now changed to &amp;#039;Client connected: /127.0.0.1&amp;#039;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Client_Connected.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Verifying Results ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can verify that the address of the border router has been set by using the ping command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7401:1:101&lt;br /&gt;
PING aaaa::212:7401:1:101(aaaa::212:7401:1:101) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=1 ttl=64 time=86.0 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=2 ttl=64 time=33.6 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=3 ttl=64 time=82.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=4 ttl=64 time=43.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=5 ttl=64 time=70.1 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7401:1:101 ping statistics ---&lt;br /&gt;
5 packets transmitted, 5 received, 0% packet loss, time 4006ms&lt;br /&gt;
rtt min/avg/max/mdev = 33.669/63.090/86.015/20.985 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also ping one of the other nodes in the network. Here we are pinging node 4&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7404:4:404&lt;br /&gt;
PING aaaa::212:7404:4:404(aaaa::212:7404:4:404) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=1 ttl=63 time=670 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=2 ttl=63 time=703 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=3 ttl=63 time=746 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=4 ttl=63 time=674 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7404:4:404 ping statistics ---&lt;br /&gt;
5 packets transmitted, 4 received, 20% packet loss, time 4001ms&lt;br /&gt;
rtt min/avg/max/mdev = 670.230/698.666/746.619/30.514 ms&lt;br /&gt;
user@instant-contiki:~/contiki-2.7$ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IPv6 address of a node can be checked from the log screen on Cooja. Filter the nodes by their ID&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Node_Address.png]]&lt;br /&gt;
&lt;br /&gt;
You can enter the address of the border router in the web browser. The border router host a page which will be displayed on the browser as shown below. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:RPL_Browser.png]]&lt;br /&gt;
&lt;br /&gt;
== Common Issues ==&lt;br /&gt;
&lt;br /&gt;
1. Make sure that you enter the IPv6 address properly in the command sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64 . There should be no spaces in aaaa::1/64. Otherwise the code will give unexpected behavior.&amp;lt;br&amp;gt;&lt;br /&gt;
2. When you pause the simulation the SLIP connection is lost. It might not work properly on resuming the simulation. In such cases reload the simulation. Create a fresh SLIP connection and then run the simulation again.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
[https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md]  https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md &amp;lt;br&amp;gt;&lt;br /&gt;
[http://cnds.eecs.jacobs-university.de/courses/iotlab-2013/cooja.pdf] Using the Contiki Cooja Simulator - Anuj Sehgal&lt;/div&gt;</summary>
		<author><name>Ckapoor</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1411</id>
		<title>RPL Border Router</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1411"/>
				<updated>2014-11-09T06:40:53Z</updated>
		
		<summary type="html">&lt;p&gt;Ckapoor: /* Testing on Cooja */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction: ==&lt;br /&gt;
  &lt;br /&gt;
Border routers are routers that can be found at the edge of a network. Their function is to connect one network to another. In this tutorial we will learn how to run a simulation using the border router in Contiki 2.7. In the example which we will discuss in the rest of this tutorial the border router will be used to route data between a WSN (RPL network) and an external IP network.  &lt;br /&gt;
&lt;br /&gt;
[[File:Diagram.png]]&lt;br /&gt;
&lt;br /&gt;
Objective:  &lt;br /&gt;
The objective of this tutorial is to give you an understanding of the RPL Border Router code in Contiki 2.7 OS and learn how to simulate a network with a border router on Cooja &lt;br /&gt;
&lt;br /&gt;
At the end of the tutorial you would have learnt the following: &lt;br /&gt;
&lt;br /&gt;
1. Understanding the working of the rpl border router code &amp;lt;br&amp;gt;&lt;br /&gt;
2. Starting a simulation on Cooja simulator. &amp;lt;br&amp;gt; &lt;br /&gt;
3. Observing and validating the results &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code building blocks. ==&lt;br /&gt;
 &lt;br /&gt;
We will be using the following files &lt;br /&gt;
&lt;br /&gt;
1. border-router.c &amp;lt;br&amp;gt;&lt;br /&gt;
2. udp-server.c  (udp-client.c can also be used)&amp;lt;br&amp;gt;&lt;br /&gt;
3. slip-bridge.c (It contains callback function for processing a SLIP connection request) &amp;lt;br&amp;gt;&lt;br /&gt;
4. httpd-simple.c   (A simple web server forwarding page generation to a protothread)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
udp-server nodes will form a DAG with the border router set as the root. The border router will receive the prefix through a [SLIP][http://en.wikipedia.org/wiki/Serial_Line_Internet_Protocol] (Serial Line Interface Protocol) connection and it will be communicated to the rest of the nodes in the RPL network. &lt;br /&gt;
&lt;br /&gt;
Refer to the following code snippets in the file border-router.c In this piece of code the node configured as the border router waits for the prefix to be set. Once it receives the prefix, the border router is set as the root of the DAG after which it sets the prefix of the rest of the nodes in the network.  &lt;br /&gt;
 &lt;br /&gt;
 /* Request prefix until it has been received */ &lt;br /&gt;
  while(!prefix_set) { &lt;br /&gt;
    etimer_set(&amp;amp;et, CLOCK_SECOND); &lt;br /&gt;
    request_prefix(); &lt;br /&gt;
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&amp;amp;et)); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
  dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)dag_id); &lt;br /&gt;
  if(dag != NULL) { &lt;br /&gt;
    rpl_set_prefix(dag, &amp;amp;prefix, 64); &lt;br /&gt;
    PRINTF(&amp;quot;created a new RPL dag\n&amp;quot;); &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
By default the border router hosts a simple web page. However this can be disabled by defining WEBSERVER as seen the code snippet below. This webpage is displayed when the IPv6 address of the border router is entered in the browser. Refer to the file httpd-simple.c for the following code snippet&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;PROCESS(border_router_process, &amp;quot;Border router process&amp;quot;);&lt;br /&gt;
#if WEBSERVER==0&lt;br /&gt;
/* No webserver */&lt;br /&gt;
AUTOSTART_PROCESSES(&amp;amp;border_router_process);&lt;br /&gt;
#elif WEBSERVER&amp;gt;1&lt;br /&gt;
/* Use an external webserver application */&lt;br /&gt;
#include &amp;quot;webserver-nogui.h&amp;quot;&lt;br /&gt;
AUTOSTART_PROCESSES(&amp;amp;border_router_process,&amp;amp;webserver_nogui_process); &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Compiling the code ==&lt;br /&gt;
 &lt;br /&gt;
The code for RPL border router can be found at /contiki-2.7/examples/ipv6/rpl-border-router. Use the following command to compile the code for the border router &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-border-router &lt;br /&gt;
make TARGET=sky. &amp;lt;/pre&amp;gt;   &lt;br /&gt;
Once this command has been successfully executed, a file named border-router.sky will be created. This file will be used to program one of the motes as the border router on Cooja.  &lt;br /&gt;
For the purpose of this tutorial we will  select  TMote Sky  as our target. &lt;br /&gt;
&lt;br /&gt;
In order to demonstrate the functionality of the border router we will create a network of nodes with the border router as the root. For creating such a network we will user the udp-server.c code.  &lt;br /&gt;
This code can be found at /contiki-2.7/examples/ipv6/rpl-udp . Use the following command to compile the code for rpl-udp &lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-udp &lt;br /&gt;
make TARGET=sky &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once this command has been successfully executed a file named udp-server.sky will be created. This file will be used to program the remaining nodes in Cooja simulator. These nodes will form a DAG with the rpl border router as the root.&lt;br /&gt;
&lt;br /&gt;
== Testing on Cooja ==&lt;br /&gt;
 &lt;br /&gt;
Upon the successful completion of the above mentioned steps we are ready to create a simulation in Cooja.  &lt;br /&gt;
Start the Cooja simulator using the following command &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd /contiki-2.7/tools/cooja &lt;br /&gt;
ant run&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
When the GUI launches execute the following steps to create a simulation. &amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
1. From &amp;#039;File&amp;#039; select &amp;#039;New Simulation&amp;#039;. Select &amp;#039;UDGM&amp;#039;, enter the name of the simulation and click on &amp;#039;create&amp;#039;. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Click on &amp;#039;Motes&amp;#039;. From the drop down menu select &amp;#039;Add New Motes&amp;#039; followed by &amp;#039;Create new motes&amp;#039; and select the mote type as &amp;#039;Sky&amp;#039;. &amp;lt;br&amp;gt;&lt;br /&gt;
3. Browse to the location /contiki-2.7/examples/ipv6/rpl-border-router and select the file rpl-border-router.sky. Click on &amp;#039;Create&amp;#039;. Add one mote of this type. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Repeat step 2 and 3 but this time browse to the location /contiki-2.7/examples/ipv6/rpl-udp  and select the file udp-server.sky. Add 3 - 4 motes of the type udp-server &amp;lt;br&amp;gt;&lt;br /&gt;
5. Once the motes have been added you can position the motes. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Cooja_motes.png]]&lt;br /&gt;
&lt;br /&gt;
Select the options under View as shown below. These will help you creating a topology of your choice.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Motes_view.png]]&lt;br /&gt;
&lt;br /&gt;
6. Now, we need to create a bridge between the RPL network simulated on Cooja and the local machine. This can be done by right clicking on the mote which is programmed as the border router. Select &amp;#039;More tools for border router&amp;#039; and then select &amp;#039;Serial Socket (SERVER)&amp;#039;. You will get the following message on the successful completion of this step.Note that the message says &amp;#039;Listening on port 60001&amp;#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Serial_Socket.png]]&lt;br /&gt;
&lt;br /&gt;
7. Now start the simulation by clicking on Start&lt;br /&gt;
&lt;br /&gt;
== Tunslip utility ==&lt;br /&gt;
 &lt;br /&gt;
As mentioned in the introduction a border router helps in connecting one network to another. In this example the border router is used to route data between an RPL network and an external network. Till now we have only created the RPL network. Now we need to simulate the scenario in which this RPL network is connected to an external network. For this purpose we will use the Tunslip utility provided in Contiki. In this example tunslip creates a bridge between the RPL network and the local machine. &lt;br /&gt;
tunslip6.c can be found in /contiki-2.7/tools &lt;br /&gt;
Compile the tunslip6 code.&lt;br /&gt;
&amp;lt;pre&amp;gt;make tunslip6 &amp;lt;/pre&amp;gt; &lt;br /&gt;
Make a connection between the RPL network and your local machine. &lt;br /&gt;
&amp;lt;pre&amp;gt;sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64&amp;lt;/pre&amp;gt;&lt;br /&gt;
On the successful execution this command the following output will be printed on the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;slip connected to ``127.0.0.1:60001&amp;#039;&amp;#039;&lt;br /&gt;
opened tun device ``/dev/tun0&amp;#039;&amp;#039;&lt;br /&gt;
ifconfig tun0 inet `hostname` up&lt;br /&gt;
ifconfig tun0 add aaaa::1/64&lt;br /&gt;
ifconfig tun0 add fe80::0:0:0:1/64&lt;br /&gt;
ifconfig tun0&lt;br /&gt;
&lt;br /&gt;
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  &lt;br /&gt;
          inet addr:127.0.1.1  P-t-P:127.0.1.1  Mask:255.255.255.255&lt;br /&gt;
          inet6 addr: fe80::1/64 Scope:Link&lt;br /&gt;
          inet6 addr: aaaa::1/64 Scope:Global&lt;br /&gt;
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1&lt;br /&gt;
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0&lt;br /&gt;
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0&lt;br /&gt;
          collisions:0 txqueuelen:500 &lt;br /&gt;
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)&lt;br /&gt;
&lt;br /&gt;
Rime started with address 0.18.116.1.0.1.1.1&lt;br /&gt;
MAC 00:12:74:01:00:01:01:01 Contiki 2.7 started. Node id is set to 1.&lt;br /&gt;
CSMA ContikiMAC, channel check rate 8 Hz, radio channel 26&lt;br /&gt;
Tentative link-local IPv6 address fe80:0000:0000:0000:0212:7401:0001:0101&lt;br /&gt;
Starting &amp;#039;Border router process&amp;#039; &amp;#039;Web server&amp;#039;&lt;br /&gt;
*** Address:aaaa::1 =&amp;gt; aaaa:0000:0000:0000&lt;br /&gt;
Got configuration message of type P&lt;br /&gt;
Setting prefix aaaa::&lt;br /&gt;
Server IPv6 addresses:&lt;br /&gt;
 aaaa::212:7401:1:101&lt;br /&gt;
 fe80::212:7401:1:101&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Go back to the Cooja simulator GUI and look at the dialogue box. The message has now changed to &amp;#039;Client connected: /127.0.0.1&amp;#039;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Client_Connected.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Verifying Results ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can verify that the address of the border router has been set by using the ping command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7401:1:101&lt;br /&gt;
PING aaaa::212:7401:1:101(aaaa::212:7401:1:101) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=1 ttl=64 time=86.0 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=2 ttl=64 time=33.6 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=3 ttl=64 time=82.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=4 ttl=64 time=43.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=5 ttl=64 time=70.1 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7401:1:101 ping statistics ---&lt;br /&gt;
5 packets transmitted, 5 received, 0% packet loss, time 4006ms&lt;br /&gt;
rtt min/avg/max/mdev = 33.669/63.090/86.015/20.985 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also ping one of the other nodes in the network. Here we are pinging node 4&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7404:4:404&lt;br /&gt;
PING aaaa::212:7404:4:404(aaaa::212:7404:4:404) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=1 ttl=63 time=670 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=2 ttl=63 time=703 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=3 ttl=63 time=746 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=4 ttl=63 time=674 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7404:4:404 ping statistics ---&lt;br /&gt;
5 packets transmitted, 4 received, 20% packet loss, time 4001ms&lt;br /&gt;
rtt min/avg/max/mdev = 670.230/698.666/746.619/30.514 ms&lt;br /&gt;
user@instant-contiki:~/contiki-2.7$ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IPv6 address of a node can be checked from the log screen on Cooja. Filter the nodes by their ID&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Node_Address.png]]&lt;br /&gt;
&lt;br /&gt;
You can enter the address of the border router in the web browser. The border router host a page which will be displayed on the browser as shown below. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:RPL_Browser.png]]&lt;br /&gt;
&lt;br /&gt;
== Common Issues ==&lt;br /&gt;
&lt;br /&gt;
1. Make sure that you enter the IPv6 address properly in the command sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64 . There should be no spaces in aaaa::1/64. Otherwise the code will give unexpected behavior.&amp;lt;br&amp;gt;&lt;br /&gt;
2. When you pause the simulation the SLIP connection is lost. It might not work properly on resuming the simulation. In such cases reload the simulation. Create a fresh SLIP connection and then run the simulation again.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
[https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md]  https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md &amp;lt;br&amp;gt;&lt;br /&gt;
[http://cnds.eecs.jacobs-university.de/courses/iotlab-2013/cooja.pdf] Using the Contiki Cooja Simulator - Anuj Sehgal&lt;/div&gt;</summary>
		<author><name>Ckapoor</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1408</id>
		<title>RPL Border Router</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1408"/>
				<updated>2014-11-09T06:39:15Z</updated>
		
		<summary type="html">&lt;p&gt;Ckapoor: /* Compiling the code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction: ==&lt;br /&gt;
  &lt;br /&gt;
Border routers are routers that can be found at the edge of a network. Their function is to connect one network to another. In this tutorial we will learn how to run a simulation using the border router in Contiki 2.7. In the example which we will discuss in the rest of this tutorial the border router will be used to route data between a WSN (RPL network) and an external IP network.  &lt;br /&gt;
&lt;br /&gt;
[[File:Diagram.png]]&lt;br /&gt;
&lt;br /&gt;
Objective:  &lt;br /&gt;
The objective of this tutorial is to give you an understanding of the RPL Border Router code in Contiki 2.7 OS and learn how to simulate a network with a border router on Cooja &lt;br /&gt;
&lt;br /&gt;
At the end of the tutorial you would have learnt the following: &lt;br /&gt;
&lt;br /&gt;
1. Understanding the working of the rpl border router code &amp;lt;br&amp;gt;&lt;br /&gt;
2. Starting a simulation on Cooja simulator. &amp;lt;br&amp;gt; &lt;br /&gt;
3. Observing and validating the results &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code building blocks. ==&lt;br /&gt;
 &lt;br /&gt;
We will be using the following files &lt;br /&gt;
&lt;br /&gt;
1. border-router.c &amp;lt;br&amp;gt;&lt;br /&gt;
2. udp-server.c  (udp-client.c can also be used)&amp;lt;br&amp;gt;&lt;br /&gt;
3. slip-bridge.c (It contains callback function for processing a SLIP connection request) &amp;lt;br&amp;gt;&lt;br /&gt;
4. httpd-simple.c   (A simple web server forwarding page generation to a protothread)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
udp-server nodes will form a DAG with the border router set as the root. The border router will receive the prefix through a [SLIP][http://en.wikipedia.org/wiki/Serial_Line_Internet_Protocol] (Serial Line Interface Protocol) connection and it will be communicated to the rest of the nodes in the RPL network. &lt;br /&gt;
&lt;br /&gt;
Refer to the following code snippets in the file border-router.c In this piece of code the node configured as the border router waits for the prefix to be set. Once it receives the prefix, the border router is set as the root of the DAG after which it sets the prefix of the rest of the nodes in the network.  &lt;br /&gt;
 &lt;br /&gt;
 /* Request prefix until it has been received */ &lt;br /&gt;
  while(!prefix_set) { &lt;br /&gt;
    etimer_set(&amp;amp;et, CLOCK_SECOND); &lt;br /&gt;
    request_prefix(); &lt;br /&gt;
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&amp;amp;et)); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
  dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)dag_id); &lt;br /&gt;
  if(dag != NULL) { &lt;br /&gt;
    rpl_set_prefix(dag, &amp;amp;prefix, 64); &lt;br /&gt;
    PRINTF(&amp;quot;created a new RPL dag\n&amp;quot;); &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
By default the border router hosts a simple web page. However this can be disabled by defining WEBSERVER as seen the code snippet below. This webpage is displayed when the IPv6 address of the border router is entered in the browser. Refer to the file httpd-simple.c for the following code snippet&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;PROCESS(border_router_process, &amp;quot;Border router process&amp;quot;);&lt;br /&gt;
#if WEBSERVER==0&lt;br /&gt;
/* No webserver */&lt;br /&gt;
AUTOSTART_PROCESSES(&amp;amp;border_router_process);&lt;br /&gt;
#elif WEBSERVER&amp;gt;1&lt;br /&gt;
/* Use an external webserver application */&lt;br /&gt;
#include &amp;quot;webserver-nogui.h&amp;quot;&lt;br /&gt;
AUTOSTART_PROCESSES(&amp;amp;border_router_process,&amp;amp;webserver_nogui_process); &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Compiling the code ==&lt;br /&gt;
 &lt;br /&gt;
The code for RPL border router can be found at /contiki-2.7/examples/ipv6/rpl-border-router. Use the following command to compile the code for the border router &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-border-router &lt;br /&gt;
make TARGET=sky. &amp;lt;/pre&amp;gt;   &lt;br /&gt;
Once this command has been successfully executed, a file named border-router.sky will be created. This file will be used to program one of the motes as the border router on Cooja.  &lt;br /&gt;
For the purpose of this tutorial we will  select  TMote Sky  as our target. &lt;br /&gt;
&lt;br /&gt;
In order to demonstrate the functionality of the border router we will create a network of nodes with the border router as the root. For creating such a network we will user the udp-server.c code.  &lt;br /&gt;
This code can be found at /contiki-2.7/examples/ipv6/rpl-udp . Use the following command to compile the code for rpl-udp &lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-udp &lt;br /&gt;
make TARGET=sky &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once this command has been successfully executed a file named udp-server.sky will be created. This file will be used to program the remaining nodes in Cooja simulator. These nodes will form a DAG with the rpl border router as the root.&lt;br /&gt;
&lt;br /&gt;
== Testing on Cooja ==&lt;br /&gt;
 &lt;br /&gt;
Upon the successful completion of the above mentioned steps we are ready to create a simulation in Cooja.  &lt;br /&gt;
Start the Cooja simulator using the following command &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd /contiki-2.7/tools/cooja &lt;br /&gt;
ant run&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
When the GUI launches execute the following steps to create a simulation. &amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
1. From &amp;#039;File&amp;#039; select &amp;#039;New Simulation&amp;#039;. Select UDGM, enter the name of the simulation and click on create. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Click on Motes. From the drop down menu select &amp;#039;Add New Motes&amp;#039; followed by &amp;#039;Create new motes&amp;#039; and select the mote type as Sky. &amp;lt;br&amp;gt;&lt;br /&gt;
3. Browse to the location /contiki-2.7/examples/ipv6/rpl-border-router and select the file rpl-border-router.sky. Click on &amp;#039;Create&amp;#039;. Add one mote of this type. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Repeat step 2 and 3 but this time browse to the location /contiki-2.7/examples/ipv6/rpl-udp  and select the file udp-server.sky. Add 3 - 4 motes of the type udp-server &amp;lt;br&amp;gt;&lt;br /&gt;
5. Once the motes have been added you can position the motes. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Cooja_motes.png]]&lt;br /&gt;
&lt;br /&gt;
Select the options under View as shown below. These will help you creating a topology of your choice.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Motes_view.png]]&lt;br /&gt;
&lt;br /&gt;
6. Now, we need to create a bridge between the RPL network simulated on Cooja and the local machine. This can be done by right clicking on the mote which is programmed as the border router. Select &amp;#039;More tools for border router&amp;#039; and then select &amp;#039;Serial Socket (SERVER)&amp;#039;. You will get the following message on the successful completion of this step.Note that the message says &amp;#039;Listening on port 60001&amp;#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Serial_Socket.png]]&lt;br /&gt;
&lt;br /&gt;
7. Now start the simulation by clicking on Start&lt;br /&gt;
&lt;br /&gt;
== Tunslip utility ==&lt;br /&gt;
 &lt;br /&gt;
As mentioned in the introduction a border router helps in connecting one network to another. In this example the border router is used to route data between an RPL network and an external network. Till now we have only created the RPL network. Now we need to simulate the scenario in which this RPL network is connected to an external network. For this purpose we will use the Tunslip utility provided in Contiki. In this example tunslip creates a bridge between the RPL network and the local machine. &lt;br /&gt;
tunslip6.c can be found in /contiki-2.7/tools &lt;br /&gt;
Compile the tunslip6 code.&lt;br /&gt;
&amp;lt;pre&amp;gt;make tunslip6 &amp;lt;/pre&amp;gt; &lt;br /&gt;
Make a connection between the RPL network and your local machine. &lt;br /&gt;
&amp;lt;pre&amp;gt;sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64&amp;lt;/pre&amp;gt;&lt;br /&gt;
On the successful execution this command the following output will be printed on the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;slip connected to ``127.0.0.1:60001&amp;#039;&amp;#039;&lt;br /&gt;
opened tun device ``/dev/tun0&amp;#039;&amp;#039;&lt;br /&gt;
ifconfig tun0 inet `hostname` up&lt;br /&gt;
ifconfig tun0 add aaaa::1/64&lt;br /&gt;
ifconfig tun0 add fe80::0:0:0:1/64&lt;br /&gt;
ifconfig tun0&lt;br /&gt;
&lt;br /&gt;
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  &lt;br /&gt;
          inet addr:127.0.1.1  P-t-P:127.0.1.1  Mask:255.255.255.255&lt;br /&gt;
          inet6 addr: fe80::1/64 Scope:Link&lt;br /&gt;
          inet6 addr: aaaa::1/64 Scope:Global&lt;br /&gt;
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1&lt;br /&gt;
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0&lt;br /&gt;
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0&lt;br /&gt;
          collisions:0 txqueuelen:500 &lt;br /&gt;
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)&lt;br /&gt;
&lt;br /&gt;
Rime started with address 0.18.116.1.0.1.1.1&lt;br /&gt;
MAC 00:12:74:01:00:01:01:01 Contiki 2.7 started. Node id is set to 1.&lt;br /&gt;
CSMA ContikiMAC, channel check rate 8 Hz, radio channel 26&lt;br /&gt;
Tentative link-local IPv6 address fe80:0000:0000:0000:0212:7401:0001:0101&lt;br /&gt;
Starting &amp;#039;Border router process&amp;#039; &amp;#039;Web server&amp;#039;&lt;br /&gt;
*** Address:aaaa::1 =&amp;gt; aaaa:0000:0000:0000&lt;br /&gt;
Got configuration message of type P&lt;br /&gt;
Setting prefix aaaa::&lt;br /&gt;
Server IPv6 addresses:&lt;br /&gt;
 aaaa::212:7401:1:101&lt;br /&gt;
 fe80::212:7401:1:101&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Go back to the Cooja simulator GUI and look at the dialogue box. The message has now changed to &amp;#039;Client connected: /127.0.0.1&amp;#039;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Client_Connected.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Verifying Results ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can verify that the address of the border router has been set by using the ping command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7401:1:101&lt;br /&gt;
PING aaaa::212:7401:1:101(aaaa::212:7401:1:101) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=1 ttl=64 time=86.0 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=2 ttl=64 time=33.6 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=3 ttl=64 time=82.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=4 ttl=64 time=43.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=5 ttl=64 time=70.1 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7401:1:101 ping statistics ---&lt;br /&gt;
5 packets transmitted, 5 received, 0% packet loss, time 4006ms&lt;br /&gt;
rtt min/avg/max/mdev = 33.669/63.090/86.015/20.985 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also ping one of the other nodes in the network. Here we are pinging node 4&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7404:4:404&lt;br /&gt;
PING aaaa::212:7404:4:404(aaaa::212:7404:4:404) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=1 ttl=63 time=670 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=2 ttl=63 time=703 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=3 ttl=63 time=746 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=4 ttl=63 time=674 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7404:4:404 ping statistics ---&lt;br /&gt;
5 packets transmitted, 4 received, 20% packet loss, time 4001ms&lt;br /&gt;
rtt min/avg/max/mdev = 670.230/698.666/746.619/30.514 ms&lt;br /&gt;
user@instant-contiki:~/contiki-2.7$ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IPv6 address of a node can be checked from the log screen on Cooja. Filter the nodes by their ID&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Node_Address.png]]&lt;br /&gt;
&lt;br /&gt;
You can enter the address of the border router in the web browser. The border router host a page which will be displayed on the browser as shown below. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:RPL_Browser.png]]&lt;br /&gt;
&lt;br /&gt;
== Common Issues ==&lt;br /&gt;
&lt;br /&gt;
1. Make sure that you enter the IPv6 address properly in the command sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64 . There should be no spaces in aaaa::1/64. Otherwise the code will give unexpected behavior.&amp;lt;br&amp;gt;&lt;br /&gt;
2. When you pause the simulation the SLIP connection is lost. It might not work properly on resuming the simulation. In such cases reload the simulation. Create a fresh SLIP connection and then run the simulation again.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
[https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md]  https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md &amp;lt;br&amp;gt;&lt;br /&gt;
[http://cnds.eecs.jacobs-university.de/courses/iotlab-2013/cooja.pdf] Using the Contiki Cooja Simulator - Anuj Sehgal&lt;/div&gt;</summary>
		<author><name>Ckapoor</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1406</id>
		<title>RPL Border Router</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1406"/>
				<updated>2014-11-09T06:38:39Z</updated>
		
		<summary type="html">&lt;p&gt;Ckapoor: /* Code building blocks. */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction: ==&lt;br /&gt;
  &lt;br /&gt;
Border routers are routers that can be found at the edge of a network. Their function is to connect one network to another. In this tutorial we will learn how to run a simulation using the border router in Contiki 2.7. In the example which we will discuss in the rest of this tutorial the border router will be used to route data between a WSN (RPL network) and an external IP network.  &lt;br /&gt;
&lt;br /&gt;
[[File:Diagram.png]]&lt;br /&gt;
&lt;br /&gt;
Objective:  &lt;br /&gt;
The objective of this tutorial is to give you an understanding of the RPL Border Router code in Contiki 2.7 OS and learn how to simulate a network with a border router on Cooja &lt;br /&gt;
&lt;br /&gt;
At the end of the tutorial you would have learnt the following: &lt;br /&gt;
&lt;br /&gt;
1. Understanding the working of the rpl border router code &amp;lt;br&amp;gt;&lt;br /&gt;
2. Starting a simulation on Cooja simulator. &amp;lt;br&amp;gt; &lt;br /&gt;
3. Observing and validating the results &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code building blocks. ==&lt;br /&gt;
 &lt;br /&gt;
We will be using the following files &lt;br /&gt;
&lt;br /&gt;
1. border-router.c &amp;lt;br&amp;gt;&lt;br /&gt;
2. udp-server.c  (udp-client.c can also be used)&amp;lt;br&amp;gt;&lt;br /&gt;
3. slip-bridge.c (It contains callback function for processing a SLIP connection request) &amp;lt;br&amp;gt;&lt;br /&gt;
4. httpd-simple.c   (A simple web server forwarding page generation to a protothread)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
udp-server nodes will form a DAG with the border router set as the root. The border router will receive the prefix through a [SLIP][http://en.wikipedia.org/wiki/Serial_Line_Internet_Protocol] (Serial Line Interface Protocol) connection and it will be communicated to the rest of the nodes in the RPL network. &lt;br /&gt;
&lt;br /&gt;
Refer to the following code snippets in the file border-router.c In this piece of code the node configured as the border router waits for the prefix to be set. Once it receives the prefix, the border router is set as the root of the DAG after which it sets the prefix of the rest of the nodes in the network.  &lt;br /&gt;
 &lt;br /&gt;
 /* Request prefix until it has been received */ &lt;br /&gt;
  while(!prefix_set) { &lt;br /&gt;
    etimer_set(&amp;amp;et, CLOCK_SECOND); &lt;br /&gt;
    request_prefix(); &lt;br /&gt;
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&amp;amp;et)); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
  dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)dag_id); &lt;br /&gt;
  if(dag != NULL) { &lt;br /&gt;
    rpl_set_prefix(dag, &amp;amp;prefix, 64); &lt;br /&gt;
    PRINTF(&amp;quot;created a new RPL dag\n&amp;quot;); &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
By default the border router hosts a simple web page. However this can be disabled by defining WEBSERVER as seen the code snippet below. This webpage is displayed when the IPv6 address of the border router is entered in the browser. Refer to the file httpd-simple.c for the following code snippet&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;PROCESS(border_router_process, &amp;quot;Border router process&amp;quot;);&lt;br /&gt;
#if WEBSERVER==0&lt;br /&gt;
/* No webserver */&lt;br /&gt;
AUTOSTART_PROCESSES(&amp;amp;border_router_process);&lt;br /&gt;
#elif WEBSERVER&amp;gt;1&lt;br /&gt;
/* Use an external webserver application */&lt;br /&gt;
#include &amp;quot;webserver-nogui.h&amp;quot;&lt;br /&gt;
AUTOSTART_PROCESSES(&amp;amp;border_router_process,&amp;amp;webserver_nogui_process); &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Compiling the code ==&lt;br /&gt;
 &lt;br /&gt;
The code for RPL border router can be found at /contiki-2.7/examples/ipv6/rpl-border-router. Use the following command to compile the code for the border router &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-border-router &lt;br /&gt;
make TARGET=sky. &amp;lt;/pre&amp;gt;   &lt;br /&gt;
Once this command has been successfully executed a file named border-router.sky will be created. This file will be used to program one of the motes as the border router on Cooja.  &lt;br /&gt;
For the purpose of this tutorial we will  select  TMote Sky  as our target. &lt;br /&gt;
&lt;br /&gt;
In order to demonstrate the functionality of the border router we will create a network of nodes with the border router as the root. For creating such a network we will user the udp-server.c code.  &lt;br /&gt;
This code can be found at /contiki-2.7/examples/ipv6/rpl-udp . Use the following command to compile the code for rpl-udp &lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-udp &lt;br /&gt;
make TARGET=sky &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once this command has been successfully executed a file named udp-server.sky will be created. This file will be used to program the remaining nodes in Cooja simulator. These nodes will form a DAG with the rpl border router as the root.&lt;br /&gt;
&lt;br /&gt;
== Testing on Cooja ==&lt;br /&gt;
 &lt;br /&gt;
Upon the successful completion of the above mentioned steps we are ready to create a simulation in Cooja.  &lt;br /&gt;
Start the Cooja simulator using the following command &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd /contiki-2.7/tools/cooja &lt;br /&gt;
ant run&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
When the GUI launches execute the following steps to create a simulation. &amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
1. From &amp;#039;File&amp;#039; select &amp;#039;New Simulation&amp;#039;. Select UDGM, enter the name of the simulation and click on create. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Click on Motes. From the drop down menu select &amp;#039;Add New Motes&amp;#039; followed by &amp;#039;Create new motes&amp;#039; and select the mote type as Sky. &amp;lt;br&amp;gt;&lt;br /&gt;
3. Browse to the location /contiki-2.7/examples/ipv6/rpl-border-router and select the file rpl-border-router.sky. Click on &amp;#039;Create&amp;#039;. Add one mote of this type. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Repeat step 2 and 3 but this time browse to the location /contiki-2.7/examples/ipv6/rpl-udp  and select the file udp-server.sky. Add 3 - 4 motes of the type udp-server &amp;lt;br&amp;gt;&lt;br /&gt;
5. Once the motes have been added you can position the motes. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Cooja_motes.png]]&lt;br /&gt;
&lt;br /&gt;
Select the options under View as shown below. These will help you creating a topology of your choice.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Motes_view.png]]&lt;br /&gt;
&lt;br /&gt;
6. Now, we need to create a bridge between the RPL network simulated on Cooja and the local machine. This can be done by right clicking on the mote which is programmed as the border router. Select &amp;#039;More tools for border router&amp;#039; and then select &amp;#039;Serial Socket (SERVER)&amp;#039;. You will get the following message on the successful completion of this step.Note that the message says &amp;#039;Listening on port 60001&amp;#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Serial_Socket.png]]&lt;br /&gt;
&lt;br /&gt;
7. Now start the simulation by clicking on Start&lt;br /&gt;
&lt;br /&gt;
== Tunslip utility ==&lt;br /&gt;
 &lt;br /&gt;
As mentioned in the introduction a border router helps in connecting one network to another. In this example the border router is used to route data between an RPL network and an external network. Till now we have only created the RPL network. Now we need to simulate the scenario in which this RPL network is connected to an external network. For this purpose we will use the Tunslip utility provided in Contiki. In this example tunslip creates a bridge between the RPL network and the local machine. &lt;br /&gt;
tunslip6.c can be found in /contiki-2.7/tools &lt;br /&gt;
Compile the tunslip6 code.&lt;br /&gt;
&amp;lt;pre&amp;gt;make tunslip6 &amp;lt;/pre&amp;gt; &lt;br /&gt;
Make a connection between the RPL network and your local machine. &lt;br /&gt;
&amp;lt;pre&amp;gt;sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64&amp;lt;/pre&amp;gt;&lt;br /&gt;
On the successful execution this command the following output will be printed on the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;slip connected to ``127.0.0.1:60001&amp;#039;&amp;#039;&lt;br /&gt;
opened tun device ``/dev/tun0&amp;#039;&amp;#039;&lt;br /&gt;
ifconfig tun0 inet `hostname` up&lt;br /&gt;
ifconfig tun0 add aaaa::1/64&lt;br /&gt;
ifconfig tun0 add fe80::0:0:0:1/64&lt;br /&gt;
ifconfig tun0&lt;br /&gt;
&lt;br /&gt;
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  &lt;br /&gt;
          inet addr:127.0.1.1  P-t-P:127.0.1.1  Mask:255.255.255.255&lt;br /&gt;
          inet6 addr: fe80::1/64 Scope:Link&lt;br /&gt;
          inet6 addr: aaaa::1/64 Scope:Global&lt;br /&gt;
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1&lt;br /&gt;
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0&lt;br /&gt;
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0&lt;br /&gt;
          collisions:0 txqueuelen:500 &lt;br /&gt;
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)&lt;br /&gt;
&lt;br /&gt;
Rime started with address 0.18.116.1.0.1.1.1&lt;br /&gt;
MAC 00:12:74:01:00:01:01:01 Contiki 2.7 started. Node id is set to 1.&lt;br /&gt;
CSMA ContikiMAC, channel check rate 8 Hz, radio channel 26&lt;br /&gt;
Tentative link-local IPv6 address fe80:0000:0000:0000:0212:7401:0001:0101&lt;br /&gt;
Starting &amp;#039;Border router process&amp;#039; &amp;#039;Web server&amp;#039;&lt;br /&gt;
*** Address:aaaa::1 =&amp;gt; aaaa:0000:0000:0000&lt;br /&gt;
Got configuration message of type P&lt;br /&gt;
Setting prefix aaaa::&lt;br /&gt;
Server IPv6 addresses:&lt;br /&gt;
 aaaa::212:7401:1:101&lt;br /&gt;
 fe80::212:7401:1:101&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Go back to the Cooja simulator GUI and look at the dialogue box. The message has now changed to &amp;#039;Client connected: /127.0.0.1&amp;#039;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Client_Connected.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Verifying Results ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can verify that the address of the border router has been set by using the ping command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7401:1:101&lt;br /&gt;
PING aaaa::212:7401:1:101(aaaa::212:7401:1:101) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=1 ttl=64 time=86.0 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=2 ttl=64 time=33.6 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=3 ttl=64 time=82.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=4 ttl=64 time=43.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=5 ttl=64 time=70.1 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7401:1:101 ping statistics ---&lt;br /&gt;
5 packets transmitted, 5 received, 0% packet loss, time 4006ms&lt;br /&gt;
rtt min/avg/max/mdev = 33.669/63.090/86.015/20.985 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also ping one of the other nodes in the network. Here we are pinging node 4&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7404:4:404&lt;br /&gt;
PING aaaa::212:7404:4:404(aaaa::212:7404:4:404) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=1 ttl=63 time=670 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=2 ttl=63 time=703 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=3 ttl=63 time=746 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=4 ttl=63 time=674 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7404:4:404 ping statistics ---&lt;br /&gt;
5 packets transmitted, 4 received, 20% packet loss, time 4001ms&lt;br /&gt;
rtt min/avg/max/mdev = 670.230/698.666/746.619/30.514 ms&lt;br /&gt;
user@instant-contiki:~/contiki-2.7$ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IPv6 address of a node can be checked from the log screen on Cooja. Filter the nodes by their ID&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Node_Address.png]]&lt;br /&gt;
&lt;br /&gt;
You can enter the address of the border router in the web browser. The border router host a page which will be displayed on the browser as shown below. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:RPL_Browser.png]]&lt;br /&gt;
&lt;br /&gt;
== Common Issues ==&lt;br /&gt;
&lt;br /&gt;
1. Make sure that you enter the IPv6 address properly in the command sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64 . There should be no spaces in aaaa::1/64. Otherwise the code will give unexpected behavior.&amp;lt;br&amp;gt;&lt;br /&gt;
2. When you pause the simulation the SLIP connection is lost. It might not work properly on resuming the simulation. In such cases reload the simulation. Create a fresh SLIP connection and then run the simulation again.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
[https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md]  https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md &amp;lt;br&amp;gt;&lt;br /&gt;
[http://cnds.eecs.jacobs-university.de/courses/iotlab-2013/cooja.pdf] Using the Contiki Cooja Simulator - Anuj Sehgal&lt;/div&gt;</summary>
		<author><name>Ckapoor</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1176</id>
		<title>RPL Border Router</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1176"/>
				<updated>2014-11-09T00:14:47Z</updated>
		
		<summary type="html">&lt;p&gt;Ckapoor: /* Introduction: */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction: ==&lt;br /&gt;
  &lt;br /&gt;
Border routers are routers that can be found at the edge of a network. Their function is to connect one network to another. In this tutorial we will learn how to run a simulation using the border router in Contiki 2.7. In the example which we will discuss in the rest of this tutorial the border router will be used to route data between a WSN (RPL network) and an external IP network.  &lt;br /&gt;
&lt;br /&gt;
[[File:Diagram.png]]&lt;br /&gt;
&lt;br /&gt;
Objective:  &lt;br /&gt;
The objective of this tutorial is to give you an understanding of the RPL Border Router code in Contiki 2.7 OS and learn how to simulate a network with a border router on Cooja &lt;br /&gt;
&lt;br /&gt;
At the end of the tutorial you would have learnt the following: &lt;br /&gt;
&lt;br /&gt;
1. Understanding the working of the rpl border router code &amp;lt;br&amp;gt;&lt;br /&gt;
2. Starting a simulation on Cooja simulator. &amp;lt;br&amp;gt; &lt;br /&gt;
3. Observing and validating the results &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code building blocks. ==&lt;br /&gt;
 &lt;br /&gt;
We will using the following files &lt;br /&gt;
&lt;br /&gt;
1. border-router.c &amp;lt;br&amp;gt;&lt;br /&gt;
2. udp-server.c  (udp-client.c can also be used)&amp;lt;br&amp;gt;&lt;br /&gt;
3. slip-bridge.c (It contains callback function for processing a SLIP connection request) &amp;lt;br&amp;gt;&lt;br /&gt;
4. httpd-simple.c   (A simple web server forwarding page generation to a protothread)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
udp-server nodes will form a DAG with the border router set as the root. The border router will receive the prefix through a [SLIP][http://en.wikipedia.org/wiki/Serial_Line_Internet_Protocol] (Serial Line Interface Protocol) connection and it will be communicated to the rest of the nodes in the RPL network. &lt;br /&gt;
&lt;br /&gt;
Refer to the following code snippets in the file border-router.c In this piece of code the node configured as the border router waits for the prefix to be set. Once it receives the prefix, the border router is set as the root of the DAG after which it sets the prefix of the rest of the nodes in the network.  &lt;br /&gt;
 &lt;br /&gt;
 /* Request prefix until it has been received */ &lt;br /&gt;
  while(!prefix_set) { &lt;br /&gt;
    etimer_set(&amp;amp;et, CLOCK_SECOND); &lt;br /&gt;
    request_prefix(); &lt;br /&gt;
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&amp;amp;et)); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
  dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)dag_id); &lt;br /&gt;
  if(dag != NULL) { &lt;br /&gt;
    rpl_set_prefix(dag, &amp;amp;prefix, 64); &lt;br /&gt;
    PRINTF(&amp;quot;created a new RPL dag\n&amp;quot;); &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
By default the border router hosts a simple web page. However this can be disabled by defining WEBSERVER as seen the code snippet below. This webpage is displayed when the IPv6 address of the border router is entered in the browser. Refer to the file httpd-simple.c for the following code snippet&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;PROCESS(border_router_process, &amp;quot;Border router process&amp;quot;);&lt;br /&gt;
#if WEBSERVER==0&lt;br /&gt;
/* No webserver */&lt;br /&gt;
AUTOSTART_PROCESSES(&amp;amp;border_router_process);&lt;br /&gt;
#elif WEBSERVER&amp;gt;1&lt;br /&gt;
/* Use an external webserver application */&lt;br /&gt;
#include &amp;quot;webserver-nogui.h&amp;quot;&lt;br /&gt;
AUTOSTART_PROCESSES(&amp;amp;border_router_process,&amp;amp;webserver_nogui_process); &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Compiling the code ==&lt;br /&gt;
 &lt;br /&gt;
The code for RPL border router can be found at /contiki-2.7/examples/ipv6/rpl-border-router. Use the following command to compile the code for the border router &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-border-router &lt;br /&gt;
make TARGET=sky. &amp;lt;/pre&amp;gt;   &lt;br /&gt;
Once this command has been successfully executed a file named border-router.sky will be created. This file will be used to program one of the motes as the border router on Cooja.  &lt;br /&gt;
For the purpose of this tutorial we will  select  TMote Sky  as our target. &lt;br /&gt;
&lt;br /&gt;
In order to demonstrate the functionality of the border router we will create a network of nodes with the border router as the root. For creating such a network we will user the udp-server.c code.  &lt;br /&gt;
This code can be found at /contiki-2.7/examples/ipv6/rpl-udp . Use the following command to compile the code for rpl-udp &lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-udp &lt;br /&gt;
make TARGET=sky &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once this command has been successfully executed a file named udp-server.sky will be created. This file will be used to program the remaining nodes in Cooja simulator. These nodes will form a DAG with the rpl border router as the root.&lt;br /&gt;
&lt;br /&gt;
== Testing on Cooja ==&lt;br /&gt;
 &lt;br /&gt;
Upon the successful completion of the above mentioned steps we are ready to create a simulation in Cooja.  &lt;br /&gt;
Start the Cooja simulator using the following command &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd /contiki-2.7/tools/cooja &lt;br /&gt;
ant run&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
When the GUI launches execute the following steps to create a simulation. &amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
1. From &amp;#039;File&amp;#039; select &amp;#039;New Simulation&amp;#039;. Select UDGM, enter the name of the simulation and click on create. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Click on Motes. From the drop down menu select &amp;#039;Add New Motes&amp;#039; followed by &amp;#039;Create new motes&amp;#039; and select the mote type as Sky. &amp;lt;br&amp;gt;&lt;br /&gt;
3. Browse to the location /contiki-2.7/examples/ipv6/rpl-border-router and select the file rpl-border-router.sky. Click on &amp;#039;Create&amp;#039;. Add one mote of this type. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Repeat step 2 and 3 but this time browse to the location /contiki-2.7/examples/ipv6/rpl-udp  and select the file udp-server.sky. Add 3 - 4 motes of the type udp-server &amp;lt;br&amp;gt;&lt;br /&gt;
5. Once the motes have been added you can position the motes. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Cooja_motes.png]]&lt;br /&gt;
&lt;br /&gt;
Select the options under View as shown below. These will help you creating a topology of your choice.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Motes_view.png]]&lt;br /&gt;
&lt;br /&gt;
6. Now, we need to create a bridge between the RPL network simulated on Cooja and the local machine. This can be done by right clicking on the mote which is programmed as the border router. Select &amp;#039;More tools for border router&amp;#039; and then select &amp;#039;Serial Socket (SERVER)&amp;#039;. You will get the following message on the successful completion of this step.Note that the message says &amp;#039;Listening on port 60001&amp;#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Serial_Socket.png]]&lt;br /&gt;
&lt;br /&gt;
7. Now start the simulation by clicking on Start&lt;br /&gt;
&lt;br /&gt;
== Tunslip utility ==&lt;br /&gt;
 &lt;br /&gt;
As mentioned in the introduction a border router helps in connecting one network to another. In this example the border router is used to route data between an RPL network and an external network. Till now we have only created the RPL network. Now we need to simulate the scenario in which this RPL network is connected to an external network. For this purpose we will use the Tunslip utility provided in Contiki. In this example tunslip creates a bridge between the RPL network and the local machine. &lt;br /&gt;
tunslip6.c can be found in /contiki-2.7/tools &lt;br /&gt;
Compile the tunslip6 code.&lt;br /&gt;
&amp;lt;pre&amp;gt;make tunslip6 &amp;lt;/pre&amp;gt; &lt;br /&gt;
Make a connection between the RPL network and your local machine. &lt;br /&gt;
&amp;lt;pre&amp;gt;sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64&amp;lt;/pre&amp;gt;&lt;br /&gt;
On the successful execution this command the following output will be printed on the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;slip connected to ``127.0.0.1:60001&amp;#039;&amp;#039;&lt;br /&gt;
opened tun device ``/dev/tun0&amp;#039;&amp;#039;&lt;br /&gt;
ifconfig tun0 inet `hostname` up&lt;br /&gt;
ifconfig tun0 add aaaa::1/64&lt;br /&gt;
ifconfig tun0 add fe80::0:0:0:1/64&lt;br /&gt;
ifconfig tun0&lt;br /&gt;
&lt;br /&gt;
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  &lt;br /&gt;
          inet addr:127.0.1.1  P-t-P:127.0.1.1  Mask:255.255.255.255&lt;br /&gt;
          inet6 addr: fe80::1/64 Scope:Link&lt;br /&gt;
          inet6 addr: aaaa::1/64 Scope:Global&lt;br /&gt;
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1&lt;br /&gt;
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0&lt;br /&gt;
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0&lt;br /&gt;
          collisions:0 txqueuelen:500 &lt;br /&gt;
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)&lt;br /&gt;
&lt;br /&gt;
Rime started with address 0.18.116.1.0.1.1.1&lt;br /&gt;
MAC 00:12:74:01:00:01:01:01 Contiki 2.7 started. Node id is set to 1.&lt;br /&gt;
CSMA ContikiMAC, channel check rate 8 Hz, radio channel 26&lt;br /&gt;
Tentative link-local IPv6 address fe80:0000:0000:0000:0212:7401:0001:0101&lt;br /&gt;
Starting &amp;#039;Border router process&amp;#039; &amp;#039;Web server&amp;#039;&lt;br /&gt;
*** Address:aaaa::1 =&amp;gt; aaaa:0000:0000:0000&lt;br /&gt;
Got configuration message of type P&lt;br /&gt;
Setting prefix aaaa::&lt;br /&gt;
Server IPv6 addresses:&lt;br /&gt;
 aaaa::212:7401:1:101&lt;br /&gt;
 fe80::212:7401:1:101&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Go back to the Cooja simulator GUI and look at the dialogue box. The message has now changed to &amp;#039;Client connected: /127.0.0.1&amp;#039;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Client_Connected.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Verifying Results ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can verify that the address of the border router has been set by using the ping command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7401:1:101&lt;br /&gt;
PING aaaa::212:7401:1:101(aaaa::212:7401:1:101) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=1 ttl=64 time=86.0 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=2 ttl=64 time=33.6 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=3 ttl=64 time=82.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=4 ttl=64 time=43.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=5 ttl=64 time=70.1 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7401:1:101 ping statistics ---&lt;br /&gt;
5 packets transmitted, 5 received, 0% packet loss, time 4006ms&lt;br /&gt;
rtt min/avg/max/mdev = 33.669/63.090/86.015/20.985 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also ping one of the other nodes in the network. Here we are pinging node 4&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7404:4:404&lt;br /&gt;
PING aaaa::212:7404:4:404(aaaa::212:7404:4:404) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=1 ttl=63 time=670 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=2 ttl=63 time=703 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=3 ttl=63 time=746 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=4 ttl=63 time=674 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7404:4:404 ping statistics ---&lt;br /&gt;
5 packets transmitted, 4 received, 20% packet loss, time 4001ms&lt;br /&gt;
rtt min/avg/max/mdev = 670.230/698.666/746.619/30.514 ms&lt;br /&gt;
user@instant-contiki:~/contiki-2.7$ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IPv6 address of a node can be checked from the log screen on Cooja. Filter the nodes by their ID&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Node_Address.png]]&lt;br /&gt;
&lt;br /&gt;
You can enter the address of the border router in the web browser. The border router host a page which will be displayed on the browser as shown below. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:RPL_Browser.png]]&lt;br /&gt;
&lt;br /&gt;
== Common Issues ==&lt;br /&gt;
&lt;br /&gt;
1. Make sure that you enter the IPv6 address properly in the command sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64 . There should be no spaces in aaaa::1/64. Otherwise the code will give unexpected behavior.&amp;lt;br&amp;gt;&lt;br /&gt;
2. When you pause the simulation the SLIP connection is lost. It might not work properly on resuming the simulation. In such cases reload the simulation. Create a fresh SLIP connection and then run the simulation again.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
[https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md]  https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md &amp;lt;br&amp;gt;&lt;br /&gt;
[http://cnds.eecs.jacobs-university.de/courses/iotlab-2013/cooja.pdf] Using the Contiki Cooja Simulator - Anuj Sehgal&lt;/div&gt;</summary>
		<author><name>Ckapoor</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=File:Diagram.png&amp;diff=1175</id>
		<title>File:Diagram.png</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=File:Diagram.png&amp;diff=1175"/>
				<updated>2014-11-09T00:14:23Z</updated>
		
		<summary type="html">&lt;p&gt;Ckapoor: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ckapoor</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1174</id>
		<title>RPL Border Router</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1174"/>
				<updated>2014-11-09T00:13:41Z</updated>
		
		<summary type="html">&lt;p&gt;Ckapoor: /* Introduction: */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction: ==&lt;br /&gt;
  &lt;br /&gt;
Border routers are routers that can be found at the edge of a network. Their function is to connect one network to another. In this tutorial we will learn how to run a simulation using the border router in Contiki 2.7. In the example which we will discuss in the rest of this tutorial the border router will be used to route data between a WSN (RPL network) and an external IP network.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Objective:  &lt;br /&gt;
The objective of this tutorial is to give you an understanding of the RPL Border Router code in Contiki 2.7 OS and learn how to simulate a network with a border router on Cooja &lt;br /&gt;
&lt;br /&gt;
At the end of the tutorial you would have learnt the following: &lt;br /&gt;
&lt;br /&gt;
1. Understanding the working of the rpl border router code &amp;lt;br&amp;gt;&lt;br /&gt;
2. Starting a simulation on Cooja simulator. &amp;lt;br&amp;gt; &lt;br /&gt;
3. Observing and validating the results &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code building blocks. ==&lt;br /&gt;
 &lt;br /&gt;
We will using the following files &lt;br /&gt;
&lt;br /&gt;
1. border-router.c &amp;lt;br&amp;gt;&lt;br /&gt;
2. udp-server.c  (udp-client.c can also be used)&amp;lt;br&amp;gt;&lt;br /&gt;
3. slip-bridge.c (It contains callback function for processing a SLIP connection request) &amp;lt;br&amp;gt;&lt;br /&gt;
4. httpd-simple.c   (A simple web server forwarding page generation to a protothread)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
udp-server nodes will form a DAG with the border router set as the root. The border router will receive the prefix through a [SLIP][http://en.wikipedia.org/wiki/Serial_Line_Internet_Protocol] (Serial Line Interface Protocol) connection and it will be communicated to the rest of the nodes in the RPL network. &lt;br /&gt;
&lt;br /&gt;
Refer to the following code snippets in the file border-router.c In this piece of code the node configured as the border router waits for the prefix to be set. Once it receives the prefix, the border router is set as the root of the DAG after which it sets the prefix of the rest of the nodes in the network.  &lt;br /&gt;
 &lt;br /&gt;
 /* Request prefix until it has been received */ &lt;br /&gt;
  while(!prefix_set) { &lt;br /&gt;
    etimer_set(&amp;amp;et, CLOCK_SECOND); &lt;br /&gt;
    request_prefix(); &lt;br /&gt;
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&amp;amp;et)); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
  dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)dag_id); &lt;br /&gt;
  if(dag != NULL) { &lt;br /&gt;
    rpl_set_prefix(dag, &amp;amp;prefix, 64); &lt;br /&gt;
    PRINTF(&amp;quot;created a new RPL dag\n&amp;quot;); &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
By default the border router hosts a simple web page. However this can be disabled by defining WEBSERVER as seen the code snippet below. This webpage is displayed when the IPv6 address of the border router is entered in the browser. Refer to the file httpd-simple.c for the following code snippet&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;PROCESS(border_router_process, &amp;quot;Border router process&amp;quot;);&lt;br /&gt;
#if WEBSERVER==0&lt;br /&gt;
/* No webserver */&lt;br /&gt;
AUTOSTART_PROCESSES(&amp;amp;border_router_process);&lt;br /&gt;
#elif WEBSERVER&amp;gt;1&lt;br /&gt;
/* Use an external webserver application */&lt;br /&gt;
#include &amp;quot;webserver-nogui.h&amp;quot;&lt;br /&gt;
AUTOSTART_PROCESSES(&amp;amp;border_router_process,&amp;amp;webserver_nogui_process); &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Compiling the code ==&lt;br /&gt;
 &lt;br /&gt;
The code for RPL border router can be found at /contiki-2.7/examples/ipv6/rpl-border-router. Use the following command to compile the code for the border router &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-border-router &lt;br /&gt;
make TARGET=sky. &amp;lt;/pre&amp;gt;   &lt;br /&gt;
Once this command has been successfully executed a file named border-router.sky will be created. This file will be used to program one of the motes as the border router on Cooja.  &lt;br /&gt;
For the purpose of this tutorial we will  select  TMote Sky  as our target. &lt;br /&gt;
&lt;br /&gt;
In order to demonstrate the functionality of the border router we will create a network of nodes with the border router as the root. For creating such a network we will user the udp-server.c code.  &lt;br /&gt;
This code can be found at /contiki-2.7/examples/ipv6/rpl-udp . Use the following command to compile the code for rpl-udp &lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-udp &lt;br /&gt;
make TARGET=sky &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once this command has been successfully executed a file named udp-server.sky will be created. This file will be used to program the remaining nodes in Cooja simulator. These nodes will form a DAG with the rpl border router as the root.&lt;br /&gt;
&lt;br /&gt;
== Testing on Cooja ==&lt;br /&gt;
 &lt;br /&gt;
Upon the successful completion of the above mentioned steps we are ready to create a simulation in Cooja.  &lt;br /&gt;
Start the Cooja simulator using the following command &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd /contiki-2.7/tools/cooja &lt;br /&gt;
ant run&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
When the GUI launches execute the following steps to create a simulation. &amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
1. From &amp;#039;File&amp;#039; select &amp;#039;New Simulation&amp;#039;. Select UDGM, enter the name of the simulation and click on create. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Click on Motes. From the drop down menu select &amp;#039;Add New Motes&amp;#039; followed by &amp;#039;Create new motes&amp;#039; and select the mote type as Sky. &amp;lt;br&amp;gt;&lt;br /&gt;
3. Browse to the location /contiki-2.7/examples/ipv6/rpl-border-router and select the file rpl-border-router.sky. Click on &amp;#039;Create&amp;#039;. Add one mote of this type. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Repeat step 2 and 3 but this time browse to the location /contiki-2.7/examples/ipv6/rpl-udp  and select the file udp-server.sky. Add 3 - 4 motes of the type udp-server &amp;lt;br&amp;gt;&lt;br /&gt;
5. Once the motes have been added you can position the motes. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Cooja_motes.png]]&lt;br /&gt;
&lt;br /&gt;
Select the options under View as shown below. These will help you creating a topology of your choice.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Motes_view.png]]&lt;br /&gt;
&lt;br /&gt;
6. Now, we need to create a bridge between the RPL network simulated on Cooja and the local machine. This can be done by right clicking on the mote which is programmed as the border router. Select &amp;#039;More tools for border router&amp;#039; and then select &amp;#039;Serial Socket (SERVER)&amp;#039;. You will get the following message on the successful completion of this step.Note that the message says &amp;#039;Listening on port 60001&amp;#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Serial_Socket.png]]&lt;br /&gt;
&lt;br /&gt;
7. Now start the simulation by clicking on Start&lt;br /&gt;
&lt;br /&gt;
== Tunslip utility ==&lt;br /&gt;
 &lt;br /&gt;
As mentioned in the introduction a border router helps in connecting one network to another. In this example the border router is used to route data between an RPL network and an external network. Till now we have only created the RPL network. Now we need to simulate the scenario in which this RPL network is connected to an external network. For this purpose we will use the Tunslip utility provided in Contiki. In this example tunslip creates a bridge between the RPL network and the local machine. &lt;br /&gt;
tunslip6.c can be found in /contiki-2.7/tools &lt;br /&gt;
Compile the tunslip6 code.&lt;br /&gt;
&amp;lt;pre&amp;gt;make tunslip6 &amp;lt;/pre&amp;gt; &lt;br /&gt;
Make a connection between the RPL network and your local machine. &lt;br /&gt;
&amp;lt;pre&amp;gt;sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64&amp;lt;/pre&amp;gt;&lt;br /&gt;
On the successful execution this command the following output will be printed on the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;slip connected to ``127.0.0.1:60001&amp;#039;&amp;#039;&lt;br /&gt;
opened tun device ``/dev/tun0&amp;#039;&amp;#039;&lt;br /&gt;
ifconfig tun0 inet `hostname` up&lt;br /&gt;
ifconfig tun0 add aaaa::1/64&lt;br /&gt;
ifconfig tun0 add fe80::0:0:0:1/64&lt;br /&gt;
ifconfig tun0&lt;br /&gt;
&lt;br /&gt;
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  &lt;br /&gt;
          inet addr:127.0.1.1  P-t-P:127.0.1.1  Mask:255.255.255.255&lt;br /&gt;
          inet6 addr: fe80::1/64 Scope:Link&lt;br /&gt;
          inet6 addr: aaaa::1/64 Scope:Global&lt;br /&gt;
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1&lt;br /&gt;
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0&lt;br /&gt;
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0&lt;br /&gt;
          collisions:0 txqueuelen:500 &lt;br /&gt;
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)&lt;br /&gt;
&lt;br /&gt;
Rime started with address 0.18.116.1.0.1.1.1&lt;br /&gt;
MAC 00:12:74:01:00:01:01:01 Contiki 2.7 started. Node id is set to 1.&lt;br /&gt;
CSMA ContikiMAC, channel check rate 8 Hz, radio channel 26&lt;br /&gt;
Tentative link-local IPv6 address fe80:0000:0000:0000:0212:7401:0001:0101&lt;br /&gt;
Starting &amp;#039;Border router process&amp;#039; &amp;#039;Web server&amp;#039;&lt;br /&gt;
*** Address:aaaa::1 =&amp;gt; aaaa:0000:0000:0000&lt;br /&gt;
Got configuration message of type P&lt;br /&gt;
Setting prefix aaaa::&lt;br /&gt;
Server IPv6 addresses:&lt;br /&gt;
 aaaa::212:7401:1:101&lt;br /&gt;
 fe80::212:7401:1:101&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Go back to the Cooja simulator GUI and look at the dialogue box. The message has now changed to &amp;#039;Client connected: /127.0.0.1&amp;#039;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Client_Connected.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Verifying Results ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can verify that the address of the border router has been set by using the ping command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7401:1:101&lt;br /&gt;
PING aaaa::212:7401:1:101(aaaa::212:7401:1:101) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=1 ttl=64 time=86.0 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=2 ttl=64 time=33.6 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=3 ttl=64 time=82.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=4 ttl=64 time=43.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=5 ttl=64 time=70.1 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7401:1:101 ping statistics ---&lt;br /&gt;
5 packets transmitted, 5 received, 0% packet loss, time 4006ms&lt;br /&gt;
rtt min/avg/max/mdev = 33.669/63.090/86.015/20.985 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also ping one of the other nodes in the network. Here we are pinging node 4&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7404:4:404&lt;br /&gt;
PING aaaa::212:7404:4:404(aaaa::212:7404:4:404) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=1 ttl=63 time=670 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=2 ttl=63 time=703 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=3 ttl=63 time=746 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=4 ttl=63 time=674 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7404:4:404 ping statistics ---&lt;br /&gt;
5 packets transmitted, 4 received, 20% packet loss, time 4001ms&lt;br /&gt;
rtt min/avg/max/mdev = 670.230/698.666/746.619/30.514 ms&lt;br /&gt;
user@instant-contiki:~/contiki-2.7$ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IPv6 address of a node can be checked from the log screen on Cooja. Filter the nodes by their ID&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Node_Address.png]]&lt;br /&gt;
&lt;br /&gt;
You can enter the address of the border router in the web browser. The border router host a page which will be displayed on the browser as shown below. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:RPL_Browser.png]]&lt;br /&gt;
&lt;br /&gt;
== Common Issues ==&lt;br /&gt;
&lt;br /&gt;
1. Make sure that you enter the IPv6 address properly in the command sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64 . There should be no spaces in aaaa::1/64. Otherwise the code will give unexpected behavior.&amp;lt;br&amp;gt;&lt;br /&gt;
2. When you pause the simulation the SLIP connection is lost. It might not work properly on resuming the simulation. In such cases reload the simulation. Create a fresh SLIP connection and then run the simulation again.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
[https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md]  https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md &amp;lt;br&amp;gt;&lt;br /&gt;
[http://cnds.eecs.jacobs-university.de/courses/iotlab-2013/cooja.pdf] Using the Contiki Cooja Simulator - Anuj Sehgal&lt;/div&gt;</summary>
		<author><name>Ckapoor</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1165</id>
		<title>RPL Border Router</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1165"/>
				<updated>2014-11-08T23:52:06Z</updated>
		
		<summary type="html">&lt;p&gt;Ckapoor: /* Code building blocks. */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction: ==&lt;br /&gt;
  &lt;br /&gt;
Border routers are routers that can be found at the edge of a network. Their function is to connect one network to another. In this tutorial we will learn how to run a simulation using the border router in Contiki 2.7. In the example which we will discuss in the rest of this tutorial the border router will be used to route data between a WSN (RPL network) and an external IP network.  &lt;br /&gt;
Objective:  &lt;br /&gt;
The objective of this tutorial is to give you an understanding of the RPL Border Router code in Contiki 2.7 OS and learn how to simulate a network with a border router on Cooja &lt;br /&gt;
&lt;br /&gt;
At the end of the tutorial you would have learnt the following: &lt;br /&gt;
&lt;br /&gt;
1. Understanding the working of the rpl border router code &amp;lt;br&amp;gt;&lt;br /&gt;
2. Starting a simulation on Cooja simulator. &amp;lt;br&amp;gt; &lt;br /&gt;
3. Observing and validating the results &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code building blocks. ==&lt;br /&gt;
 &lt;br /&gt;
We will using the following files &lt;br /&gt;
&lt;br /&gt;
1. border-router.c &amp;lt;br&amp;gt;&lt;br /&gt;
2. udp-server.c  (udp-client.c can also be used)&amp;lt;br&amp;gt;&lt;br /&gt;
3. slip-bridge.c (It contains callback function for processing a SLIP connection request) &amp;lt;br&amp;gt;&lt;br /&gt;
4. httpd-simple.c   (A simple web server forwarding page generation to a protothread)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
udp-server nodes will form a DAG with the border router set as the root. The border router will receive the prefix through a [SLIP][http://en.wikipedia.org/wiki/Serial_Line_Internet_Protocol] (Serial Line Interface Protocol) connection and it will be communicated to the rest of the nodes in the RPL network. &lt;br /&gt;
&lt;br /&gt;
Refer to the following code snippets in the file border-router.c In this piece of code the node configured as the border router waits for the prefix to be set. Once it receives the prefix, the border router is set as the root of the DAG after which it sets the prefix of the rest of the nodes in the network.  &lt;br /&gt;
 &lt;br /&gt;
 /* Request prefix until it has been received */ &lt;br /&gt;
  while(!prefix_set) { &lt;br /&gt;
    etimer_set(&amp;amp;et, CLOCK_SECOND); &lt;br /&gt;
    request_prefix(); &lt;br /&gt;
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&amp;amp;et)); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
  dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)dag_id); &lt;br /&gt;
  if(dag != NULL) { &lt;br /&gt;
    rpl_set_prefix(dag, &amp;amp;prefix, 64); &lt;br /&gt;
    PRINTF(&amp;quot;created a new RPL dag\n&amp;quot;); &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
By default the border router hosts a simple web page. However this can be disabled by defining WEBSERVER as seen the code snippet below. This webpage is displayed when the IPv6 address of the border router is entered in the browser. Refer to the file httpd-simple.c for the following code snippet&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;PROCESS(border_router_process, &amp;quot;Border router process&amp;quot;);&lt;br /&gt;
#if WEBSERVER==0&lt;br /&gt;
/* No webserver */&lt;br /&gt;
AUTOSTART_PROCESSES(&amp;amp;border_router_process);&lt;br /&gt;
#elif WEBSERVER&amp;gt;1&lt;br /&gt;
/* Use an external webserver application */&lt;br /&gt;
#include &amp;quot;webserver-nogui.h&amp;quot;&lt;br /&gt;
AUTOSTART_PROCESSES(&amp;amp;border_router_process,&amp;amp;webserver_nogui_process); &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Compiling the code ==&lt;br /&gt;
 &lt;br /&gt;
The code for RPL border router can be found at /contiki-2.7/examples/ipv6/rpl-border-router. Use the following command to compile the code for the border router &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-border-router &lt;br /&gt;
make TARGET=sky. &amp;lt;/pre&amp;gt;   &lt;br /&gt;
Once this command has been successfully executed a file named border-router.sky will be created. This file will be used to program one of the motes as the border router on Cooja.  &lt;br /&gt;
For the purpose of this tutorial we will  select  TMote Sky  as our target. &lt;br /&gt;
&lt;br /&gt;
In order to demonstrate the functionality of the border router we will create a network of nodes with the border router as the root. For creating such a network we will user the udp-server.c code.  &lt;br /&gt;
This code can be found at /contiki-2.7/examples/ipv6/rpl-udp . Use the following command to compile the code for rpl-udp &lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-udp &lt;br /&gt;
make TARGET=sky &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once this command has been successfully executed a file named udp-server.sky will be created. This file will be used to program the remaining nodes in Cooja simulator. These nodes will form a DAG with the rpl border router as the root.&lt;br /&gt;
&lt;br /&gt;
== Testing on Cooja ==&lt;br /&gt;
 &lt;br /&gt;
Upon the successful completion of the above mentioned steps we are ready to create a simulation in Cooja.  &lt;br /&gt;
Start the Cooja simulator using the following command &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd /contiki-2.7/tools/cooja &lt;br /&gt;
ant run&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
When the GUI launches execute the following steps to create a simulation. &amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
1. From &amp;#039;File&amp;#039; select &amp;#039;New Simulation&amp;#039;. Select UDGM, enter the name of the simulation and click on create. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Click on Motes. From the drop down menu select &amp;#039;Add New Motes&amp;#039; followed by &amp;#039;Create new motes&amp;#039; and select the mote type as Sky. &amp;lt;br&amp;gt;&lt;br /&gt;
3. Browse to the location /contiki-2.7/examples/ipv6/rpl-border-router and select the file rpl-border-router.sky. Click on &amp;#039;Create&amp;#039;. Add one mote of this type. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Repeat step 2 and 3 but this time browse to the location /contiki-2.7/examples/ipv6/rpl-udp  and select the file udp-server.sky. Add 3 - 4 motes of the type udp-server &amp;lt;br&amp;gt;&lt;br /&gt;
5. Once the motes have been added you can position the motes. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Cooja_motes.png]]&lt;br /&gt;
&lt;br /&gt;
Select the options under View as shown below. These will help you creating a topology of your choice.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Motes_view.png]]&lt;br /&gt;
&lt;br /&gt;
6. Now, we need to create a bridge between the RPL network simulated on Cooja and the local machine. This can be done by right clicking on the mote which is programmed as the border router. Select &amp;#039;More tools for border router&amp;#039; and then select &amp;#039;Serial Socket (SERVER)&amp;#039;. You will get the following message on the successful completion of this step.Note that the message says &amp;#039;Listening on port 60001&amp;#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Serial_Socket.png]]&lt;br /&gt;
&lt;br /&gt;
7. Now start the simulation by clicking on Start&lt;br /&gt;
&lt;br /&gt;
== Tunslip utility ==&lt;br /&gt;
 &lt;br /&gt;
As mentioned in the introduction a border router helps in connecting one network to another. In this example the border router is used to route data between an RPL network and an external network. Till now we have only created the RPL network. Now we need to simulate the scenario in which this RPL network is connected to an external network. For this purpose we will use the Tunslip utility provided in Contiki. In this example tunslip creates a bridge between the RPL network and the local machine. &lt;br /&gt;
tunslip6.c can be found in /contiki-2.7/tools &lt;br /&gt;
Compile the tunslip6 code.&lt;br /&gt;
&amp;lt;pre&amp;gt;make tunslip6 &amp;lt;/pre&amp;gt; &lt;br /&gt;
Make a connection between the RPL network and your local machine. &lt;br /&gt;
&amp;lt;pre&amp;gt;sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64&amp;lt;/pre&amp;gt;&lt;br /&gt;
On the successful execution this command the following output will be printed on the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;slip connected to ``127.0.0.1:60001&amp;#039;&amp;#039;&lt;br /&gt;
opened tun device ``/dev/tun0&amp;#039;&amp;#039;&lt;br /&gt;
ifconfig tun0 inet `hostname` up&lt;br /&gt;
ifconfig tun0 add aaaa::1/64&lt;br /&gt;
ifconfig tun0 add fe80::0:0:0:1/64&lt;br /&gt;
ifconfig tun0&lt;br /&gt;
&lt;br /&gt;
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  &lt;br /&gt;
          inet addr:127.0.1.1  P-t-P:127.0.1.1  Mask:255.255.255.255&lt;br /&gt;
          inet6 addr: fe80::1/64 Scope:Link&lt;br /&gt;
          inet6 addr: aaaa::1/64 Scope:Global&lt;br /&gt;
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1&lt;br /&gt;
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0&lt;br /&gt;
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0&lt;br /&gt;
          collisions:0 txqueuelen:500 &lt;br /&gt;
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)&lt;br /&gt;
&lt;br /&gt;
Rime started with address 0.18.116.1.0.1.1.1&lt;br /&gt;
MAC 00:12:74:01:00:01:01:01 Contiki 2.7 started. Node id is set to 1.&lt;br /&gt;
CSMA ContikiMAC, channel check rate 8 Hz, radio channel 26&lt;br /&gt;
Tentative link-local IPv6 address fe80:0000:0000:0000:0212:7401:0001:0101&lt;br /&gt;
Starting &amp;#039;Border router process&amp;#039; &amp;#039;Web server&amp;#039;&lt;br /&gt;
*** Address:aaaa::1 =&amp;gt; aaaa:0000:0000:0000&lt;br /&gt;
Got configuration message of type P&lt;br /&gt;
Setting prefix aaaa::&lt;br /&gt;
Server IPv6 addresses:&lt;br /&gt;
 aaaa::212:7401:1:101&lt;br /&gt;
 fe80::212:7401:1:101&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Go back to the Cooja simulator GUI and look at the dialogue box. The message has now changed to &amp;#039;Client connected: /127.0.0.1&amp;#039;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Client_Connected.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Verifying Results ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can verify that the address of the border router has been set by using the ping command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7401:1:101&lt;br /&gt;
PING aaaa::212:7401:1:101(aaaa::212:7401:1:101) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=1 ttl=64 time=86.0 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=2 ttl=64 time=33.6 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=3 ttl=64 time=82.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=4 ttl=64 time=43.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=5 ttl=64 time=70.1 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7401:1:101 ping statistics ---&lt;br /&gt;
5 packets transmitted, 5 received, 0% packet loss, time 4006ms&lt;br /&gt;
rtt min/avg/max/mdev = 33.669/63.090/86.015/20.985 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also ping one of the other nodes in the network. Here we are pinging node 4&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7404:4:404&lt;br /&gt;
PING aaaa::212:7404:4:404(aaaa::212:7404:4:404) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=1 ttl=63 time=670 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=2 ttl=63 time=703 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=3 ttl=63 time=746 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=4 ttl=63 time=674 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7404:4:404 ping statistics ---&lt;br /&gt;
5 packets transmitted, 4 received, 20% packet loss, time 4001ms&lt;br /&gt;
rtt min/avg/max/mdev = 670.230/698.666/746.619/30.514 ms&lt;br /&gt;
user@instant-contiki:~/contiki-2.7$ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IPv6 address of a node can be checked from the log screen on Cooja. Filter the nodes by their ID&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Node_Address.png]]&lt;br /&gt;
&lt;br /&gt;
You can enter the address of the border router in the web browser. The border router host a page which will be displayed on the browser as shown below. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:RPL_Browser.png]]&lt;br /&gt;
&lt;br /&gt;
== Common Issues ==&lt;br /&gt;
&lt;br /&gt;
1. Make sure that you enter the IPv6 address properly in the command sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64 . There should be no spaces in aaaa::1/64. Otherwise the code will give unexpected behavior.&amp;lt;br&amp;gt;&lt;br /&gt;
2. When you pause the simulation the SLIP connection is lost. It might not work properly on resuming the simulation. In such cases reload the simulation. Create a fresh SLIP connection and then run the simulation again.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
[https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md]  https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md &amp;lt;br&amp;gt;&lt;br /&gt;
[http://cnds.eecs.jacobs-university.de/courses/iotlab-2013/cooja.pdf] Using the Contiki Cooja Simulator - Anuj Sehgal&lt;/div&gt;</summary>
		<author><name>Ckapoor</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1164</id>
		<title>RPL Border Router</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1164"/>
				<updated>2014-11-08T23:51:16Z</updated>
		
		<summary type="html">&lt;p&gt;Ckapoor: /* Code building blocks. */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction: ==&lt;br /&gt;
  &lt;br /&gt;
Border routers are routers that can be found at the edge of a network. Their function is to connect one network to another. In this tutorial we will learn how to run a simulation using the border router in Contiki 2.7. In the example which we will discuss in the rest of this tutorial the border router will be used to route data between a WSN (RPL network) and an external IP network.  &lt;br /&gt;
Objective:  &lt;br /&gt;
The objective of this tutorial is to give you an understanding of the RPL Border Router code in Contiki 2.7 OS and learn how to simulate a network with a border router on Cooja &lt;br /&gt;
&lt;br /&gt;
At the end of the tutorial you would have learnt the following: &lt;br /&gt;
&lt;br /&gt;
1. Understanding the working of the rpl border router code &amp;lt;br&amp;gt;&lt;br /&gt;
2. Starting a simulation on Cooja simulator. &amp;lt;br&amp;gt; &lt;br /&gt;
3. Observing and validating the results &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code building blocks. ==&lt;br /&gt;
 &lt;br /&gt;
We will using the following files &lt;br /&gt;
&lt;br /&gt;
1. border-router.c &amp;lt;br&amp;gt;&lt;br /&gt;
2. udp-server.c  (udp-client.c can also be used)&amp;lt;br&amp;gt;&lt;br /&gt;
3. slip-bridge.c (It contains callback function for processing a SLIP connection request) &amp;lt;br&amp;gt;&lt;br /&gt;
4. httpd-simple.c   (A simple web server forwarding page generation to a protothread)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
udp-server nodes will form a DAG with the border router set as the root. The border router will receive the prefix through a [SLIP][http://www.example.com link title] (Serial Line Interface Protocol) connection and it will be communicated to the rest of the nodes in the RPL network. &lt;br /&gt;
&lt;br /&gt;
Refer to the following code snippets in the file border-router.c In this piece of code the node configured as the border router waits for the prefix to be set. Once it receives the prefix, the border router is set as the root of the DAG after which it sets the prefix of the rest of the nodes in the network.  &lt;br /&gt;
 &lt;br /&gt;
 /* Request prefix until it has been received */ &lt;br /&gt;
  while(!prefix_set) { &lt;br /&gt;
    etimer_set(&amp;amp;et, CLOCK_SECOND); &lt;br /&gt;
    request_prefix(); &lt;br /&gt;
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&amp;amp;et)); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
  dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)dag_id); &lt;br /&gt;
  if(dag != NULL) { &lt;br /&gt;
    rpl_set_prefix(dag, &amp;amp;prefix, 64); &lt;br /&gt;
    PRINTF(&amp;quot;created a new RPL dag\n&amp;quot;); &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
By default the border router hosts a simple web page. However this can be disabled by defining WEBSERVER as seen the code snippet below. This webpage is displayed when the IPv6 address of the border router is entered in the browser. Refer to the file httpd-simple.c for the following code snippet&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;PROCESS(border_router_process, &amp;quot;Border router process&amp;quot;);&lt;br /&gt;
#if WEBSERVER==0&lt;br /&gt;
/* No webserver */&lt;br /&gt;
AUTOSTART_PROCESSES(&amp;amp;border_router_process);&lt;br /&gt;
#elif WEBSERVER&amp;gt;1&lt;br /&gt;
/* Use an external webserver application */&lt;br /&gt;
#include &amp;quot;webserver-nogui.h&amp;quot;&lt;br /&gt;
AUTOSTART_PROCESSES(&amp;amp;border_router_process,&amp;amp;webserver_nogui_process); &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Compiling the code ==&lt;br /&gt;
 &lt;br /&gt;
The code for RPL border router can be found at /contiki-2.7/examples/ipv6/rpl-border-router. Use the following command to compile the code for the border router &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-border-router &lt;br /&gt;
make TARGET=sky. &amp;lt;/pre&amp;gt;   &lt;br /&gt;
Once this command has been successfully executed a file named border-router.sky will be created. This file will be used to program one of the motes as the border router on Cooja.  &lt;br /&gt;
For the purpose of this tutorial we will  select  TMote Sky  as our target. &lt;br /&gt;
&lt;br /&gt;
In order to demonstrate the functionality of the border router we will create a network of nodes with the border router as the root. For creating such a network we will user the udp-server.c code.  &lt;br /&gt;
This code can be found at /contiki-2.7/examples/ipv6/rpl-udp . Use the following command to compile the code for rpl-udp &lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-udp &lt;br /&gt;
make TARGET=sky &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once this command has been successfully executed a file named udp-server.sky will be created. This file will be used to program the remaining nodes in Cooja simulator. These nodes will form a DAG with the rpl border router as the root.&lt;br /&gt;
&lt;br /&gt;
== Testing on Cooja ==&lt;br /&gt;
 &lt;br /&gt;
Upon the successful completion of the above mentioned steps we are ready to create a simulation in Cooja.  &lt;br /&gt;
Start the Cooja simulator using the following command &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd /contiki-2.7/tools/cooja &lt;br /&gt;
ant run&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
When the GUI launches execute the following steps to create a simulation. &amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
1. From &amp;#039;File&amp;#039; select &amp;#039;New Simulation&amp;#039;. Select UDGM, enter the name of the simulation and click on create. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Click on Motes. From the drop down menu select &amp;#039;Add New Motes&amp;#039; followed by &amp;#039;Create new motes&amp;#039; and select the mote type as Sky. &amp;lt;br&amp;gt;&lt;br /&gt;
3. Browse to the location /contiki-2.7/examples/ipv6/rpl-border-router and select the file rpl-border-router.sky. Click on &amp;#039;Create&amp;#039;. Add one mote of this type. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Repeat step 2 and 3 but this time browse to the location /contiki-2.7/examples/ipv6/rpl-udp  and select the file udp-server.sky. Add 3 - 4 motes of the type udp-server &amp;lt;br&amp;gt;&lt;br /&gt;
5. Once the motes have been added you can position the motes. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Cooja_motes.png]]&lt;br /&gt;
&lt;br /&gt;
Select the options under View as shown below. These will help you creating a topology of your choice.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Motes_view.png]]&lt;br /&gt;
&lt;br /&gt;
6. Now, we need to create a bridge between the RPL network simulated on Cooja and the local machine. This can be done by right clicking on the mote which is programmed as the border router. Select &amp;#039;More tools for border router&amp;#039; and then select &amp;#039;Serial Socket (SERVER)&amp;#039;. You will get the following message on the successful completion of this step.Note that the message says &amp;#039;Listening on port 60001&amp;#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Serial_Socket.png]]&lt;br /&gt;
&lt;br /&gt;
7. Now start the simulation by clicking on Start&lt;br /&gt;
&lt;br /&gt;
== Tunslip utility ==&lt;br /&gt;
 &lt;br /&gt;
As mentioned in the introduction a border router helps in connecting one network to another. In this example the border router is used to route data between an RPL network and an external network. Till now we have only created the RPL network. Now we need to simulate the scenario in which this RPL network is connected to an external network. For this purpose we will use the Tunslip utility provided in Contiki. In this example tunslip creates a bridge between the RPL network and the local machine. &lt;br /&gt;
tunslip6.c can be found in /contiki-2.7/tools &lt;br /&gt;
Compile the tunslip6 code.&lt;br /&gt;
&amp;lt;pre&amp;gt;make tunslip6 &amp;lt;/pre&amp;gt; &lt;br /&gt;
Make a connection between the RPL network and your local machine. &lt;br /&gt;
&amp;lt;pre&amp;gt;sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64&amp;lt;/pre&amp;gt;&lt;br /&gt;
On the successful execution this command the following output will be printed on the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;slip connected to ``127.0.0.1:60001&amp;#039;&amp;#039;&lt;br /&gt;
opened tun device ``/dev/tun0&amp;#039;&amp;#039;&lt;br /&gt;
ifconfig tun0 inet `hostname` up&lt;br /&gt;
ifconfig tun0 add aaaa::1/64&lt;br /&gt;
ifconfig tun0 add fe80::0:0:0:1/64&lt;br /&gt;
ifconfig tun0&lt;br /&gt;
&lt;br /&gt;
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  &lt;br /&gt;
          inet addr:127.0.1.1  P-t-P:127.0.1.1  Mask:255.255.255.255&lt;br /&gt;
          inet6 addr: fe80::1/64 Scope:Link&lt;br /&gt;
          inet6 addr: aaaa::1/64 Scope:Global&lt;br /&gt;
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1&lt;br /&gt;
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0&lt;br /&gt;
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0&lt;br /&gt;
          collisions:0 txqueuelen:500 &lt;br /&gt;
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)&lt;br /&gt;
&lt;br /&gt;
Rime started with address 0.18.116.1.0.1.1.1&lt;br /&gt;
MAC 00:12:74:01:00:01:01:01 Contiki 2.7 started. Node id is set to 1.&lt;br /&gt;
CSMA ContikiMAC, channel check rate 8 Hz, radio channel 26&lt;br /&gt;
Tentative link-local IPv6 address fe80:0000:0000:0000:0212:7401:0001:0101&lt;br /&gt;
Starting &amp;#039;Border router process&amp;#039; &amp;#039;Web server&amp;#039;&lt;br /&gt;
*** Address:aaaa::1 =&amp;gt; aaaa:0000:0000:0000&lt;br /&gt;
Got configuration message of type P&lt;br /&gt;
Setting prefix aaaa::&lt;br /&gt;
Server IPv6 addresses:&lt;br /&gt;
 aaaa::212:7401:1:101&lt;br /&gt;
 fe80::212:7401:1:101&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Go back to the Cooja simulator GUI and look at the dialogue box. The message has now changed to &amp;#039;Client connected: /127.0.0.1&amp;#039;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Client_Connected.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Verifying Results ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can verify that the address of the border router has been set by using the ping command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7401:1:101&lt;br /&gt;
PING aaaa::212:7401:1:101(aaaa::212:7401:1:101) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=1 ttl=64 time=86.0 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=2 ttl=64 time=33.6 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=3 ttl=64 time=82.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=4 ttl=64 time=43.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=5 ttl=64 time=70.1 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7401:1:101 ping statistics ---&lt;br /&gt;
5 packets transmitted, 5 received, 0% packet loss, time 4006ms&lt;br /&gt;
rtt min/avg/max/mdev = 33.669/63.090/86.015/20.985 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also ping one of the other nodes in the network. Here we are pinging node 4&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7404:4:404&lt;br /&gt;
PING aaaa::212:7404:4:404(aaaa::212:7404:4:404) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=1 ttl=63 time=670 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=2 ttl=63 time=703 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=3 ttl=63 time=746 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=4 ttl=63 time=674 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7404:4:404 ping statistics ---&lt;br /&gt;
5 packets transmitted, 4 received, 20% packet loss, time 4001ms&lt;br /&gt;
rtt min/avg/max/mdev = 670.230/698.666/746.619/30.514 ms&lt;br /&gt;
user@instant-contiki:~/contiki-2.7$ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IPv6 address of a node can be checked from the log screen on Cooja. Filter the nodes by their ID&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Node_Address.png]]&lt;br /&gt;
&lt;br /&gt;
You can enter the address of the border router in the web browser. The border router host a page which will be displayed on the browser as shown below. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:RPL_Browser.png]]&lt;br /&gt;
&lt;br /&gt;
== Common Issues ==&lt;br /&gt;
&lt;br /&gt;
1. Make sure that you enter the IPv6 address properly in the command sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64 . There should be no spaces in aaaa::1/64. Otherwise the code will give unexpected behavior.&amp;lt;br&amp;gt;&lt;br /&gt;
2. When you pause the simulation the SLIP connection is lost. It might not work properly on resuming the simulation. In such cases reload the simulation. Create a fresh SLIP connection and then run the simulation again.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
[https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md]  https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md &amp;lt;br&amp;gt;&lt;br /&gt;
[http://cnds.eecs.jacobs-university.de/courses/iotlab-2013/cooja.pdf] Using the Contiki Cooja Simulator - Anuj Sehgal&lt;/div&gt;</summary>
		<author><name>Ckapoor</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1163</id>
		<title>RPL Border Router</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1163"/>
				<updated>2014-11-08T23:50:00Z</updated>
		
		<summary type="html">&lt;p&gt;Ckapoor: /* Introduction: */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction: ==&lt;br /&gt;
  &lt;br /&gt;
Border routers are routers that can be found at the edge of a network. Their function is to connect one network to another. In this tutorial we will learn how to run a simulation using the border router in Contiki 2.7. In the example which we will discuss in the rest of this tutorial the border router will be used to route data between a WSN (RPL network) and an external IP network.  &lt;br /&gt;
Objective:  &lt;br /&gt;
The objective of this tutorial is to give you an understanding of the RPL Border Router code in Contiki 2.7 OS and learn how to simulate a network with a border router on Cooja &lt;br /&gt;
&lt;br /&gt;
At the end of the tutorial you would have learnt the following: &lt;br /&gt;
&lt;br /&gt;
1. Understanding the working of the rpl border router code &amp;lt;br&amp;gt;&lt;br /&gt;
2. Starting a simulation on Cooja simulator. &amp;lt;br&amp;gt; &lt;br /&gt;
3. Observing and validating the results &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code building blocks. ==&lt;br /&gt;
 &lt;br /&gt;
We will using the following files &lt;br /&gt;
&lt;br /&gt;
1. border-router.c &amp;lt;br&amp;gt;&lt;br /&gt;
2. udp-server.c  (udp-client.c can also be used)&amp;lt;br&amp;gt;&lt;br /&gt;
3. slip-bridge.c (It contains callback function for processing a SLIP connection request) &amp;lt;br&amp;gt;&lt;br /&gt;
4. httpd-simple.c   (A simple web server forwarding page generation to a protothread)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
udp-server nodes will form a DAG with the border router set as the root. The border router will receive the prefix through a SLIP connection and it will be communicated to the rest of the nodes in the RPL network. &lt;br /&gt;
&lt;br /&gt;
Refer to the following code snippets in the file border-router.c In this piece of code the node configured as the border router waits for the prefix to be set. Once it receives the prefix, the border router is set as the root of the DAG after which it sets the prefix of the rest of the nodes in the network.  &lt;br /&gt;
 &lt;br /&gt;
 /* Request prefix until it has been received */ &lt;br /&gt;
  while(!prefix_set) { &lt;br /&gt;
    etimer_set(&amp;amp;et, CLOCK_SECOND); &lt;br /&gt;
    request_prefix(); &lt;br /&gt;
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&amp;amp;et)); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
  dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)dag_id); &lt;br /&gt;
  if(dag != NULL) { &lt;br /&gt;
    rpl_set_prefix(dag, &amp;amp;prefix, 64); &lt;br /&gt;
    PRINTF(&amp;quot;created a new RPL dag\n&amp;quot;); &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
By default the border router hosts a simple web page. However this can be disabled by defining WEBSERVER as seen the code snippet below. This webpage is displayed when the IPv6 address of the border router is entered in the browser. Refer to the file httpd-simple.c for the following code snippet&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;PROCESS(border_router_process, &amp;quot;Border router process&amp;quot;);&lt;br /&gt;
#if WEBSERVER==0&lt;br /&gt;
/* No webserver */&lt;br /&gt;
AUTOSTART_PROCESSES(&amp;amp;border_router_process);&lt;br /&gt;
#elif WEBSERVER&amp;gt;1&lt;br /&gt;
/* Use an external webserver application */&lt;br /&gt;
#include &amp;quot;webserver-nogui.h&amp;quot;&lt;br /&gt;
AUTOSTART_PROCESSES(&amp;amp;border_router_process,&amp;amp;webserver_nogui_process); &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Compiling the code ==&lt;br /&gt;
 &lt;br /&gt;
The code for RPL border router can be found at /contiki-2.7/examples/ipv6/rpl-border-router. Use the following command to compile the code for the border router &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-border-router &lt;br /&gt;
make TARGET=sky. &amp;lt;/pre&amp;gt;   &lt;br /&gt;
Once this command has been successfully executed a file named border-router.sky will be created. This file will be used to program one of the motes as the border router on Cooja.  &lt;br /&gt;
For the purpose of this tutorial we will  select  TMote Sky  as our target. &lt;br /&gt;
&lt;br /&gt;
In order to demonstrate the functionality of the border router we will create a network of nodes with the border router as the root. For creating such a network we will user the udp-server.c code.  &lt;br /&gt;
This code can be found at /contiki-2.7/examples/ipv6/rpl-udp . Use the following command to compile the code for rpl-udp &lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-udp &lt;br /&gt;
make TARGET=sky &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once this command has been successfully executed a file named udp-server.sky will be created. This file will be used to program the remaining nodes in Cooja simulator. These nodes will form a DAG with the rpl border router as the root.&lt;br /&gt;
&lt;br /&gt;
== Testing on Cooja ==&lt;br /&gt;
 &lt;br /&gt;
Upon the successful completion of the above mentioned steps we are ready to create a simulation in Cooja.  &lt;br /&gt;
Start the Cooja simulator using the following command &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd /contiki-2.7/tools/cooja &lt;br /&gt;
ant run&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
When the GUI launches execute the following steps to create a simulation. &amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
1. From &amp;#039;File&amp;#039; select &amp;#039;New Simulation&amp;#039;. Select UDGM, enter the name of the simulation and click on create. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Click on Motes. From the drop down menu select &amp;#039;Add New Motes&amp;#039; followed by &amp;#039;Create new motes&amp;#039; and select the mote type as Sky. &amp;lt;br&amp;gt;&lt;br /&gt;
3. Browse to the location /contiki-2.7/examples/ipv6/rpl-border-router and select the file rpl-border-router.sky. Click on &amp;#039;Create&amp;#039;. Add one mote of this type. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Repeat step 2 and 3 but this time browse to the location /contiki-2.7/examples/ipv6/rpl-udp  and select the file udp-server.sky. Add 3 - 4 motes of the type udp-server &amp;lt;br&amp;gt;&lt;br /&gt;
5. Once the motes have been added you can position the motes. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Cooja_motes.png]]&lt;br /&gt;
&lt;br /&gt;
Select the options under View as shown below. These will help you creating a topology of your choice.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Motes_view.png]]&lt;br /&gt;
&lt;br /&gt;
6. Now, we need to create a bridge between the RPL network simulated on Cooja and the local machine. This can be done by right clicking on the mote which is programmed as the border router. Select &amp;#039;More tools for border router&amp;#039; and then select &amp;#039;Serial Socket (SERVER)&amp;#039;. You will get the following message on the successful completion of this step.Note that the message says &amp;#039;Listening on port 60001&amp;#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Serial_Socket.png]]&lt;br /&gt;
&lt;br /&gt;
7. Now start the simulation by clicking on Start&lt;br /&gt;
&lt;br /&gt;
== Tunslip utility ==&lt;br /&gt;
 &lt;br /&gt;
As mentioned in the introduction a border router helps in connecting one network to another. In this example the border router is used to route data between an RPL network and an external network. Till now we have only created the RPL network. Now we need to simulate the scenario in which this RPL network is connected to an external network. For this purpose we will use the Tunslip utility provided in Contiki. In this example tunslip creates a bridge between the RPL network and the local machine. &lt;br /&gt;
tunslip6.c can be found in /contiki-2.7/tools &lt;br /&gt;
Compile the tunslip6 code.&lt;br /&gt;
&amp;lt;pre&amp;gt;make tunslip6 &amp;lt;/pre&amp;gt; &lt;br /&gt;
Make a connection between the RPL network and your local machine. &lt;br /&gt;
&amp;lt;pre&amp;gt;sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64&amp;lt;/pre&amp;gt;&lt;br /&gt;
On the successful execution this command the following output will be printed on the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;slip connected to ``127.0.0.1:60001&amp;#039;&amp;#039;&lt;br /&gt;
opened tun device ``/dev/tun0&amp;#039;&amp;#039;&lt;br /&gt;
ifconfig tun0 inet `hostname` up&lt;br /&gt;
ifconfig tun0 add aaaa::1/64&lt;br /&gt;
ifconfig tun0 add fe80::0:0:0:1/64&lt;br /&gt;
ifconfig tun0&lt;br /&gt;
&lt;br /&gt;
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  &lt;br /&gt;
          inet addr:127.0.1.1  P-t-P:127.0.1.1  Mask:255.255.255.255&lt;br /&gt;
          inet6 addr: fe80::1/64 Scope:Link&lt;br /&gt;
          inet6 addr: aaaa::1/64 Scope:Global&lt;br /&gt;
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1&lt;br /&gt;
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0&lt;br /&gt;
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0&lt;br /&gt;
          collisions:0 txqueuelen:500 &lt;br /&gt;
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)&lt;br /&gt;
&lt;br /&gt;
Rime started with address 0.18.116.1.0.1.1.1&lt;br /&gt;
MAC 00:12:74:01:00:01:01:01 Contiki 2.7 started. Node id is set to 1.&lt;br /&gt;
CSMA ContikiMAC, channel check rate 8 Hz, radio channel 26&lt;br /&gt;
Tentative link-local IPv6 address fe80:0000:0000:0000:0212:7401:0001:0101&lt;br /&gt;
Starting &amp;#039;Border router process&amp;#039; &amp;#039;Web server&amp;#039;&lt;br /&gt;
*** Address:aaaa::1 =&amp;gt; aaaa:0000:0000:0000&lt;br /&gt;
Got configuration message of type P&lt;br /&gt;
Setting prefix aaaa::&lt;br /&gt;
Server IPv6 addresses:&lt;br /&gt;
 aaaa::212:7401:1:101&lt;br /&gt;
 fe80::212:7401:1:101&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Go back to the Cooja simulator GUI and look at the dialogue box. The message has now changed to &amp;#039;Client connected: /127.0.0.1&amp;#039;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Client_Connected.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Verifying Results ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can verify that the address of the border router has been set by using the ping command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7401:1:101&lt;br /&gt;
PING aaaa::212:7401:1:101(aaaa::212:7401:1:101) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=1 ttl=64 time=86.0 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=2 ttl=64 time=33.6 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=3 ttl=64 time=82.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=4 ttl=64 time=43.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=5 ttl=64 time=70.1 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7401:1:101 ping statistics ---&lt;br /&gt;
5 packets transmitted, 5 received, 0% packet loss, time 4006ms&lt;br /&gt;
rtt min/avg/max/mdev = 33.669/63.090/86.015/20.985 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also ping one of the other nodes in the network. Here we are pinging node 4&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7404:4:404&lt;br /&gt;
PING aaaa::212:7404:4:404(aaaa::212:7404:4:404) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=1 ttl=63 time=670 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=2 ttl=63 time=703 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=3 ttl=63 time=746 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=4 ttl=63 time=674 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7404:4:404 ping statistics ---&lt;br /&gt;
5 packets transmitted, 4 received, 20% packet loss, time 4001ms&lt;br /&gt;
rtt min/avg/max/mdev = 670.230/698.666/746.619/30.514 ms&lt;br /&gt;
user@instant-contiki:~/contiki-2.7$ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IPv6 address of a node can be checked from the log screen on Cooja. Filter the nodes by their ID&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Node_Address.png]]&lt;br /&gt;
&lt;br /&gt;
You can enter the address of the border router in the web browser. The border router host a page which will be displayed on the browser as shown below. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:RPL_Browser.png]]&lt;br /&gt;
&lt;br /&gt;
== Common Issues ==&lt;br /&gt;
&lt;br /&gt;
1. Make sure that you enter the IPv6 address properly in the command sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64 . There should be no spaces in aaaa::1/64. Otherwise the code will give unexpected behavior.&amp;lt;br&amp;gt;&lt;br /&gt;
2. When you pause the simulation the SLIP connection is lost. It might not work properly on resuming the simulation. In such cases reload the simulation. Create a fresh SLIP connection and then run the simulation again.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
[https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md]  https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md &amp;lt;br&amp;gt;&lt;br /&gt;
[http://cnds.eecs.jacobs-university.de/courses/iotlab-2013/cooja.pdf] Using the Contiki Cooja Simulator - Anuj Sehgal&lt;/div&gt;</summary>
		<author><name>Ckapoor</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1161</id>
		<title>RPL Border Router</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1161"/>
				<updated>2014-11-08T23:47:44Z</updated>
		
		<summary type="html">&lt;p&gt;Ckapoor: /* Code building blocks. */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction: ==&lt;br /&gt;
  &lt;br /&gt;
Border routers are routers that can be found at the edge of a network. Their function is to connect one network to another. In this tutorial we will learn how to run a simulation using the border router in Contiki In the example which we will discuss in the rest of this tutorial the border router will be used to route data between a WSN (using RPL) and an external IP network.  &lt;br /&gt;
Objective:  &lt;br /&gt;
The objective of this tutorial is to give you an understanding of the RPL Border Router code on Contiki OS and learn how to simulate the code on Cooja &lt;br /&gt;
What will you learn at the end of this tutorial. At the end of the tutorial you would have learnt the following: &lt;br /&gt;
&lt;br /&gt;
1. Understanding the working of the rpl border router code &amp;lt;br&amp;gt;&lt;br /&gt;
2. Starting a simulation on Cooja simulator. &amp;lt;br&amp;gt; &lt;br /&gt;
3. Observing and validating the results &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code building blocks. ==&lt;br /&gt;
 &lt;br /&gt;
We will using the following files &lt;br /&gt;
&lt;br /&gt;
1. border-router.c &amp;lt;br&amp;gt;&lt;br /&gt;
2. udp-server.c  (udp-client.c can also be used)&amp;lt;br&amp;gt;&lt;br /&gt;
3. slip-bridge.c (It contains callback function for processing a SLIP connection request) &amp;lt;br&amp;gt;&lt;br /&gt;
4. httpd-simple.c   (A simple web server forwarding page generation to a protothread)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
udp-server nodes will form a DAG with the border router set as the root. The border router will receive the prefix through a SLIP connection and it will be communicated to the rest of the nodes in the RPL network. &lt;br /&gt;
&lt;br /&gt;
Refer to the following code snippets in the file border-router.c In this piece of code the node configured as the border router waits for the prefix to be set. Once it receives the prefix, the border router is set as the root of the DAG after which it sets the prefix of the rest of the nodes in the network.  &lt;br /&gt;
 &lt;br /&gt;
 /* Request prefix until it has been received */ &lt;br /&gt;
  while(!prefix_set) { &lt;br /&gt;
    etimer_set(&amp;amp;et, CLOCK_SECOND); &lt;br /&gt;
    request_prefix(); &lt;br /&gt;
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&amp;amp;et)); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
  dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)dag_id); &lt;br /&gt;
  if(dag != NULL) { &lt;br /&gt;
    rpl_set_prefix(dag, &amp;amp;prefix, 64); &lt;br /&gt;
    PRINTF(&amp;quot;created a new RPL dag\n&amp;quot;); &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
By default the border router hosts a simple web page. However this can be disabled by defining WEBSERVER as seen the code snippet below. This webpage is displayed when the IPv6 address of the border router is entered in the browser. Refer to the file httpd-simple.c for the following code snippet&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;PROCESS(border_router_process, &amp;quot;Border router process&amp;quot;);&lt;br /&gt;
#if WEBSERVER==0&lt;br /&gt;
/* No webserver */&lt;br /&gt;
AUTOSTART_PROCESSES(&amp;amp;border_router_process);&lt;br /&gt;
#elif WEBSERVER&amp;gt;1&lt;br /&gt;
/* Use an external webserver application */&lt;br /&gt;
#include &amp;quot;webserver-nogui.h&amp;quot;&lt;br /&gt;
AUTOSTART_PROCESSES(&amp;amp;border_router_process,&amp;amp;webserver_nogui_process); &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Compiling the code ==&lt;br /&gt;
 &lt;br /&gt;
The code for RPL border router can be found at /contiki-2.7/examples/ipv6/rpl-border-router. Use the following command to compile the code for the border router &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-border-router &lt;br /&gt;
make TARGET=sky. &amp;lt;/pre&amp;gt;   &lt;br /&gt;
Once this command has been successfully executed a file named border-router.sky will be created. This file will be used to program one of the motes as the border router on Cooja.  &lt;br /&gt;
For the purpose of this tutorial we will  select  TMote Sky  as our target. &lt;br /&gt;
&lt;br /&gt;
In order to demonstrate the functionality of the border router we will create a network of nodes with the border router as the root. For creating such a network we will user the udp-server.c code.  &lt;br /&gt;
This code can be found at /contiki-2.7/examples/ipv6/rpl-udp . Use the following command to compile the code for rpl-udp &lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-udp &lt;br /&gt;
make TARGET=sky &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once this command has been successfully executed a file named udp-server.sky will be created. This file will be used to program the remaining nodes in Cooja simulator. These nodes will form a DAG with the rpl border router as the root.&lt;br /&gt;
&lt;br /&gt;
== Testing on Cooja ==&lt;br /&gt;
 &lt;br /&gt;
Upon the successful completion of the above mentioned steps we are ready to create a simulation in Cooja.  &lt;br /&gt;
Start the Cooja simulator using the following command &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd /contiki-2.7/tools/cooja &lt;br /&gt;
ant run&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
When the GUI launches execute the following steps to create a simulation. &amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
1. From &amp;#039;File&amp;#039; select &amp;#039;New Simulation&amp;#039;. Select UDGM, enter the name of the simulation and click on create. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Click on Motes. From the drop down menu select &amp;#039;Add New Motes&amp;#039; followed by &amp;#039;Create new motes&amp;#039; and select the mote type as Sky. &amp;lt;br&amp;gt;&lt;br /&gt;
3. Browse to the location /contiki-2.7/examples/ipv6/rpl-border-router and select the file rpl-border-router.sky. Click on &amp;#039;Create&amp;#039;. Add one mote of this type. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Repeat step 2 and 3 but this time browse to the location /contiki-2.7/examples/ipv6/rpl-udp  and select the file udp-server.sky. Add 3 - 4 motes of the type udp-server &amp;lt;br&amp;gt;&lt;br /&gt;
5. Once the motes have been added you can position the motes. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Cooja_motes.png]]&lt;br /&gt;
&lt;br /&gt;
Select the options under View as shown below. These will help you creating a topology of your choice.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Motes_view.png]]&lt;br /&gt;
&lt;br /&gt;
6. Now, we need to create a bridge between the RPL network simulated on Cooja and the local machine. This can be done by right clicking on the mote which is programmed as the border router. Select &amp;#039;More tools for border router&amp;#039; and then select &amp;#039;Serial Socket (SERVER)&amp;#039;. You will get the following message on the successful completion of this step.Note that the message says &amp;#039;Listening on port 60001&amp;#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Serial_Socket.png]]&lt;br /&gt;
&lt;br /&gt;
7. Now start the simulation by clicking on Start&lt;br /&gt;
&lt;br /&gt;
== Tunslip utility ==&lt;br /&gt;
 &lt;br /&gt;
As mentioned in the introduction a border router helps in connecting one network to another. In this example the border router is used to route data between an RPL network and an external network. Till now we have only created the RPL network. Now we need to simulate the scenario in which this RPL network is connected to an external network. For this purpose we will use the Tunslip utility provided in Contiki. In this example tunslip creates a bridge between the RPL network and the local machine. &lt;br /&gt;
tunslip6.c can be found in /contiki-2.7/tools &lt;br /&gt;
Compile the tunslip6 code.&lt;br /&gt;
&amp;lt;pre&amp;gt;make tunslip6 &amp;lt;/pre&amp;gt; &lt;br /&gt;
Make a connection between the RPL network and your local machine. &lt;br /&gt;
&amp;lt;pre&amp;gt;sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64&amp;lt;/pre&amp;gt;&lt;br /&gt;
On the successful execution this command the following output will be printed on the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;slip connected to ``127.0.0.1:60001&amp;#039;&amp;#039;&lt;br /&gt;
opened tun device ``/dev/tun0&amp;#039;&amp;#039;&lt;br /&gt;
ifconfig tun0 inet `hostname` up&lt;br /&gt;
ifconfig tun0 add aaaa::1/64&lt;br /&gt;
ifconfig tun0 add fe80::0:0:0:1/64&lt;br /&gt;
ifconfig tun0&lt;br /&gt;
&lt;br /&gt;
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  &lt;br /&gt;
          inet addr:127.0.1.1  P-t-P:127.0.1.1  Mask:255.255.255.255&lt;br /&gt;
          inet6 addr: fe80::1/64 Scope:Link&lt;br /&gt;
          inet6 addr: aaaa::1/64 Scope:Global&lt;br /&gt;
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1&lt;br /&gt;
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0&lt;br /&gt;
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0&lt;br /&gt;
          collisions:0 txqueuelen:500 &lt;br /&gt;
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)&lt;br /&gt;
&lt;br /&gt;
Rime started with address 0.18.116.1.0.1.1.1&lt;br /&gt;
MAC 00:12:74:01:00:01:01:01 Contiki 2.7 started. Node id is set to 1.&lt;br /&gt;
CSMA ContikiMAC, channel check rate 8 Hz, radio channel 26&lt;br /&gt;
Tentative link-local IPv6 address fe80:0000:0000:0000:0212:7401:0001:0101&lt;br /&gt;
Starting &amp;#039;Border router process&amp;#039; &amp;#039;Web server&amp;#039;&lt;br /&gt;
*** Address:aaaa::1 =&amp;gt; aaaa:0000:0000:0000&lt;br /&gt;
Got configuration message of type P&lt;br /&gt;
Setting prefix aaaa::&lt;br /&gt;
Server IPv6 addresses:&lt;br /&gt;
 aaaa::212:7401:1:101&lt;br /&gt;
 fe80::212:7401:1:101&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Go back to the Cooja simulator GUI and look at the dialogue box. The message has now changed to &amp;#039;Client connected: /127.0.0.1&amp;#039;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Client_Connected.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Verifying Results ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can verify that the address of the border router has been set by using the ping command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7401:1:101&lt;br /&gt;
PING aaaa::212:7401:1:101(aaaa::212:7401:1:101) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=1 ttl=64 time=86.0 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=2 ttl=64 time=33.6 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=3 ttl=64 time=82.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=4 ttl=64 time=43.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=5 ttl=64 time=70.1 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7401:1:101 ping statistics ---&lt;br /&gt;
5 packets transmitted, 5 received, 0% packet loss, time 4006ms&lt;br /&gt;
rtt min/avg/max/mdev = 33.669/63.090/86.015/20.985 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also ping one of the other nodes in the network. Here we are pinging node 4&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7404:4:404&lt;br /&gt;
PING aaaa::212:7404:4:404(aaaa::212:7404:4:404) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=1 ttl=63 time=670 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=2 ttl=63 time=703 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=3 ttl=63 time=746 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=4 ttl=63 time=674 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7404:4:404 ping statistics ---&lt;br /&gt;
5 packets transmitted, 4 received, 20% packet loss, time 4001ms&lt;br /&gt;
rtt min/avg/max/mdev = 670.230/698.666/746.619/30.514 ms&lt;br /&gt;
user@instant-contiki:~/contiki-2.7$ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IPv6 address of a node can be checked from the log screen on Cooja. Filter the nodes by their ID&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Node_Address.png]]&lt;br /&gt;
&lt;br /&gt;
You can enter the address of the border router in the web browser. The border router host a page which will be displayed on the browser as shown below. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:RPL_Browser.png]]&lt;br /&gt;
&lt;br /&gt;
== Common Issues ==&lt;br /&gt;
&lt;br /&gt;
1. Make sure that you enter the IPv6 address properly in the command sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64 . There should be no spaces in aaaa::1/64. Otherwise the code will give unexpected behavior.&amp;lt;br&amp;gt;&lt;br /&gt;
2. When you pause the simulation the SLIP connection is lost. It might not work properly on resuming the simulation. In such cases reload the simulation. Create a fresh SLIP connection and then run the simulation again.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
[https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md]  https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md &amp;lt;br&amp;gt;&lt;br /&gt;
[http://cnds.eecs.jacobs-university.de/courses/iotlab-2013/cooja.pdf] Using the Contiki Cooja Simulator - Anuj Sehgal&lt;/div&gt;</summary>
		<author><name>Ckapoor</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1156</id>
		<title>RPL Border Router</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1156"/>
				<updated>2014-11-08T23:27:00Z</updated>
		
		<summary type="html">&lt;p&gt;Ckapoor: /* Code building blocks. */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction: ==&lt;br /&gt;
  &lt;br /&gt;
Border routers are routers that can be found at the edge of a network. Their function is to connect one network to another. In this tutorial we will learn how to run a simulation using the border router in Contiki In the example which we will discuss in the rest of this tutorial the border router will be used to route data between a WSN (using RPL) and an external IP network.  &lt;br /&gt;
Objective:  &lt;br /&gt;
The objective of this tutorial is to give you an understanding of the RPL Border Router code on Contiki OS and learn how to simulate the code on Cooja &lt;br /&gt;
What will you learn at the end of this tutorial. At the end of the tutorial you would have learnt the following: &lt;br /&gt;
&lt;br /&gt;
1. Understanding the working of the rpl border router code &amp;lt;br&amp;gt;&lt;br /&gt;
2. Starting a simulation on Cooja simulator. &amp;lt;br&amp;gt; &lt;br /&gt;
3. Observing and validating the results &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code building blocks. ==&lt;br /&gt;
 &lt;br /&gt;
We will using the following files &lt;br /&gt;
&lt;br /&gt;
1. border-router.c &amp;lt;br&amp;gt;&lt;br /&gt;
2. udp-server.c  (udp-client.c can also be used)&amp;lt;br&amp;gt;&lt;br /&gt;
3. slip-bridge.c&amp;lt;br&amp;gt;&lt;br /&gt;
4. httpd-simple.c   (A simple web server forwarding page generation to a protothread)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
udp-server nodes will form a DAG with the border router set as the root. The border router will receive the prefix through a SLIP connection and it will be communicated to the rest of the nodes in the RPL network. &lt;br /&gt;
&lt;br /&gt;
Refer to the following code snippets in the file border-router.c In this piece of code the node configured as the border router waits for the prefix to be set. Once it receives the prefix, the border router is set as the root of the DAG after which it sets the prefix of the rest of the nodes in the network.  &lt;br /&gt;
 &lt;br /&gt;
 /* Request prefix until it has been received */ &lt;br /&gt;
  while(!prefix_set) { &lt;br /&gt;
    etimer_set(&amp;amp;et, CLOCK_SECOND); &lt;br /&gt;
    request_prefix(); &lt;br /&gt;
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&amp;amp;et)); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
  dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)dag_id); &lt;br /&gt;
  if(dag != NULL) { &lt;br /&gt;
    rpl_set_prefix(dag, &amp;amp;prefix, 64); &lt;br /&gt;
    PRINTF(&amp;quot;created a new RPL dag\n&amp;quot;); &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
By default the border router hosts a simple web page. However this can be disabled by defining WEBSERVER as seen the code snippet below. This webpage is displayed when the IPv6 address of the border router is entered in the browser. Refer to the file httpd-simple.c for the following code snippet&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;PROCESS(border_router_process, &amp;quot;Border router process&amp;quot;);&lt;br /&gt;
#if WEBSERVER==0&lt;br /&gt;
/* No webserver */&lt;br /&gt;
AUTOSTART_PROCESSES(&amp;amp;border_router_process);&lt;br /&gt;
#elif WEBSERVER&amp;gt;1&lt;br /&gt;
/* Use an external webserver application */&lt;br /&gt;
#include &amp;quot;webserver-nogui.h&amp;quot;&lt;br /&gt;
AUTOSTART_PROCESSES(&amp;amp;border_router_process,&amp;amp;webserver_nogui_process); &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Compiling the code ==&lt;br /&gt;
 &lt;br /&gt;
The code for RPL border router can be found at /contiki-2.7/examples/ipv6/rpl-border-router. Use the following command to compile the code for the border router &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-border-router &lt;br /&gt;
make TARGET=sky. &amp;lt;/pre&amp;gt;   &lt;br /&gt;
Once this command has been successfully executed a file named border-router.sky will be created. This file will be used to program one of the motes as the border router on Cooja.  &lt;br /&gt;
For the purpose of this tutorial we will  select  TMote Sky  as our target. &lt;br /&gt;
&lt;br /&gt;
In order to demonstrate the functionality of the border router we will create a network of nodes with the border router as the root. For creating such a network we will user the udp-server.c code.  &lt;br /&gt;
This code can be found at /contiki-2.7/examples/ipv6/rpl-udp . Use the following command to compile the code for rpl-udp &lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-udp &lt;br /&gt;
make TARGET=sky &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once this command has been successfully executed a file named udp-server.sky will be created. This file will be used to program the remaining nodes in Cooja simulator. These nodes will form a DAG with the rpl border router as the root.&lt;br /&gt;
&lt;br /&gt;
== Testing on Cooja ==&lt;br /&gt;
 &lt;br /&gt;
Upon the successful completion of the above mentioned steps we are ready to create a simulation in Cooja.  &lt;br /&gt;
Start the Cooja simulator using the following command &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd /contiki-2.7/tools/cooja &lt;br /&gt;
ant run&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
When the GUI launches execute the following steps to create a simulation. &amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
1. From &amp;#039;File&amp;#039; select &amp;#039;New Simulation&amp;#039;. Select UDGM, enter the name of the simulation and click on create. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Click on Motes. From the drop down menu select &amp;#039;Add New Motes&amp;#039; followed by &amp;#039;Create new motes&amp;#039; and select the mote type as Sky. &amp;lt;br&amp;gt;&lt;br /&gt;
3. Browse to the location /contiki-2.7/examples/ipv6/rpl-border-router and select the file rpl-border-router.sky. Click on &amp;#039;Create&amp;#039;. Add one mote of this type. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Repeat step 2 and 3 but this time browse to the location /contiki-2.7/examples/ipv6/rpl-udp  and select the file udp-server.sky. Add 3 - 4 motes of the type udp-server &amp;lt;br&amp;gt;&lt;br /&gt;
5. Once the motes have been added you can position the motes. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Cooja_motes.png]]&lt;br /&gt;
&lt;br /&gt;
Select the options under View as shown below. These will help you creating a topology of your choice.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Motes_view.png]]&lt;br /&gt;
&lt;br /&gt;
6. Now, we need to create a bridge between the RPL network simulated on Cooja and the local machine. This can be done by right clicking on the mote which is programmed as the border router. Select &amp;#039;More tools for border router&amp;#039; and then select &amp;#039;Serial Socket (SERVER)&amp;#039;. You will get the following message on the successful completion of this step.Note that the message says &amp;#039;Listening on port 60001&amp;#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Serial_Socket.png]]&lt;br /&gt;
&lt;br /&gt;
7. Now start the simulation by clicking on Start&lt;br /&gt;
&lt;br /&gt;
== Tunslip utility ==&lt;br /&gt;
 &lt;br /&gt;
As mentioned in the introduction a border router helps in connecting one network to another. In this example the border router is used to route data between an RPL network and an external network. Till now we have only created the RPL network. Now we need to simulate the scenario in which this RPL network is connected to an external network. For this purpose we will use the Tunslip utility provided in Contiki. In this example tunslip creates a bridge between the RPL network and the local machine. &lt;br /&gt;
tunslip6.c can be found in /contiki-2.7/tools &lt;br /&gt;
Compile the tunslip6 code.&lt;br /&gt;
&amp;lt;pre&amp;gt;make tunslip6 &amp;lt;/pre&amp;gt; &lt;br /&gt;
Make a connection between the RPL network and your local machine. &lt;br /&gt;
&amp;lt;pre&amp;gt;sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64&amp;lt;/pre&amp;gt;&lt;br /&gt;
On the successful execution this command the following output will be printed on the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;slip connected to ``127.0.0.1:60001&amp;#039;&amp;#039;&lt;br /&gt;
opened tun device ``/dev/tun0&amp;#039;&amp;#039;&lt;br /&gt;
ifconfig tun0 inet `hostname` up&lt;br /&gt;
ifconfig tun0 add aaaa::1/64&lt;br /&gt;
ifconfig tun0 add fe80::0:0:0:1/64&lt;br /&gt;
ifconfig tun0&lt;br /&gt;
&lt;br /&gt;
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  &lt;br /&gt;
          inet addr:127.0.1.1  P-t-P:127.0.1.1  Mask:255.255.255.255&lt;br /&gt;
          inet6 addr: fe80::1/64 Scope:Link&lt;br /&gt;
          inet6 addr: aaaa::1/64 Scope:Global&lt;br /&gt;
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1&lt;br /&gt;
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0&lt;br /&gt;
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0&lt;br /&gt;
          collisions:0 txqueuelen:500 &lt;br /&gt;
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)&lt;br /&gt;
&lt;br /&gt;
Rime started with address 0.18.116.1.0.1.1.1&lt;br /&gt;
MAC 00:12:74:01:00:01:01:01 Contiki 2.7 started. Node id is set to 1.&lt;br /&gt;
CSMA ContikiMAC, channel check rate 8 Hz, radio channel 26&lt;br /&gt;
Tentative link-local IPv6 address fe80:0000:0000:0000:0212:7401:0001:0101&lt;br /&gt;
Starting &amp;#039;Border router process&amp;#039; &amp;#039;Web server&amp;#039;&lt;br /&gt;
*** Address:aaaa::1 =&amp;gt; aaaa:0000:0000:0000&lt;br /&gt;
Got configuration message of type P&lt;br /&gt;
Setting prefix aaaa::&lt;br /&gt;
Server IPv6 addresses:&lt;br /&gt;
 aaaa::212:7401:1:101&lt;br /&gt;
 fe80::212:7401:1:101&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Go back to the Cooja simulator GUI and look at the dialogue box. The message has now changed to &amp;#039;Client connected: /127.0.0.1&amp;#039;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Client_Connected.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Verifying Results ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can verify that the address of the border router has been set by using the ping command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7401:1:101&lt;br /&gt;
PING aaaa::212:7401:1:101(aaaa::212:7401:1:101) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=1 ttl=64 time=86.0 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=2 ttl=64 time=33.6 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=3 ttl=64 time=82.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=4 ttl=64 time=43.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=5 ttl=64 time=70.1 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7401:1:101 ping statistics ---&lt;br /&gt;
5 packets transmitted, 5 received, 0% packet loss, time 4006ms&lt;br /&gt;
rtt min/avg/max/mdev = 33.669/63.090/86.015/20.985 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also ping one of the other nodes in the network. Here we are pinging node 4&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7404:4:404&lt;br /&gt;
PING aaaa::212:7404:4:404(aaaa::212:7404:4:404) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=1 ttl=63 time=670 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=2 ttl=63 time=703 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=3 ttl=63 time=746 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=4 ttl=63 time=674 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7404:4:404 ping statistics ---&lt;br /&gt;
5 packets transmitted, 4 received, 20% packet loss, time 4001ms&lt;br /&gt;
rtt min/avg/max/mdev = 670.230/698.666/746.619/30.514 ms&lt;br /&gt;
user@instant-contiki:~/contiki-2.7$ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IPv6 address of a node can be checked from the log screen on Cooja. Filter the nodes by their ID&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Node_Address.png]]&lt;br /&gt;
&lt;br /&gt;
You can enter the address of the border router in the web browser. The border router host a page which will be displayed on the browser as shown below. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:RPL_Browser.png]]&lt;br /&gt;
&lt;br /&gt;
== Common Issues ==&lt;br /&gt;
&lt;br /&gt;
1. Make sure that you enter the IPv6 address properly in the command sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64 . There should be no spaces in aaaa::1/64. Otherwise the code will give unexpected behavior.&amp;lt;br&amp;gt;&lt;br /&gt;
2. When you pause the simulation the SLIP connection is lost. It might not work properly on resuming the simulation. In such cases reload the simulation. Create a fresh SLIP connection and then run the simulation again.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
[https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md]  https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md &amp;lt;br&amp;gt;&lt;br /&gt;
[http://cnds.eecs.jacobs-university.de/courses/iotlab-2013/cooja.pdf] Using the Contiki Cooja Simulator - Anuj Sehgal&lt;/div&gt;</summary>
		<author><name>Ckapoor</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1155</id>
		<title>RPL Border Router</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1155"/>
				<updated>2014-11-08T23:25:23Z</updated>
		
		<summary type="html">&lt;p&gt;Ckapoor: /* Code building blocks. */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction: ==&lt;br /&gt;
  &lt;br /&gt;
Border routers are routers that can be found at the edge of a network. Their function is to connect one network to another. In this tutorial we will learn how to run a simulation using the border router in Contiki In the example which we will discuss in the rest of this tutorial the border router will be used to route data between a WSN (using RPL) and an external IP network.  &lt;br /&gt;
Objective:  &lt;br /&gt;
The objective of this tutorial is to give you an understanding of the RPL Border Router code on Contiki OS and learn how to simulate the code on Cooja &lt;br /&gt;
What will you learn at the end of this tutorial. At the end of the tutorial you would have learnt the following: &lt;br /&gt;
&lt;br /&gt;
1. Understanding the working of the rpl border router code &amp;lt;br&amp;gt;&lt;br /&gt;
2. Starting a simulation on Cooja simulator. &amp;lt;br&amp;gt; &lt;br /&gt;
3. Observing and validating the results &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code building blocks. ==&lt;br /&gt;
 &lt;br /&gt;
We will using the following files &lt;br /&gt;
&lt;br /&gt;
1. border-router.c &amp;lt;br&amp;gt;&lt;br /&gt;
2. udp-server.c  (udp-client.c can also be used)&amp;lt;br&amp;gt;&lt;br /&gt;
3. slip-bridge.c&amp;lt;br&amp;gt;&lt;br /&gt;
4. httpd-simple.c   (A simple web server forwarding page generation to a protothread)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
udp-server nodes will form a DAG with the border router set as the root. The border router will receive the prefix through a SLIP connection and it will be communicated to the rest of the nodes in the RPL network. &lt;br /&gt;
&lt;br /&gt;
Refer to the following code snippets in the file border-router.c In this piece of code the node configured as the border router waits for the prefix to be set. Once it receives the prefix, the border router is set as the root of the DODAG after which it sets the prefix of the rest of the nodes in the network.  &lt;br /&gt;
 &lt;br /&gt;
 /* Request prefix until it has been received */ &lt;br /&gt;
  while(!prefix_set) { &lt;br /&gt;
    etimer_set(&amp;amp;et, CLOCK_SECOND); &lt;br /&gt;
    request_prefix(); &lt;br /&gt;
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&amp;amp;et)); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
  dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)dag_id); &lt;br /&gt;
  if(dag != NULL) { &lt;br /&gt;
    rpl_set_prefix(dag, &amp;amp;prefix, 64); &lt;br /&gt;
    PRINTF(&amp;quot;created a new RPL dag\n&amp;quot;); &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
By default the border router hosts a simple web page. However this can be disabled by defining WEBSERVER as seen the code snippet below. This webpage is displayed when the IPv6 address of the border router is entered in the browser. Refer to the file httpd-simple.c for the following code snippet&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;PROCESS(border_router_process, &amp;quot;Border router process&amp;quot;);&lt;br /&gt;
#if WEBSERVER==0&lt;br /&gt;
/* No webserver */&lt;br /&gt;
AUTOSTART_PROCESSES(&amp;amp;border_router_process);&lt;br /&gt;
#elif WEBSERVER&amp;gt;1&lt;br /&gt;
/* Use an external webserver application */&lt;br /&gt;
#include &amp;quot;webserver-nogui.h&amp;quot;&lt;br /&gt;
AUTOSTART_PROCESSES(&amp;amp;border_router_process,&amp;amp;webserver_nogui_process); &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Compiling the code ==&lt;br /&gt;
 &lt;br /&gt;
The code for RPL border router can be found at /contiki-2.7/examples/ipv6/rpl-border-router. Use the following command to compile the code for the border router &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-border-router &lt;br /&gt;
make TARGET=sky. &amp;lt;/pre&amp;gt;   &lt;br /&gt;
Once this command has been successfully executed a file named border-router.sky will be created. This file will be used to program one of the motes as the border router on Cooja.  &lt;br /&gt;
For the purpose of this tutorial we will  select  TMote Sky  as our target. &lt;br /&gt;
&lt;br /&gt;
In order to demonstrate the functionality of the border router we will create a network of nodes with the border router as the root. For creating such a network we will user the udp-server.c code.  &lt;br /&gt;
This code can be found at /contiki-2.7/examples/ipv6/rpl-udp . Use the following command to compile the code for rpl-udp &lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-udp &lt;br /&gt;
make TARGET=sky &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once this command has been successfully executed a file named udp-server.sky will be created. This file will be used to program the remaining nodes in Cooja simulator. These nodes will form a DAG with the rpl border router as the root.&lt;br /&gt;
&lt;br /&gt;
== Testing on Cooja ==&lt;br /&gt;
 &lt;br /&gt;
Upon the successful completion of the above mentioned steps we are ready to create a simulation in Cooja.  &lt;br /&gt;
Start the Cooja simulator using the following command &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd /contiki-2.7/tools/cooja &lt;br /&gt;
ant run&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
When the GUI launches execute the following steps to create a simulation. &amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
1. From &amp;#039;File&amp;#039; select &amp;#039;New Simulation&amp;#039;. Select UDGM, enter the name of the simulation and click on create. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Click on Motes. From the drop down menu select &amp;#039;Add New Motes&amp;#039; followed by &amp;#039;Create new motes&amp;#039; and select the mote type as Sky. &amp;lt;br&amp;gt;&lt;br /&gt;
3. Browse to the location /contiki-2.7/examples/ipv6/rpl-border-router and select the file rpl-border-router.sky. Click on &amp;#039;Create&amp;#039;. Add one mote of this type. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Repeat step 2 and 3 but this time browse to the location /contiki-2.7/examples/ipv6/rpl-udp  and select the file udp-server.sky. Add 3 - 4 motes of the type udp-server &amp;lt;br&amp;gt;&lt;br /&gt;
5. Once the motes have been added you can position the motes. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Cooja_motes.png]]&lt;br /&gt;
&lt;br /&gt;
Select the options under View as shown below. These will help you creating a topology of your choice.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Motes_view.png]]&lt;br /&gt;
&lt;br /&gt;
6. Now, we need to create a bridge between the RPL network simulated on Cooja and the local machine. This can be done by right clicking on the mote which is programmed as the border router. Select &amp;#039;More tools for border router&amp;#039; and then select &amp;#039;Serial Socket (SERVER)&amp;#039;. You will get the following message on the successful completion of this step.Note that the message says &amp;#039;Listening on port 60001&amp;#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Serial_Socket.png]]&lt;br /&gt;
&lt;br /&gt;
7. Now start the simulation by clicking on Start&lt;br /&gt;
&lt;br /&gt;
== Tunslip utility ==&lt;br /&gt;
 &lt;br /&gt;
As mentioned in the introduction a border router helps in connecting one network to another. In this example the border router is used to route data between an RPL network and an external network. Till now we have only created the RPL network. Now we need to simulate the scenario in which this RPL network is connected to an external network. For this purpose we will use the Tunslip utility provided in Contiki. In this example tunslip creates a bridge between the RPL network and the local machine. &lt;br /&gt;
tunslip6.c can be found in /contiki-2.7/tools &lt;br /&gt;
Compile the tunslip6 code.&lt;br /&gt;
&amp;lt;pre&amp;gt;make tunslip6 &amp;lt;/pre&amp;gt; &lt;br /&gt;
Make a connection between the RPL network and your local machine. &lt;br /&gt;
&amp;lt;pre&amp;gt;sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64&amp;lt;/pre&amp;gt;&lt;br /&gt;
On the successful execution this command the following output will be printed on the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;slip connected to ``127.0.0.1:60001&amp;#039;&amp;#039;&lt;br /&gt;
opened tun device ``/dev/tun0&amp;#039;&amp;#039;&lt;br /&gt;
ifconfig tun0 inet `hostname` up&lt;br /&gt;
ifconfig tun0 add aaaa::1/64&lt;br /&gt;
ifconfig tun0 add fe80::0:0:0:1/64&lt;br /&gt;
ifconfig tun0&lt;br /&gt;
&lt;br /&gt;
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  &lt;br /&gt;
          inet addr:127.0.1.1  P-t-P:127.0.1.1  Mask:255.255.255.255&lt;br /&gt;
          inet6 addr: fe80::1/64 Scope:Link&lt;br /&gt;
          inet6 addr: aaaa::1/64 Scope:Global&lt;br /&gt;
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1&lt;br /&gt;
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0&lt;br /&gt;
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0&lt;br /&gt;
          collisions:0 txqueuelen:500 &lt;br /&gt;
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)&lt;br /&gt;
&lt;br /&gt;
Rime started with address 0.18.116.1.0.1.1.1&lt;br /&gt;
MAC 00:12:74:01:00:01:01:01 Contiki 2.7 started. Node id is set to 1.&lt;br /&gt;
CSMA ContikiMAC, channel check rate 8 Hz, radio channel 26&lt;br /&gt;
Tentative link-local IPv6 address fe80:0000:0000:0000:0212:7401:0001:0101&lt;br /&gt;
Starting &amp;#039;Border router process&amp;#039; &amp;#039;Web server&amp;#039;&lt;br /&gt;
*** Address:aaaa::1 =&amp;gt; aaaa:0000:0000:0000&lt;br /&gt;
Got configuration message of type P&lt;br /&gt;
Setting prefix aaaa::&lt;br /&gt;
Server IPv6 addresses:&lt;br /&gt;
 aaaa::212:7401:1:101&lt;br /&gt;
 fe80::212:7401:1:101&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Go back to the Cooja simulator GUI and look at the dialogue box. The message has now changed to &amp;#039;Client connected: /127.0.0.1&amp;#039;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Client_Connected.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Verifying Results ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can verify that the address of the border router has been set by using the ping command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7401:1:101&lt;br /&gt;
PING aaaa::212:7401:1:101(aaaa::212:7401:1:101) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=1 ttl=64 time=86.0 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=2 ttl=64 time=33.6 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=3 ttl=64 time=82.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=4 ttl=64 time=43.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=5 ttl=64 time=70.1 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7401:1:101 ping statistics ---&lt;br /&gt;
5 packets transmitted, 5 received, 0% packet loss, time 4006ms&lt;br /&gt;
rtt min/avg/max/mdev = 33.669/63.090/86.015/20.985 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also ping one of the other nodes in the network. Here we are pinging node 4&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7404:4:404&lt;br /&gt;
PING aaaa::212:7404:4:404(aaaa::212:7404:4:404) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=1 ttl=63 time=670 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=2 ttl=63 time=703 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=3 ttl=63 time=746 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=4 ttl=63 time=674 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7404:4:404 ping statistics ---&lt;br /&gt;
5 packets transmitted, 4 received, 20% packet loss, time 4001ms&lt;br /&gt;
rtt min/avg/max/mdev = 670.230/698.666/746.619/30.514 ms&lt;br /&gt;
user@instant-contiki:~/contiki-2.7$ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IPv6 address of a node can be checked from the log screen on Cooja. Filter the nodes by their ID&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Node_Address.png]]&lt;br /&gt;
&lt;br /&gt;
You can enter the address of the border router in the web browser. The border router host a page which will be displayed on the browser as shown below. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:RPL_Browser.png]]&lt;br /&gt;
&lt;br /&gt;
== Common Issues ==&lt;br /&gt;
&lt;br /&gt;
1. Make sure that you enter the IPv6 address properly in the command sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64 . There should be no spaces in aaaa::1/64. Otherwise the code will give unexpected behavior.&amp;lt;br&amp;gt;&lt;br /&gt;
2. When you pause the simulation the SLIP connection is lost. It might not work properly on resuming the simulation. In such cases reload the simulation. Create a fresh SLIP connection and then run the simulation again.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
[https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md]  https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md &amp;lt;br&amp;gt;&lt;br /&gt;
[http://cnds.eecs.jacobs-university.de/courses/iotlab-2013/cooja.pdf] Using the Contiki Cooja Simulator - Anuj Sehgal&lt;/div&gt;</summary>
		<author><name>Ckapoor</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1154</id>
		<title>RPL Border Router</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1154"/>
				<updated>2014-11-08T23:19:35Z</updated>
		
		<summary type="html">&lt;p&gt;Ckapoor: /* Code building blocks. */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction: ==&lt;br /&gt;
  &lt;br /&gt;
Border routers are routers that can be found at the edge of a network. Their function is to connect one network to another. In this tutorial we will learn how to run a simulation using the border router in Contiki In the example which we will discuss in the rest of this tutorial the border router will be used to route data between a WSN (using RPL) and an external IP network.  &lt;br /&gt;
Objective:  &lt;br /&gt;
The objective of this tutorial is to give you an understanding of the RPL Border Router code on Contiki OS and learn how to simulate the code on Cooja &lt;br /&gt;
What will you learn at the end of this tutorial. At the end of the tutorial you would have learnt the following: &lt;br /&gt;
&lt;br /&gt;
1. Understanding the working of the rpl border router code &amp;lt;br&amp;gt;&lt;br /&gt;
2. Starting a simulation on Cooja simulator. &amp;lt;br&amp;gt; &lt;br /&gt;
3. Observing and validating the results &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code building blocks. ==&lt;br /&gt;
 &lt;br /&gt;
We will using the following files &lt;br /&gt;
&lt;br /&gt;
1. border-router.c &amp;lt;br&amp;gt;&lt;br /&gt;
2. udp-server.c  (udp-client.c can also be used)&amp;lt;br&amp;gt;&lt;br /&gt;
3. slip-bridge.c&amp;lt;br&amp;gt;&lt;br /&gt;
4. httpd-simple.c   (A simple web server forwarding page generation to a protothread)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
udp-server nodes will form a DAG with the border router set as the root. The border router will receive the prefix through a SLIP connection and it will be communicated to the rest of the nodes in the RPL network. &lt;br /&gt;
&lt;br /&gt;
Refer to the following code snippets in the file border-router.c In this piece of code the node configured as the border router waits for the prefix to be set. Once it receives the prefix, the border router is set as the root of the DODAG after which it sets the prefix of the rest of the nodes in the network.  &lt;br /&gt;
 &lt;br /&gt;
 /* Request prefix until it has been received */ &lt;br /&gt;
  while(!prefix_set) { &lt;br /&gt;
    etimer_set(&amp;amp;et, CLOCK_SECOND); &lt;br /&gt;
    request_prefix(); &lt;br /&gt;
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&amp;amp;et)); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
  dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)dag_id); &lt;br /&gt;
  if(dag != NULL) { &lt;br /&gt;
    rpl_set_prefix(dag, &amp;amp;prefix, 64); &lt;br /&gt;
    PRINTF(&amp;quot;created a new RPL dag\n&amp;quot;); &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
By default the border router hosts a simple web page. However this can be disabled by defining WEBSERVER as seen the code snippet below. This webpage is displayed when the IPv6 address of the border router is entered in the browser.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
PROCESS(border_router_process, &amp;quot;Border router process&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;#if WEBSERVER==0&lt;br /&gt;
/* No webserver */&lt;br /&gt;
AUTOSTART_PROCESSES(&amp;amp;border_router_process);&lt;br /&gt;
#elif WEBSERVER&amp;gt;1&lt;br /&gt;
/* Use an external webserver application */&lt;br /&gt;
#include &amp;quot;webserver-nogui.h&amp;quot;&lt;br /&gt;
AUTOSTART_PROCESSES(&amp;amp;border_router_process,&amp;amp;webserver_nogui_process); &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Compiling the code ==&lt;br /&gt;
 &lt;br /&gt;
The code for RPL border router can be found at /contiki-2.7/examples/ipv6/rpl-border-router. Use the following command to compile the code for the border router &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-border-router &lt;br /&gt;
make TARGET=sky. &amp;lt;/pre&amp;gt;   &lt;br /&gt;
Once this command has been successfully executed a file named border-router.sky will be created. This file will be used to program one of the motes as the border router on Cooja.  &lt;br /&gt;
For the purpose of this tutorial we will  select  TMote Sky  as our target. &lt;br /&gt;
&lt;br /&gt;
In order to demonstrate the functionality of the border router we will create a network of nodes with the border router as the root. For creating such a network we will user the udp-server.c code.  &lt;br /&gt;
This code can be found at /contiki-2.7/examples/ipv6/rpl-udp . Use the following command to compile the code for rpl-udp &lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-udp &lt;br /&gt;
make TARGET=sky &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once this command has been successfully executed a file named udp-server.sky will be created. This file will be used to program the remaining nodes in Cooja simulator. These nodes will form a DAG with the rpl border router as the root.&lt;br /&gt;
&lt;br /&gt;
== Testing on Cooja ==&lt;br /&gt;
 &lt;br /&gt;
Upon the successful completion of the above mentioned steps we are ready to create a simulation in Cooja.  &lt;br /&gt;
Start the Cooja simulator using the following command &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd /contiki-2.7/tools/cooja &lt;br /&gt;
ant run&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
When the GUI launches execute the following steps to create a simulation. &amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
1. From &amp;#039;File&amp;#039; select &amp;#039;New Simulation&amp;#039;. Select UDGM, enter the name of the simulation and click on create. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Click on Motes. From the drop down menu select &amp;#039;Add New Motes&amp;#039; followed by &amp;#039;Create new motes&amp;#039; and select the mote type as Sky. &amp;lt;br&amp;gt;&lt;br /&gt;
3. Browse to the location /contiki-2.7/examples/ipv6/rpl-border-router and select the file rpl-border-router.sky. Click on &amp;#039;Create&amp;#039;. Add one mote of this type. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Repeat step 2 and 3 but this time browse to the location /contiki-2.7/examples/ipv6/rpl-udp  and select the file udp-server.sky. Add 3 - 4 motes of the type udp-server &amp;lt;br&amp;gt;&lt;br /&gt;
5. Once the motes have been added you can position the motes. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Cooja_motes.png]]&lt;br /&gt;
&lt;br /&gt;
Select the options under View as shown below. These will help you creating a topology of your choice.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Motes_view.png]]&lt;br /&gt;
&lt;br /&gt;
6. Now, we need to create a bridge between the RPL network simulated on Cooja and the local machine. This can be done by right clicking on the mote which is programmed as the border router. Select &amp;#039;More tools for border router&amp;#039; and then select &amp;#039;Serial Socket (SERVER)&amp;#039;. You will get the following message on the successful completion of this step.Note that the message says &amp;#039;Listening on port 60001&amp;#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Serial_Socket.png]]&lt;br /&gt;
&lt;br /&gt;
7. Now start the simulation by clicking on Start&lt;br /&gt;
&lt;br /&gt;
== Tunslip utility ==&lt;br /&gt;
 &lt;br /&gt;
As mentioned in the introduction a border router helps in connecting one network to another. In this example the border router is used to route data between an RPL network and an external network. Till now we have only created the RPL network. Now we need to simulate the scenario in which this RPL network is connected to an external network. For this purpose we will use the Tunslip utility provided in Contiki. In this example tunslip creates a bridge between the RPL network and the local machine. &lt;br /&gt;
tunslip6.c can be found in /contiki-2.7/tools &lt;br /&gt;
Compile the tunslip6 code.&lt;br /&gt;
&amp;lt;pre&amp;gt;make tunslip6 &amp;lt;/pre&amp;gt; &lt;br /&gt;
Make a connection between the RPL network and your local machine. &lt;br /&gt;
&amp;lt;pre&amp;gt;sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64&amp;lt;/pre&amp;gt;&lt;br /&gt;
On the successful execution this command the following output will be printed on the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;slip connected to ``127.0.0.1:60001&amp;#039;&amp;#039;&lt;br /&gt;
opened tun device ``/dev/tun0&amp;#039;&amp;#039;&lt;br /&gt;
ifconfig tun0 inet `hostname` up&lt;br /&gt;
ifconfig tun0 add aaaa::1/64&lt;br /&gt;
ifconfig tun0 add fe80::0:0:0:1/64&lt;br /&gt;
ifconfig tun0&lt;br /&gt;
&lt;br /&gt;
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  &lt;br /&gt;
          inet addr:127.0.1.1  P-t-P:127.0.1.1  Mask:255.255.255.255&lt;br /&gt;
          inet6 addr: fe80::1/64 Scope:Link&lt;br /&gt;
          inet6 addr: aaaa::1/64 Scope:Global&lt;br /&gt;
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1&lt;br /&gt;
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0&lt;br /&gt;
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0&lt;br /&gt;
          collisions:0 txqueuelen:500 &lt;br /&gt;
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)&lt;br /&gt;
&lt;br /&gt;
Rime started with address 0.18.116.1.0.1.1.1&lt;br /&gt;
MAC 00:12:74:01:00:01:01:01 Contiki 2.7 started. Node id is set to 1.&lt;br /&gt;
CSMA ContikiMAC, channel check rate 8 Hz, radio channel 26&lt;br /&gt;
Tentative link-local IPv6 address fe80:0000:0000:0000:0212:7401:0001:0101&lt;br /&gt;
Starting &amp;#039;Border router process&amp;#039; &amp;#039;Web server&amp;#039;&lt;br /&gt;
*** Address:aaaa::1 =&amp;gt; aaaa:0000:0000:0000&lt;br /&gt;
Got configuration message of type P&lt;br /&gt;
Setting prefix aaaa::&lt;br /&gt;
Server IPv6 addresses:&lt;br /&gt;
 aaaa::212:7401:1:101&lt;br /&gt;
 fe80::212:7401:1:101&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Go back to the Cooja simulator GUI and look at the dialogue box. The message has now changed to &amp;#039;Client connected: /127.0.0.1&amp;#039;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Client_Connected.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Verifying Results ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can verify that the address of the border router has been set by using the ping command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7401:1:101&lt;br /&gt;
PING aaaa::212:7401:1:101(aaaa::212:7401:1:101) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=1 ttl=64 time=86.0 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=2 ttl=64 time=33.6 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=3 ttl=64 time=82.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=4 ttl=64 time=43.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=5 ttl=64 time=70.1 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7401:1:101 ping statistics ---&lt;br /&gt;
5 packets transmitted, 5 received, 0% packet loss, time 4006ms&lt;br /&gt;
rtt min/avg/max/mdev = 33.669/63.090/86.015/20.985 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also ping one of the other nodes in the network. Here we are pinging node 4&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7404:4:404&lt;br /&gt;
PING aaaa::212:7404:4:404(aaaa::212:7404:4:404) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=1 ttl=63 time=670 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=2 ttl=63 time=703 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=3 ttl=63 time=746 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=4 ttl=63 time=674 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7404:4:404 ping statistics ---&lt;br /&gt;
5 packets transmitted, 4 received, 20% packet loss, time 4001ms&lt;br /&gt;
rtt min/avg/max/mdev = 670.230/698.666/746.619/30.514 ms&lt;br /&gt;
user@instant-contiki:~/contiki-2.7$ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IPv6 address of a node can be checked from the log screen on Cooja. Filter the nodes by their ID&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Node_Address.png]]&lt;br /&gt;
&lt;br /&gt;
You can enter the address of the border router in the web browser. The border router host a page which will be displayed on the browser as shown below. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:RPL_Browser.png]]&lt;br /&gt;
&lt;br /&gt;
== Common Issues ==&lt;br /&gt;
&lt;br /&gt;
1. Make sure that you enter the IPv6 address properly in the command sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64 . There should be no spaces in aaaa::1/64. Otherwise the code will give unexpected behavior.&amp;lt;br&amp;gt;&lt;br /&gt;
2. When you pause the simulation the SLIP connection is lost. It might not work properly on resuming the simulation. In such cases reload the simulation. Create a fresh SLIP connection and then run the simulation again.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
[https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md]  https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md &amp;lt;br&amp;gt;&lt;br /&gt;
[http://cnds.eecs.jacobs-university.de/courses/iotlab-2013/cooja.pdf] Using the Contiki Cooja Simulator - Anuj Sehgal&lt;/div&gt;</summary>
		<author><name>Ckapoor</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1153</id>
		<title>RPL Border Router</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1153"/>
				<updated>2014-11-08T23:18:52Z</updated>
		
		<summary type="html">&lt;p&gt;Ckapoor: /* Code building blocks. */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction: ==&lt;br /&gt;
  &lt;br /&gt;
Border routers are routers that can be found at the edge of a network. Their function is to connect one network to another. In this tutorial we will learn how to run a simulation using the border router in Contiki In the example which we will discuss in the rest of this tutorial the border router will be used to route data between a WSN (using RPL) and an external IP network.  &lt;br /&gt;
Objective:  &lt;br /&gt;
The objective of this tutorial is to give you an understanding of the RPL Border Router code on Contiki OS and learn how to simulate the code on Cooja &lt;br /&gt;
What will you learn at the end of this tutorial. At the end of the tutorial you would have learnt the following: &lt;br /&gt;
&lt;br /&gt;
1. Understanding the working of the rpl border router code &amp;lt;br&amp;gt;&lt;br /&gt;
2. Starting a simulation on Cooja simulator. &amp;lt;br&amp;gt; &lt;br /&gt;
3. Observing and validating the results &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code building blocks. ==&lt;br /&gt;
 &lt;br /&gt;
We will using the following files &lt;br /&gt;
&lt;br /&gt;
1. border-router.c &amp;lt;br&amp;gt;&lt;br /&gt;
2. udp-server.c  (udp-client.c can also be used)&amp;lt;br&amp;gt;&lt;br /&gt;
3. slip-bridge.c&amp;lt;br&amp;gt;&lt;br /&gt;
4. httpd-simple.c   (A simple web server forwarding page generation to a protothread)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
udp-server nodes will form a DAG with the border router set as the root. The border router will receive the prefix through a SLIP connection and it will be communicated to the rest of the nodes in the RPL network. &lt;br /&gt;
&lt;br /&gt;
Refer to the following code snippets in the file border-router.c In this piece of code the node configured as the border router waits for the prefix to be set. Once it receives the prefix, the border router is set as the root of the DODAG after which it sets the prefix of the rest of the nodes in the network.  &lt;br /&gt;
 &lt;br /&gt;
 /* Request prefix until it has been received */ &lt;br /&gt;
  while(!prefix_set) { &lt;br /&gt;
    etimer_set(&amp;amp;et, CLOCK_SECOND); &lt;br /&gt;
    request_prefix(); &lt;br /&gt;
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&amp;amp;et)); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
  dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)dag_id); &lt;br /&gt;
  if(dag != NULL) { &lt;br /&gt;
    rpl_set_prefix(dag, &amp;amp;prefix, 64); &lt;br /&gt;
    PRINTF(&amp;quot;created a new RPL dag\n&amp;quot;); &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
By default the border router hosts a simple web page. However this can be disabled by defining WEBSERVER as seen the code snippet below. This webpage is displayed when the IPv6 address of the border router is entered in the browser.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
PROCESS(border_router_process, &amp;quot;Border router process&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
#if WEBSERVER==0&lt;br /&gt;
/* No webserver */&lt;br /&gt;
AUTOSTART_PROCESSES(&amp;amp;border_router_process);&lt;br /&gt;
#elif WEBSERVER&amp;gt;1&lt;br /&gt;
/* Use an external webserver application */&lt;br /&gt;
#include &amp;quot;webserver-nogui.h&amp;quot;&lt;br /&gt;
AUTOSTART_PROCESSES(&amp;amp;border_router_process,&amp;amp;webserver_nogui_process);&lt;br /&gt;
&lt;br /&gt;
== Compiling the code ==&lt;br /&gt;
 &lt;br /&gt;
The code for RPL border router can be found at /contiki-2.7/examples/ipv6/rpl-border-router. Use the following command to compile the code for the border router &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-border-router &lt;br /&gt;
make TARGET=sky. &amp;lt;/pre&amp;gt;   &lt;br /&gt;
Once this command has been successfully executed a file named border-router.sky will be created. This file will be used to program one of the motes as the border router on Cooja.  &lt;br /&gt;
For the purpose of this tutorial we will  select  TMote Sky  as our target. &lt;br /&gt;
&lt;br /&gt;
In order to demonstrate the functionality of the border router we will create a network of nodes with the border router as the root. For creating such a network we will user the udp-server.c code.  &lt;br /&gt;
This code can be found at /contiki-2.7/examples/ipv6/rpl-udp . Use the following command to compile the code for rpl-udp &lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-udp &lt;br /&gt;
make TARGET=sky &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once this command has been successfully executed a file named udp-server.sky will be created. This file will be used to program the remaining nodes in Cooja simulator. These nodes will form a DAG with the rpl border router as the root.&lt;br /&gt;
&lt;br /&gt;
== Testing on Cooja ==&lt;br /&gt;
 &lt;br /&gt;
Upon the successful completion of the above mentioned steps we are ready to create a simulation in Cooja.  &lt;br /&gt;
Start the Cooja simulator using the following command &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd /contiki-2.7/tools/cooja &lt;br /&gt;
ant run&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
When the GUI launches execute the following steps to create a simulation. &amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
1. From &amp;#039;File&amp;#039; select &amp;#039;New Simulation&amp;#039;. Select UDGM, enter the name of the simulation and click on create. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Click on Motes. From the drop down menu select &amp;#039;Add New Motes&amp;#039; followed by &amp;#039;Create new motes&amp;#039; and select the mote type as Sky. &amp;lt;br&amp;gt;&lt;br /&gt;
3. Browse to the location /contiki-2.7/examples/ipv6/rpl-border-router and select the file rpl-border-router.sky. Click on &amp;#039;Create&amp;#039;. Add one mote of this type. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Repeat step 2 and 3 but this time browse to the location /contiki-2.7/examples/ipv6/rpl-udp  and select the file udp-server.sky. Add 3 - 4 motes of the type udp-server &amp;lt;br&amp;gt;&lt;br /&gt;
5. Once the motes have been added you can position the motes. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Cooja_motes.png]]&lt;br /&gt;
&lt;br /&gt;
Select the options under View as shown below. These will help you creating a topology of your choice.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Motes_view.png]]&lt;br /&gt;
&lt;br /&gt;
6. Now, we need to create a bridge between the RPL network simulated on Cooja and the local machine. This can be done by right clicking on the mote which is programmed as the border router. Select &amp;#039;More tools for border router&amp;#039; and then select &amp;#039;Serial Socket (SERVER)&amp;#039;. You will get the following message on the successful completion of this step.Note that the message says &amp;#039;Listening on port 60001&amp;#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Serial_Socket.png]]&lt;br /&gt;
&lt;br /&gt;
7. Now start the simulation by clicking on Start&lt;br /&gt;
&lt;br /&gt;
== Tunslip utility ==&lt;br /&gt;
 &lt;br /&gt;
As mentioned in the introduction a border router helps in connecting one network to another. In this example the border router is used to route data between an RPL network and an external network. Till now we have only created the RPL network. Now we need to simulate the scenario in which this RPL network is connected to an external network. For this purpose we will use the Tunslip utility provided in Contiki. In this example tunslip creates a bridge between the RPL network and the local machine. &lt;br /&gt;
tunslip6.c can be found in /contiki-2.7/tools &lt;br /&gt;
Compile the tunslip6 code.&lt;br /&gt;
&amp;lt;pre&amp;gt;make tunslip6 &amp;lt;/pre&amp;gt; &lt;br /&gt;
Make a connection between the RPL network and your local machine. &lt;br /&gt;
&amp;lt;pre&amp;gt;sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64&amp;lt;/pre&amp;gt;&lt;br /&gt;
On the successful execution this command the following output will be printed on the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;slip connected to ``127.0.0.1:60001&amp;#039;&amp;#039;&lt;br /&gt;
opened tun device ``/dev/tun0&amp;#039;&amp;#039;&lt;br /&gt;
ifconfig tun0 inet `hostname` up&lt;br /&gt;
ifconfig tun0 add aaaa::1/64&lt;br /&gt;
ifconfig tun0 add fe80::0:0:0:1/64&lt;br /&gt;
ifconfig tun0&lt;br /&gt;
&lt;br /&gt;
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  &lt;br /&gt;
          inet addr:127.0.1.1  P-t-P:127.0.1.1  Mask:255.255.255.255&lt;br /&gt;
          inet6 addr: fe80::1/64 Scope:Link&lt;br /&gt;
          inet6 addr: aaaa::1/64 Scope:Global&lt;br /&gt;
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1&lt;br /&gt;
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0&lt;br /&gt;
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0&lt;br /&gt;
          collisions:0 txqueuelen:500 &lt;br /&gt;
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)&lt;br /&gt;
&lt;br /&gt;
Rime started with address 0.18.116.1.0.1.1.1&lt;br /&gt;
MAC 00:12:74:01:00:01:01:01 Contiki 2.7 started. Node id is set to 1.&lt;br /&gt;
CSMA ContikiMAC, channel check rate 8 Hz, radio channel 26&lt;br /&gt;
Tentative link-local IPv6 address fe80:0000:0000:0000:0212:7401:0001:0101&lt;br /&gt;
Starting &amp;#039;Border router process&amp;#039; &amp;#039;Web server&amp;#039;&lt;br /&gt;
*** Address:aaaa::1 =&amp;gt; aaaa:0000:0000:0000&lt;br /&gt;
Got configuration message of type P&lt;br /&gt;
Setting prefix aaaa::&lt;br /&gt;
Server IPv6 addresses:&lt;br /&gt;
 aaaa::212:7401:1:101&lt;br /&gt;
 fe80::212:7401:1:101&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Go back to the Cooja simulator GUI and look at the dialogue box. The message has now changed to &amp;#039;Client connected: /127.0.0.1&amp;#039;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Client_Connected.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Verifying Results ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can verify that the address of the border router has been set by using the ping command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7401:1:101&lt;br /&gt;
PING aaaa::212:7401:1:101(aaaa::212:7401:1:101) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=1 ttl=64 time=86.0 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=2 ttl=64 time=33.6 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=3 ttl=64 time=82.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=4 ttl=64 time=43.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=5 ttl=64 time=70.1 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7401:1:101 ping statistics ---&lt;br /&gt;
5 packets transmitted, 5 received, 0% packet loss, time 4006ms&lt;br /&gt;
rtt min/avg/max/mdev = 33.669/63.090/86.015/20.985 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also ping one of the other nodes in the network. Here we are pinging node 4&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7404:4:404&lt;br /&gt;
PING aaaa::212:7404:4:404(aaaa::212:7404:4:404) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=1 ttl=63 time=670 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=2 ttl=63 time=703 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=3 ttl=63 time=746 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=4 ttl=63 time=674 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7404:4:404 ping statistics ---&lt;br /&gt;
5 packets transmitted, 4 received, 20% packet loss, time 4001ms&lt;br /&gt;
rtt min/avg/max/mdev = 670.230/698.666/746.619/30.514 ms&lt;br /&gt;
user@instant-contiki:~/contiki-2.7$ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IPv6 address of a node can be checked from the log screen on Cooja. Filter the nodes by their ID&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Node_Address.png]]&lt;br /&gt;
&lt;br /&gt;
You can enter the address of the border router in the web browser. The border router host a page which will be displayed on the browser as shown below. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:RPL_Browser.png]]&lt;br /&gt;
&lt;br /&gt;
== Common Issues ==&lt;br /&gt;
&lt;br /&gt;
1. Make sure that you enter the IPv6 address properly in the command sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64 . There should be no spaces in aaaa::1/64. Otherwise the code will give unexpected behavior.&amp;lt;br&amp;gt;&lt;br /&gt;
2. When you pause the simulation the SLIP connection is lost. It might not work properly on resuming the simulation. In such cases reload the simulation. Create a fresh SLIP connection and then run the simulation again.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
[https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md]  https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md &amp;lt;br&amp;gt;&lt;br /&gt;
[http://cnds.eecs.jacobs-university.de/courses/iotlab-2013/cooja.pdf] Using the Contiki Cooja Simulator - Anuj Sehgal&lt;/div&gt;</summary>
		<author><name>Ckapoor</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1152</id>
		<title>RPL Border Router</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1152"/>
				<updated>2014-11-08T23:05:50Z</updated>
		
		<summary type="html">&lt;p&gt;Ckapoor: /* Testing on Cooja */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction: ==&lt;br /&gt;
  &lt;br /&gt;
Border routers are routers that can be found at the edge of a network. Their function is to connect one network to another. In this tutorial we will learn how to run a simulation using the border router in Contiki In the example which we will discuss in the rest of this tutorial the border router will be used to route data between a WSN (using RPL) and an external IP network.  &lt;br /&gt;
Objective:  &lt;br /&gt;
The objective of this tutorial is to give you an understanding of the RPL Border Router code on Contiki OS and learn how to simulate the code on Cooja &lt;br /&gt;
What will you learn at the end of this tutorial. At the end of the tutorial you would have learnt the following: &lt;br /&gt;
&lt;br /&gt;
1. Understanding the working of the rpl border router code &amp;lt;br&amp;gt;&lt;br /&gt;
2. Starting a simulation on Cooja simulator. &amp;lt;br&amp;gt; &lt;br /&gt;
3. Observing and validating the results &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code building blocks. ==&lt;br /&gt;
 &lt;br /&gt;
We will using the following files &lt;br /&gt;
&lt;br /&gt;
1. border-router.c &amp;lt;br&amp;gt;&lt;br /&gt;
2. udp-server.c  (udp-client.c can also be used)&amp;lt;br&amp;gt;&lt;br /&gt;
3. slip-bridge.c&amp;lt;br&amp;gt;&lt;br /&gt;
4. httpd-simple.c&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
udp-server nodes will form a DAG with the border router set as the root. The border router will receive the prefix through a SLIP connection and it will be communicated to the rest of the nodes in the RPL network. &lt;br /&gt;
&lt;br /&gt;
Refer to the following code snippets in the file border-router.c In this piece of code the node configured as the border router waits for the prefix to be set. Once it receives the prefix, the border router is set as the root of the DODAG after which it sets the prefix of the rest of the nodes in the network.  &lt;br /&gt;
 &lt;br /&gt;
 /* Request prefix until it has been received */ &lt;br /&gt;
  while(!prefix_set) { &lt;br /&gt;
    etimer_set(&amp;amp;et, CLOCK_SECOND); &lt;br /&gt;
    request_prefix(); &lt;br /&gt;
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&amp;amp;et)); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
  dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)dag_id); &lt;br /&gt;
  if(dag != NULL) { &lt;br /&gt;
    rpl_set_prefix(dag, &amp;amp;prefix, 64); &lt;br /&gt;
    PRINTF(&amp;quot;created a new RPL dag\n&amp;quot;); &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
== Compiling the code ==&lt;br /&gt;
 &lt;br /&gt;
The code for RPL border router can be found at /contiki-2.7/examples/ipv6/rpl-border-router. Use the following command to compile the code for the border router &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-border-router &lt;br /&gt;
make TARGET=sky. &amp;lt;/pre&amp;gt;   &lt;br /&gt;
Once this command has been successfully executed a file named border-router.sky will be created. This file will be used to program one of the motes as the border router on Cooja.  &lt;br /&gt;
For the purpose of this tutorial we will  select  TMote Sky  as our target. &lt;br /&gt;
&lt;br /&gt;
In order to demonstrate the functionality of the border router we will create a network of nodes with the border router as the root. For creating such a network we will user the udp-server.c code.  &lt;br /&gt;
This code can be found at /contiki-2.7/examples/ipv6/rpl-udp . Use the following command to compile the code for rpl-udp &lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-udp &lt;br /&gt;
make TARGET=sky &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once this command has been successfully executed a file named udp-server.sky will be created. This file will be used to program the remaining nodes in Cooja simulator. These nodes will form a DAG with the rpl border router as the root.&lt;br /&gt;
&lt;br /&gt;
== Testing on Cooja ==&lt;br /&gt;
 &lt;br /&gt;
Upon the successful completion of the above mentioned steps we are ready to create a simulation in Cooja.  &lt;br /&gt;
Start the Cooja simulator using the following command &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd /contiki-2.7/tools/cooja &lt;br /&gt;
ant run&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
When the GUI launches execute the following steps to create a simulation. &amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
1. From &amp;#039;File&amp;#039; select &amp;#039;New Simulation&amp;#039;. Select UDGM, enter the name of the simulation and click on create. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Click on Motes. From the drop down menu select &amp;#039;Add New Motes&amp;#039; followed by &amp;#039;Create new motes&amp;#039; and select the mote type as Sky. &amp;lt;br&amp;gt;&lt;br /&gt;
3. Browse to the location /contiki-2.7/examples/ipv6/rpl-border-router and select the file rpl-border-router.sky. Click on &amp;#039;Create&amp;#039;. Add one mote of this type. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Repeat step 2 and 3 but this time browse to the location /contiki-2.7/examples/ipv6/rpl-udp  and select the file udp-server.sky. Add 3 - 4 motes of the type udp-server &amp;lt;br&amp;gt;&lt;br /&gt;
5. Once the motes have been added you can position the motes. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Cooja_motes.png]]&lt;br /&gt;
&lt;br /&gt;
Select the options under View as shown below. These will help you creating a topology of your choice.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Motes_view.png]]&lt;br /&gt;
&lt;br /&gt;
6. Now, we need to create a bridge between the RPL network simulated on Cooja and the local machine. This can be done by right clicking on the mote which is programmed as the border router. Select &amp;#039;More tools for border router&amp;#039; and then select &amp;#039;Serial Socket (SERVER)&amp;#039;. You will get the following message on the successful completion of this step.Note that the message says &amp;#039;Listening on port 60001&amp;#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Serial_Socket.png]]&lt;br /&gt;
&lt;br /&gt;
7. Now start the simulation by clicking on Start&lt;br /&gt;
&lt;br /&gt;
== Tunslip utility ==&lt;br /&gt;
 &lt;br /&gt;
As mentioned in the introduction a border router helps in connecting one network to another. In this example the border router is used to route data between an RPL network and an external network. Till now we have only created the RPL network. Now we need to simulate the scenario in which this RPL network is connected to an external network. For this purpose we will use the Tunslip utility provided in Contiki. In this example tunslip creates a bridge between the RPL network and the local machine. &lt;br /&gt;
tunslip6.c can be found in /contiki-2.7/tools &lt;br /&gt;
Compile the tunslip6 code.&lt;br /&gt;
&amp;lt;pre&amp;gt;make tunslip6 &amp;lt;/pre&amp;gt; &lt;br /&gt;
Make a connection between the RPL network and your local machine. &lt;br /&gt;
&amp;lt;pre&amp;gt;sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64&amp;lt;/pre&amp;gt;&lt;br /&gt;
On the successful execution this command the following output will be printed on the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;slip connected to ``127.0.0.1:60001&amp;#039;&amp;#039;&lt;br /&gt;
opened tun device ``/dev/tun0&amp;#039;&amp;#039;&lt;br /&gt;
ifconfig tun0 inet `hostname` up&lt;br /&gt;
ifconfig tun0 add aaaa::1/64&lt;br /&gt;
ifconfig tun0 add fe80::0:0:0:1/64&lt;br /&gt;
ifconfig tun0&lt;br /&gt;
&lt;br /&gt;
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  &lt;br /&gt;
          inet addr:127.0.1.1  P-t-P:127.0.1.1  Mask:255.255.255.255&lt;br /&gt;
          inet6 addr: fe80::1/64 Scope:Link&lt;br /&gt;
          inet6 addr: aaaa::1/64 Scope:Global&lt;br /&gt;
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1&lt;br /&gt;
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0&lt;br /&gt;
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0&lt;br /&gt;
          collisions:0 txqueuelen:500 &lt;br /&gt;
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)&lt;br /&gt;
&lt;br /&gt;
Rime started with address 0.18.116.1.0.1.1.1&lt;br /&gt;
MAC 00:12:74:01:00:01:01:01 Contiki 2.7 started. Node id is set to 1.&lt;br /&gt;
CSMA ContikiMAC, channel check rate 8 Hz, radio channel 26&lt;br /&gt;
Tentative link-local IPv6 address fe80:0000:0000:0000:0212:7401:0001:0101&lt;br /&gt;
Starting &amp;#039;Border router process&amp;#039; &amp;#039;Web server&amp;#039;&lt;br /&gt;
*** Address:aaaa::1 =&amp;gt; aaaa:0000:0000:0000&lt;br /&gt;
Got configuration message of type P&lt;br /&gt;
Setting prefix aaaa::&lt;br /&gt;
Server IPv6 addresses:&lt;br /&gt;
 aaaa::212:7401:1:101&lt;br /&gt;
 fe80::212:7401:1:101&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Go back to the Cooja simulator GUI and look at the dialogue box. The message has now changed to &amp;#039;Client connected: /127.0.0.1&amp;#039;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Client_Connected.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Verifying Results ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can verify that the address of the border router has been set by using the ping command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7401:1:101&lt;br /&gt;
PING aaaa::212:7401:1:101(aaaa::212:7401:1:101) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=1 ttl=64 time=86.0 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=2 ttl=64 time=33.6 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=3 ttl=64 time=82.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=4 ttl=64 time=43.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=5 ttl=64 time=70.1 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7401:1:101 ping statistics ---&lt;br /&gt;
5 packets transmitted, 5 received, 0% packet loss, time 4006ms&lt;br /&gt;
rtt min/avg/max/mdev = 33.669/63.090/86.015/20.985 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also ping one of the other nodes in the network. Here we are pinging node 4&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7404:4:404&lt;br /&gt;
PING aaaa::212:7404:4:404(aaaa::212:7404:4:404) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=1 ttl=63 time=670 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=2 ttl=63 time=703 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=3 ttl=63 time=746 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=4 ttl=63 time=674 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7404:4:404 ping statistics ---&lt;br /&gt;
5 packets transmitted, 4 received, 20% packet loss, time 4001ms&lt;br /&gt;
rtt min/avg/max/mdev = 670.230/698.666/746.619/30.514 ms&lt;br /&gt;
user@instant-contiki:~/contiki-2.7$ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IPv6 address of a node can be checked from the log screen on Cooja. Filter the nodes by their ID&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Node_Address.png]]&lt;br /&gt;
&lt;br /&gt;
You can enter the address of the border router in the web browser. The border router host a page which will be displayed on the browser as shown below. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:RPL_Browser.png]]&lt;br /&gt;
&lt;br /&gt;
== Common Issues ==&lt;br /&gt;
&lt;br /&gt;
1. Make sure that you enter the IPv6 address properly in the command sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64 . There should be no spaces in aaaa::1/64. Otherwise the code will give unexpected behavior.&amp;lt;br&amp;gt;&lt;br /&gt;
2. When you pause the simulation the SLIP connection is lost. It might not work properly on resuming the simulation. In such cases reload the simulation. Create a fresh SLIP connection and then run the simulation again.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
[https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md]  https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md &amp;lt;br&amp;gt;&lt;br /&gt;
[http://cnds.eecs.jacobs-university.de/courses/iotlab-2013/cooja.pdf] Using the Contiki Cooja Simulator - Anuj Sehgal&lt;/div&gt;</summary>
		<author><name>Ckapoor</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1151</id>
		<title>RPL Border Router</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1151"/>
				<updated>2014-11-08T23:05:24Z</updated>
		
		<summary type="html">&lt;p&gt;Ckapoor: /* Testing on Cooja */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction: ==&lt;br /&gt;
  &lt;br /&gt;
Border routers are routers that can be found at the edge of a network. Their function is to connect one network to another. In this tutorial we will learn how to run a simulation using the border router in Contiki In the example which we will discuss in the rest of this tutorial the border router will be used to route data between a WSN (using RPL) and an external IP network.  &lt;br /&gt;
Objective:  &lt;br /&gt;
The objective of this tutorial is to give you an understanding of the RPL Border Router code on Contiki OS and learn how to simulate the code on Cooja &lt;br /&gt;
What will you learn at the end of this tutorial. At the end of the tutorial you would have learnt the following: &lt;br /&gt;
&lt;br /&gt;
1. Understanding the working of the rpl border router code &amp;lt;br&amp;gt;&lt;br /&gt;
2. Starting a simulation on Cooja simulator. &amp;lt;br&amp;gt; &lt;br /&gt;
3. Observing and validating the results &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code building blocks. ==&lt;br /&gt;
 &lt;br /&gt;
We will using the following files &lt;br /&gt;
&lt;br /&gt;
1. border-router.c &amp;lt;br&amp;gt;&lt;br /&gt;
2. udp-server.c  (udp-client.c can also be used)&amp;lt;br&amp;gt;&lt;br /&gt;
3. slip-bridge.c&amp;lt;br&amp;gt;&lt;br /&gt;
4. httpd-simple.c&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
udp-server nodes will form a DAG with the border router set as the root. The border router will receive the prefix through a SLIP connection and it will be communicated to the rest of the nodes in the RPL network. &lt;br /&gt;
&lt;br /&gt;
Refer to the following code snippets in the file border-router.c In this piece of code the node configured as the border router waits for the prefix to be set. Once it receives the prefix, the border router is set as the root of the DODAG after which it sets the prefix of the rest of the nodes in the network.  &lt;br /&gt;
 &lt;br /&gt;
 /* Request prefix until it has been received */ &lt;br /&gt;
  while(!prefix_set) { &lt;br /&gt;
    etimer_set(&amp;amp;et, CLOCK_SECOND); &lt;br /&gt;
    request_prefix(); &lt;br /&gt;
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&amp;amp;et)); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
  dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)dag_id); &lt;br /&gt;
  if(dag != NULL) { &lt;br /&gt;
    rpl_set_prefix(dag, &amp;amp;prefix, 64); &lt;br /&gt;
    PRINTF(&amp;quot;created a new RPL dag\n&amp;quot;); &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
== Compiling the code ==&lt;br /&gt;
 &lt;br /&gt;
The code for RPL border router can be found at /contiki-2.7/examples/ipv6/rpl-border-router. Use the following command to compile the code for the border router &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-border-router &lt;br /&gt;
make TARGET=sky. &amp;lt;/pre&amp;gt;   &lt;br /&gt;
Once this command has been successfully executed a file named border-router.sky will be created. This file will be used to program one of the motes as the border router on Cooja.  &lt;br /&gt;
For the purpose of this tutorial we will  select  TMote Sky  as our target. &lt;br /&gt;
&lt;br /&gt;
In order to demonstrate the functionality of the border router we will create a network of nodes with the border router as the root. For creating such a network we will user the udp-server.c code.  &lt;br /&gt;
This code can be found at /contiki-2.7/examples/ipv6/rpl-udp . Use the following command to compile the code for rpl-udp &lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-udp &lt;br /&gt;
make TARGET=sky &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once this command has been successfully executed a file named udp-server.sky will be created. This file will be used to program the remaining nodes in Cooja simulator. These nodes will form a DAG with the rpl border router as the root.&lt;br /&gt;
&lt;br /&gt;
== Testing on Cooja ==&lt;br /&gt;
 &lt;br /&gt;
Upon the successful completion of the above mentioned steps we are ready to create a simulation in Cooja.  &lt;br /&gt;
Start the Cooja simulator using the following command &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd /contiki-2.7/tools/cooja &lt;br /&gt;
ant run&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
When the GUI launches execute the following steps to create a simulation. &amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
1. From &amp;#039;File&amp;#039; select &amp;#039;New Simulation&amp;#039;. Select UDGM, enter the name of the simulation and click on create. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Click on Motes. From the drop down menu select &amp;#039;Add New Motes&amp;#039; followed by &amp;#039;Create new motes&amp;#039; and select the mote type as Sky. &amp;lt;br&amp;gt;&lt;br /&gt;
3. Browse to the location /contiki-2.7/examples/ipv6/rpl-border-router and select the file rpl-border-router.sky. Click on &amp;#039;Create&amp;#039;. Add one mote of this type. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Repeat step 2 and 3 but this time browse to the location /contiki-2.7/examples/ipv6/rpl-udp  and select the file udp-server.sky. Add 3 - 4 motes of the type udp-server &amp;lt;br&amp;gt;&lt;br /&gt;
5. Once the motes have been added you can position the motes. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Cooja_motes.png]]&lt;br /&gt;
&lt;br /&gt;
Select the options under View as shown below. These will help you creating a topology of your choice.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Motes_view.png]]&lt;br /&gt;
&lt;br /&gt;
6. Now, we need to create a bridge between the RPL network simulated on Cooja and the local machine. This can be done by right clicking on the mote which is programmed as the border router. Select &amp;#039;More tools for border router&amp;#039; and then select &amp;#039;Serial Socket (SERVER)&amp;#039;. You will get the following message on the successful completion of this step.Note that the message says &amp;#039;Listening on port 60001&amp;#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Serial_Socket.png]]&lt;br /&gt;
&lt;br /&gt;
7. Now start the simulation by clicking on Start&lt;br /&gt;
&lt;br /&gt;
== Tunslip utility ==&lt;br /&gt;
 &lt;br /&gt;
As mentioned in the introduction a border router helps in connecting one network to another. In this example the border router is used to route data between an RPL network and an external network. Till now we have only created the RPL network. Now we need to simulate the scenario in which this RPL network is connected to an external network. For this purpose we will use the Tunslip utility provided in Contiki. In this example tunslip creates a bridge between the RPL network and the local machine. &lt;br /&gt;
tunslip6.c can be found in /contiki-2.7/tools &lt;br /&gt;
Compile the tunslip6 code.&lt;br /&gt;
&amp;lt;pre&amp;gt;make tunslip6 &amp;lt;/pre&amp;gt; &lt;br /&gt;
Make a connection between the RPL network and your local machine. &lt;br /&gt;
&amp;lt;pre&amp;gt;sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64&amp;lt;/pre&amp;gt;&lt;br /&gt;
On the successful execution this command the following output will be printed on the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;slip connected to ``127.0.0.1:60001&amp;#039;&amp;#039;&lt;br /&gt;
opened tun device ``/dev/tun0&amp;#039;&amp;#039;&lt;br /&gt;
ifconfig tun0 inet `hostname` up&lt;br /&gt;
ifconfig tun0 add aaaa::1/64&lt;br /&gt;
ifconfig tun0 add fe80::0:0:0:1/64&lt;br /&gt;
ifconfig tun0&lt;br /&gt;
&lt;br /&gt;
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  &lt;br /&gt;
          inet addr:127.0.1.1  P-t-P:127.0.1.1  Mask:255.255.255.255&lt;br /&gt;
          inet6 addr: fe80::1/64 Scope:Link&lt;br /&gt;
          inet6 addr: aaaa::1/64 Scope:Global&lt;br /&gt;
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1&lt;br /&gt;
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0&lt;br /&gt;
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0&lt;br /&gt;
          collisions:0 txqueuelen:500 &lt;br /&gt;
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)&lt;br /&gt;
&lt;br /&gt;
Rime started with address 0.18.116.1.0.1.1.1&lt;br /&gt;
MAC 00:12:74:01:00:01:01:01 Contiki 2.7 started. Node id is set to 1.&lt;br /&gt;
CSMA ContikiMAC, channel check rate 8 Hz, radio channel 26&lt;br /&gt;
Tentative link-local IPv6 address fe80:0000:0000:0000:0212:7401:0001:0101&lt;br /&gt;
Starting &amp;#039;Border router process&amp;#039; &amp;#039;Web server&amp;#039;&lt;br /&gt;
*** Address:aaaa::1 =&amp;gt; aaaa:0000:0000:0000&lt;br /&gt;
Got configuration message of type P&lt;br /&gt;
Setting prefix aaaa::&lt;br /&gt;
Server IPv6 addresses:&lt;br /&gt;
 aaaa::212:7401:1:101&lt;br /&gt;
 fe80::212:7401:1:101&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Go back to the Cooja simulator GUI and look at the dialogue box. The message has now changed to &amp;#039;Client connected: /127.0.0.1&amp;#039;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Client_Connected.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Verifying Results ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can verify that the address of the border router has been set by using the ping command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7401:1:101&lt;br /&gt;
PING aaaa::212:7401:1:101(aaaa::212:7401:1:101) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=1 ttl=64 time=86.0 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=2 ttl=64 time=33.6 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=3 ttl=64 time=82.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=4 ttl=64 time=43.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=5 ttl=64 time=70.1 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7401:1:101 ping statistics ---&lt;br /&gt;
5 packets transmitted, 5 received, 0% packet loss, time 4006ms&lt;br /&gt;
rtt min/avg/max/mdev = 33.669/63.090/86.015/20.985 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also ping one of the other nodes in the network. Here we are pinging node 4&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7404:4:404&lt;br /&gt;
PING aaaa::212:7404:4:404(aaaa::212:7404:4:404) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=1 ttl=63 time=670 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=2 ttl=63 time=703 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=3 ttl=63 time=746 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=4 ttl=63 time=674 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7404:4:404 ping statistics ---&lt;br /&gt;
5 packets transmitted, 4 received, 20% packet loss, time 4001ms&lt;br /&gt;
rtt min/avg/max/mdev = 670.230/698.666/746.619/30.514 ms&lt;br /&gt;
user@instant-contiki:~/contiki-2.7$ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IPv6 address of a node can be checked from the log screen on Cooja. Filter the nodes by their ID&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Node_Address.png]]&lt;br /&gt;
&lt;br /&gt;
You can enter the address of the border router in the web browser. The border router host a page which will be displayed on the browser as shown below. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:RPL_Browser.png]]&lt;br /&gt;
&lt;br /&gt;
== Common Issues ==&lt;br /&gt;
&lt;br /&gt;
1. Make sure that you enter the IPv6 address properly in the command sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64 . There should be no spaces in aaaa::1/64. Otherwise the code will give unexpected behavior.&amp;lt;br&amp;gt;&lt;br /&gt;
2. When you pause the simulation the SLIP connection is lost. It might not work properly on resuming the simulation. In such cases reload the simulation. Create a fresh SLIP connection and then run the simulation again.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
[https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md]  https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md &amp;lt;br&amp;gt;&lt;br /&gt;
[http://cnds.eecs.jacobs-university.de/courses/iotlab-2013/cooja.pdf] Using the Contiki Cooja Simulator - Anuj Sehgal&lt;/div&gt;</summary>
		<author><name>Ckapoor</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1150</id>
		<title>RPL Border Router</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1150"/>
				<updated>2014-11-08T23:05:04Z</updated>
		
		<summary type="html">&lt;p&gt;Ckapoor: /* Testing on Cooja */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction: ==&lt;br /&gt;
  &lt;br /&gt;
Border routers are routers that can be found at the edge of a network. Their function is to connect one network to another. In this tutorial we will learn how to run a simulation using the border router in Contiki In the example which we will discuss in the rest of this tutorial the border router will be used to route data between a WSN (using RPL) and an external IP network.  &lt;br /&gt;
Objective:  &lt;br /&gt;
The objective of this tutorial is to give you an understanding of the RPL Border Router code on Contiki OS and learn how to simulate the code on Cooja &lt;br /&gt;
What will you learn at the end of this tutorial. At the end of the tutorial you would have learnt the following: &lt;br /&gt;
&lt;br /&gt;
1. Understanding the working of the rpl border router code &amp;lt;br&amp;gt;&lt;br /&gt;
2. Starting a simulation on Cooja simulator. &amp;lt;br&amp;gt; &lt;br /&gt;
3. Observing and validating the results &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code building blocks. ==&lt;br /&gt;
 &lt;br /&gt;
We will using the following files &lt;br /&gt;
&lt;br /&gt;
1. border-router.c &amp;lt;br&amp;gt;&lt;br /&gt;
2. udp-server.c  (udp-client.c can also be used)&amp;lt;br&amp;gt;&lt;br /&gt;
3. slip-bridge.c&amp;lt;br&amp;gt;&lt;br /&gt;
4. httpd-simple.c&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
udp-server nodes will form a DAG with the border router set as the root. The border router will receive the prefix through a SLIP connection and it will be communicated to the rest of the nodes in the RPL network. &lt;br /&gt;
&lt;br /&gt;
Refer to the following code snippets in the file border-router.c In this piece of code the node configured as the border router waits for the prefix to be set. Once it receives the prefix, the border router is set as the root of the DODAG after which it sets the prefix of the rest of the nodes in the network.  &lt;br /&gt;
 &lt;br /&gt;
 /* Request prefix until it has been received */ &lt;br /&gt;
  while(!prefix_set) { &lt;br /&gt;
    etimer_set(&amp;amp;et, CLOCK_SECOND); &lt;br /&gt;
    request_prefix(); &lt;br /&gt;
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&amp;amp;et)); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
  dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)dag_id); &lt;br /&gt;
  if(dag != NULL) { &lt;br /&gt;
    rpl_set_prefix(dag, &amp;amp;prefix, 64); &lt;br /&gt;
    PRINTF(&amp;quot;created a new RPL dag\n&amp;quot;); &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
== Compiling the code ==&lt;br /&gt;
 &lt;br /&gt;
The code for RPL border router can be found at /contiki-2.7/examples/ipv6/rpl-border-router. Use the following command to compile the code for the border router &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-border-router &lt;br /&gt;
make TARGET=sky. &amp;lt;/pre&amp;gt;   &lt;br /&gt;
Once this command has been successfully executed a file named border-router.sky will be created. This file will be used to program one of the motes as the border router on Cooja.  &lt;br /&gt;
For the purpose of this tutorial we will  select  TMote Sky  as our target. &lt;br /&gt;
&lt;br /&gt;
In order to demonstrate the functionality of the border router we will create a network of nodes with the border router as the root. For creating such a network we will user the udp-server.c code.  &lt;br /&gt;
This code can be found at /contiki-2.7/examples/ipv6/rpl-udp . Use the following command to compile the code for rpl-udp &lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-udp &lt;br /&gt;
make TARGET=sky &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once this command has been successfully executed a file named udp-server.sky will be created. This file will be used to program the remaining nodes in Cooja simulator. These nodes will form a DAG with the rpl border router as the root.&lt;br /&gt;
&lt;br /&gt;
== Testing on Cooja ==&lt;br /&gt;
 &lt;br /&gt;
Upon the successful completion of the above mentioned steps we are ready to create a simulation in Cooja.  &lt;br /&gt;
Start the Cooja simulator using the following command &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd /contiki-2.7/tools/cooja &lt;br /&gt;
ant run&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
When the GUI launches execute the following steps to create a simulation. &amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
1. From &amp;#039;File&amp;#039; select &amp;#039;New Simulation&amp;#039;. Select UDGM, enter the name of the simulation and click on create. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Click on Motes. From the drop down menu select &amp;#039;Add New Motes&amp;#039; followed by &amp;#039;Create new motes&amp;#039; and select the mote type as Sky. &amp;lt;br&amp;gt;&lt;br /&gt;
3. Browse to the location /contiki-2.7/examples/ipv6/rpl-border-router and select the file rpl-border-router.sky. Click on &amp;#039;Create&amp;#039;. Add one mote of this type. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Repeat step 2 and 3 but this time browse to the location /contiki-2.7/examples/ipv6/rpl-udp  and select the file udp-server.sky. Add 3 - 4 motes of the type udp-server &amp;lt;br&amp;gt;&lt;br /&gt;
5. Once the motes have been added you can position the motes. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Cooja_motes.png]]&lt;br /&gt;
&lt;br /&gt;
Select the options under View as shown below. These will help you creating a topology of your choice.&lt;br /&gt;
[[File:Motes_view.png]]&lt;br /&gt;
&lt;br /&gt;
6. Now, we need to create a bridge between the RPL network simulated on Cooja and the local machine. This can be done by right clicking on the mote which is programmed as the border router. Select &amp;#039;More tools for border router&amp;#039; and then select &amp;#039;Serial Socket (SERVER)&amp;#039;. You will get the following message on the successful completion of this step.Note that the message says &amp;#039;Listening on port 60001&amp;#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Serial_Socket.png]]&lt;br /&gt;
&lt;br /&gt;
7. Now start the simulation by clicking on Start&lt;br /&gt;
&lt;br /&gt;
== Tunslip utility ==&lt;br /&gt;
 &lt;br /&gt;
As mentioned in the introduction a border router helps in connecting one network to another. In this example the border router is used to route data between an RPL network and an external network. Till now we have only created the RPL network. Now we need to simulate the scenario in which this RPL network is connected to an external network. For this purpose we will use the Tunslip utility provided in Contiki. In this example tunslip creates a bridge between the RPL network and the local machine. &lt;br /&gt;
tunslip6.c can be found in /contiki-2.7/tools &lt;br /&gt;
Compile the tunslip6 code.&lt;br /&gt;
&amp;lt;pre&amp;gt;make tunslip6 &amp;lt;/pre&amp;gt; &lt;br /&gt;
Make a connection between the RPL network and your local machine. &lt;br /&gt;
&amp;lt;pre&amp;gt;sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64&amp;lt;/pre&amp;gt;&lt;br /&gt;
On the successful execution this command the following output will be printed on the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;slip connected to ``127.0.0.1:60001&amp;#039;&amp;#039;&lt;br /&gt;
opened tun device ``/dev/tun0&amp;#039;&amp;#039;&lt;br /&gt;
ifconfig tun0 inet `hostname` up&lt;br /&gt;
ifconfig tun0 add aaaa::1/64&lt;br /&gt;
ifconfig tun0 add fe80::0:0:0:1/64&lt;br /&gt;
ifconfig tun0&lt;br /&gt;
&lt;br /&gt;
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  &lt;br /&gt;
          inet addr:127.0.1.1  P-t-P:127.0.1.1  Mask:255.255.255.255&lt;br /&gt;
          inet6 addr: fe80::1/64 Scope:Link&lt;br /&gt;
          inet6 addr: aaaa::1/64 Scope:Global&lt;br /&gt;
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1&lt;br /&gt;
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0&lt;br /&gt;
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0&lt;br /&gt;
          collisions:0 txqueuelen:500 &lt;br /&gt;
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)&lt;br /&gt;
&lt;br /&gt;
Rime started with address 0.18.116.1.0.1.1.1&lt;br /&gt;
MAC 00:12:74:01:00:01:01:01 Contiki 2.7 started. Node id is set to 1.&lt;br /&gt;
CSMA ContikiMAC, channel check rate 8 Hz, radio channel 26&lt;br /&gt;
Tentative link-local IPv6 address fe80:0000:0000:0000:0212:7401:0001:0101&lt;br /&gt;
Starting &amp;#039;Border router process&amp;#039; &amp;#039;Web server&amp;#039;&lt;br /&gt;
*** Address:aaaa::1 =&amp;gt; aaaa:0000:0000:0000&lt;br /&gt;
Got configuration message of type P&lt;br /&gt;
Setting prefix aaaa::&lt;br /&gt;
Server IPv6 addresses:&lt;br /&gt;
 aaaa::212:7401:1:101&lt;br /&gt;
 fe80::212:7401:1:101&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Go back to the Cooja simulator GUI and look at the dialogue box. The message has now changed to &amp;#039;Client connected: /127.0.0.1&amp;#039;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Client_Connected.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Verifying Results ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can verify that the address of the border router has been set by using the ping command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7401:1:101&lt;br /&gt;
PING aaaa::212:7401:1:101(aaaa::212:7401:1:101) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=1 ttl=64 time=86.0 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=2 ttl=64 time=33.6 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=3 ttl=64 time=82.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=4 ttl=64 time=43.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=5 ttl=64 time=70.1 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7401:1:101 ping statistics ---&lt;br /&gt;
5 packets transmitted, 5 received, 0% packet loss, time 4006ms&lt;br /&gt;
rtt min/avg/max/mdev = 33.669/63.090/86.015/20.985 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also ping one of the other nodes in the network. Here we are pinging node 4&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7404:4:404&lt;br /&gt;
PING aaaa::212:7404:4:404(aaaa::212:7404:4:404) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=1 ttl=63 time=670 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=2 ttl=63 time=703 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=3 ttl=63 time=746 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=4 ttl=63 time=674 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7404:4:404 ping statistics ---&lt;br /&gt;
5 packets transmitted, 4 received, 20% packet loss, time 4001ms&lt;br /&gt;
rtt min/avg/max/mdev = 670.230/698.666/746.619/30.514 ms&lt;br /&gt;
user@instant-contiki:~/contiki-2.7$ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IPv6 address of a node can be checked from the log screen on Cooja. Filter the nodes by their ID&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Node_Address.png]]&lt;br /&gt;
&lt;br /&gt;
You can enter the address of the border router in the web browser. The border router host a page which will be displayed on the browser as shown below. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:RPL_Browser.png]]&lt;br /&gt;
&lt;br /&gt;
== Common Issues ==&lt;br /&gt;
&lt;br /&gt;
1. Make sure that you enter the IPv6 address properly in the command sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64 . There should be no spaces in aaaa::1/64. Otherwise the code will give unexpected behavior.&amp;lt;br&amp;gt;&lt;br /&gt;
2. When you pause the simulation the SLIP connection is lost. It might not work properly on resuming the simulation. In such cases reload the simulation. Create a fresh SLIP connection and then run the simulation again.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
[https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md]  https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md &amp;lt;br&amp;gt;&lt;br /&gt;
[http://cnds.eecs.jacobs-university.de/courses/iotlab-2013/cooja.pdf] Using the Contiki Cooja Simulator - Anuj Sehgal&lt;/div&gt;</summary>
		<author><name>Ckapoor</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=File:Motes_view.png&amp;diff=1149</id>
		<title>File:Motes view.png</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=File:Motes_view.png&amp;diff=1149"/>
				<updated>2014-11-08T23:03:08Z</updated>
		
		<summary type="html">&lt;p&gt;Ckapoor: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ckapoor</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1148</id>
		<title>RPL Border Router</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1148"/>
				<updated>2014-11-08T22:59:19Z</updated>
		
		<summary type="html">&lt;p&gt;Ckapoor: /* Compiling the code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction: ==&lt;br /&gt;
  &lt;br /&gt;
Border routers are routers that can be found at the edge of a network. Their function is to connect one network to another. In this tutorial we will learn how to run a simulation using the border router in Contiki In the example which we will discuss in the rest of this tutorial the border router will be used to route data between a WSN (using RPL) and an external IP network.  &lt;br /&gt;
Objective:  &lt;br /&gt;
The objective of this tutorial is to give you an understanding of the RPL Border Router code on Contiki OS and learn how to simulate the code on Cooja &lt;br /&gt;
What will you learn at the end of this tutorial. At the end of the tutorial you would have learnt the following: &lt;br /&gt;
&lt;br /&gt;
1. Understanding the working of the rpl border router code &amp;lt;br&amp;gt;&lt;br /&gt;
2. Starting a simulation on Cooja simulator. &amp;lt;br&amp;gt; &lt;br /&gt;
3. Observing and validating the results &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code building blocks. ==&lt;br /&gt;
 &lt;br /&gt;
We will using the following files &lt;br /&gt;
&lt;br /&gt;
1. border-router.c &amp;lt;br&amp;gt;&lt;br /&gt;
2. udp-server.c  (udp-client.c can also be used)&amp;lt;br&amp;gt;&lt;br /&gt;
3. slip-bridge.c&amp;lt;br&amp;gt;&lt;br /&gt;
4. httpd-simple.c&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
udp-server nodes will form a DAG with the border router set as the root. The border router will receive the prefix through a SLIP connection and it will be communicated to the rest of the nodes in the RPL network. &lt;br /&gt;
&lt;br /&gt;
Refer to the following code snippets in the file border-router.c In this piece of code the node configured as the border router waits for the prefix to be set. Once it receives the prefix, the border router is set as the root of the DODAG after which it sets the prefix of the rest of the nodes in the network.  &lt;br /&gt;
 &lt;br /&gt;
 /* Request prefix until it has been received */ &lt;br /&gt;
  while(!prefix_set) { &lt;br /&gt;
    etimer_set(&amp;amp;et, CLOCK_SECOND); &lt;br /&gt;
    request_prefix(); &lt;br /&gt;
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&amp;amp;et)); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
  dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)dag_id); &lt;br /&gt;
  if(dag != NULL) { &lt;br /&gt;
    rpl_set_prefix(dag, &amp;amp;prefix, 64); &lt;br /&gt;
    PRINTF(&amp;quot;created a new RPL dag\n&amp;quot;); &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
== Compiling the code ==&lt;br /&gt;
 &lt;br /&gt;
The code for RPL border router can be found at /contiki-2.7/examples/ipv6/rpl-border-router. Use the following command to compile the code for the border router &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-border-router &lt;br /&gt;
make TARGET=sky. &amp;lt;/pre&amp;gt;   &lt;br /&gt;
Once this command has been successfully executed a file named border-router.sky will be created. This file will be used to program one of the motes as the border router on Cooja.  &lt;br /&gt;
For the purpose of this tutorial we will  select  TMote Sky  as our target. &lt;br /&gt;
&lt;br /&gt;
In order to demonstrate the functionality of the border router we will create a network of nodes with the border router as the root. For creating such a network we will user the udp-server.c code.  &lt;br /&gt;
This code can be found at /contiki-2.7/examples/ipv6/rpl-udp . Use the following command to compile the code for rpl-udp &lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-udp &lt;br /&gt;
make TARGET=sky &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once this command has been successfully executed a file named udp-server.sky will be created. This file will be used to program the remaining nodes in Cooja simulator. These nodes will form a DAG with the rpl border router as the root.&lt;br /&gt;
&lt;br /&gt;
== Testing on Cooja ==&lt;br /&gt;
 &lt;br /&gt;
Upon the successful completion of the above mentioned steps we are ready to create a simulation in Cooja.  &lt;br /&gt;
Start the Cooja simulator using the following command &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd /contiki-2.7/tools/cooja &lt;br /&gt;
ant run&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
When the GUI launches execute the following steps to create a simulation. &amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
1. From &amp;#039;File&amp;#039; select &amp;#039;New Simulation&amp;#039;. Select UDGM, enter the name of the simulation and click on create. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Click on Motes. From the drop down menu select &amp;#039;Add New Motes&amp;#039; followed by &amp;#039;Create new motes&amp;#039; and select the mote type as Sky. &amp;lt;br&amp;gt;&lt;br /&gt;
3. Browse to the location /contiki-2.7/examples/ipv6/rpl-border-router and select the file rpl-border-router.sky. Click on &amp;#039;Create&amp;#039;. Add one mote of this type. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Repeat step 2 and 3 but this time browse to the location /contiki-2.7/examples/ipv6/rpl-udp  and select the file udp-server.sky. Add 3 - 4 motes of the type udp-server &amp;lt;br&amp;gt;&lt;br /&gt;
5. Once the motes have been added you can position the motes.&lt;br /&gt;
&lt;br /&gt;
[[File:Cooja_motes.png]]&lt;br /&gt;
&lt;br /&gt;
6. Now, we need to create a bridge between the RPL network simulated on Cooja and the local machine. This can be done by right clicking on the mote which is programmed as the border router. Select &amp;#039;More tools for border router&amp;#039; and then select &amp;#039;Serial Socket (SERVER)&amp;#039;. You will get the following message on the successful completion of this step.Note that the message says &amp;#039;Listening on port 60001&amp;#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Serial_Socket.png]]&lt;br /&gt;
&lt;br /&gt;
7. Now start the simulation by clicking on Start&lt;br /&gt;
&lt;br /&gt;
== Tunslip utility ==&lt;br /&gt;
 &lt;br /&gt;
As mentioned in the introduction a border router helps in connecting one network to another. In this example the border router is used to route data between an RPL network and an external network. Till now we have only created the RPL network. Now we need to simulate the scenario in which this RPL network is connected to an external network. For this purpose we will use the Tunslip utility provided in Contiki. In this example tunslip creates a bridge between the RPL network and the local machine. &lt;br /&gt;
tunslip6.c can be found in /contiki-2.7/tools &lt;br /&gt;
Compile the tunslip6 code.&lt;br /&gt;
&amp;lt;pre&amp;gt;make tunslip6 &amp;lt;/pre&amp;gt; &lt;br /&gt;
Make a connection between the RPL network and your local machine. &lt;br /&gt;
&amp;lt;pre&amp;gt;sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64&amp;lt;/pre&amp;gt;&lt;br /&gt;
On the successful execution this command the following output will be printed on the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;slip connected to ``127.0.0.1:60001&amp;#039;&amp;#039;&lt;br /&gt;
opened tun device ``/dev/tun0&amp;#039;&amp;#039;&lt;br /&gt;
ifconfig tun0 inet `hostname` up&lt;br /&gt;
ifconfig tun0 add aaaa::1/64&lt;br /&gt;
ifconfig tun0 add fe80::0:0:0:1/64&lt;br /&gt;
ifconfig tun0&lt;br /&gt;
&lt;br /&gt;
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  &lt;br /&gt;
          inet addr:127.0.1.1  P-t-P:127.0.1.1  Mask:255.255.255.255&lt;br /&gt;
          inet6 addr: fe80::1/64 Scope:Link&lt;br /&gt;
          inet6 addr: aaaa::1/64 Scope:Global&lt;br /&gt;
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1&lt;br /&gt;
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0&lt;br /&gt;
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0&lt;br /&gt;
          collisions:0 txqueuelen:500 &lt;br /&gt;
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)&lt;br /&gt;
&lt;br /&gt;
Rime started with address 0.18.116.1.0.1.1.1&lt;br /&gt;
MAC 00:12:74:01:00:01:01:01 Contiki 2.7 started. Node id is set to 1.&lt;br /&gt;
CSMA ContikiMAC, channel check rate 8 Hz, radio channel 26&lt;br /&gt;
Tentative link-local IPv6 address fe80:0000:0000:0000:0212:7401:0001:0101&lt;br /&gt;
Starting &amp;#039;Border router process&amp;#039; &amp;#039;Web server&amp;#039;&lt;br /&gt;
*** Address:aaaa::1 =&amp;gt; aaaa:0000:0000:0000&lt;br /&gt;
Got configuration message of type P&lt;br /&gt;
Setting prefix aaaa::&lt;br /&gt;
Server IPv6 addresses:&lt;br /&gt;
 aaaa::212:7401:1:101&lt;br /&gt;
 fe80::212:7401:1:101&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Go back to the Cooja simulator GUI and look at the dialogue box. The message has now changed to &amp;#039;Client connected: /127.0.0.1&amp;#039;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Client_Connected.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Verifying Results ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can verify that the address of the border router has been set by using the ping command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7401:1:101&lt;br /&gt;
PING aaaa::212:7401:1:101(aaaa::212:7401:1:101) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=1 ttl=64 time=86.0 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=2 ttl=64 time=33.6 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=3 ttl=64 time=82.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=4 ttl=64 time=43.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=5 ttl=64 time=70.1 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7401:1:101 ping statistics ---&lt;br /&gt;
5 packets transmitted, 5 received, 0% packet loss, time 4006ms&lt;br /&gt;
rtt min/avg/max/mdev = 33.669/63.090/86.015/20.985 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also ping one of the other nodes in the network. Here we are pinging node 4&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7404:4:404&lt;br /&gt;
PING aaaa::212:7404:4:404(aaaa::212:7404:4:404) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=1 ttl=63 time=670 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=2 ttl=63 time=703 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=3 ttl=63 time=746 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=4 ttl=63 time=674 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7404:4:404 ping statistics ---&lt;br /&gt;
5 packets transmitted, 4 received, 20% packet loss, time 4001ms&lt;br /&gt;
rtt min/avg/max/mdev = 670.230/698.666/746.619/30.514 ms&lt;br /&gt;
user@instant-contiki:~/contiki-2.7$ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IPv6 address of a node can be checked from the log screen on Cooja. Filter the nodes by their ID&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Node_Address.png]]&lt;br /&gt;
&lt;br /&gt;
You can enter the address of the border router in the web browser. The border router host a page which will be displayed on the browser as shown below. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:RPL_Browser.png]]&lt;br /&gt;
&lt;br /&gt;
== Common Issues ==&lt;br /&gt;
&lt;br /&gt;
1. Make sure that you enter the IPv6 address properly in the command sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64 . There should be no spaces in aaaa::1/64. Otherwise the code will give unexpected behavior.&amp;lt;br&amp;gt;&lt;br /&gt;
2. When you pause the simulation the SLIP connection is lost. It might not work properly on resuming the simulation. In such cases reload the simulation. Create a fresh SLIP connection and then run the simulation again.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
[https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md]  https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md &amp;lt;br&amp;gt;&lt;br /&gt;
[http://cnds.eecs.jacobs-university.de/courses/iotlab-2013/cooja.pdf] Using the Contiki Cooja Simulator - Anuj Sehgal&lt;/div&gt;</summary>
		<author><name>Ckapoor</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1147</id>
		<title>RPL Border Router</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1147"/>
				<updated>2014-11-08T22:58:17Z</updated>
		
		<summary type="html">&lt;p&gt;Ckapoor: /* Introduction: */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction: ==&lt;br /&gt;
  &lt;br /&gt;
Border routers are routers that can be found at the edge of a network. Their function is to connect one network to another. In this tutorial we will learn how to run a simulation using the border router in Contiki In the example which we will discuss in the rest of this tutorial the border router will be used to route data between a WSN (using RPL) and an external IP network.  &lt;br /&gt;
Objective:  &lt;br /&gt;
The objective of this tutorial is to give you an understanding of the RPL Border Router code on Contiki OS and learn how to simulate the code on Cooja &lt;br /&gt;
What will you learn at the end of this tutorial. At the end of the tutorial you would have learnt the following: &lt;br /&gt;
&lt;br /&gt;
1. Understanding the working of the rpl border router code &amp;lt;br&amp;gt;&lt;br /&gt;
2. Starting a simulation on Cooja simulator. &amp;lt;br&amp;gt; &lt;br /&gt;
3. Observing and validating the results &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code building blocks. ==&lt;br /&gt;
 &lt;br /&gt;
We will using the following files &lt;br /&gt;
&lt;br /&gt;
1. border-router.c &amp;lt;br&amp;gt;&lt;br /&gt;
2. udp-server.c  (udp-client.c can also be used)&amp;lt;br&amp;gt;&lt;br /&gt;
3. slip-bridge.c&amp;lt;br&amp;gt;&lt;br /&gt;
4. httpd-simple.c&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
udp-server nodes will form a DAG with the border router set as the root. The border router will receive the prefix through a SLIP connection and it will be communicated to the rest of the nodes in the RPL network. &lt;br /&gt;
&lt;br /&gt;
Refer to the following code snippets in the file border-router.c In this piece of code the node configured as the border router waits for the prefix to be set. Once it receives the prefix, the border router is set as the root of the DODAG after which it sets the prefix of the rest of the nodes in the network.  &lt;br /&gt;
 &lt;br /&gt;
 /* Request prefix until it has been received */ &lt;br /&gt;
  while(!prefix_set) { &lt;br /&gt;
    etimer_set(&amp;amp;et, CLOCK_SECOND); &lt;br /&gt;
    request_prefix(); &lt;br /&gt;
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&amp;amp;et)); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
  dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)dag_id); &lt;br /&gt;
  if(dag != NULL) { &lt;br /&gt;
    rpl_set_prefix(dag, &amp;amp;prefix, 64); &lt;br /&gt;
    PRINTF(&amp;quot;created a new RPL dag\n&amp;quot;); &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
== Compiling the code ==&lt;br /&gt;
 &lt;br /&gt;
The code for RPL border router can be found at /contiki-2.7/examples/ipv6/rpl-border-router. Use the following command to compile the code for the border router &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-border-router &lt;br /&gt;
make TARGET=sky. &amp;lt;/pre&amp;gt;   &lt;br /&gt;
Once this command has been successfully executed a file named border-router.sky will be created. This file will be used to program one of the motes as the border router on Cooja.  &lt;br /&gt;
For the purpose of this tutorial we will  select  TMote Sky  as our target. &lt;br /&gt;
&lt;br /&gt;
In order to demonstrate the functioning of the border router we will create a network of nodes with the border router as the root. For creating such a network we will user the udp-server.c code.  &lt;br /&gt;
This code can be found at /contiki-2.7/examples/ipv6/rpl-udp . Use the following command to compile the code for rpl-udp &lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-udp &lt;br /&gt;
make TARGET=sky &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once this command has been successfully executed a file named udp-server.sky will be created. This file will be used to program the remaining nodes in Cooja simulator. These nodes will form a DAG with the rpl border router as the root.&lt;br /&gt;
&lt;br /&gt;
== Testing on Cooja ==&lt;br /&gt;
 &lt;br /&gt;
Upon the successful completion of the above mentioned steps we are ready to create a simulation in Cooja.  &lt;br /&gt;
Start the Cooja simulator using the following command &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd /contiki-2.7/tools/cooja &lt;br /&gt;
ant run&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
When the GUI launches execute the following steps to create a simulation. &amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
1. From &amp;#039;File&amp;#039; select &amp;#039;New Simulation&amp;#039;. Select UDGM, enter the name of the simulation and click on create. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Click on Motes. From the drop down menu select &amp;#039;Add New Motes&amp;#039; followed by &amp;#039;Create new motes&amp;#039; and select the mote type as Sky. &amp;lt;br&amp;gt;&lt;br /&gt;
3. Browse to the location /contiki-2.7/examples/ipv6/rpl-border-router and select the file rpl-border-router.sky. Click on &amp;#039;Create&amp;#039;. Add one mote of this type. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Repeat step 2 and 3 but this time browse to the location /contiki-2.7/examples/ipv6/rpl-udp  and select the file udp-server.sky. Add 3 - 4 motes of the type udp-server &amp;lt;br&amp;gt;&lt;br /&gt;
5. Once the motes have been added you can position the motes.&lt;br /&gt;
&lt;br /&gt;
[[File:Cooja_motes.png]]&lt;br /&gt;
&lt;br /&gt;
6. Now, we need to create a bridge between the RPL network simulated on Cooja and the local machine. This can be done by right clicking on the mote which is programmed as the border router. Select &amp;#039;More tools for border router&amp;#039; and then select &amp;#039;Serial Socket (SERVER)&amp;#039;. You will get the following message on the successful completion of this step.Note that the message says &amp;#039;Listening on port 60001&amp;#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Serial_Socket.png]]&lt;br /&gt;
&lt;br /&gt;
7. Now start the simulation by clicking on Start&lt;br /&gt;
&lt;br /&gt;
== Tunslip utility ==&lt;br /&gt;
 &lt;br /&gt;
As mentioned in the introduction a border router helps in connecting one network to another. In this example the border router is used to route data between an RPL network and an external network. Till now we have only created the RPL network. Now we need to simulate the scenario in which this RPL network is connected to an external network. For this purpose we will use the Tunslip utility provided in Contiki. In this example tunslip creates a bridge between the RPL network and the local machine. &lt;br /&gt;
tunslip6.c can be found in /contiki-2.7/tools &lt;br /&gt;
Compile the tunslip6 code.&lt;br /&gt;
&amp;lt;pre&amp;gt;make tunslip6 &amp;lt;/pre&amp;gt; &lt;br /&gt;
Make a connection between the RPL network and your local machine. &lt;br /&gt;
&amp;lt;pre&amp;gt;sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64&amp;lt;/pre&amp;gt;&lt;br /&gt;
On the successful execution this command the following output will be printed on the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;slip connected to ``127.0.0.1:60001&amp;#039;&amp;#039;&lt;br /&gt;
opened tun device ``/dev/tun0&amp;#039;&amp;#039;&lt;br /&gt;
ifconfig tun0 inet `hostname` up&lt;br /&gt;
ifconfig tun0 add aaaa::1/64&lt;br /&gt;
ifconfig tun0 add fe80::0:0:0:1/64&lt;br /&gt;
ifconfig tun0&lt;br /&gt;
&lt;br /&gt;
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  &lt;br /&gt;
          inet addr:127.0.1.1  P-t-P:127.0.1.1  Mask:255.255.255.255&lt;br /&gt;
          inet6 addr: fe80::1/64 Scope:Link&lt;br /&gt;
          inet6 addr: aaaa::1/64 Scope:Global&lt;br /&gt;
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1&lt;br /&gt;
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0&lt;br /&gt;
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0&lt;br /&gt;
          collisions:0 txqueuelen:500 &lt;br /&gt;
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)&lt;br /&gt;
&lt;br /&gt;
Rime started with address 0.18.116.1.0.1.1.1&lt;br /&gt;
MAC 00:12:74:01:00:01:01:01 Contiki 2.7 started. Node id is set to 1.&lt;br /&gt;
CSMA ContikiMAC, channel check rate 8 Hz, radio channel 26&lt;br /&gt;
Tentative link-local IPv6 address fe80:0000:0000:0000:0212:7401:0001:0101&lt;br /&gt;
Starting &amp;#039;Border router process&amp;#039; &amp;#039;Web server&amp;#039;&lt;br /&gt;
*** Address:aaaa::1 =&amp;gt; aaaa:0000:0000:0000&lt;br /&gt;
Got configuration message of type P&lt;br /&gt;
Setting prefix aaaa::&lt;br /&gt;
Server IPv6 addresses:&lt;br /&gt;
 aaaa::212:7401:1:101&lt;br /&gt;
 fe80::212:7401:1:101&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Go back to the Cooja simulator GUI and look at the dialogue box. The message has now changed to &amp;#039;Client connected: /127.0.0.1&amp;#039;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Client_Connected.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Verifying Results ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can verify that the address of the border router has been set by using the ping command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7401:1:101&lt;br /&gt;
PING aaaa::212:7401:1:101(aaaa::212:7401:1:101) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=1 ttl=64 time=86.0 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=2 ttl=64 time=33.6 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=3 ttl=64 time=82.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=4 ttl=64 time=43.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=5 ttl=64 time=70.1 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7401:1:101 ping statistics ---&lt;br /&gt;
5 packets transmitted, 5 received, 0% packet loss, time 4006ms&lt;br /&gt;
rtt min/avg/max/mdev = 33.669/63.090/86.015/20.985 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also ping one of the other nodes in the network. Here we are pinging node 4&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7404:4:404&lt;br /&gt;
PING aaaa::212:7404:4:404(aaaa::212:7404:4:404) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=1 ttl=63 time=670 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=2 ttl=63 time=703 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=3 ttl=63 time=746 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=4 ttl=63 time=674 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7404:4:404 ping statistics ---&lt;br /&gt;
5 packets transmitted, 4 received, 20% packet loss, time 4001ms&lt;br /&gt;
rtt min/avg/max/mdev = 670.230/698.666/746.619/30.514 ms&lt;br /&gt;
user@instant-contiki:~/contiki-2.7$ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IPv6 address of a node can be checked from the log screen on Cooja. Filter the nodes by their ID&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Node_Address.png]]&lt;br /&gt;
&lt;br /&gt;
You can enter the address of the border router in the web browser. The border router host a page which will be displayed on the browser as shown below. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:RPL_Browser.png]]&lt;br /&gt;
&lt;br /&gt;
== Common Issues ==&lt;br /&gt;
&lt;br /&gt;
1. Make sure that you enter the IPv6 address properly in the command sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64 . There should be no spaces in aaaa::1/64. Otherwise the code will give unexpected behavior.&amp;lt;br&amp;gt;&lt;br /&gt;
2. When you pause the simulation the SLIP connection is lost. It might not work properly on resuming the simulation. In such cases reload the simulation. Create a fresh SLIP connection and then run the simulation again.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
[https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md]  https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md &amp;lt;br&amp;gt;&lt;br /&gt;
[http://cnds.eecs.jacobs-university.de/courses/iotlab-2013/cooja.pdf] Using the Contiki Cooja Simulator - Anuj Sehgal&lt;/div&gt;</summary>
		<author><name>Ckapoor</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1146</id>
		<title>RPL Border Router</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1146"/>
				<updated>2014-11-08T22:53:44Z</updated>
		
		<summary type="html">&lt;p&gt;Ckapoor: /* Code building blocks. */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction: ==&lt;br /&gt;
  &lt;br /&gt;
Border routers are routers that can be found at the edge of a network. Their function is to connect one network to another. In this tutorial we will learn how to run a simulation using the border router in Contiki In the example which we will discuss in the rest of this tutorial the border router will be used to route data between a WSN (using RPL) and an external IP network.  &lt;br /&gt;
Objective:  &lt;br /&gt;
The objective of this tutorial is to give you an understanding of the RPL Border Router code on Contiki OS and learn how to simulate the code on Cooja &lt;br /&gt;
What will you learn at the end of this tutorial. At the end of the tutorial you would have learnt the following: &lt;br /&gt;
&lt;br /&gt;
1. Understanding the working of the rpl border router code &amp;lt;br&amp;gt;&lt;br /&gt;
2. Starting a simulation on Cooja simulator. &amp;lt;br&amp;gt; &lt;br /&gt;
3. Observing the results &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code building blocks. ==&lt;br /&gt;
 &lt;br /&gt;
We will using the following files &lt;br /&gt;
&lt;br /&gt;
1. border-router.c &amp;lt;br&amp;gt;&lt;br /&gt;
2. udp-server.c  (udp-client.c can also be used)&amp;lt;br&amp;gt;&lt;br /&gt;
3. slip-bridge.c&amp;lt;br&amp;gt;&lt;br /&gt;
4. httpd-simple.c&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
udp-server nodes will form a DAG with the border router set as the root. The border router will receive the prefix through a SLIP connection and it will be communicated to the rest of the nodes in the RPL network. &lt;br /&gt;
&lt;br /&gt;
Refer to the following code snippets in the file border-router.c In this piece of code the node configured as the border router waits for the prefix to be set. Once it receives the prefix, the border router is set as the root of the DODAG after which it sets the prefix of the rest of the nodes in the network.  &lt;br /&gt;
 &lt;br /&gt;
 /* Request prefix until it has been received */ &lt;br /&gt;
  while(!prefix_set) { &lt;br /&gt;
    etimer_set(&amp;amp;et, CLOCK_SECOND); &lt;br /&gt;
    request_prefix(); &lt;br /&gt;
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&amp;amp;et)); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
  dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)dag_id); &lt;br /&gt;
  if(dag != NULL) { &lt;br /&gt;
    rpl_set_prefix(dag, &amp;amp;prefix, 64); &lt;br /&gt;
    PRINTF(&amp;quot;created a new RPL dag\n&amp;quot;); &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
== Compiling the code ==&lt;br /&gt;
 &lt;br /&gt;
The code for RPL border router can be found at /contiki-2.7/examples/ipv6/rpl-border-router. Use the following command to compile the code for the border router &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-border-router &lt;br /&gt;
make TARGET=sky. &amp;lt;/pre&amp;gt;   &lt;br /&gt;
Once this command has been successfully executed a file named border-router.sky will be created. This file will be used to program one of the motes as the border router on Cooja.  &lt;br /&gt;
For the purpose of this tutorial we will  select  TMote Sky  as our target. &lt;br /&gt;
&lt;br /&gt;
In order to demonstrate the functioning of the border router we will create a network of nodes with the border router as the root. For creating such a network we will user the udp-server.c code.  &lt;br /&gt;
This code can be found at /contiki-2.7/examples/ipv6/rpl-udp . Use the following command to compile the code for rpl-udp &lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-udp &lt;br /&gt;
make TARGET=sky &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once this command has been successfully executed a file named udp-server.sky will be created. This file will be used to program the remaining nodes in Cooja simulator. These nodes will form a DAG with the rpl border router as the root.&lt;br /&gt;
&lt;br /&gt;
== Testing on Cooja ==&lt;br /&gt;
 &lt;br /&gt;
Upon the successful completion of the above mentioned steps we are ready to create a simulation in Cooja.  &lt;br /&gt;
Start the Cooja simulator using the following command &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd /contiki-2.7/tools/cooja &lt;br /&gt;
ant run&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
When the GUI launches execute the following steps to create a simulation. &amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
1. From &amp;#039;File&amp;#039; select &amp;#039;New Simulation&amp;#039;. Select UDGM, enter the name of the simulation and click on create. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Click on Motes. From the drop down menu select &amp;#039;Add New Motes&amp;#039; followed by &amp;#039;Create new motes&amp;#039; and select the mote type as Sky. &amp;lt;br&amp;gt;&lt;br /&gt;
3. Browse to the location /contiki-2.7/examples/ipv6/rpl-border-router and select the file rpl-border-router.sky. Click on &amp;#039;Create&amp;#039;. Add one mote of this type. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Repeat step 2 and 3 but this time browse to the location /contiki-2.7/examples/ipv6/rpl-udp  and select the file udp-server.sky. Add 3 - 4 motes of the type udp-server &amp;lt;br&amp;gt;&lt;br /&gt;
5. Once the motes have been added you can position the motes.&lt;br /&gt;
&lt;br /&gt;
[[File:Cooja_motes.png]]&lt;br /&gt;
&lt;br /&gt;
6. Now, we need to create a bridge between the RPL network simulated on Cooja and the local machine. This can be done by right clicking on the mote which is programmed as the border router. Select &amp;#039;More tools for border router&amp;#039; and then select &amp;#039;Serial Socket (SERVER)&amp;#039;. You will get the following message on the successful completion of this step.Note that the message says &amp;#039;Listening on port 60001&amp;#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Serial_Socket.png]]&lt;br /&gt;
&lt;br /&gt;
7. Now start the simulation by clicking on Start&lt;br /&gt;
&lt;br /&gt;
== Tunslip utility ==&lt;br /&gt;
 &lt;br /&gt;
As mentioned in the introduction a border router helps in connecting one network to another. In this example the border router is used to route data between an RPL network and an external network. Till now we have only created the RPL network. Now we need to simulate the scenario in which this RPL network is connected to an external network. For this purpose we will use the Tunslip utility provided in Contiki. In this example tunslip creates a bridge between the RPL network and the local machine. &lt;br /&gt;
tunslip6.c can be found in /contiki-2.7/tools &lt;br /&gt;
Compile the tunslip6 code.&lt;br /&gt;
&amp;lt;pre&amp;gt;make tunslip6 &amp;lt;/pre&amp;gt; &lt;br /&gt;
Make a connection between the RPL network and your local machine. &lt;br /&gt;
&amp;lt;pre&amp;gt;sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64&amp;lt;/pre&amp;gt;&lt;br /&gt;
On the successful execution this command the following output will be printed on the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;slip connected to ``127.0.0.1:60001&amp;#039;&amp;#039;&lt;br /&gt;
opened tun device ``/dev/tun0&amp;#039;&amp;#039;&lt;br /&gt;
ifconfig tun0 inet `hostname` up&lt;br /&gt;
ifconfig tun0 add aaaa::1/64&lt;br /&gt;
ifconfig tun0 add fe80::0:0:0:1/64&lt;br /&gt;
ifconfig tun0&lt;br /&gt;
&lt;br /&gt;
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  &lt;br /&gt;
          inet addr:127.0.1.1  P-t-P:127.0.1.1  Mask:255.255.255.255&lt;br /&gt;
          inet6 addr: fe80::1/64 Scope:Link&lt;br /&gt;
          inet6 addr: aaaa::1/64 Scope:Global&lt;br /&gt;
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1&lt;br /&gt;
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0&lt;br /&gt;
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0&lt;br /&gt;
          collisions:0 txqueuelen:500 &lt;br /&gt;
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)&lt;br /&gt;
&lt;br /&gt;
Rime started with address 0.18.116.1.0.1.1.1&lt;br /&gt;
MAC 00:12:74:01:00:01:01:01 Contiki 2.7 started. Node id is set to 1.&lt;br /&gt;
CSMA ContikiMAC, channel check rate 8 Hz, radio channel 26&lt;br /&gt;
Tentative link-local IPv6 address fe80:0000:0000:0000:0212:7401:0001:0101&lt;br /&gt;
Starting &amp;#039;Border router process&amp;#039; &amp;#039;Web server&amp;#039;&lt;br /&gt;
*** Address:aaaa::1 =&amp;gt; aaaa:0000:0000:0000&lt;br /&gt;
Got configuration message of type P&lt;br /&gt;
Setting prefix aaaa::&lt;br /&gt;
Server IPv6 addresses:&lt;br /&gt;
 aaaa::212:7401:1:101&lt;br /&gt;
 fe80::212:7401:1:101&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Go back to the Cooja simulator GUI and look at the dialogue box. The message has now changed to &amp;#039;Client connected: /127.0.0.1&amp;#039;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Client_Connected.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Verifying Results ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can verify that the address of the border router has been set by using the ping command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7401:1:101&lt;br /&gt;
PING aaaa::212:7401:1:101(aaaa::212:7401:1:101) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=1 ttl=64 time=86.0 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=2 ttl=64 time=33.6 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=3 ttl=64 time=82.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=4 ttl=64 time=43.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=5 ttl=64 time=70.1 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7401:1:101 ping statistics ---&lt;br /&gt;
5 packets transmitted, 5 received, 0% packet loss, time 4006ms&lt;br /&gt;
rtt min/avg/max/mdev = 33.669/63.090/86.015/20.985 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also ping one of the other nodes in the network. Here we are pinging node 4&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7404:4:404&lt;br /&gt;
PING aaaa::212:7404:4:404(aaaa::212:7404:4:404) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=1 ttl=63 time=670 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=2 ttl=63 time=703 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=3 ttl=63 time=746 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=4 ttl=63 time=674 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7404:4:404 ping statistics ---&lt;br /&gt;
5 packets transmitted, 4 received, 20% packet loss, time 4001ms&lt;br /&gt;
rtt min/avg/max/mdev = 670.230/698.666/746.619/30.514 ms&lt;br /&gt;
user@instant-contiki:~/contiki-2.7$ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IPv6 address of a node can be checked from the log screen on Cooja. Filter the nodes by their ID&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Node_Address.png]]&lt;br /&gt;
&lt;br /&gt;
You can enter the address of the border router in the web browser. The border router host a page which will be displayed on the browser as shown below. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:RPL_Browser.png]]&lt;br /&gt;
&lt;br /&gt;
== Common Issues ==&lt;br /&gt;
&lt;br /&gt;
1. Make sure that you enter the IPv6 address properly in the command sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64 . There should be no spaces in aaaa::1/64. Otherwise the code will give unexpected behavior.&amp;lt;br&amp;gt;&lt;br /&gt;
2. When you pause the simulation the SLIP connection is lost. It might not work properly on resuming the simulation. In such cases reload the simulation. Create a fresh SLIP connection and then run the simulation again.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
[https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md]  https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md &amp;lt;br&amp;gt;&lt;br /&gt;
[http://cnds.eecs.jacobs-university.de/courses/iotlab-2013/cooja.pdf] Using the Contiki Cooja Simulator - Anuj Sehgal&lt;/div&gt;</summary>
		<author><name>Ckapoor</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1145</id>
		<title>RPL Border Router</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1145"/>
				<updated>2014-11-08T22:53:28Z</updated>
		
		<summary type="html">&lt;p&gt;Ckapoor: /* Code building blocks. */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction: ==&lt;br /&gt;
  &lt;br /&gt;
Border routers are routers that can be found at the edge of a network. Their function is to connect one network to another. In this tutorial we will learn how to run a simulation using the border router in Contiki In the example which we will discuss in the rest of this tutorial the border router will be used to route data between a WSN (using RPL) and an external IP network.  &lt;br /&gt;
Objective:  &lt;br /&gt;
The objective of this tutorial is to give you an understanding of the RPL Border Router code on Contiki OS and learn how to simulate the code on Cooja &lt;br /&gt;
What will you learn at the end of this tutorial. At the end of the tutorial you would have learnt the following: &lt;br /&gt;
&lt;br /&gt;
1. Understanding the working of the rpl border router code &amp;lt;br&amp;gt;&lt;br /&gt;
2. Starting a simulation on Cooja simulator. &amp;lt;br&amp;gt; &lt;br /&gt;
3. Observing the results &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code building blocks. ==&lt;br /&gt;
 &lt;br /&gt;
We will using the following files &lt;br /&gt;
&lt;br /&gt;
1. border-router.c &amp;lt;br&amp;gt;&lt;br /&gt;
2. udp-server.c  (udp-client.c can also be used)&amp;lt;br&amp;gt;&lt;br /&gt;
3. slip-bridge.c&amp;lt;br&amp;gt;&lt;br /&gt;
4. httpd-simple.c&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
udp-server nodes will form a DODAG with the border router set as the root. The border router will receive the prefix through a SLIP connection and it will be communicated to the rest of the nodes in the RPL network. &lt;br /&gt;
&lt;br /&gt;
Refer to the following code snippets in the file border-router.c In this piece of code the node configured as the border router waits for the prefix to be set. Once it receives the prefix, the border router is set as the root of the DODAG after which it sets the prefix of the rest of the nodes in the network.  &lt;br /&gt;
 &lt;br /&gt;
 /* Request prefix until it has been received */ &lt;br /&gt;
  while(!prefix_set) { &lt;br /&gt;
    etimer_set(&amp;amp;et, CLOCK_SECOND); &lt;br /&gt;
    request_prefix(); &lt;br /&gt;
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&amp;amp;et)); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
  dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)dag_id); &lt;br /&gt;
  if(dag != NULL) { &lt;br /&gt;
    rpl_set_prefix(dag, &amp;amp;prefix, 64); &lt;br /&gt;
    PRINTF(&amp;quot;created a new RPL dag\n&amp;quot;); &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
== Compiling the code ==&lt;br /&gt;
 &lt;br /&gt;
The code for RPL border router can be found at /contiki-2.7/examples/ipv6/rpl-border-router. Use the following command to compile the code for the border router &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-border-router &lt;br /&gt;
make TARGET=sky. &amp;lt;/pre&amp;gt;   &lt;br /&gt;
Once this command has been successfully executed a file named border-router.sky will be created. This file will be used to program one of the motes as the border router on Cooja.  &lt;br /&gt;
For the purpose of this tutorial we will  select  TMote Sky  as our target. &lt;br /&gt;
&lt;br /&gt;
In order to demonstrate the functioning of the border router we will create a network of nodes with the border router as the root. For creating such a network we will user the udp-server.c code.  &lt;br /&gt;
This code can be found at /contiki-2.7/examples/ipv6/rpl-udp . Use the following command to compile the code for rpl-udp &lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-udp &lt;br /&gt;
make TARGET=sky &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once this command has been successfully executed a file named udp-server.sky will be created. This file will be used to program the remaining nodes in Cooja simulator. These nodes will form a DAG with the rpl border router as the root.&lt;br /&gt;
&lt;br /&gt;
== Testing on Cooja ==&lt;br /&gt;
 &lt;br /&gt;
Upon the successful completion of the above mentioned steps we are ready to create a simulation in Cooja.  &lt;br /&gt;
Start the Cooja simulator using the following command &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd /contiki-2.7/tools/cooja &lt;br /&gt;
ant run&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
When the GUI launches execute the following steps to create a simulation. &amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
1. From &amp;#039;File&amp;#039; select &amp;#039;New Simulation&amp;#039;. Select UDGM, enter the name of the simulation and click on create. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Click on Motes. From the drop down menu select &amp;#039;Add New Motes&amp;#039; followed by &amp;#039;Create new motes&amp;#039; and select the mote type as Sky. &amp;lt;br&amp;gt;&lt;br /&gt;
3. Browse to the location /contiki-2.7/examples/ipv6/rpl-border-router and select the file rpl-border-router.sky. Click on &amp;#039;Create&amp;#039;. Add one mote of this type. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Repeat step 2 and 3 but this time browse to the location /contiki-2.7/examples/ipv6/rpl-udp  and select the file udp-server.sky. Add 3 - 4 motes of the type udp-server &amp;lt;br&amp;gt;&lt;br /&gt;
5. Once the motes have been added you can position the motes.&lt;br /&gt;
&lt;br /&gt;
[[File:Cooja_motes.png]]&lt;br /&gt;
&lt;br /&gt;
6. Now, we need to create a bridge between the RPL network simulated on Cooja and the local machine. This can be done by right clicking on the mote which is programmed as the border router. Select &amp;#039;More tools for border router&amp;#039; and then select &amp;#039;Serial Socket (SERVER)&amp;#039;. You will get the following message on the successful completion of this step.Note that the message says &amp;#039;Listening on port 60001&amp;#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Serial_Socket.png]]&lt;br /&gt;
&lt;br /&gt;
7. Now start the simulation by clicking on Start&lt;br /&gt;
&lt;br /&gt;
== Tunslip utility ==&lt;br /&gt;
 &lt;br /&gt;
As mentioned in the introduction a border router helps in connecting one network to another. In this example the border router is used to route data between an RPL network and an external network. Till now we have only created the RPL network. Now we need to simulate the scenario in which this RPL network is connected to an external network. For this purpose we will use the Tunslip utility provided in Contiki. In this example tunslip creates a bridge between the RPL network and the local machine. &lt;br /&gt;
tunslip6.c can be found in /contiki-2.7/tools &lt;br /&gt;
Compile the tunslip6 code.&lt;br /&gt;
&amp;lt;pre&amp;gt;make tunslip6 &amp;lt;/pre&amp;gt; &lt;br /&gt;
Make a connection between the RPL network and your local machine. &lt;br /&gt;
&amp;lt;pre&amp;gt;sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64&amp;lt;/pre&amp;gt;&lt;br /&gt;
On the successful execution this command the following output will be printed on the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;slip connected to ``127.0.0.1:60001&amp;#039;&amp;#039;&lt;br /&gt;
opened tun device ``/dev/tun0&amp;#039;&amp;#039;&lt;br /&gt;
ifconfig tun0 inet `hostname` up&lt;br /&gt;
ifconfig tun0 add aaaa::1/64&lt;br /&gt;
ifconfig tun0 add fe80::0:0:0:1/64&lt;br /&gt;
ifconfig tun0&lt;br /&gt;
&lt;br /&gt;
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  &lt;br /&gt;
          inet addr:127.0.1.1  P-t-P:127.0.1.1  Mask:255.255.255.255&lt;br /&gt;
          inet6 addr: fe80::1/64 Scope:Link&lt;br /&gt;
          inet6 addr: aaaa::1/64 Scope:Global&lt;br /&gt;
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1&lt;br /&gt;
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0&lt;br /&gt;
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0&lt;br /&gt;
          collisions:0 txqueuelen:500 &lt;br /&gt;
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)&lt;br /&gt;
&lt;br /&gt;
Rime started with address 0.18.116.1.0.1.1.1&lt;br /&gt;
MAC 00:12:74:01:00:01:01:01 Contiki 2.7 started. Node id is set to 1.&lt;br /&gt;
CSMA ContikiMAC, channel check rate 8 Hz, radio channel 26&lt;br /&gt;
Tentative link-local IPv6 address fe80:0000:0000:0000:0212:7401:0001:0101&lt;br /&gt;
Starting &amp;#039;Border router process&amp;#039; &amp;#039;Web server&amp;#039;&lt;br /&gt;
*** Address:aaaa::1 =&amp;gt; aaaa:0000:0000:0000&lt;br /&gt;
Got configuration message of type P&lt;br /&gt;
Setting prefix aaaa::&lt;br /&gt;
Server IPv6 addresses:&lt;br /&gt;
 aaaa::212:7401:1:101&lt;br /&gt;
 fe80::212:7401:1:101&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Go back to the Cooja simulator GUI and look at the dialogue box. The message has now changed to &amp;#039;Client connected: /127.0.0.1&amp;#039;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Client_Connected.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Verifying Results ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can verify that the address of the border router has been set by using the ping command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7401:1:101&lt;br /&gt;
PING aaaa::212:7401:1:101(aaaa::212:7401:1:101) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=1 ttl=64 time=86.0 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=2 ttl=64 time=33.6 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=3 ttl=64 time=82.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=4 ttl=64 time=43.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=5 ttl=64 time=70.1 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7401:1:101 ping statistics ---&lt;br /&gt;
5 packets transmitted, 5 received, 0% packet loss, time 4006ms&lt;br /&gt;
rtt min/avg/max/mdev = 33.669/63.090/86.015/20.985 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also ping one of the other nodes in the network. Here we are pinging node 4&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7404:4:404&lt;br /&gt;
PING aaaa::212:7404:4:404(aaaa::212:7404:4:404) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=1 ttl=63 time=670 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=2 ttl=63 time=703 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=3 ttl=63 time=746 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=4 ttl=63 time=674 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7404:4:404 ping statistics ---&lt;br /&gt;
5 packets transmitted, 4 received, 20% packet loss, time 4001ms&lt;br /&gt;
rtt min/avg/max/mdev = 670.230/698.666/746.619/30.514 ms&lt;br /&gt;
user@instant-contiki:~/contiki-2.7$ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IPv6 address of a node can be checked from the log screen on Cooja. Filter the nodes by their ID&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Node_Address.png]]&lt;br /&gt;
&lt;br /&gt;
You can enter the address of the border router in the web browser. The border router host a page which will be displayed on the browser as shown below. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:RPL_Browser.png]]&lt;br /&gt;
&lt;br /&gt;
== Common Issues ==&lt;br /&gt;
&lt;br /&gt;
1. Make sure that you enter the IPv6 address properly in the command sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64 . There should be no spaces in aaaa::1/64. Otherwise the code will give unexpected behavior.&amp;lt;br&amp;gt;&lt;br /&gt;
2. When you pause the simulation the SLIP connection is lost. It might not work properly on resuming the simulation. In such cases reload the simulation. Create a fresh SLIP connection and then run the simulation again.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
[https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md]  https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md &amp;lt;br&amp;gt;&lt;br /&gt;
[http://cnds.eecs.jacobs-university.de/courses/iotlab-2013/cooja.pdf] Using the Contiki Cooja Simulator - Anuj Sehgal&lt;/div&gt;</summary>
		<author><name>Ckapoor</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1144</id>
		<title>RPL Border Router</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1144"/>
				<updated>2014-11-08T22:52:52Z</updated>
		
		<summary type="html">&lt;p&gt;Ckapoor: /* Code building blocks. */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction: ==&lt;br /&gt;
  &lt;br /&gt;
Border routers are routers that can be found at the edge of a network. Their function is to connect one network to another. In this tutorial we will learn how to run a simulation using the border router in Contiki In the example which we will discuss in the rest of this tutorial the border router will be used to route data between a WSN (using RPL) and an external IP network.  &lt;br /&gt;
Objective:  &lt;br /&gt;
The objective of this tutorial is to give you an understanding of the RPL Border Router code on Contiki OS and learn how to simulate the code on Cooja &lt;br /&gt;
What will you learn at the end of this tutorial. At the end of the tutorial you would have learnt the following: &lt;br /&gt;
&lt;br /&gt;
1. Understanding the working of the rpl border router code &amp;lt;br&amp;gt;&lt;br /&gt;
2. Starting a simulation on Cooja simulator. &amp;lt;br&amp;gt; &lt;br /&gt;
3. Observing the results &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code building blocks. ==&lt;br /&gt;
 &lt;br /&gt;
We will using the following files &lt;br /&gt;
&lt;br /&gt;
1. border-router.c &lt;br /&gt;
2. udp-server.c  (udp-client.c can also be used)&lt;br /&gt;
3. slip-bridge.c&lt;br /&gt;
4. httpd-simple.c&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
udp-server nodes will form a DODAG with the border router set as the root. The border router will receive the prefix through a SLIP connection and it will be communicated to the rest of the nodes in the RPL network. &lt;br /&gt;
&lt;br /&gt;
Refer to the following code snippets in the file border-router.c In this piece of code the node configured as the border router waits for the prefix to be set. Once it receives the prefix, the border router is set as the root of the DODAG after which it sets the prefix of the rest of the nodes in the network.  &lt;br /&gt;
 &lt;br /&gt;
 /* Request prefix until it has been received */ &lt;br /&gt;
  while(!prefix_set) { &lt;br /&gt;
    etimer_set(&amp;amp;et, CLOCK_SECOND); &lt;br /&gt;
    request_prefix(); &lt;br /&gt;
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&amp;amp;et)); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
  dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)dag_id); &lt;br /&gt;
  if(dag != NULL) { &lt;br /&gt;
    rpl_set_prefix(dag, &amp;amp;prefix, 64); &lt;br /&gt;
    PRINTF(&amp;quot;created a new RPL dag\n&amp;quot;); &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
== Compiling the code ==&lt;br /&gt;
 &lt;br /&gt;
The code for RPL border router can be found at /contiki-2.7/examples/ipv6/rpl-border-router. Use the following command to compile the code for the border router &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-border-router &lt;br /&gt;
make TARGET=sky. &amp;lt;/pre&amp;gt;   &lt;br /&gt;
Once this command has been successfully executed a file named border-router.sky will be created. This file will be used to program one of the motes as the border router on Cooja.  &lt;br /&gt;
For the purpose of this tutorial we will  select  TMote Sky  as our target. &lt;br /&gt;
&lt;br /&gt;
In order to demonstrate the functioning of the border router we will create a network of nodes with the border router as the root. For creating such a network we will user the udp-server.c code.  &lt;br /&gt;
This code can be found at /contiki-2.7/examples/ipv6/rpl-udp . Use the following command to compile the code for rpl-udp &lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-udp &lt;br /&gt;
make TARGET=sky &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once this command has been successfully executed a file named udp-server.sky will be created. This file will be used to program the remaining nodes in Cooja simulator. These nodes will form a DAG with the rpl border router as the root.&lt;br /&gt;
&lt;br /&gt;
== Testing on Cooja ==&lt;br /&gt;
 &lt;br /&gt;
Upon the successful completion of the above mentioned steps we are ready to create a simulation in Cooja.  &lt;br /&gt;
Start the Cooja simulator using the following command &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd /contiki-2.7/tools/cooja &lt;br /&gt;
ant run&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
When the GUI launches execute the following steps to create a simulation. &amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
1. From &amp;#039;File&amp;#039; select &amp;#039;New Simulation&amp;#039;. Select UDGM, enter the name of the simulation and click on create. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Click on Motes. From the drop down menu select &amp;#039;Add New Motes&amp;#039; followed by &amp;#039;Create new motes&amp;#039; and select the mote type as Sky. &amp;lt;br&amp;gt;&lt;br /&gt;
3. Browse to the location /contiki-2.7/examples/ipv6/rpl-border-router and select the file rpl-border-router.sky. Click on &amp;#039;Create&amp;#039;. Add one mote of this type. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Repeat step 2 and 3 but this time browse to the location /contiki-2.7/examples/ipv6/rpl-udp  and select the file udp-server.sky. Add 3 - 4 motes of the type udp-server &amp;lt;br&amp;gt;&lt;br /&gt;
5. Once the motes have been added you can position the motes.&lt;br /&gt;
&lt;br /&gt;
[[File:Cooja_motes.png]]&lt;br /&gt;
&lt;br /&gt;
6. Now, we need to create a bridge between the RPL network simulated on Cooja and the local machine. This can be done by right clicking on the mote which is programmed as the border router. Select &amp;#039;More tools for border router&amp;#039; and then select &amp;#039;Serial Socket (SERVER)&amp;#039;. You will get the following message on the successful completion of this step.Note that the message says &amp;#039;Listening on port 60001&amp;#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Serial_Socket.png]]&lt;br /&gt;
&lt;br /&gt;
7. Now start the simulation by clicking on Start&lt;br /&gt;
&lt;br /&gt;
== Tunslip utility ==&lt;br /&gt;
 &lt;br /&gt;
As mentioned in the introduction a border router helps in connecting one network to another. In this example the border router is used to route data between an RPL network and an external network. Till now we have only created the RPL network. Now we need to simulate the scenario in which this RPL network is connected to an external network. For this purpose we will use the Tunslip utility provided in Contiki. In this example tunslip creates a bridge between the RPL network and the local machine. &lt;br /&gt;
tunslip6.c can be found in /contiki-2.7/tools &lt;br /&gt;
Compile the tunslip6 code.&lt;br /&gt;
&amp;lt;pre&amp;gt;make tunslip6 &amp;lt;/pre&amp;gt; &lt;br /&gt;
Make a connection between the RPL network and your local machine. &lt;br /&gt;
&amp;lt;pre&amp;gt;sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64&amp;lt;/pre&amp;gt;&lt;br /&gt;
On the successful execution this command the following output will be printed on the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;slip connected to ``127.0.0.1:60001&amp;#039;&amp;#039;&lt;br /&gt;
opened tun device ``/dev/tun0&amp;#039;&amp;#039;&lt;br /&gt;
ifconfig tun0 inet `hostname` up&lt;br /&gt;
ifconfig tun0 add aaaa::1/64&lt;br /&gt;
ifconfig tun0 add fe80::0:0:0:1/64&lt;br /&gt;
ifconfig tun0&lt;br /&gt;
&lt;br /&gt;
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  &lt;br /&gt;
          inet addr:127.0.1.1  P-t-P:127.0.1.1  Mask:255.255.255.255&lt;br /&gt;
          inet6 addr: fe80::1/64 Scope:Link&lt;br /&gt;
          inet6 addr: aaaa::1/64 Scope:Global&lt;br /&gt;
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1&lt;br /&gt;
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0&lt;br /&gt;
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0&lt;br /&gt;
          collisions:0 txqueuelen:500 &lt;br /&gt;
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)&lt;br /&gt;
&lt;br /&gt;
Rime started with address 0.18.116.1.0.1.1.1&lt;br /&gt;
MAC 00:12:74:01:00:01:01:01 Contiki 2.7 started. Node id is set to 1.&lt;br /&gt;
CSMA ContikiMAC, channel check rate 8 Hz, radio channel 26&lt;br /&gt;
Tentative link-local IPv6 address fe80:0000:0000:0000:0212:7401:0001:0101&lt;br /&gt;
Starting &amp;#039;Border router process&amp;#039; &amp;#039;Web server&amp;#039;&lt;br /&gt;
*** Address:aaaa::1 =&amp;gt; aaaa:0000:0000:0000&lt;br /&gt;
Got configuration message of type P&lt;br /&gt;
Setting prefix aaaa::&lt;br /&gt;
Server IPv6 addresses:&lt;br /&gt;
 aaaa::212:7401:1:101&lt;br /&gt;
 fe80::212:7401:1:101&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Go back to the Cooja simulator GUI and look at the dialogue box. The message has now changed to &amp;#039;Client connected: /127.0.0.1&amp;#039;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Client_Connected.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Verifying Results ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can verify that the address of the border router has been set by using the ping command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7401:1:101&lt;br /&gt;
PING aaaa::212:7401:1:101(aaaa::212:7401:1:101) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=1 ttl=64 time=86.0 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=2 ttl=64 time=33.6 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=3 ttl=64 time=82.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=4 ttl=64 time=43.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=5 ttl=64 time=70.1 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7401:1:101 ping statistics ---&lt;br /&gt;
5 packets transmitted, 5 received, 0% packet loss, time 4006ms&lt;br /&gt;
rtt min/avg/max/mdev = 33.669/63.090/86.015/20.985 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also ping one of the other nodes in the network. Here we are pinging node 4&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7404:4:404&lt;br /&gt;
PING aaaa::212:7404:4:404(aaaa::212:7404:4:404) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=1 ttl=63 time=670 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=2 ttl=63 time=703 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=3 ttl=63 time=746 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=4 ttl=63 time=674 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7404:4:404 ping statistics ---&lt;br /&gt;
5 packets transmitted, 4 received, 20% packet loss, time 4001ms&lt;br /&gt;
rtt min/avg/max/mdev = 670.230/698.666/746.619/30.514 ms&lt;br /&gt;
user@instant-contiki:~/contiki-2.7$ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IPv6 address of a node can be checked from the log screen on Cooja. Filter the nodes by their ID&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Node_Address.png]]&lt;br /&gt;
&lt;br /&gt;
You can enter the address of the border router in the web browser. The border router host a page which will be displayed on the browser as shown below. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:RPL_Browser.png]]&lt;br /&gt;
&lt;br /&gt;
== Common Issues ==&lt;br /&gt;
&lt;br /&gt;
1. Make sure that you enter the IPv6 address properly in the command sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64 . There should be no spaces in aaaa::1/64. Otherwise the code will give unexpected behavior.&amp;lt;br&amp;gt;&lt;br /&gt;
2. When you pause the simulation the SLIP connection is lost. It might not work properly on resuming the simulation. In such cases reload the simulation. Create a fresh SLIP connection and then run the simulation again.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
[https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md]  https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md &amp;lt;br&amp;gt;&lt;br /&gt;
[http://cnds.eecs.jacobs-university.de/courses/iotlab-2013/cooja.pdf] Using the Contiki Cooja Simulator - Anuj Sehgal&lt;/div&gt;</summary>
		<author><name>Ckapoor</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1143</id>
		<title>RPL Border Router</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1143"/>
				<updated>2014-11-08T22:47:10Z</updated>
		
		<summary type="html">&lt;p&gt;Ckapoor: /* Code building blocks. */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction: ==&lt;br /&gt;
  &lt;br /&gt;
Border routers are routers that can be found at the edge of a network. Their function is to connect one network to another. In this tutorial we will learn how to run a simulation using the border router in Contiki In the example which we will discuss in the rest of this tutorial the border router will be used to route data between a WSN (using RPL) and an external IP network.  &lt;br /&gt;
Objective:  &lt;br /&gt;
The objective of this tutorial is to give you an understanding of the RPL Border Router code on Contiki OS and learn how to simulate the code on Cooja &lt;br /&gt;
What will you learn at the end of this tutorial. At the end of the tutorial you would have learnt the following: &lt;br /&gt;
&lt;br /&gt;
1. Understanding the working of the rpl border router code &amp;lt;br&amp;gt;&lt;br /&gt;
2. Starting a simulation on Cooja simulator. &amp;lt;br&amp;gt; &lt;br /&gt;
3. Observing the results &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code building blocks. ==&lt;br /&gt;
 &lt;br /&gt;
We will using the following files &lt;br /&gt;
border-router.c &lt;br /&gt;
Go to the location /contiki-2.7/examples/ipv6/rpl-udp   and use either udp-client.c or udp-server.c to create a network of nodes. In this example we have used udp-server.c&lt;br /&gt;
These nodes will form a DODAG with the border router set as the root. The border router will receive the prefix through a SLIP connection and it will be communicated to the rest of the nodes in the network. &lt;br /&gt;
Refer to the following code snippets in the file border-router.c In this piece of code the node configured as the border router waits for the prefix to be set. Once the prefix is set, the border router is set as the root of the DODAG after which it sets the prefix.  &lt;br /&gt;
 &lt;br /&gt;
 /* Request prefix until it has been received */ &lt;br /&gt;
  while(!prefix_set) { &lt;br /&gt;
    etimer_set(&amp;amp;et, CLOCK_SECOND); &lt;br /&gt;
    request_prefix(); &lt;br /&gt;
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&amp;amp;et)); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
  dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)dag_id); &lt;br /&gt;
  if(dag != NULL) { &lt;br /&gt;
    rpl_set_prefix(dag, &amp;amp;prefix, 64); &lt;br /&gt;
    PRINTF(&amp;quot;created a new RPL dag\n&amp;quot;); &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
== Compiling the code ==&lt;br /&gt;
 &lt;br /&gt;
The code for RPL border router can be found at /contiki-2.7/examples/ipv6/rpl-border-router. Use the following command to compile the code for the border router &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-border-router &lt;br /&gt;
make TARGET=sky. &amp;lt;/pre&amp;gt;   &lt;br /&gt;
Once this command has been successfully executed a file named border-router.sky will be created. This file will be used to program one of the motes as the border router on Cooja.  &lt;br /&gt;
For the purpose of this tutorial we will  select  TMote Sky  as our target. &lt;br /&gt;
&lt;br /&gt;
In order to demonstrate the functioning of the border router we will create a network of nodes with the border router as the root. For creating such a network we will user the udp-server.c code.  &lt;br /&gt;
This code can be found at /contiki-2.7/examples/ipv6/rpl-udp . Use the following command to compile the code for rpl-udp &lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-udp &lt;br /&gt;
make TARGET=sky &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once this command has been successfully executed a file named udp-server.sky will be created. This file will be used to program the remaining nodes in Cooja simulator. These nodes will form a DAG with the rpl border router as the root.&lt;br /&gt;
&lt;br /&gt;
== Testing on Cooja ==&lt;br /&gt;
 &lt;br /&gt;
Upon the successful completion of the above mentioned steps we are ready to create a simulation in Cooja.  &lt;br /&gt;
Start the Cooja simulator using the following command &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd /contiki-2.7/tools/cooja &lt;br /&gt;
ant run&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
When the GUI launches execute the following steps to create a simulation. &amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
1. From &amp;#039;File&amp;#039; select &amp;#039;New Simulation&amp;#039;. Select UDGM, enter the name of the simulation and click on create. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Click on Motes. From the drop down menu select &amp;#039;Add New Motes&amp;#039; followed by &amp;#039;Create new motes&amp;#039; and select the mote type as Sky. &amp;lt;br&amp;gt;&lt;br /&gt;
3. Browse to the location /contiki-2.7/examples/ipv6/rpl-border-router and select the file rpl-border-router.sky. Click on &amp;#039;Create&amp;#039;. Add one mote of this type. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Repeat step 2 and 3 but this time browse to the location /contiki-2.7/examples/ipv6/rpl-udp  and select the file udp-server.sky. Add 3 - 4 motes of the type udp-server &amp;lt;br&amp;gt;&lt;br /&gt;
5. Once the motes have been added you can position the motes.&lt;br /&gt;
&lt;br /&gt;
[[File:Cooja_motes.png]]&lt;br /&gt;
&lt;br /&gt;
6. Now, we need to create a bridge between the RPL network simulated on Cooja and the local machine. This can be done by right clicking on the mote which is programmed as the border router. Select &amp;#039;More tools for border router&amp;#039; and then select &amp;#039;Serial Socket (SERVER)&amp;#039;. You will get the following message on the successful completion of this step.Note that the message says &amp;#039;Listening on port 60001&amp;#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Serial_Socket.png]]&lt;br /&gt;
&lt;br /&gt;
7. Now start the simulation by clicking on Start&lt;br /&gt;
&lt;br /&gt;
== Tunslip utility ==&lt;br /&gt;
 &lt;br /&gt;
As mentioned in the introduction a border router helps in connecting one network to another. In this example the border router is used to route data between an RPL network and an external network. Till now we have only created the RPL network. Now we need to simulate the scenario in which this RPL network is connected to an external network. For this purpose we will use the Tunslip utility provided in Contiki. In this example tunslip creates a bridge between the RPL network and the local machine. &lt;br /&gt;
tunslip6.c can be found in /contiki-2.7/tools &lt;br /&gt;
Compile the tunslip6 code.&lt;br /&gt;
&amp;lt;pre&amp;gt;make tunslip6 &amp;lt;/pre&amp;gt; &lt;br /&gt;
Make a connection between the RPL network and your local machine. &lt;br /&gt;
&amp;lt;pre&amp;gt;sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64&amp;lt;/pre&amp;gt;&lt;br /&gt;
On the successful execution this command the following output will be printed on the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;slip connected to ``127.0.0.1:60001&amp;#039;&amp;#039;&lt;br /&gt;
opened tun device ``/dev/tun0&amp;#039;&amp;#039;&lt;br /&gt;
ifconfig tun0 inet `hostname` up&lt;br /&gt;
ifconfig tun0 add aaaa::1/64&lt;br /&gt;
ifconfig tun0 add fe80::0:0:0:1/64&lt;br /&gt;
ifconfig tun0&lt;br /&gt;
&lt;br /&gt;
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  &lt;br /&gt;
          inet addr:127.0.1.1  P-t-P:127.0.1.1  Mask:255.255.255.255&lt;br /&gt;
          inet6 addr: fe80::1/64 Scope:Link&lt;br /&gt;
          inet6 addr: aaaa::1/64 Scope:Global&lt;br /&gt;
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1&lt;br /&gt;
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0&lt;br /&gt;
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0&lt;br /&gt;
          collisions:0 txqueuelen:500 &lt;br /&gt;
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)&lt;br /&gt;
&lt;br /&gt;
Rime started with address 0.18.116.1.0.1.1.1&lt;br /&gt;
MAC 00:12:74:01:00:01:01:01 Contiki 2.7 started. Node id is set to 1.&lt;br /&gt;
CSMA ContikiMAC, channel check rate 8 Hz, radio channel 26&lt;br /&gt;
Tentative link-local IPv6 address fe80:0000:0000:0000:0212:7401:0001:0101&lt;br /&gt;
Starting &amp;#039;Border router process&amp;#039; &amp;#039;Web server&amp;#039;&lt;br /&gt;
*** Address:aaaa::1 =&amp;gt; aaaa:0000:0000:0000&lt;br /&gt;
Got configuration message of type P&lt;br /&gt;
Setting prefix aaaa::&lt;br /&gt;
Server IPv6 addresses:&lt;br /&gt;
 aaaa::212:7401:1:101&lt;br /&gt;
 fe80::212:7401:1:101&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Go back to the Cooja simulator GUI and look at the dialogue box. The message has now changed to &amp;#039;Client connected: /127.0.0.1&amp;#039;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Client_Connected.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Verifying Results ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can verify that the address of the border router has been set by using the ping command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7401:1:101&lt;br /&gt;
PING aaaa::212:7401:1:101(aaaa::212:7401:1:101) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=1 ttl=64 time=86.0 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=2 ttl=64 time=33.6 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=3 ttl=64 time=82.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=4 ttl=64 time=43.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=5 ttl=64 time=70.1 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7401:1:101 ping statistics ---&lt;br /&gt;
5 packets transmitted, 5 received, 0% packet loss, time 4006ms&lt;br /&gt;
rtt min/avg/max/mdev = 33.669/63.090/86.015/20.985 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also ping one of the other nodes in the network. Here we are pinging node 4&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7404:4:404&lt;br /&gt;
PING aaaa::212:7404:4:404(aaaa::212:7404:4:404) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=1 ttl=63 time=670 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=2 ttl=63 time=703 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=3 ttl=63 time=746 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=4 ttl=63 time=674 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7404:4:404 ping statistics ---&lt;br /&gt;
5 packets transmitted, 4 received, 20% packet loss, time 4001ms&lt;br /&gt;
rtt min/avg/max/mdev = 670.230/698.666/746.619/30.514 ms&lt;br /&gt;
user@instant-contiki:~/contiki-2.7$ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IPv6 address of a node can be checked from the log screen on Cooja. Filter the nodes by their ID&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Node_Address.png]]&lt;br /&gt;
&lt;br /&gt;
You can enter the address of the border router in the web browser. The border router host a page which will be displayed on the browser as shown below. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:RPL_Browser.png]]&lt;br /&gt;
&lt;br /&gt;
== Common Issues ==&lt;br /&gt;
&lt;br /&gt;
1. Make sure that you enter the IPv6 address properly in the command sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64 . There should be no spaces in aaaa::1/64. Otherwise the code will give unexpected behavior.&amp;lt;br&amp;gt;&lt;br /&gt;
2. When you pause the simulation the SLIP connection is lost. It might not work properly on resuming the simulation. In such cases reload the simulation. Create a fresh SLIP connection and then run the simulation again.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
[https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md]  https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md &amp;lt;br&amp;gt;&lt;br /&gt;
[http://cnds.eecs.jacobs-university.de/courses/iotlab-2013/cooja.pdf] Using the Contiki Cooja Simulator - Anuj Sehgal&lt;/div&gt;</summary>
		<author><name>Ckapoor</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1142</id>
		<title>RPL Border Router</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1142"/>
				<updated>2014-11-08T22:46:15Z</updated>
		
		<summary type="html">&lt;p&gt;Ckapoor: /* Code building blocks. */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction: ==&lt;br /&gt;
  &lt;br /&gt;
Border routers are routers that can be found at the edge of a network. Their function is to connect one network to another. In this tutorial we will learn how to run a simulation using the border router in Contiki In the example which we will discuss in the rest of this tutorial the border router will be used to route data between a WSN (using RPL) and an external IP network.  &lt;br /&gt;
Objective:  &lt;br /&gt;
The objective of this tutorial is to give you an understanding of the RPL Border Router code on Contiki OS and learn how to simulate the code on Cooja &lt;br /&gt;
What will you learn at the end of this tutorial. At the end of the tutorial you would have learnt the following: &lt;br /&gt;
&lt;br /&gt;
1. Understanding the working of the rpl border router code &amp;lt;br&amp;gt;&lt;br /&gt;
2. Starting a simulation on Cooja simulator. &amp;lt;br&amp;gt; &lt;br /&gt;
3. Observing the results &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code building blocks. ==&lt;br /&gt;
 &lt;br /&gt;
We will using the following files &lt;br /&gt;
border-router.c &lt;br /&gt;
Go to the location /contiki-2.7/examples/ipv6/rpl-udp   and use either udp-client.c or udp-server.c to create a network of nodes.  &lt;br /&gt;
These nodes will form a DODAG with the border router set as the root. The border router will receive the prefix through a SLIP connection and it will be communicated to the rest of the nodes in the network. &lt;br /&gt;
Refer to the following code snippets in the file border-router.c In this piece of code the node configured as the border router waits for the prefix to be set. Once the prefix is set, the border router is set as the root of the DODAG after which it sets the prefix.  &lt;br /&gt;
 &lt;br /&gt;
 /* Request prefix until it has been received */ &lt;br /&gt;
  while(!prefix_set) { &lt;br /&gt;
    etimer_set(&amp;amp;et, CLOCK_SECOND); &lt;br /&gt;
    request_prefix(); &lt;br /&gt;
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&amp;amp;et)); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
  dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)dag_id); &lt;br /&gt;
  if(dag != NULL) { &lt;br /&gt;
    rpl_set_prefix(dag, &amp;amp;prefix, 64); &lt;br /&gt;
    PRINTF(&amp;quot;created a new RPL dag\n&amp;quot;); &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
== Compiling the code ==&lt;br /&gt;
 &lt;br /&gt;
The code for RPL border router can be found at /contiki-2.7/examples/ipv6/rpl-border-router. Use the following command to compile the code for the border router &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-border-router &lt;br /&gt;
make TARGET=sky. &amp;lt;/pre&amp;gt;   &lt;br /&gt;
Once this command has been successfully executed a file named border-router.sky will be created. This file will be used to program one of the motes as the border router on Cooja.  &lt;br /&gt;
For the purpose of this tutorial we will  select  TMote Sky  as our target. &lt;br /&gt;
&lt;br /&gt;
In order to demonstrate the functioning of the border router we will create a network of nodes with the border router as the root. For creating such a network we will user the udp-server.c code.  &lt;br /&gt;
This code can be found at /contiki-2.7/examples/ipv6/rpl-udp . Use the following command to compile the code for rpl-udp &lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-udp &lt;br /&gt;
make TARGET=sky &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once this command has been successfully executed a file named udp-server.sky will be created. This file will be used to program the remaining nodes in Cooja simulator. These nodes will form a DAG with the rpl border router as the root.&lt;br /&gt;
&lt;br /&gt;
== Testing on Cooja ==&lt;br /&gt;
 &lt;br /&gt;
Upon the successful completion of the above mentioned steps we are ready to create a simulation in Cooja.  &lt;br /&gt;
Start the Cooja simulator using the following command &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd /contiki-2.7/tools/cooja &lt;br /&gt;
ant run&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
When the GUI launches execute the following steps to create a simulation. &amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
1. From &amp;#039;File&amp;#039; select &amp;#039;New Simulation&amp;#039;. Select UDGM, enter the name of the simulation and click on create. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Click on Motes. From the drop down menu select &amp;#039;Add New Motes&amp;#039; followed by &amp;#039;Create new motes&amp;#039; and select the mote type as Sky. &amp;lt;br&amp;gt;&lt;br /&gt;
3. Browse to the location /contiki-2.7/examples/ipv6/rpl-border-router and select the file rpl-border-router.sky. Click on &amp;#039;Create&amp;#039;. Add one mote of this type. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Repeat step 2 and 3 but this time browse to the location /contiki-2.7/examples/ipv6/rpl-udp  and select the file udp-server.sky. Add 3 - 4 motes of the type udp-server &amp;lt;br&amp;gt;&lt;br /&gt;
5. Once the motes have been added you can position the motes.&lt;br /&gt;
&lt;br /&gt;
[[File:Cooja_motes.png]]&lt;br /&gt;
&lt;br /&gt;
6. Now, we need to create a bridge between the RPL network simulated on Cooja and the local machine. This can be done by right clicking on the mote which is programmed as the border router. Select &amp;#039;More tools for border router&amp;#039; and then select &amp;#039;Serial Socket (SERVER)&amp;#039;. You will get the following message on the successful completion of this step.Note that the message says &amp;#039;Listening on port 60001&amp;#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Serial_Socket.png]]&lt;br /&gt;
&lt;br /&gt;
7. Now start the simulation by clicking on Start&lt;br /&gt;
&lt;br /&gt;
== Tunslip utility ==&lt;br /&gt;
 &lt;br /&gt;
As mentioned in the introduction a border router helps in connecting one network to another. In this example the border router is used to route data between an RPL network and an external network. Till now we have only created the RPL network. Now we need to simulate the scenario in which this RPL network is connected to an external network. For this purpose we will use the Tunslip utility provided in Contiki. In this example tunslip creates a bridge between the RPL network and the local machine. &lt;br /&gt;
tunslip6.c can be found in /contiki-2.7/tools &lt;br /&gt;
Compile the tunslip6 code.&lt;br /&gt;
&amp;lt;pre&amp;gt;make tunslip6 &amp;lt;/pre&amp;gt; &lt;br /&gt;
Make a connection between the RPL network and your local machine. &lt;br /&gt;
&amp;lt;pre&amp;gt;sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64&amp;lt;/pre&amp;gt;&lt;br /&gt;
On the successful execution this command the following output will be printed on the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;slip connected to ``127.0.0.1:60001&amp;#039;&amp;#039;&lt;br /&gt;
opened tun device ``/dev/tun0&amp;#039;&amp;#039;&lt;br /&gt;
ifconfig tun0 inet `hostname` up&lt;br /&gt;
ifconfig tun0 add aaaa::1/64&lt;br /&gt;
ifconfig tun0 add fe80::0:0:0:1/64&lt;br /&gt;
ifconfig tun0&lt;br /&gt;
&lt;br /&gt;
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  &lt;br /&gt;
          inet addr:127.0.1.1  P-t-P:127.0.1.1  Mask:255.255.255.255&lt;br /&gt;
          inet6 addr: fe80::1/64 Scope:Link&lt;br /&gt;
          inet6 addr: aaaa::1/64 Scope:Global&lt;br /&gt;
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1&lt;br /&gt;
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0&lt;br /&gt;
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0&lt;br /&gt;
          collisions:0 txqueuelen:500 &lt;br /&gt;
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)&lt;br /&gt;
&lt;br /&gt;
Rime started with address 0.18.116.1.0.1.1.1&lt;br /&gt;
MAC 00:12:74:01:00:01:01:01 Contiki 2.7 started. Node id is set to 1.&lt;br /&gt;
CSMA ContikiMAC, channel check rate 8 Hz, radio channel 26&lt;br /&gt;
Tentative link-local IPv6 address fe80:0000:0000:0000:0212:7401:0001:0101&lt;br /&gt;
Starting &amp;#039;Border router process&amp;#039; &amp;#039;Web server&amp;#039;&lt;br /&gt;
*** Address:aaaa::1 =&amp;gt; aaaa:0000:0000:0000&lt;br /&gt;
Got configuration message of type P&lt;br /&gt;
Setting prefix aaaa::&lt;br /&gt;
Server IPv6 addresses:&lt;br /&gt;
 aaaa::212:7401:1:101&lt;br /&gt;
 fe80::212:7401:1:101&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Go back to the Cooja simulator GUI and look at the dialogue box. The message has now changed to &amp;#039;Client connected: /127.0.0.1&amp;#039;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Client_Connected.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Verifying Results ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can verify that the address of the border router has been set by using the ping command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7401:1:101&lt;br /&gt;
PING aaaa::212:7401:1:101(aaaa::212:7401:1:101) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=1 ttl=64 time=86.0 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=2 ttl=64 time=33.6 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=3 ttl=64 time=82.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=4 ttl=64 time=43.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=5 ttl=64 time=70.1 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7401:1:101 ping statistics ---&lt;br /&gt;
5 packets transmitted, 5 received, 0% packet loss, time 4006ms&lt;br /&gt;
rtt min/avg/max/mdev = 33.669/63.090/86.015/20.985 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also ping one of the other nodes in the network. Here we are pinging node 4&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7404:4:404&lt;br /&gt;
PING aaaa::212:7404:4:404(aaaa::212:7404:4:404) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=1 ttl=63 time=670 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=2 ttl=63 time=703 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=3 ttl=63 time=746 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=4 ttl=63 time=674 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7404:4:404 ping statistics ---&lt;br /&gt;
5 packets transmitted, 4 received, 20% packet loss, time 4001ms&lt;br /&gt;
rtt min/avg/max/mdev = 670.230/698.666/746.619/30.514 ms&lt;br /&gt;
user@instant-contiki:~/contiki-2.7$ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IPv6 address of a node can be checked from the log screen on Cooja. Filter the nodes by their ID&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Node_Address.png]]&lt;br /&gt;
&lt;br /&gt;
You can enter the address of the border router in the web browser. The border router host a page which will be displayed on the browser as shown below. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:RPL_Browser.png]]&lt;br /&gt;
&lt;br /&gt;
== Common Issues ==&lt;br /&gt;
&lt;br /&gt;
1. Make sure that you enter the IPv6 address properly in the command sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64 . There should be no spaces in aaaa::1/64. Otherwise the code will give unexpected behavior.&amp;lt;br&amp;gt;&lt;br /&gt;
2. When you pause the simulation the SLIP connection is lost. It might not work properly on resuming the simulation. In such cases reload the simulation. Create a fresh SLIP connection and then run the simulation again.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
[https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md]  https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md &amp;lt;br&amp;gt;&lt;br /&gt;
[http://cnds.eecs.jacobs-university.de/courses/iotlab-2013/cooja.pdf] Using the Contiki Cooja Simulator - Anuj Sehgal&lt;/div&gt;</summary>
		<author><name>Ckapoor</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1141</id>
		<title>RPL Border Router</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1141"/>
				<updated>2014-11-08T22:42:42Z</updated>
		
		<summary type="html">&lt;p&gt;Ckapoor: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction: ==&lt;br /&gt;
  &lt;br /&gt;
Border routers are routers that can be found at the edge of a network. Their function is to connect one network to another. In this tutorial we will learn how to run a simulation using the border router in Contiki In the example which we will discuss in the rest of this tutorial the border router will be used to route data between a WSN (using RPL) and an external IP network.  &lt;br /&gt;
Objective:  &lt;br /&gt;
The objective of this tutorial is to give you an understanding of the RPL Border Router code on Contiki OS and learn how to simulate the code on Cooja &lt;br /&gt;
What will you learn at the end of this tutorial. At the end of the tutorial you would have learnt the following: &lt;br /&gt;
&lt;br /&gt;
1. Understanding the working of the rpl border router code &amp;lt;br&amp;gt;&lt;br /&gt;
2. Starting a simulation on Cooja simulator. &amp;lt;br&amp;gt; &lt;br /&gt;
3. Observing the results &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code building blocks. ==&lt;br /&gt;
 &lt;br /&gt;
We will using the following files &lt;br /&gt;
border-router.c &lt;br /&gt;
Go to the location /contiki-2.7/examples/ipv6/rpl-udp   and use either udp-client.c or udp-server.c to create a network of nodes.  &lt;br /&gt;
These nodes will form a DODAG with the border router set as the root. The border router will receive the prefix through a SLIP connection and it will be communicated to the rest of the nodes in the network. &lt;br /&gt;
Refer to the following code snippets in the file border-router.c In this piece of code the node configured as the border router waits for the prefix to be set. Once the prefix is set, the border router is set as the root of the DODAG after which it sets the prefix.  &lt;br /&gt;
 &lt;br /&gt;
 /* Request prefix until it has been received */ &lt;br /&gt;
  while(!prefix_set) { &lt;br /&gt;
    etimer_set(&amp;amp;et, CLOCK_SECOND); &lt;br /&gt;
    request_prefix(); &lt;br /&gt;
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&amp;amp;et)); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
  dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)dag_id); &lt;br /&gt;
  if(dag != NULL) { &lt;br /&gt;
    rpl_set_prefix(dag, &amp;amp;prefix, 64); &lt;br /&gt;
    PRINTF(&amp;quot;created a new RPL dag\n&amp;quot;); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
Explain the key points in the code. Include snippets. Add at least one Diagram. &lt;br /&gt;
&lt;br /&gt;
== Compiling the code ==&lt;br /&gt;
 &lt;br /&gt;
The code for RPL border router can be found at /contiki-2.7/examples/ipv6/rpl-border-router. Use the following command to compile the code for the border router &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-border-router &lt;br /&gt;
make TARGET=sky. &amp;lt;/pre&amp;gt;   &lt;br /&gt;
Once this command has been successfully executed a file named border-router.sky will be created. This file will be used to program one of the motes as the border router on Cooja.  &lt;br /&gt;
For the purpose of this tutorial we will  select  TMote Sky  as our target. &lt;br /&gt;
&lt;br /&gt;
In order to demonstrate the functioning of the border router we will create a network of nodes with the border router as the root. For creating such a network we will user the udp-server.c code.  &lt;br /&gt;
This code can be found at /contiki-2.7/examples/ipv6/rpl-udp . Use the following command to compile the code for rpl-udp &lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-udp &lt;br /&gt;
make TARGET=sky &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once this command has been successfully executed a file named udp-server.sky will be created. This file will be used to program the remaining nodes in Cooja simulator. These nodes will form a DAG with the rpl border router as the root.&lt;br /&gt;
&lt;br /&gt;
== Testing on Cooja ==&lt;br /&gt;
 &lt;br /&gt;
Upon the successful completion of the above mentioned steps we are ready to create a simulation in Cooja.  &lt;br /&gt;
Start the Cooja simulator using the following command &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd /contiki-2.7/tools/cooja &lt;br /&gt;
ant run&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
When the GUI launches execute the following steps to create a simulation. &amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
1. From &amp;#039;File&amp;#039; select &amp;#039;New Simulation&amp;#039;. Select UDGM, enter the name of the simulation and click on create. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Click on Motes. From the drop down menu select &amp;#039;Add New Motes&amp;#039; followed by &amp;#039;Create new motes&amp;#039; and select the mote type as Sky. &amp;lt;br&amp;gt;&lt;br /&gt;
3. Browse to the location /contiki-2.7/examples/ipv6/rpl-border-router and select the file rpl-border-router.sky. Click on &amp;#039;Create&amp;#039;. Add one mote of this type. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Repeat step 2 and 3 but this time browse to the location /contiki-2.7/examples/ipv6/rpl-udp  and select the file udp-server.sky. Add 3 - 4 motes of the type udp-server &amp;lt;br&amp;gt;&lt;br /&gt;
5. Once the motes have been added you can position the motes.&lt;br /&gt;
&lt;br /&gt;
[[File:Cooja_motes.png]]&lt;br /&gt;
&lt;br /&gt;
6. Now, we need to create a bridge between the RPL network simulated on Cooja and the local machine. This can be done by right clicking on the mote which is programmed as the border router. Select &amp;#039;More tools for border router&amp;#039; and then select &amp;#039;Serial Socket (SERVER)&amp;#039;. You will get the following message on the successful completion of this step.Note that the message says &amp;#039;Listening on port 60001&amp;#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Serial_Socket.png]]&lt;br /&gt;
&lt;br /&gt;
7. Now start the simulation by clicking on Start&lt;br /&gt;
&lt;br /&gt;
== Tunslip utility ==&lt;br /&gt;
 &lt;br /&gt;
As mentioned in the introduction a border router helps in connecting one network to another. In this example the border router is used to route data between an RPL network and an external network. Till now we have only created the RPL network. Now we need to simulate the scenario in which this RPL network is connected to an external network. For this purpose we will use the Tunslip utility provided in Contiki. In this example tunslip creates a bridge between the RPL network and the local machine. &lt;br /&gt;
tunslip6.c can be found in /contiki-2.7/tools &lt;br /&gt;
Compile the tunslip6 code.&lt;br /&gt;
&amp;lt;pre&amp;gt;make tunslip6 &amp;lt;/pre&amp;gt; &lt;br /&gt;
Make a connection between the RPL network and your local machine. &lt;br /&gt;
&amp;lt;pre&amp;gt;sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64&amp;lt;/pre&amp;gt;&lt;br /&gt;
On the successful execution this command the following output will be printed on the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;slip connected to ``127.0.0.1:60001&amp;#039;&amp;#039;&lt;br /&gt;
opened tun device ``/dev/tun0&amp;#039;&amp;#039;&lt;br /&gt;
ifconfig tun0 inet `hostname` up&lt;br /&gt;
ifconfig tun0 add aaaa::1/64&lt;br /&gt;
ifconfig tun0 add fe80::0:0:0:1/64&lt;br /&gt;
ifconfig tun0&lt;br /&gt;
&lt;br /&gt;
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  &lt;br /&gt;
          inet addr:127.0.1.1  P-t-P:127.0.1.1  Mask:255.255.255.255&lt;br /&gt;
          inet6 addr: fe80::1/64 Scope:Link&lt;br /&gt;
          inet6 addr: aaaa::1/64 Scope:Global&lt;br /&gt;
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1&lt;br /&gt;
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0&lt;br /&gt;
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0&lt;br /&gt;
          collisions:0 txqueuelen:500 &lt;br /&gt;
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)&lt;br /&gt;
&lt;br /&gt;
Rime started with address 0.18.116.1.0.1.1.1&lt;br /&gt;
MAC 00:12:74:01:00:01:01:01 Contiki 2.7 started. Node id is set to 1.&lt;br /&gt;
CSMA ContikiMAC, channel check rate 8 Hz, radio channel 26&lt;br /&gt;
Tentative link-local IPv6 address fe80:0000:0000:0000:0212:7401:0001:0101&lt;br /&gt;
Starting &amp;#039;Border router process&amp;#039; &amp;#039;Web server&amp;#039;&lt;br /&gt;
*** Address:aaaa::1 =&amp;gt; aaaa:0000:0000:0000&lt;br /&gt;
Got configuration message of type P&lt;br /&gt;
Setting prefix aaaa::&lt;br /&gt;
Server IPv6 addresses:&lt;br /&gt;
 aaaa::212:7401:1:101&lt;br /&gt;
 fe80::212:7401:1:101&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Go back to the Cooja simulator GUI and look at the dialogue box. The message has now changed to &amp;#039;Client connected: /127.0.0.1&amp;#039;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Client_Connected.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Verifying Results ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can verify that the address of the border router has been set by using the ping command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7401:1:101&lt;br /&gt;
PING aaaa::212:7401:1:101(aaaa::212:7401:1:101) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=1 ttl=64 time=86.0 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=2 ttl=64 time=33.6 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=3 ttl=64 time=82.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=4 ttl=64 time=43.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=5 ttl=64 time=70.1 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7401:1:101 ping statistics ---&lt;br /&gt;
5 packets transmitted, 5 received, 0% packet loss, time 4006ms&lt;br /&gt;
rtt min/avg/max/mdev = 33.669/63.090/86.015/20.985 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also ping one of the other nodes in the network. Here we are pinging node 4&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7404:4:404&lt;br /&gt;
PING aaaa::212:7404:4:404(aaaa::212:7404:4:404) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=1 ttl=63 time=670 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=2 ttl=63 time=703 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=3 ttl=63 time=746 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=4 ttl=63 time=674 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7404:4:404 ping statistics ---&lt;br /&gt;
5 packets transmitted, 4 received, 20% packet loss, time 4001ms&lt;br /&gt;
rtt min/avg/max/mdev = 670.230/698.666/746.619/30.514 ms&lt;br /&gt;
user@instant-contiki:~/contiki-2.7$ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IPv6 address of a node can be checked from the log screen on Cooja. Filter the nodes by their ID&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Node_Address.png]]&lt;br /&gt;
&lt;br /&gt;
You can enter the address of the border router in the web browser. The border router host a page which will be displayed on the browser as shown below. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:RPL_Browser.png]]&lt;br /&gt;
&lt;br /&gt;
== Common Issues ==&lt;br /&gt;
&lt;br /&gt;
1. Make sure that you enter the IPv6 address properly in the command sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64 . There should be no spaces in aaaa::1/64. Otherwise the code will give unexpected behavior.&amp;lt;br&amp;gt;&lt;br /&gt;
2. When you pause the simulation the SLIP connection is lost. It might not work properly on resuming the simulation. In such cases reload the simulation. Create a fresh SLIP connection and then run the simulation again.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
[https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md]  https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md &amp;lt;br&amp;gt;&lt;br /&gt;
[http://cnds.eecs.jacobs-university.de/courses/iotlab-2013/cooja.pdf] Using the Contiki Cooja Simulator - Anuj Sehgal&lt;/div&gt;</summary>
		<author><name>Ckapoor</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1140</id>
		<title>RPL Border Router</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1140"/>
				<updated>2014-11-08T22:41:08Z</updated>
		
		<summary type="html">&lt;p&gt;Ckapoor: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction: ==&lt;br /&gt;
  &lt;br /&gt;
Border routers are routers that can be found at the edge of a network. Their function is to connect one network to another. In this tutorial we will learn how to run a simulation using the border router in Contiki In the example which we will discuss in the rest of this tutorial the border router will be used to route data between a WSN (using RPL) and an external IP network.  &lt;br /&gt;
Objective:  &lt;br /&gt;
The objective of this tutorial is to give you an understanding of the RPL Border Router code on Contiki OS and learn how to simulate the code on Cooja &lt;br /&gt;
What will you learn at the end of this tutorial. At the end of the tutorial you would have learnt the following: &lt;br /&gt;
&lt;br /&gt;
1. Understanding the working of the rpl border router code &amp;lt;br&amp;gt;&lt;br /&gt;
2. Starting a simulation on Cooja simulator. &amp;lt;br&amp;gt; &lt;br /&gt;
3. Observing the results &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code building blocks. ==&lt;br /&gt;
 &lt;br /&gt;
We will using the following files &lt;br /&gt;
border-router.c &lt;br /&gt;
Go to the location /contiki-2.7/examples/ipv6/rpl-udp   and use either udp-client.c or udp-server.c to create a network of nodes.  &lt;br /&gt;
These nodes will form a DODAG with the border router set as the root. The border router will receive the prefix through a SLIP connection and it will be communicated to the rest of the nodes in the network. &lt;br /&gt;
Refer to the following code snippets in the file border-router.c In this piece of code the node configured as the border router waits for the prefix to be set. Once the prefix is set, the border router is set as the root of the DODAG after which it sets the prefix.  &lt;br /&gt;
 &lt;br /&gt;
 /* Request prefix until it has been received */ &lt;br /&gt;
  while(!prefix_set) { &lt;br /&gt;
    etimer_set(&amp;amp;et, CLOCK_SECOND); &lt;br /&gt;
    request_prefix(); &lt;br /&gt;
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&amp;amp;et)); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
  dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)dag_id); &lt;br /&gt;
  if(dag != NULL) { &lt;br /&gt;
    rpl_set_prefix(dag, &amp;amp;prefix, 64); &lt;br /&gt;
    PRINTF(&amp;quot;created a new RPL dag\n&amp;quot;); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
Explain the key points in the code. Include snippets. Add at least one Diagram. &lt;br /&gt;
&lt;br /&gt;
== Compiling the code ==&lt;br /&gt;
 &lt;br /&gt;
The code for RPL border router can be found at /contiki-2.7/examples/ipv6/rpl-border-router. Use the following command to compile the code for the border router &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-border-router &lt;br /&gt;
make TARGET=sky. &amp;lt;/pre&amp;gt;   &lt;br /&gt;
Once this command has been successfully executed a file named border-router.sky will be created. This file will be used to program one of the motes as the border router on Cooja.  &lt;br /&gt;
For the purpose of this tutorial we will  select  TMote Sky  as our target. &lt;br /&gt;
&lt;br /&gt;
In order to demonstrate the functioning of the border router we will create a network of nodes with the border router as the root. For creating such a network we will user the udp-server.c code.  &lt;br /&gt;
This code can be found at /contiki-2.7/examples/ipv6/rpl-udp . Use the following command to compile the code for rpl-udp &lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-udp &lt;br /&gt;
make TARGET=sky &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once this command has been successfully executed a file named udp-server.sky will be created. This file will be used to program the remaining nodes in Cooja simulator. These nodes will form a DAG with the rpl border router as the root.&lt;br /&gt;
&lt;br /&gt;
== Testing on Cooja ==&lt;br /&gt;
 &lt;br /&gt;
Upon the successful completion of the above mentioned steps we are ready to create a simulation in Cooja.  &lt;br /&gt;
Start the Cooja simulator using the following command &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd /contiki-2.7/tools/cooja &lt;br /&gt;
ant run&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
When the GUI launches execute the following steps to create a simulation. &amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
1. From &amp;#039;File&amp;#039; select &amp;#039;New Simulation&amp;#039;. Select UDGM, enter the name of the simulation and click on create. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Click on Motes. From the drop down menu select &amp;#039;Add New Motes&amp;#039; followed by &amp;#039;Create new motes&amp;#039; and select the mote type as Sky. &amp;lt;br&amp;gt;&lt;br /&gt;
3. Browse to the location /contiki-2.7/examples/ipv6/rpl-border-router and select the file rpl-border-router.sky. Click on &amp;#039;Create&amp;#039;. Add one mote of this type. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Repeat step 2 and 3 but this time browse to the location /contiki-2.7/examples/ipv6/rpl-udp  and select the file udp-server.sky. Add 3 - 4 motes of the type udp-server &amp;lt;br&amp;gt;&lt;br /&gt;
5. Once the motes have been added you can position the motes.&lt;br /&gt;
&lt;br /&gt;
[[File:Cooja_motes.png]]&lt;br /&gt;
&lt;br /&gt;
6. Now, we need to create a bridge between the RPL network simulated on Cooja and the local machine. This can be done by right clicking on the mote which is programmed as the border router. Select &amp;#039;More tools for border router&amp;#039; and then select &amp;#039;Serial Socket (SERVER)&amp;#039;. You will get the following message on the successful completion of this step.Note that the message says &amp;#039;Listening on port 60001&amp;#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Serial_Socket.png]]&lt;br /&gt;
&lt;br /&gt;
7. Now start the simulation by clicking on Start&lt;br /&gt;
&lt;br /&gt;
== Tunslip utility ==&lt;br /&gt;
 &lt;br /&gt;
As mentioned in the introduction a border router helps in connecting one network to another. In this example the border router is used to route data between an RPL network and an external network. Till now we have only created the RPL network. Now we need to simulate the scenario in which this RPL network is connected to an external network. For this purpose we will use the Tunslip utility provided in Contiki. In this example tunslip creates a bridge between the RPL network and the local machine. &lt;br /&gt;
tunslip6.c can be found in /contiki-2.7/tools &lt;br /&gt;
Compile the tunslip6 code.&lt;br /&gt;
&amp;lt;pre&amp;gt;make tunslip6 &amp;lt;/pre&amp;gt; &lt;br /&gt;
Make a connection between the RPL network and your local machine. &lt;br /&gt;
&amp;lt;pre&amp;gt;sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64&amp;lt;/pre&amp;gt;&lt;br /&gt;
On the successful execution this command the following output will be printed on the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;slip connected to ``127.0.0.1:60001&amp;#039;&amp;#039;&lt;br /&gt;
opened tun device ``/dev/tun0&amp;#039;&amp;#039;&lt;br /&gt;
ifconfig tun0 inet `hostname` up&lt;br /&gt;
ifconfig tun0 add aaaa::1/64&lt;br /&gt;
ifconfig tun0 add fe80::0:0:0:1/64&lt;br /&gt;
ifconfig tun0&lt;br /&gt;
&lt;br /&gt;
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  &lt;br /&gt;
          inet addr:127.0.1.1  P-t-P:127.0.1.1  Mask:255.255.255.255&lt;br /&gt;
          inet6 addr: fe80::1/64 Scope:Link&lt;br /&gt;
          inet6 addr: aaaa::1/64 Scope:Global&lt;br /&gt;
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1&lt;br /&gt;
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0&lt;br /&gt;
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0&lt;br /&gt;
          collisions:0 txqueuelen:500 &lt;br /&gt;
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)&lt;br /&gt;
&lt;br /&gt;
Rime started with address 0.18.116.1.0.1.1.1&lt;br /&gt;
MAC 00:12:74:01:00:01:01:01 Contiki 2.7 started. Node id is set to 1.&lt;br /&gt;
CSMA ContikiMAC, channel check rate 8 Hz, radio channel 26&lt;br /&gt;
Tentative link-local IPv6 address fe80:0000:0000:0000:0212:7401:0001:0101&lt;br /&gt;
Starting &amp;#039;Border router process&amp;#039; &amp;#039;Web server&amp;#039;&lt;br /&gt;
*** Address:aaaa::1 =&amp;gt; aaaa:0000:0000:0000&lt;br /&gt;
Got configuration message of type P&lt;br /&gt;
Setting prefix aaaa::&lt;br /&gt;
Server IPv6 addresses:&lt;br /&gt;
 aaaa::212:7401:1:101&lt;br /&gt;
 fe80::212:7401:1:101&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Go back to the Cooja simulator GUI and look at the dialogue box. The message has now changed to &amp;#039;Client connected: /127.0.0.1&amp;#039;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Client_Connected.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Verifying Results ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can verify that the address of the border router has been set by using the ping command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7401:1:101&lt;br /&gt;
PING aaaa::212:7401:1:101(aaaa::212:7401:1:101) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=1 ttl=64 time=86.0 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=2 ttl=64 time=33.6 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=3 ttl=64 time=82.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=4 ttl=64 time=43.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=5 ttl=64 time=70.1 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7401:1:101 ping statistics ---&lt;br /&gt;
5 packets transmitted, 5 received, 0% packet loss, time 4006ms&lt;br /&gt;
rtt min/avg/max/mdev = 33.669/63.090/86.015/20.985 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also ping one of the other nodes in the network. Here we are pinging node 4&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7404:4:404&lt;br /&gt;
PING aaaa::212:7404:4:404(aaaa::212:7404:4:404) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=1 ttl=63 time=670 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=2 ttl=63 time=703 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=3 ttl=63 time=746 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=4 ttl=63 time=674 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7404:4:404 ping statistics ---&lt;br /&gt;
5 packets transmitted, 4 received, 20% packet loss, time 4001ms&lt;br /&gt;
rtt min/avg/max/mdev = 670.230/698.666/746.619/30.514 ms&lt;br /&gt;
user@instant-contiki:~/contiki-2.7$ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IPv6 address of a node can be checked from the log screen on Cooja. Filter the nodes by their ID&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Node_Address.png]]&lt;br /&gt;
&lt;br /&gt;
You can enter the address of the border router in the web browser. The border router host a page which will be displayed on the browser as shown below. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:RPL_Browser.png]]&lt;br /&gt;
&lt;br /&gt;
== Common Issues ==&lt;br /&gt;
&lt;br /&gt;
1. Make sure that you enter the IPv6 address properly in the command sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64 . There should be no spaces in aaaa::1/64. Otherwise the code will give unexpected behavior.&amp;lt;br&amp;gt;&lt;br /&gt;
2. When you pause the simulation the SLIP connection is lost. It might not work properly on resuming the simulation. In such cases reload the simulation. Create a fresh SLIP connection and then run the simulation again.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
[https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md]  https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md &amp;lt;br&amp;gt;&lt;br /&gt;
Using the Contiki Cooja Simulator - Anuj Sehgal&lt;/div&gt;</summary>
		<author><name>Ckapoor</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1139</id>
		<title>RPL Border Router</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1139"/>
				<updated>2014-11-08T22:40:48Z</updated>
		
		<summary type="html">&lt;p&gt;Ckapoor: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction: ==&lt;br /&gt;
  &lt;br /&gt;
Border routers are routers that can be found at the edge of a network. Their function is to connect one network to another. In this tutorial we will learn how to run a simulation using the border router in Contiki In the example which we will discuss in the rest of this tutorial the border router will be used to route data between a WSN (using RPL) and an external IP network.  &lt;br /&gt;
Objective:  &lt;br /&gt;
The objective of this tutorial is to give you an understanding of the RPL Border Router code on Contiki OS and learn how to simulate the code on Cooja &lt;br /&gt;
What will you learn at the end of this tutorial. At the end of the tutorial you would have learnt the following: &lt;br /&gt;
&lt;br /&gt;
1. Understanding the working of the rpl border router code &amp;lt;br&amp;gt;&lt;br /&gt;
2. Starting a simulation on Cooja simulator. &amp;lt;br&amp;gt; &lt;br /&gt;
3. Observing the results &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code building blocks. ==&lt;br /&gt;
 &lt;br /&gt;
We will using the following files &lt;br /&gt;
border-router.c &lt;br /&gt;
Go to the location /contiki-2.7/examples/ipv6/rpl-udp   and use either udp-client.c or udp-server.c to create a network of nodes.  &lt;br /&gt;
These nodes will form a DODAG with the border router set as the root. The border router will receive the prefix through a SLIP connection and it will be communicated to the rest of the nodes in the network. &lt;br /&gt;
Refer to the following code snippets in the file border-router.c In this piece of code the node configured as the border router waits for the prefix to be set. Once the prefix is set, the border router is set as the root of the DODAG after which it sets the prefix.  &lt;br /&gt;
 &lt;br /&gt;
 /* Request prefix until it has been received */ &lt;br /&gt;
  while(!prefix_set) { &lt;br /&gt;
    etimer_set(&amp;amp;et, CLOCK_SECOND); &lt;br /&gt;
    request_prefix(); &lt;br /&gt;
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&amp;amp;et)); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
  dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)dag_id); &lt;br /&gt;
  if(dag != NULL) { &lt;br /&gt;
    rpl_set_prefix(dag, &amp;amp;prefix, 64); &lt;br /&gt;
    PRINTF(&amp;quot;created a new RPL dag\n&amp;quot;); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
Explain the key points in the code. Include snippets. Add at least one Diagram. &lt;br /&gt;
&lt;br /&gt;
== Compiling the code ==&lt;br /&gt;
 &lt;br /&gt;
The code for RPL border router can be found at /contiki-2.7/examples/ipv6/rpl-border-router. Use the following command to compile the code for the border router &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-border-router &lt;br /&gt;
make TARGET=sky. &amp;lt;/pre&amp;gt;   &lt;br /&gt;
Once this command has been successfully executed a file named border-router.sky will be created. This file will be used to program one of the motes as the border router on Cooja.  &lt;br /&gt;
For the purpose of this tutorial we will  select  TMote Sky  as our target. &lt;br /&gt;
&lt;br /&gt;
In order to demonstrate the functioning of the border router we will create a network of nodes with the border router as the root. For creating such a network we will user the udp-server.c code.  &lt;br /&gt;
This code can be found at /contiki-2.7/examples/ipv6/rpl-udp . Use the following command to compile the code for rpl-udp &lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-udp &lt;br /&gt;
make TARGET=sky &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once this command has been successfully executed a file named udp-server.sky will be created. This file will be used to program the remaining nodes in Cooja simulator. These nodes will form a DAG with the rpl border router as the root.&lt;br /&gt;
&lt;br /&gt;
== Testing on Cooja ==&lt;br /&gt;
 &lt;br /&gt;
Upon the successful completion of the above mentioned steps we are ready to create a simulation in Cooja.  &lt;br /&gt;
Start the Cooja simulator using the following command &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd /contiki-2.7/tools/cooja &lt;br /&gt;
ant run&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
When the GUI launches execute the following steps to create a simulation. &amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
1. From &amp;#039;File&amp;#039; select &amp;#039;New Simulation&amp;#039;. Select UDGM, enter the name of the simulation and click on create. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Click on Motes. From the drop down menu select &amp;#039;Add New Motes&amp;#039; followed by &amp;#039;Create new motes&amp;#039; and select the mote type as Sky. &amp;lt;br&amp;gt;&lt;br /&gt;
3. Browse to the location /contiki-2.7/examples/ipv6/rpl-border-router and select the file rpl-border-router.sky. Click on &amp;#039;Create&amp;#039;. Add one mote of this type. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Repeat step 2 and 3 but this time browse to the location /contiki-2.7/examples/ipv6/rpl-udp  and select the file udp-server.sky. Add 3 - 4 motes of the type udp-server &amp;lt;br&amp;gt;&lt;br /&gt;
5. Once the motes have been added you can position the motes.&lt;br /&gt;
&lt;br /&gt;
[[File:Cooja_motes.png]]&lt;br /&gt;
&lt;br /&gt;
6. Now, we need to create a bridge between the RPL network simulated on Cooja and the local machine. This can be done by right clicking on the mote which is programmed as the border router. Select &amp;#039;More tools for border router&amp;#039; and then select &amp;#039;Serial Socket (SERVER)&amp;#039;. You will get the following message on the successful completion of this step.Note that the message says &amp;#039;Listening on port 60001&amp;#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Serial_Socket.png]]&lt;br /&gt;
&lt;br /&gt;
7. Now start the simulation by clicking on Start&lt;br /&gt;
&lt;br /&gt;
== Tunslip utility ==&lt;br /&gt;
 &lt;br /&gt;
As mentioned in the introduction a border router helps in connecting one network to another. In this example the border router is used to route data between an RPL network and an external network. Till now we have only created the RPL network. Now we need to simulate the scenario in which this RPL network is connected to an external network. For this purpose we will use the Tunslip utility provided in Contiki. In this example tunslip creates a bridge between the RPL network and the local machine. &lt;br /&gt;
tunslip6.c can be found in /contiki-2.7/tools &lt;br /&gt;
Compile the tunslip6 code.&lt;br /&gt;
&amp;lt;pre&amp;gt;make tunslip6 &amp;lt;/pre&amp;gt; &lt;br /&gt;
Make a connection between the RPL network and your local machine. &lt;br /&gt;
&amp;lt;pre&amp;gt;sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64&amp;lt;/pre&amp;gt;&lt;br /&gt;
On the successful execution this command the following output will be printed on the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;slip connected to ``127.0.0.1:60001&amp;#039;&amp;#039;&lt;br /&gt;
opened tun device ``/dev/tun0&amp;#039;&amp;#039;&lt;br /&gt;
ifconfig tun0 inet `hostname` up&lt;br /&gt;
ifconfig tun0 add aaaa::1/64&lt;br /&gt;
ifconfig tun0 add fe80::0:0:0:1/64&lt;br /&gt;
ifconfig tun0&lt;br /&gt;
&lt;br /&gt;
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  &lt;br /&gt;
          inet addr:127.0.1.1  P-t-P:127.0.1.1  Mask:255.255.255.255&lt;br /&gt;
          inet6 addr: fe80::1/64 Scope:Link&lt;br /&gt;
          inet6 addr: aaaa::1/64 Scope:Global&lt;br /&gt;
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1&lt;br /&gt;
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0&lt;br /&gt;
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0&lt;br /&gt;
          collisions:0 txqueuelen:500 &lt;br /&gt;
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)&lt;br /&gt;
&lt;br /&gt;
Rime started with address 0.18.116.1.0.1.1.1&lt;br /&gt;
MAC 00:12:74:01:00:01:01:01 Contiki 2.7 started. Node id is set to 1.&lt;br /&gt;
CSMA ContikiMAC, channel check rate 8 Hz, radio channel 26&lt;br /&gt;
Tentative link-local IPv6 address fe80:0000:0000:0000:0212:7401:0001:0101&lt;br /&gt;
Starting &amp;#039;Border router process&amp;#039; &amp;#039;Web server&amp;#039;&lt;br /&gt;
*** Address:aaaa::1 =&amp;gt; aaaa:0000:0000:0000&lt;br /&gt;
Got configuration message of type P&lt;br /&gt;
Setting prefix aaaa::&lt;br /&gt;
Server IPv6 addresses:&lt;br /&gt;
 aaaa::212:7401:1:101&lt;br /&gt;
 fe80::212:7401:1:101&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Go back to the Cooja simulator GUI and look at the dialogue box. The message has now changed to &amp;#039;Client connected: /127.0.0.1&amp;#039;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Client_Connected.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Verifying Results ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can verify that the address of the border router has been set by using the ping command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7401:1:101&lt;br /&gt;
PING aaaa::212:7401:1:101(aaaa::212:7401:1:101) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=1 ttl=64 time=86.0 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=2 ttl=64 time=33.6 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=3 ttl=64 time=82.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=4 ttl=64 time=43.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=5 ttl=64 time=70.1 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7401:1:101 ping statistics ---&lt;br /&gt;
5 packets transmitted, 5 received, 0% packet loss, time 4006ms&lt;br /&gt;
rtt min/avg/max/mdev = 33.669/63.090/86.015/20.985 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also ping one of the other nodes in the network. Here we are pinging node 4&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7404:4:404&lt;br /&gt;
PING aaaa::212:7404:4:404(aaaa::212:7404:4:404) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=1 ttl=63 time=670 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=2 ttl=63 time=703 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=3 ttl=63 time=746 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=4 ttl=63 time=674 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7404:4:404 ping statistics ---&lt;br /&gt;
5 packets transmitted, 4 received, 20% packet loss, time 4001ms&lt;br /&gt;
rtt min/avg/max/mdev = 670.230/698.666/746.619/30.514 ms&lt;br /&gt;
user@instant-contiki:~/contiki-2.7$ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IPv6 address of a node can be checked from the log screen on Cooja. Filter the nodes by their ID&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Node_Address.png]]&lt;br /&gt;
&lt;br /&gt;
You can enter the address of the border router in the web browser. The border router host a page which will be displayed on the browser as shown below. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:RPL_Browser.png]]&lt;br /&gt;
&lt;br /&gt;
== Common Issues ==&lt;br /&gt;
&lt;br /&gt;
1. Make sure that you enter the IPv6 address properly in the command sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64 . There should be no spaces in aaaa::1/64. Otherwise the code will give unexpected behavior.&amp;lt;br&amp;gt;&lt;br /&gt;
2. When you pause the simulation the SLIP connection is lost. It might not work properly on resuming the simulation. In such cases reload the simulation. Create a fresh SLIP connection and then run the simulation again.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
[https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md] &amp;lt;br&amp;gt;&lt;br /&gt;
Using the Contiki Cooja Simulator - Anuj Sehgal&lt;/div&gt;</summary>
		<author><name>Ckapoor</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1138</id>
		<title>RPL Border Router</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1138"/>
				<updated>2014-11-08T22:40:28Z</updated>
		
		<summary type="html">&lt;p&gt;Ckapoor: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction: ==&lt;br /&gt;
  &lt;br /&gt;
Border routers are routers that can be found at the edge of a network. Their function is to connect one network to another. In this tutorial we will learn how to run a simulation using the border router in Contiki In the example which we will discuss in the rest of this tutorial the border router will be used to route data between a WSN (using RPL) and an external IP network.  &lt;br /&gt;
Objective:  &lt;br /&gt;
The objective of this tutorial is to give you an understanding of the RPL Border Router code on Contiki OS and learn how to simulate the code on Cooja &lt;br /&gt;
What will you learn at the end of this tutorial. At the end of the tutorial you would have learnt the following: &lt;br /&gt;
&lt;br /&gt;
1. Understanding the working of the rpl border router code &amp;lt;br&amp;gt;&lt;br /&gt;
2. Starting a simulation on Cooja simulator. &amp;lt;br&amp;gt; &lt;br /&gt;
3. Observing the results &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code building blocks. ==&lt;br /&gt;
 &lt;br /&gt;
We will using the following files &lt;br /&gt;
border-router.c &lt;br /&gt;
Go to the location /contiki-2.7/examples/ipv6/rpl-udp   and use either udp-client.c or udp-server.c to create a network of nodes.  &lt;br /&gt;
These nodes will form a DODAG with the border router set as the root. The border router will receive the prefix through a SLIP connection and it will be communicated to the rest of the nodes in the network. &lt;br /&gt;
Refer to the following code snippets in the file border-router.c In this piece of code the node configured as the border router waits for the prefix to be set. Once the prefix is set, the border router is set as the root of the DODAG after which it sets the prefix.  &lt;br /&gt;
 &lt;br /&gt;
 /* Request prefix until it has been received */ &lt;br /&gt;
  while(!prefix_set) { &lt;br /&gt;
    etimer_set(&amp;amp;et, CLOCK_SECOND); &lt;br /&gt;
    request_prefix(); &lt;br /&gt;
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&amp;amp;et)); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
  dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)dag_id); &lt;br /&gt;
  if(dag != NULL) { &lt;br /&gt;
    rpl_set_prefix(dag, &amp;amp;prefix, 64); &lt;br /&gt;
    PRINTF(&amp;quot;created a new RPL dag\n&amp;quot;); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
Explain the key points in the code. Include snippets. Add at least one Diagram. &lt;br /&gt;
&lt;br /&gt;
== Compiling the code ==&lt;br /&gt;
 &lt;br /&gt;
The code for RPL border router can be found at /contiki-2.7/examples/ipv6/rpl-border-router. Use the following command to compile the code for the border router &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-border-router &lt;br /&gt;
make TARGET=sky. &amp;lt;/pre&amp;gt;   &lt;br /&gt;
Once this command has been successfully executed a file named border-router.sky will be created. This file will be used to program one of the motes as the border router on Cooja.  &lt;br /&gt;
For the purpose of this tutorial we will  select  TMote Sky  as our target. &lt;br /&gt;
&lt;br /&gt;
In order to demonstrate the functioning of the border router we will create a network of nodes with the border router as the root. For creating such a network we will user the udp-server.c code.  &lt;br /&gt;
This code can be found at /contiki-2.7/examples/ipv6/rpl-udp . Use the following command to compile the code for rpl-udp &lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-udp &lt;br /&gt;
make TARGET=sky &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once this command has been successfully executed a file named udp-server.sky will be created. This file will be used to program the remaining nodes in Cooja simulator. These nodes will form a DAG with the rpl border router as the root.&lt;br /&gt;
&lt;br /&gt;
== Testing on Cooja ==&lt;br /&gt;
 &lt;br /&gt;
Upon the successful completion of the above mentioned steps we are ready to create a simulation in Cooja.  &lt;br /&gt;
Start the Cooja simulator using the following command &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd /contiki-2.7/tools/cooja &lt;br /&gt;
ant run&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
When the GUI launches execute the following steps to create a simulation. &amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
1. From &amp;#039;File&amp;#039; select &amp;#039;New Simulation&amp;#039;. Select UDGM, enter the name of the simulation and click on create. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Click on Motes. From the drop down menu select &amp;#039;Add New Motes&amp;#039; followed by &amp;#039;Create new motes&amp;#039; and select the mote type as Sky. &amp;lt;br&amp;gt;&lt;br /&gt;
3. Browse to the location /contiki-2.7/examples/ipv6/rpl-border-router and select the file rpl-border-router.sky. Click on &amp;#039;Create&amp;#039;. Add one mote of this type. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Repeat step 2 and 3 but this time browse to the location /contiki-2.7/examples/ipv6/rpl-udp  and select the file udp-server.sky. Add 3 - 4 motes of the type udp-server &amp;lt;br&amp;gt;&lt;br /&gt;
5. Once the motes have been added you can position the motes.&lt;br /&gt;
&lt;br /&gt;
[[File:Cooja_motes.png]]&lt;br /&gt;
&lt;br /&gt;
6. Now, we need to create a bridge between the RPL network simulated on Cooja and the local machine. This can be done by right clicking on the mote which is programmed as the border router. Select &amp;#039;More tools for border router&amp;#039; and then select &amp;#039;Serial Socket (SERVER)&amp;#039;. You will get the following message on the successful completion of this step.Note that the message says &amp;#039;Listening on port 60001&amp;#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Serial_Socket.png]]&lt;br /&gt;
&lt;br /&gt;
7. Now start the simulation by clicking on Start&lt;br /&gt;
&lt;br /&gt;
== Tunslip utility ==&lt;br /&gt;
 &lt;br /&gt;
As mentioned in the introduction a border router helps in connecting one network to another. In this example the border router is used to route data between an RPL network and an external network. Till now we have only created the RPL network. Now we need to simulate the scenario in which this RPL network is connected to an external network. For this purpose we will use the Tunslip utility provided in Contiki. In this example tunslip creates a bridge between the RPL network and the local machine. &lt;br /&gt;
tunslip6.c can be found in /contiki-2.7/tools &lt;br /&gt;
Compile the tunslip6 code.&lt;br /&gt;
&amp;lt;pre&amp;gt;make tunslip6 &amp;lt;/pre&amp;gt; &lt;br /&gt;
Make a connection between the RPL network and your local machine. &lt;br /&gt;
&amp;lt;pre&amp;gt;sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64&amp;lt;/pre&amp;gt;&lt;br /&gt;
On the successful execution this command the following output will be printed on the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;slip connected to ``127.0.0.1:60001&amp;#039;&amp;#039;&lt;br /&gt;
opened tun device ``/dev/tun0&amp;#039;&amp;#039;&lt;br /&gt;
ifconfig tun0 inet `hostname` up&lt;br /&gt;
ifconfig tun0 add aaaa::1/64&lt;br /&gt;
ifconfig tun0 add fe80::0:0:0:1/64&lt;br /&gt;
ifconfig tun0&lt;br /&gt;
&lt;br /&gt;
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  &lt;br /&gt;
          inet addr:127.0.1.1  P-t-P:127.0.1.1  Mask:255.255.255.255&lt;br /&gt;
          inet6 addr: fe80::1/64 Scope:Link&lt;br /&gt;
          inet6 addr: aaaa::1/64 Scope:Global&lt;br /&gt;
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1&lt;br /&gt;
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0&lt;br /&gt;
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0&lt;br /&gt;
          collisions:0 txqueuelen:500 &lt;br /&gt;
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)&lt;br /&gt;
&lt;br /&gt;
Rime started with address 0.18.116.1.0.1.1.1&lt;br /&gt;
MAC 00:12:74:01:00:01:01:01 Contiki 2.7 started. Node id is set to 1.&lt;br /&gt;
CSMA ContikiMAC, channel check rate 8 Hz, radio channel 26&lt;br /&gt;
Tentative link-local IPv6 address fe80:0000:0000:0000:0212:7401:0001:0101&lt;br /&gt;
Starting &amp;#039;Border router process&amp;#039; &amp;#039;Web server&amp;#039;&lt;br /&gt;
*** Address:aaaa::1 =&amp;gt; aaaa:0000:0000:0000&lt;br /&gt;
Got configuration message of type P&lt;br /&gt;
Setting prefix aaaa::&lt;br /&gt;
Server IPv6 addresses:&lt;br /&gt;
 aaaa::212:7401:1:101&lt;br /&gt;
 fe80::212:7401:1:101&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Go back to the Cooja simulator GUI and look at the dialogue box. The message has now changed to &amp;#039;Client connected: /127.0.0.1&amp;#039;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Client_Connected.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Verifying Results ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can verify that the address of the border router has been set by using the ping command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7401:1:101&lt;br /&gt;
PING aaaa::212:7401:1:101(aaaa::212:7401:1:101) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=1 ttl=64 time=86.0 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=2 ttl=64 time=33.6 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=3 ttl=64 time=82.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=4 ttl=64 time=43.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=5 ttl=64 time=70.1 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7401:1:101 ping statistics ---&lt;br /&gt;
5 packets transmitted, 5 received, 0% packet loss, time 4006ms&lt;br /&gt;
rtt min/avg/max/mdev = 33.669/63.090/86.015/20.985 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also ping one of the other nodes in the network. Here we are pinging node 4&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7404:4:404&lt;br /&gt;
PING aaaa::212:7404:4:404(aaaa::212:7404:4:404) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=1 ttl=63 time=670 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=2 ttl=63 time=703 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=3 ttl=63 time=746 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=4 ttl=63 time=674 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7404:4:404 ping statistics ---&lt;br /&gt;
5 packets transmitted, 4 received, 20% packet loss, time 4001ms&lt;br /&gt;
rtt min/avg/max/mdev = 670.230/698.666/746.619/30.514 ms&lt;br /&gt;
user@instant-contiki:~/contiki-2.7$ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IPv6 address of a node can be checked from the log screen on Cooja. Filter the nodes by their ID&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Node_Address.png]]&lt;br /&gt;
&lt;br /&gt;
You can enter the address of the border router in the web browser. The border router host a page which will be displayed on the browser as shown below. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:RPL_Browser.png]]&lt;br /&gt;
&lt;br /&gt;
== Common Issues ==&lt;br /&gt;
&lt;br /&gt;
1. Make sure that you enter the IPv6 address properly in the command sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64 . There should be no spaces in aaaa::1/64. Otherwise the code will give unexpected behavior.&amp;lt;br&amp;gt;&lt;br /&gt;
2. When you pause the simulation the SLIP connection is lost. It might not work properly on resuming the simulation. In such cases reload the simulation. Create a fresh SLIP connection and then run the simulation again.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
[https://github.com/njh/contiki/blob/master/cpu/mc1322x/doc/rpl-tutorial.md]&lt;br /&gt;
Using the Contiki Cooja Simulator - Anuj Sehgal&lt;/div&gt;</summary>
		<author><name>Ckapoor</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1137</id>
		<title>RPL Border Router</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1137"/>
				<updated>2014-11-08T22:38:29Z</updated>
		
		<summary type="html">&lt;p&gt;Ckapoor: /* Verifying Results */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction: ==&lt;br /&gt;
  &lt;br /&gt;
Border routers are routers that can be found at the edge of a network. Their function is to connect one network to another. In this tutorial we will learn how to run a simulation using the border router in Contiki In the example which we will discuss in the rest of this tutorial the border router will be used to route data between a WSN (using RPL) and an external IP network.  &lt;br /&gt;
Objective:  &lt;br /&gt;
The objective of this tutorial is to give you an understanding of the RPL Border Router code on Contiki OS and learn how to simulate the code on Cooja &lt;br /&gt;
What will you learn at the end of this tutorial. At the end of the tutorial you would have learnt the following: &lt;br /&gt;
&lt;br /&gt;
1. Understanding the working of the rpl border router code &amp;lt;br&amp;gt;&lt;br /&gt;
2. Starting a simulation on Cooja simulator. &amp;lt;br&amp;gt; &lt;br /&gt;
3. Observing the results &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code building blocks. ==&lt;br /&gt;
 &lt;br /&gt;
We will using the following files &lt;br /&gt;
border-router.c &lt;br /&gt;
Go to the location /contiki-2.7/examples/ipv6/rpl-udp   and use either udp-client.c or udp-server.c to create a network of nodes.  &lt;br /&gt;
These nodes will form a DODAG with the border router set as the root. The border router will receive the prefix through a SLIP connection and it will be communicated to the rest of the nodes in the network. &lt;br /&gt;
Refer to the following code snippets in the file border-router.c In this piece of code the node configured as the border router waits for the prefix to be set. Once the prefix is set, the border router is set as the root of the DODAG after which it sets the prefix.  &lt;br /&gt;
 &lt;br /&gt;
 /* Request prefix until it has been received */ &lt;br /&gt;
  while(!prefix_set) { &lt;br /&gt;
    etimer_set(&amp;amp;et, CLOCK_SECOND); &lt;br /&gt;
    request_prefix(); &lt;br /&gt;
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&amp;amp;et)); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
  dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)dag_id); &lt;br /&gt;
  if(dag != NULL) { &lt;br /&gt;
    rpl_set_prefix(dag, &amp;amp;prefix, 64); &lt;br /&gt;
    PRINTF(&amp;quot;created a new RPL dag\n&amp;quot;); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
Explain the key points in the code. Include snippets. Add at least one Diagram. &lt;br /&gt;
&lt;br /&gt;
== Compiling the code ==&lt;br /&gt;
 &lt;br /&gt;
The code for RPL border router can be found at /contiki-2.7/examples/ipv6/rpl-border-router. Use the following command to compile the code for the border router &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-border-router &lt;br /&gt;
make TARGET=sky. &amp;lt;/pre&amp;gt;   &lt;br /&gt;
Once this command has been successfully executed a file named border-router.sky will be created. This file will be used to program one of the motes as the border router on Cooja.  &lt;br /&gt;
For the purpose of this tutorial we will  select  TMote Sky  as our target. &lt;br /&gt;
&lt;br /&gt;
In order to demonstrate the functioning of the border router we will create a network of nodes with the border router as the root. For creating such a network we will user the udp-server.c code.  &lt;br /&gt;
This code can be found at /contiki-2.7/examples/ipv6/rpl-udp . Use the following command to compile the code for rpl-udp &lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-udp &lt;br /&gt;
make TARGET=sky &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once this command has been successfully executed a file named udp-server.sky will be created. This file will be used to program the remaining nodes in Cooja simulator. These nodes will form a DAG with the rpl border router as the root.&lt;br /&gt;
&lt;br /&gt;
== Testing on Cooja ==&lt;br /&gt;
 &lt;br /&gt;
Upon the successful completion of the above mentioned steps we are ready to create a simulation in Cooja.  &lt;br /&gt;
Start the Cooja simulator using the following command &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd /contiki-2.7/tools/cooja &lt;br /&gt;
ant run&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
When the GUI launches execute the following steps to create a simulation. &amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
1. From &amp;#039;File&amp;#039; select &amp;#039;New Simulation&amp;#039;. Select UDGM, enter the name of the simulation and click on create. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Click on Motes. From the drop down menu select &amp;#039;Add New Motes&amp;#039; followed by &amp;#039;Create new motes&amp;#039; and select the mote type as Sky. &amp;lt;br&amp;gt;&lt;br /&gt;
3. Browse to the location /contiki-2.7/examples/ipv6/rpl-border-router and select the file rpl-border-router.sky. Click on &amp;#039;Create&amp;#039;. Add one mote of this type. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Repeat step 2 and 3 but this time browse to the location /contiki-2.7/examples/ipv6/rpl-udp  and select the file udp-server.sky. Add 3 - 4 motes of the type udp-server &amp;lt;br&amp;gt;&lt;br /&gt;
5. Once the motes have been added you can position the motes.&lt;br /&gt;
&lt;br /&gt;
[[File:Cooja_motes.png]]&lt;br /&gt;
&lt;br /&gt;
6. Now, we need to create a bridge between the RPL network simulated on Cooja and the local machine. This can be done by right clicking on the mote which is programmed as the border router. Select &amp;#039;More tools for border router&amp;#039; and then select &amp;#039;Serial Socket (SERVER)&amp;#039;. You will get the following message on the successful completion of this step.Note that the message says &amp;#039;Listening on port 60001&amp;#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Serial_Socket.png]]&lt;br /&gt;
&lt;br /&gt;
7. Now start the simulation by clicking on Start&lt;br /&gt;
&lt;br /&gt;
== Tunslip utility ==&lt;br /&gt;
 &lt;br /&gt;
As mentioned in the introduction a border router helps in connecting one network to another. In this example the border router is used to route data between an RPL network and an external network. Till now we have only created the RPL network. Now we need to simulate the scenario in which this RPL network is connected to an external network. For this purpose we will use the Tunslip utility provided in Contiki. In this example tunslip creates a bridge between the RPL network and the local machine. &lt;br /&gt;
tunslip6.c can be found in /contiki-2.7/tools &lt;br /&gt;
Compile the tunslip6 code.&lt;br /&gt;
&amp;lt;pre&amp;gt;make tunslip6 &amp;lt;/pre&amp;gt; &lt;br /&gt;
Make a connection between the RPL network and your local machine. &lt;br /&gt;
&amp;lt;pre&amp;gt;sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64&amp;lt;/pre&amp;gt;&lt;br /&gt;
On the successful execution this command the following output will be printed on the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;slip connected to ``127.0.0.1:60001&amp;#039;&amp;#039;&lt;br /&gt;
opened tun device ``/dev/tun0&amp;#039;&amp;#039;&lt;br /&gt;
ifconfig tun0 inet `hostname` up&lt;br /&gt;
ifconfig tun0 add aaaa::1/64&lt;br /&gt;
ifconfig tun0 add fe80::0:0:0:1/64&lt;br /&gt;
ifconfig tun0&lt;br /&gt;
&lt;br /&gt;
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  &lt;br /&gt;
          inet addr:127.0.1.1  P-t-P:127.0.1.1  Mask:255.255.255.255&lt;br /&gt;
          inet6 addr: fe80::1/64 Scope:Link&lt;br /&gt;
          inet6 addr: aaaa::1/64 Scope:Global&lt;br /&gt;
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1&lt;br /&gt;
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0&lt;br /&gt;
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0&lt;br /&gt;
          collisions:0 txqueuelen:500 &lt;br /&gt;
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)&lt;br /&gt;
&lt;br /&gt;
Rime started with address 0.18.116.1.0.1.1.1&lt;br /&gt;
MAC 00:12:74:01:00:01:01:01 Contiki 2.7 started. Node id is set to 1.&lt;br /&gt;
CSMA ContikiMAC, channel check rate 8 Hz, radio channel 26&lt;br /&gt;
Tentative link-local IPv6 address fe80:0000:0000:0000:0212:7401:0001:0101&lt;br /&gt;
Starting &amp;#039;Border router process&amp;#039; &amp;#039;Web server&amp;#039;&lt;br /&gt;
*** Address:aaaa::1 =&amp;gt; aaaa:0000:0000:0000&lt;br /&gt;
Got configuration message of type P&lt;br /&gt;
Setting prefix aaaa::&lt;br /&gt;
Server IPv6 addresses:&lt;br /&gt;
 aaaa::212:7401:1:101&lt;br /&gt;
 fe80::212:7401:1:101&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Go back to the Cooja simulator GUI and look at the dialogue box. The message has now changed to &amp;#039;Client connected: /127.0.0.1&amp;#039;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Client_Connected.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Verifying Results ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can verify that the address of the border router has been set by using the ping command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7401:1:101&lt;br /&gt;
PING aaaa::212:7401:1:101(aaaa::212:7401:1:101) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=1 ttl=64 time=86.0 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=2 ttl=64 time=33.6 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=3 ttl=64 time=82.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=4 ttl=64 time=43.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=5 ttl=64 time=70.1 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7401:1:101 ping statistics ---&lt;br /&gt;
5 packets transmitted, 5 received, 0% packet loss, time 4006ms&lt;br /&gt;
rtt min/avg/max/mdev = 33.669/63.090/86.015/20.985 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also ping one of the other nodes in the network. Here we are pinging node 4&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7404:4:404&lt;br /&gt;
PING aaaa::212:7404:4:404(aaaa::212:7404:4:404) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=1 ttl=63 time=670 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=2 ttl=63 time=703 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=3 ttl=63 time=746 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=4 ttl=63 time=674 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7404:4:404 ping statistics ---&lt;br /&gt;
5 packets transmitted, 4 received, 20% packet loss, time 4001ms&lt;br /&gt;
rtt min/avg/max/mdev = 670.230/698.666/746.619/30.514 ms&lt;br /&gt;
user@instant-contiki:~/contiki-2.7$ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IPv6 address of a node can be checked from the log screen on Cooja. Filter the nodes by their ID&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Node_Address.png]]&lt;br /&gt;
&lt;br /&gt;
You can enter the address of the border router in the web browser. The border router host a page which will be displayed on the browser as shown below. &amp;lt;br&amp;gt;&lt;br /&gt;
[[File:RPL_Browser.png]]&lt;br /&gt;
&lt;br /&gt;
== Common Issues ==&lt;br /&gt;
&lt;br /&gt;
1. Make sure that you enter the IPv6 address properly in the command sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64 . There should be no spaces in aaaa::1/64. Otherwise the code will give unexpected behavior.&amp;lt;br&amp;gt;&lt;br /&gt;
2. When you pause the simulation the SLIP connection is lost. It might not work properly on resuming the simulation. In such cases reload the simulation. Create a fresh SLIP connection and then run the simulation again.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Ckapoor</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1136</id>
		<title>RPL Border Router</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1136"/>
				<updated>2014-11-08T22:38:04Z</updated>
		
		<summary type="html">&lt;p&gt;Ckapoor: /* Verifying Results */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction: ==&lt;br /&gt;
  &lt;br /&gt;
Border routers are routers that can be found at the edge of a network. Their function is to connect one network to another. In this tutorial we will learn how to run a simulation using the border router in Contiki In the example which we will discuss in the rest of this tutorial the border router will be used to route data between a WSN (using RPL) and an external IP network.  &lt;br /&gt;
Objective:  &lt;br /&gt;
The objective of this tutorial is to give you an understanding of the RPL Border Router code on Contiki OS and learn how to simulate the code on Cooja &lt;br /&gt;
What will you learn at the end of this tutorial. At the end of the tutorial you would have learnt the following: &lt;br /&gt;
&lt;br /&gt;
1. Understanding the working of the rpl border router code &amp;lt;br&amp;gt;&lt;br /&gt;
2. Starting a simulation on Cooja simulator. &amp;lt;br&amp;gt; &lt;br /&gt;
3. Observing the results &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code building blocks. ==&lt;br /&gt;
 &lt;br /&gt;
We will using the following files &lt;br /&gt;
border-router.c &lt;br /&gt;
Go to the location /contiki-2.7/examples/ipv6/rpl-udp   and use either udp-client.c or udp-server.c to create a network of nodes.  &lt;br /&gt;
These nodes will form a DODAG with the border router set as the root. The border router will receive the prefix through a SLIP connection and it will be communicated to the rest of the nodes in the network. &lt;br /&gt;
Refer to the following code snippets in the file border-router.c In this piece of code the node configured as the border router waits for the prefix to be set. Once the prefix is set, the border router is set as the root of the DODAG after which it sets the prefix.  &lt;br /&gt;
 &lt;br /&gt;
 /* Request prefix until it has been received */ &lt;br /&gt;
  while(!prefix_set) { &lt;br /&gt;
    etimer_set(&amp;amp;et, CLOCK_SECOND); &lt;br /&gt;
    request_prefix(); &lt;br /&gt;
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&amp;amp;et)); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
  dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)dag_id); &lt;br /&gt;
  if(dag != NULL) { &lt;br /&gt;
    rpl_set_prefix(dag, &amp;amp;prefix, 64); &lt;br /&gt;
    PRINTF(&amp;quot;created a new RPL dag\n&amp;quot;); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
Explain the key points in the code. Include snippets. Add at least one Diagram. &lt;br /&gt;
&lt;br /&gt;
== Compiling the code ==&lt;br /&gt;
 &lt;br /&gt;
The code for RPL border router can be found at /contiki-2.7/examples/ipv6/rpl-border-router. Use the following command to compile the code for the border router &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-border-router &lt;br /&gt;
make TARGET=sky. &amp;lt;/pre&amp;gt;   &lt;br /&gt;
Once this command has been successfully executed a file named border-router.sky will be created. This file will be used to program one of the motes as the border router on Cooja.  &lt;br /&gt;
For the purpose of this tutorial we will  select  TMote Sky  as our target. &lt;br /&gt;
&lt;br /&gt;
In order to demonstrate the functioning of the border router we will create a network of nodes with the border router as the root. For creating such a network we will user the udp-server.c code.  &lt;br /&gt;
This code can be found at /contiki-2.7/examples/ipv6/rpl-udp . Use the following command to compile the code for rpl-udp &lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-udp &lt;br /&gt;
make TARGET=sky &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once this command has been successfully executed a file named udp-server.sky will be created. This file will be used to program the remaining nodes in Cooja simulator. These nodes will form a DAG with the rpl border router as the root.&lt;br /&gt;
&lt;br /&gt;
== Testing on Cooja ==&lt;br /&gt;
 &lt;br /&gt;
Upon the successful completion of the above mentioned steps we are ready to create a simulation in Cooja.  &lt;br /&gt;
Start the Cooja simulator using the following command &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd /contiki-2.7/tools/cooja &lt;br /&gt;
ant run&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
When the GUI launches execute the following steps to create a simulation. &amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
1. From &amp;#039;File&amp;#039; select &amp;#039;New Simulation&amp;#039;. Select UDGM, enter the name of the simulation and click on create. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Click on Motes. From the drop down menu select &amp;#039;Add New Motes&amp;#039; followed by &amp;#039;Create new motes&amp;#039; and select the mote type as Sky. &amp;lt;br&amp;gt;&lt;br /&gt;
3. Browse to the location /contiki-2.7/examples/ipv6/rpl-border-router and select the file rpl-border-router.sky. Click on &amp;#039;Create&amp;#039;. Add one mote of this type. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Repeat step 2 and 3 but this time browse to the location /contiki-2.7/examples/ipv6/rpl-udp  and select the file udp-server.sky. Add 3 - 4 motes of the type udp-server &amp;lt;br&amp;gt;&lt;br /&gt;
5. Once the motes have been added you can position the motes.&lt;br /&gt;
&lt;br /&gt;
[[File:Cooja_motes.png]]&lt;br /&gt;
&lt;br /&gt;
6. Now, we need to create a bridge between the RPL network simulated on Cooja and the local machine. This can be done by right clicking on the mote which is programmed as the border router. Select &amp;#039;More tools for border router&amp;#039; and then select &amp;#039;Serial Socket (SERVER)&amp;#039;. You will get the following message on the successful completion of this step.Note that the message says &amp;#039;Listening on port 60001&amp;#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Serial_Socket.png]]&lt;br /&gt;
&lt;br /&gt;
7. Now start the simulation by clicking on Start&lt;br /&gt;
&lt;br /&gt;
== Tunslip utility ==&lt;br /&gt;
 &lt;br /&gt;
As mentioned in the introduction a border router helps in connecting one network to another. In this example the border router is used to route data between an RPL network and an external network. Till now we have only created the RPL network. Now we need to simulate the scenario in which this RPL network is connected to an external network. For this purpose we will use the Tunslip utility provided in Contiki. In this example tunslip creates a bridge between the RPL network and the local machine. &lt;br /&gt;
tunslip6.c can be found in /contiki-2.7/tools &lt;br /&gt;
Compile the tunslip6 code.&lt;br /&gt;
&amp;lt;pre&amp;gt;make tunslip6 &amp;lt;/pre&amp;gt; &lt;br /&gt;
Make a connection between the RPL network and your local machine. &lt;br /&gt;
&amp;lt;pre&amp;gt;sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64&amp;lt;/pre&amp;gt;&lt;br /&gt;
On the successful execution this command the following output will be printed on the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;slip connected to ``127.0.0.1:60001&amp;#039;&amp;#039;&lt;br /&gt;
opened tun device ``/dev/tun0&amp;#039;&amp;#039;&lt;br /&gt;
ifconfig tun0 inet `hostname` up&lt;br /&gt;
ifconfig tun0 add aaaa::1/64&lt;br /&gt;
ifconfig tun0 add fe80::0:0:0:1/64&lt;br /&gt;
ifconfig tun0&lt;br /&gt;
&lt;br /&gt;
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  &lt;br /&gt;
          inet addr:127.0.1.1  P-t-P:127.0.1.1  Mask:255.255.255.255&lt;br /&gt;
          inet6 addr: fe80::1/64 Scope:Link&lt;br /&gt;
          inet6 addr: aaaa::1/64 Scope:Global&lt;br /&gt;
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1&lt;br /&gt;
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0&lt;br /&gt;
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0&lt;br /&gt;
          collisions:0 txqueuelen:500 &lt;br /&gt;
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)&lt;br /&gt;
&lt;br /&gt;
Rime started with address 0.18.116.1.0.1.1.1&lt;br /&gt;
MAC 00:12:74:01:00:01:01:01 Contiki 2.7 started. Node id is set to 1.&lt;br /&gt;
CSMA ContikiMAC, channel check rate 8 Hz, radio channel 26&lt;br /&gt;
Tentative link-local IPv6 address fe80:0000:0000:0000:0212:7401:0001:0101&lt;br /&gt;
Starting &amp;#039;Border router process&amp;#039; &amp;#039;Web server&amp;#039;&lt;br /&gt;
*** Address:aaaa::1 =&amp;gt; aaaa:0000:0000:0000&lt;br /&gt;
Got configuration message of type P&lt;br /&gt;
Setting prefix aaaa::&lt;br /&gt;
Server IPv6 addresses:&lt;br /&gt;
 aaaa::212:7401:1:101&lt;br /&gt;
 fe80::212:7401:1:101&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Go back to the Cooja simulator GUI and look at the dialogue box. The message has now changed to &amp;#039;Client connected: /127.0.0.1&amp;#039;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Client_Connected.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Verifying Results ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can verify that the address of the border router has been set by using the ping command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7401:1:101&lt;br /&gt;
PING aaaa::212:7401:1:101(aaaa::212:7401:1:101) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=1 ttl=64 time=86.0 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=2 ttl=64 time=33.6 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=3 ttl=64 time=82.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=4 ttl=64 time=43.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=5 ttl=64 time=70.1 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7401:1:101 ping statistics ---&lt;br /&gt;
5 packets transmitted, 5 received, 0% packet loss, time 4006ms&lt;br /&gt;
rtt min/avg/max/mdev = 33.669/63.090/86.015/20.985 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also ping one of the other nodes in the network. Here we are pinging node 4&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7404:4:404&lt;br /&gt;
PING aaaa::212:7404:4:404(aaaa::212:7404:4:404) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=1 ttl=63 time=670 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=2 ttl=63 time=703 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=3 ttl=63 time=746 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=4 ttl=63 time=674 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7404:4:404 ping statistics ---&lt;br /&gt;
5 packets transmitted, 4 received, 20% packet loss, time 4001ms&lt;br /&gt;
rtt min/avg/max/mdev = 670.230/698.666/746.619/30.514 ms&lt;br /&gt;
user@instant-contiki:~/contiki-2.7$ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IPv6 address of a node can be checked from the log screen on Cooja. Filter the nodes by their ID&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Node_Address.png]]&lt;br /&gt;
&lt;br /&gt;
You can enter the address of the border router in the web browser. The border router host a page which will be displayed on the browser as shown below&lt;br /&gt;
[[File:RPL_Browser.png]]&lt;br /&gt;
&lt;br /&gt;
== Common Issues ==&lt;br /&gt;
&lt;br /&gt;
1. Make sure that you enter the IPv6 address properly in the command sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64 . There should be no spaces in aaaa::1/64. Otherwise the code will give unexpected behavior.&amp;lt;br&amp;gt;&lt;br /&gt;
2. When you pause the simulation the SLIP connection is lost. It might not work properly on resuming the simulation. In such cases reload the simulation. Create a fresh SLIP connection and then run the simulation again.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Ckapoor</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=File:RPL_Browser.png&amp;diff=1135</id>
		<title>File:RPL Browser.png</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=File:RPL_Browser.png&amp;diff=1135"/>
				<updated>2014-11-08T22:36:41Z</updated>
		
		<summary type="html">&lt;p&gt;Ckapoor: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ckapoor</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1134</id>
		<title>RPL Border Router</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1134"/>
				<updated>2014-11-08T22:36:14Z</updated>
		
		<summary type="html">&lt;p&gt;Ckapoor: /* Verifying Results */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction: ==&lt;br /&gt;
  &lt;br /&gt;
Border routers are routers that can be found at the edge of a network. Their function is to connect one network to another. In this tutorial we will learn how to run a simulation using the border router in Contiki In the example which we will discuss in the rest of this tutorial the border router will be used to route data between a WSN (using RPL) and an external IP network.  &lt;br /&gt;
Objective:  &lt;br /&gt;
The objective of this tutorial is to give you an understanding of the RPL Border Router code on Contiki OS and learn how to simulate the code on Cooja &lt;br /&gt;
What will you learn at the end of this tutorial. At the end of the tutorial you would have learnt the following: &lt;br /&gt;
&lt;br /&gt;
1. Understanding the working of the rpl border router code &amp;lt;br&amp;gt;&lt;br /&gt;
2. Starting a simulation on Cooja simulator. &amp;lt;br&amp;gt; &lt;br /&gt;
3. Observing the results &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code building blocks. ==&lt;br /&gt;
 &lt;br /&gt;
We will using the following files &lt;br /&gt;
border-router.c &lt;br /&gt;
Go to the location /contiki-2.7/examples/ipv6/rpl-udp   and use either udp-client.c or udp-server.c to create a network of nodes.  &lt;br /&gt;
These nodes will form a DODAG with the border router set as the root. The border router will receive the prefix through a SLIP connection and it will be communicated to the rest of the nodes in the network. &lt;br /&gt;
Refer to the following code snippets in the file border-router.c In this piece of code the node configured as the border router waits for the prefix to be set. Once the prefix is set, the border router is set as the root of the DODAG after which it sets the prefix.  &lt;br /&gt;
 &lt;br /&gt;
 /* Request prefix until it has been received */ &lt;br /&gt;
  while(!prefix_set) { &lt;br /&gt;
    etimer_set(&amp;amp;et, CLOCK_SECOND); &lt;br /&gt;
    request_prefix(); &lt;br /&gt;
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&amp;amp;et)); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
  dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)dag_id); &lt;br /&gt;
  if(dag != NULL) { &lt;br /&gt;
    rpl_set_prefix(dag, &amp;amp;prefix, 64); &lt;br /&gt;
    PRINTF(&amp;quot;created a new RPL dag\n&amp;quot;); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
Explain the key points in the code. Include snippets. Add at least one Diagram. &lt;br /&gt;
&lt;br /&gt;
== Compiling the code ==&lt;br /&gt;
 &lt;br /&gt;
The code for RPL border router can be found at /contiki-2.7/examples/ipv6/rpl-border-router. Use the following command to compile the code for the border router &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-border-router &lt;br /&gt;
make TARGET=sky. &amp;lt;/pre&amp;gt;   &lt;br /&gt;
Once this command has been successfully executed a file named border-router.sky will be created. This file will be used to program one of the motes as the border router on Cooja.  &lt;br /&gt;
For the purpose of this tutorial we will  select  TMote Sky  as our target. &lt;br /&gt;
&lt;br /&gt;
In order to demonstrate the functioning of the border router we will create a network of nodes with the border router as the root. For creating such a network we will user the udp-server.c code.  &lt;br /&gt;
This code can be found at /contiki-2.7/examples/ipv6/rpl-udp . Use the following command to compile the code for rpl-udp &lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-udp &lt;br /&gt;
make TARGET=sky &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once this command has been successfully executed a file named udp-server.sky will be created. This file will be used to program the remaining nodes in Cooja simulator. These nodes will form a DAG with the rpl border router as the root.&lt;br /&gt;
&lt;br /&gt;
== Testing on Cooja ==&lt;br /&gt;
 &lt;br /&gt;
Upon the successful completion of the above mentioned steps we are ready to create a simulation in Cooja.  &lt;br /&gt;
Start the Cooja simulator using the following command &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd /contiki-2.7/tools/cooja &lt;br /&gt;
ant run&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
When the GUI launches execute the following steps to create a simulation. &amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
1. From &amp;#039;File&amp;#039; select &amp;#039;New Simulation&amp;#039;. Select UDGM, enter the name of the simulation and click on create. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Click on Motes. From the drop down menu select &amp;#039;Add New Motes&amp;#039; followed by &amp;#039;Create new motes&amp;#039; and select the mote type as Sky. &amp;lt;br&amp;gt;&lt;br /&gt;
3. Browse to the location /contiki-2.7/examples/ipv6/rpl-border-router and select the file rpl-border-router.sky. Click on &amp;#039;Create&amp;#039;. Add one mote of this type. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Repeat step 2 and 3 but this time browse to the location /contiki-2.7/examples/ipv6/rpl-udp  and select the file udp-server.sky. Add 3 - 4 motes of the type udp-server &amp;lt;br&amp;gt;&lt;br /&gt;
5. Once the motes have been added you can position the motes.&lt;br /&gt;
&lt;br /&gt;
[[File:Cooja_motes.png]]&lt;br /&gt;
&lt;br /&gt;
6. Now, we need to create a bridge between the RPL network simulated on Cooja and the local machine. This can be done by right clicking on the mote which is programmed as the border router. Select &amp;#039;More tools for border router&amp;#039; and then select &amp;#039;Serial Socket (SERVER)&amp;#039;. You will get the following message on the successful completion of this step.Note that the message says &amp;#039;Listening on port 60001&amp;#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Serial_Socket.png]]&lt;br /&gt;
&lt;br /&gt;
7. Now start the simulation by clicking on Start&lt;br /&gt;
&lt;br /&gt;
== Tunslip utility ==&lt;br /&gt;
 &lt;br /&gt;
As mentioned in the introduction a border router helps in connecting one network to another. In this example the border router is used to route data between an RPL network and an external network. Till now we have only created the RPL network. Now we need to simulate the scenario in which this RPL network is connected to an external network. For this purpose we will use the Tunslip utility provided in Contiki. In this example tunslip creates a bridge between the RPL network and the local machine. &lt;br /&gt;
tunslip6.c can be found in /contiki-2.7/tools &lt;br /&gt;
Compile the tunslip6 code.&lt;br /&gt;
&amp;lt;pre&amp;gt;make tunslip6 &amp;lt;/pre&amp;gt; &lt;br /&gt;
Make a connection between the RPL network and your local machine. &lt;br /&gt;
&amp;lt;pre&amp;gt;sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64&amp;lt;/pre&amp;gt;&lt;br /&gt;
On the successful execution this command the following output will be printed on the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;slip connected to ``127.0.0.1:60001&amp;#039;&amp;#039;&lt;br /&gt;
opened tun device ``/dev/tun0&amp;#039;&amp;#039;&lt;br /&gt;
ifconfig tun0 inet `hostname` up&lt;br /&gt;
ifconfig tun0 add aaaa::1/64&lt;br /&gt;
ifconfig tun0 add fe80::0:0:0:1/64&lt;br /&gt;
ifconfig tun0&lt;br /&gt;
&lt;br /&gt;
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  &lt;br /&gt;
          inet addr:127.0.1.1  P-t-P:127.0.1.1  Mask:255.255.255.255&lt;br /&gt;
          inet6 addr: fe80::1/64 Scope:Link&lt;br /&gt;
          inet6 addr: aaaa::1/64 Scope:Global&lt;br /&gt;
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1&lt;br /&gt;
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0&lt;br /&gt;
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0&lt;br /&gt;
          collisions:0 txqueuelen:500 &lt;br /&gt;
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)&lt;br /&gt;
&lt;br /&gt;
Rime started with address 0.18.116.1.0.1.1.1&lt;br /&gt;
MAC 00:12:74:01:00:01:01:01 Contiki 2.7 started. Node id is set to 1.&lt;br /&gt;
CSMA ContikiMAC, channel check rate 8 Hz, radio channel 26&lt;br /&gt;
Tentative link-local IPv6 address fe80:0000:0000:0000:0212:7401:0001:0101&lt;br /&gt;
Starting &amp;#039;Border router process&amp;#039; &amp;#039;Web server&amp;#039;&lt;br /&gt;
*** Address:aaaa::1 =&amp;gt; aaaa:0000:0000:0000&lt;br /&gt;
Got configuration message of type P&lt;br /&gt;
Setting prefix aaaa::&lt;br /&gt;
Server IPv6 addresses:&lt;br /&gt;
 aaaa::212:7401:1:101&lt;br /&gt;
 fe80::212:7401:1:101&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Go back to the Cooja simulator GUI and look at the dialogue box. The message has now changed to &amp;#039;Client connected: /127.0.0.1&amp;#039;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Client_Connected.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Verifying Results ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can verify that the address of the border router has been set by using the ping command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7401:1:101&lt;br /&gt;
PING aaaa::212:7401:1:101(aaaa::212:7401:1:101) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=1 ttl=64 time=86.0 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=2 ttl=64 time=33.6 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=3 ttl=64 time=82.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=4 ttl=64 time=43.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=5 ttl=64 time=70.1 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7401:1:101 ping statistics ---&lt;br /&gt;
5 packets transmitted, 5 received, 0% packet loss, time 4006ms&lt;br /&gt;
rtt min/avg/max/mdev = 33.669/63.090/86.015/20.985 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also ping one of the other nodes in the network. Here we are pinging node 4&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7404:4:404&lt;br /&gt;
PING aaaa::212:7404:4:404(aaaa::212:7404:4:404) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=1 ttl=63 time=670 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=2 ttl=63 time=703 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=3 ttl=63 time=746 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=4 ttl=63 time=674 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7404:4:404 ping statistics ---&lt;br /&gt;
5 packets transmitted, 4 received, 20% packet loss, time 4001ms&lt;br /&gt;
rtt min/avg/max/mdev = 670.230/698.666/746.619/30.514 ms&lt;br /&gt;
user@instant-contiki:~/contiki-2.7$ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IPv6 address of a node can be checked from the log screen on Cooja. Filter the nodes by their ID&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Node_Address.png]]&lt;br /&gt;
&lt;br /&gt;
You can enter the address of the border router in the web browser. The border router host a page which will be displayed on the browser as shown below&lt;br /&gt;
&lt;br /&gt;
== Common Issues ==&lt;br /&gt;
&lt;br /&gt;
1. Make sure that you enter the IPv6 address properly in the command sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64 . There should be no spaces in aaaa::1/64. Otherwise the code will give unexpected behavior.&amp;lt;br&amp;gt;&lt;br /&gt;
2. When you pause the simulation the SLIP connection is lost. It might not work properly on resuming the simulation. In such cases reload the simulation. Create a fresh SLIP connection and then run the simulation again.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Ckapoor</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1075</id>
		<title>RPL Border Router</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1075"/>
				<updated>2014-11-08T09:41:33Z</updated>
		
		<summary type="html">&lt;p&gt;Ckapoor: /* Common Issues */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction: ==&lt;br /&gt;
  &lt;br /&gt;
Border routers are routers that can be found at the edge of a network. Their function is to connect one network to another. In this tutorial we will learn how to run a simulation using the border router in Contiki In the example which we will discuss in the rest of this tutorial the border router will be used to route data between a WSN (using RPL) and an external IP network.  &lt;br /&gt;
Objective:  &lt;br /&gt;
The objective of this tutorial is to give you an understanding of the RPL Border Router code on Contiki OS and learn how to simulate the code on Cooja &lt;br /&gt;
What will you learn at the end of this tutorial. At the end of the tutorial you would have learnt the following: &lt;br /&gt;
&lt;br /&gt;
1. Understanding the working of the rpl border router code &amp;lt;br&amp;gt;&lt;br /&gt;
2. Starting a simulation on Cooja simulator. &amp;lt;br&amp;gt; &lt;br /&gt;
3. Observing the results &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code building blocks. ==&lt;br /&gt;
 &lt;br /&gt;
We will using the following files &lt;br /&gt;
border-router.c &lt;br /&gt;
Go to the location /contiki-2.7/examples/ipv6/rpl-udp   and use either udp-client.c or udp-server.c to create a network of nodes.  &lt;br /&gt;
These nodes will form a DODAG with the border router set as the root. The border router will receive the prefix through a SLIP connection and it will be communicated to the rest of the nodes in the network. &lt;br /&gt;
Refer to the following code snippets in the file border-router.c In this piece of code the node configured as the border router waits for the prefix to be set. Once the prefix is set, the border router is set as the root of the DODAG after which it sets the prefix.  &lt;br /&gt;
 &lt;br /&gt;
 /* Request prefix until it has been received */ &lt;br /&gt;
  while(!prefix_set) { &lt;br /&gt;
    etimer_set(&amp;amp;et, CLOCK_SECOND); &lt;br /&gt;
    request_prefix(); &lt;br /&gt;
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&amp;amp;et)); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
  dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)dag_id); &lt;br /&gt;
  if(dag != NULL) { &lt;br /&gt;
    rpl_set_prefix(dag, &amp;amp;prefix, 64); &lt;br /&gt;
    PRINTF(&amp;quot;created a new RPL dag\n&amp;quot;); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
Explain the key points in the code. Include snippets. Add at least one Diagram. &lt;br /&gt;
&lt;br /&gt;
== Compiling the code ==&lt;br /&gt;
 &lt;br /&gt;
The code for RPL border router can be found at /contiki-2.7/examples/ipv6/rpl-border-router. Use the following command to compile the code for the border router &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-border-router &lt;br /&gt;
make TARGET=sky. &amp;lt;/pre&amp;gt;   &lt;br /&gt;
Once this command has been successfully executed a file named border-router.sky will be created. This file will be used to program one of the motes as the border router on Cooja.  &lt;br /&gt;
For the purpose of this tutorial we will  select  TMote Sky  as our target. &lt;br /&gt;
&lt;br /&gt;
In order to demonstrate the functioning of the border router we will create a network of nodes with the border router as the root. For creating such a network we will user the udp-server.c code.  &lt;br /&gt;
This code can be found at /contiki-2.7/examples/ipv6/rpl-udp . Use the following command to compile the code for rpl-udp &lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-udp &lt;br /&gt;
make TARGET=sky &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once this command has been successfully executed a file named udp-server.sky will be created. This file will be used to program the remaining nodes in Cooja simulator. These nodes will form a DAG with the rpl border router as the root.&lt;br /&gt;
&lt;br /&gt;
== Testing on Cooja ==&lt;br /&gt;
 &lt;br /&gt;
Upon the successful completion of the above mentioned steps we are ready to create a simulation in Cooja.  &lt;br /&gt;
Start the Cooja simulator using the following command &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd /contiki-2.7/tools/cooja &lt;br /&gt;
ant run&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
When the GUI launches execute the following steps to create a simulation. &amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
1. From &amp;#039;File&amp;#039; select &amp;#039;New Simulation&amp;#039;. Select UDGM, enter the name of the simulation and click on create. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Click on Motes. From the drop down menu select &amp;#039;Add New Motes&amp;#039; followed by &amp;#039;Create new motes&amp;#039; and select the mote type as Sky. &amp;lt;br&amp;gt;&lt;br /&gt;
3. Browse to the location /contiki-2.7/examples/ipv6/rpl-border-router and select the file rpl-border-router.sky. Click on &amp;#039;Create&amp;#039;. Add one mote of this type. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Repeat step 2 and 3 but this time browse to the location /contiki-2.7/examples/ipv6/rpl-udp  and select the file udp-server.sky. Add 3 - 4 motes of the type udp-server &amp;lt;br&amp;gt;&lt;br /&gt;
5. Once the motes have been added you can position the motes.&lt;br /&gt;
&lt;br /&gt;
[[File:Cooja_motes.png]]&lt;br /&gt;
&lt;br /&gt;
6. Now, we need to create a bridge between the RPL network simulated on Cooja and the local machine. This can be done by right clicking on the mote which is programmed as the border router. Select &amp;#039;More tools for border router&amp;#039; and then select &amp;#039;Serial Socket (SERVER)&amp;#039;. You will get the following message on the successful completion of this step.Note that the message says &amp;#039;Listening on port 60001&amp;#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Serial_Socket.png]]&lt;br /&gt;
&lt;br /&gt;
7. Now start the simulation by clicking on Start&lt;br /&gt;
&lt;br /&gt;
== Tunslip utility ==&lt;br /&gt;
 &lt;br /&gt;
As mentioned in the introduction a border router helps in connecting one network to another. In this example the border router is used to route data between an RPL network and an external network. Till now we have only created the RPL network. Now we need to simulate the scenario in which this RPL network is connected to an external network. For this purpose we will use the Tunslip utility provided in Contiki. In this example tunslip creates a bridge between the RPL network and the local machine. &lt;br /&gt;
tunslip6.c can be found in /contiki-2.7/tools &lt;br /&gt;
Compile the tunslip6 code.&lt;br /&gt;
&amp;lt;pre&amp;gt;make tunslip6 &amp;lt;/pre&amp;gt; &lt;br /&gt;
Make a connection between the RPL network and your local machine. &lt;br /&gt;
&amp;lt;pre&amp;gt;sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64&amp;lt;/pre&amp;gt;&lt;br /&gt;
On the successful execution this command the following output will be printed on the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;slip connected to ``127.0.0.1:60001&amp;#039;&amp;#039;&lt;br /&gt;
opened tun device ``/dev/tun0&amp;#039;&amp;#039;&lt;br /&gt;
ifconfig tun0 inet `hostname` up&lt;br /&gt;
ifconfig tun0 add aaaa::1/64&lt;br /&gt;
ifconfig tun0 add fe80::0:0:0:1/64&lt;br /&gt;
ifconfig tun0&lt;br /&gt;
&lt;br /&gt;
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  &lt;br /&gt;
          inet addr:127.0.1.1  P-t-P:127.0.1.1  Mask:255.255.255.255&lt;br /&gt;
          inet6 addr: fe80::1/64 Scope:Link&lt;br /&gt;
          inet6 addr: aaaa::1/64 Scope:Global&lt;br /&gt;
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1&lt;br /&gt;
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0&lt;br /&gt;
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0&lt;br /&gt;
          collisions:0 txqueuelen:500 &lt;br /&gt;
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)&lt;br /&gt;
&lt;br /&gt;
Rime started with address 0.18.116.1.0.1.1.1&lt;br /&gt;
MAC 00:12:74:01:00:01:01:01 Contiki 2.7 started. Node id is set to 1.&lt;br /&gt;
CSMA ContikiMAC, channel check rate 8 Hz, radio channel 26&lt;br /&gt;
Tentative link-local IPv6 address fe80:0000:0000:0000:0212:7401:0001:0101&lt;br /&gt;
Starting &amp;#039;Border router process&amp;#039; &amp;#039;Web server&amp;#039;&lt;br /&gt;
*** Address:aaaa::1 =&amp;gt; aaaa:0000:0000:0000&lt;br /&gt;
Got configuration message of type P&lt;br /&gt;
Setting prefix aaaa::&lt;br /&gt;
Server IPv6 addresses:&lt;br /&gt;
 aaaa::212:7401:1:101&lt;br /&gt;
 fe80::212:7401:1:101&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Go back to the Cooja simulator GUI and look at the dialogue box. The message has now changed to &amp;#039;Client connected: /127.0.0.1&amp;#039;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Client_Connected.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Verifying Results ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can verify that the address of the border router has been set by using the ping command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7401:1:101&lt;br /&gt;
PING aaaa::212:7401:1:101(aaaa::212:7401:1:101) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=1 ttl=64 time=86.0 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=2 ttl=64 time=33.6 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=3 ttl=64 time=82.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=4 ttl=64 time=43.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=5 ttl=64 time=70.1 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7401:1:101 ping statistics ---&lt;br /&gt;
5 packets transmitted, 5 received, 0% packet loss, time 4006ms&lt;br /&gt;
rtt min/avg/max/mdev = 33.669/63.090/86.015/20.985 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also ping one of the other nodes in the network. Here we are pinging node 4&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7404:4:404&lt;br /&gt;
PING aaaa::212:7404:4:404(aaaa::212:7404:4:404) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=1 ttl=63 time=670 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=2 ttl=63 time=703 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=3 ttl=63 time=746 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=4 ttl=63 time=674 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7404:4:404 ping statistics ---&lt;br /&gt;
5 packets transmitted, 4 received, 20% packet loss, time 4001ms&lt;br /&gt;
rtt min/avg/max/mdev = 670.230/698.666/746.619/30.514 ms&lt;br /&gt;
user@instant-contiki:~/contiki-2.7$ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IPv6 address of a node can be checked from the log screen on Cooja. Filter the nodes by their ID&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Node_Address.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Common Issues ==&lt;br /&gt;
&lt;br /&gt;
1. Make sure that you enter the IPv6 address properly in the command sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64 . There should be no spaces in aaaa::1/64. Otherwise the code will give unexpected behavior.&amp;lt;br&amp;gt;&lt;br /&gt;
2. When you pause the simulation the SLIP connection is lost. It might not work properly on resuming the simulation. In such cases reload the simulation. Create a fresh SLIP connection and then run the simulation again.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Ckapoor</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1074</id>
		<title>RPL Border Router</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1074"/>
				<updated>2014-11-08T09:40:59Z</updated>
		
		<summary type="html">&lt;p&gt;Ckapoor: /* Issues you might face */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction: ==&lt;br /&gt;
  &lt;br /&gt;
Border routers are routers that can be found at the edge of a network. Their function is to connect one network to another. In this tutorial we will learn how to run a simulation using the border router in Contiki In the example which we will discuss in the rest of this tutorial the border router will be used to route data between a WSN (using RPL) and an external IP network.  &lt;br /&gt;
Objective:  &lt;br /&gt;
The objective of this tutorial is to give you an understanding of the RPL Border Router code on Contiki OS and learn how to simulate the code on Cooja &lt;br /&gt;
What will you learn at the end of this tutorial. At the end of the tutorial you would have learnt the following: &lt;br /&gt;
&lt;br /&gt;
1. Understanding the working of the rpl border router code &amp;lt;br&amp;gt;&lt;br /&gt;
2. Starting a simulation on Cooja simulator. &amp;lt;br&amp;gt; &lt;br /&gt;
3. Observing the results &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code building blocks. ==&lt;br /&gt;
 &lt;br /&gt;
We will using the following files &lt;br /&gt;
border-router.c &lt;br /&gt;
Go to the location /contiki-2.7/examples/ipv6/rpl-udp   and use either udp-client.c or udp-server.c to create a network of nodes.  &lt;br /&gt;
These nodes will form a DODAG with the border router set as the root. The border router will receive the prefix through a SLIP connection and it will be communicated to the rest of the nodes in the network. &lt;br /&gt;
Refer to the following code snippets in the file border-router.c In this piece of code the node configured as the border router waits for the prefix to be set. Once the prefix is set, the border router is set as the root of the DODAG after which it sets the prefix.  &lt;br /&gt;
 &lt;br /&gt;
 /* Request prefix until it has been received */ &lt;br /&gt;
  while(!prefix_set) { &lt;br /&gt;
    etimer_set(&amp;amp;et, CLOCK_SECOND); &lt;br /&gt;
    request_prefix(); &lt;br /&gt;
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&amp;amp;et)); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
  dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)dag_id); &lt;br /&gt;
  if(dag != NULL) { &lt;br /&gt;
    rpl_set_prefix(dag, &amp;amp;prefix, 64); &lt;br /&gt;
    PRINTF(&amp;quot;created a new RPL dag\n&amp;quot;); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
Explain the key points in the code. Include snippets. Add at least one Diagram. &lt;br /&gt;
&lt;br /&gt;
== Compiling the code ==&lt;br /&gt;
 &lt;br /&gt;
The code for RPL border router can be found at /contiki-2.7/examples/ipv6/rpl-border-router. Use the following command to compile the code for the border router &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-border-router &lt;br /&gt;
make TARGET=sky. &amp;lt;/pre&amp;gt;   &lt;br /&gt;
Once this command has been successfully executed a file named border-router.sky will be created. This file will be used to program one of the motes as the border router on Cooja.  &lt;br /&gt;
For the purpose of this tutorial we will  select  TMote Sky  as our target. &lt;br /&gt;
&lt;br /&gt;
In order to demonstrate the functioning of the border router we will create a network of nodes with the border router as the root. For creating such a network we will user the udp-server.c code.  &lt;br /&gt;
This code can be found at /contiki-2.7/examples/ipv6/rpl-udp . Use the following command to compile the code for rpl-udp &lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-udp &lt;br /&gt;
make TARGET=sky &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once this command has been successfully executed a file named udp-server.sky will be created. This file will be used to program the remaining nodes in Cooja simulator. These nodes will form a DAG with the rpl border router as the root.&lt;br /&gt;
&lt;br /&gt;
== Testing on Cooja ==&lt;br /&gt;
 &lt;br /&gt;
Upon the successful completion of the above mentioned steps we are ready to create a simulation in Cooja.  &lt;br /&gt;
Start the Cooja simulator using the following command &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd /contiki-2.7/tools/cooja &lt;br /&gt;
ant run&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
When the GUI launches execute the following steps to create a simulation. &amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
1. From &amp;#039;File&amp;#039; select &amp;#039;New Simulation&amp;#039;. Select UDGM, enter the name of the simulation and click on create. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Click on Motes. From the drop down menu select &amp;#039;Add New Motes&amp;#039; followed by &amp;#039;Create new motes&amp;#039; and select the mote type as Sky. &amp;lt;br&amp;gt;&lt;br /&gt;
3. Browse to the location /contiki-2.7/examples/ipv6/rpl-border-router and select the file rpl-border-router.sky. Click on &amp;#039;Create&amp;#039;. Add one mote of this type. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Repeat step 2 and 3 but this time browse to the location /contiki-2.7/examples/ipv6/rpl-udp  and select the file udp-server.sky. Add 3 - 4 motes of the type udp-server &amp;lt;br&amp;gt;&lt;br /&gt;
5. Once the motes have been added you can position the motes.&lt;br /&gt;
&lt;br /&gt;
[[File:Cooja_motes.png]]&lt;br /&gt;
&lt;br /&gt;
6. Now, we need to create a bridge between the RPL network simulated on Cooja and the local machine. This can be done by right clicking on the mote which is programmed as the border router. Select &amp;#039;More tools for border router&amp;#039; and then select &amp;#039;Serial Socket (SERVER)&amp;#039;. You will get the following message on the successful completion of this step.Note that the message says &amp;#039;Listening on port 60001&amp;#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Serial_Socket.png]]&lt;br /&gt;
&lt;br /&gt;
7. Now start the simulation by clicking on Start&lt;br /&gt;
&lt;br /&gt;
== Tunslip utility ==&lt;br /&gt;
 &lt;br /&gt;
As mentioned in the introduction a border router helps in connecting one network to another. In this example the border router is used to route data between an RPL network and an external network. Till now we have only created the RPL network. Now we need to simulate the scenario in which this RPL network is connected to an external network. For this purpose we will use the Tunslip utility provided in Contiki. In this example tunslip creates a bridge between the RPL network and the local machine. &lt;br /&gt;
tunslip6.c can be found in /contiki-2.7/tools &lt;br /&gt;
Compile the tunslip6 code.&lt;br /&gt;
&amp;lt;pre&amp;gt;make tunslip6 &amp;lt;/pre&amp;gt; &lt;br /&gt;
Make a connection between the RPL network and your local machine. &lt;br /&gt;
&amp;lt;pre&amp;gt;sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64&amp;lt;/pre&amp;gt;&lt;br /&gt;
On the successful execution this command the following output will be printed on the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;slip connected to ``127.0.0.1:60001&amp;#039;&amp;#039;&lt;br /&gt;
opened tun device ``/dev/tun0&amp;#039;&amp;#039;&lt;br /&gt;
ifconfig tun0 inet `hostname` up&lt;br /&gt;
ifconfig tun0 add aaaa::1/64&lt;br /&gt;
ifconfig tun0 add fe80::0:0:0:1/64&lt;br /&gt;
ifconfig tun0&lt;br /&gt;
&lt;br /&gt;
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  &lt;br /&gt;
          inet addr:127.0.1.1  P-t-P:127.0.1.1  Mask:255.255.255.255&lt;br /&gt;
          inet6 addr: fe80::1/64 Scope:Link&lt;br /&gt;
          inet6 addr: aaaa::1/64 Scope:Global&lt;br /&gt;
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1&lt;br /&gt;
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0&lt;br /&gt;
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0&lt;br /&gt;
          collisions:0 txqueuelen:500 &lt;br /&gt;
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)&lt;br /&gt;
&lt;br /&gt;
Rime started with address 0.18.116.1.0.1.1.1&lt;br /&gt;
MAC 00:12:74:01:00:01:01:01 Contiki 2.7 started. Node id is set to 1.&lt;br /&gt;
CSMA ContikiMAC, channel check rate 8 Hz, radio channel 26&lt;br /&gt;
Tentative link-local IPv6 address fe80:0000:0000:0000:0212:7401:0001:0101&lt;br /&gt;
Starting &amp;#039;Border router process&amp;#039; &amp;#039;Web server&amp;#039;&lt;br /&gt;
*** Address:aaaa::1 =&amp;gt; aaaa:0000:0000:0000&lt;br /&gt;
Got configuration message of type P&lt;br /&gt;
Setting prefix aaaa::&lt;br /&gt;
Server IPv6 addresses:&lt;br /&gt;
 aaaa::212:7401:1:101&lt;br /&gt;
 fe80::212:7401:1:101&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Go back to the Cooja simulator GUI and look at the dialogue box. The message has now changed to &amp;#039;Client connected: /127.0.0.1&amp;#039;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Client_Connected.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Verifying Results ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can verify that the address of the border router has been set by using the ping command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7401:1:101&lt;br /&gt;
PING aaaa::212:7401:1:101(aaaa::212:7401:1:101) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=1 ttl=64 time=86.0 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=2 ttl=64 time=33.6 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=3 ttl=64 time=82.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=4 ttl=64 time=43.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=5 ttl=64 time=70.1 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7401:1:101 ping statistics ---&lt;br /&gt;
5 packets transmitted, 5 received, 0% packet loss, time 4006ms&lt;br /&gt;
rtt min/avg/max/mdev = 33.669/63.090/86.015/20.985 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also ping one of the other nodes in the network. Here we are pinging node 4&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7404:4:404&lt;br /&gt;
PING aaaa::212:7404:4:404(aaaa::212:7404:4:404) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=1 ttl=63 time=670 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=2 ttl=63 time=703 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=3 ttl=63 time=746 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=4 ttl=63 time=674 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7404:4:404 ping statistics ---&lt;br /&gt;
5 packets transmitted, 4 received, 20% packet loss, time 4001ms&lt;br /&gt;
rtt min/avg/max/mdev = 670.230/698.666/746.619/30.514 ms&lt;br /&gt;
user@instant-contiki:~/contiki-2.7$ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IPv6 address of a node can be checked from the log screen on Cooja. Filter the nodes by their ID&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Node_Address.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Common Issues ==&lt;br /&gt;
&lt;br /&gt;
1. Make sure that you enter the IPv6 address properly in the command sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64 . There should be no spaces in aaaa::1/64. Otherwise the code will give unexpected behavior.&amp;lt;br&amp;gt;&lt;br /&gt;
2. In when you pause the simulation the SLIP connection is lost. It might not work properly on resuming the simulation. In such cases reload the simulation. Create a fresh SLIP connection and then run the simulation again.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Ckapoor</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1073</id>
		<title>RPL Border Router</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1073"/>
				<updated>2014-11-08T09:40:26Z</updated>
		
		<summary type="html">&lt;p&gt;Ckapoor: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction: ==&lt;br /&gt;
  &lt;br /&gt;
Border routers are routers that can be found at the edge of a network. Their function is to connect one network to another. In this tutorial we will learn how to run a simulation using the border router in Contiki In the example which we will discuss in the rest of this tutorial the border router will be used to route data between a WSN (using RPL) and an external IP network.  &lt;br /&gt;
Objective:  &lt;br /&gt;
The objective of this tutorial is to give you an understanding of the RPL Border Router code on Contiki OS and learn how to simulate the code on Cooja &lt;br /&gt;
What will you learn at the end of this tutorial. At the end of the tutorial you would have learnt the following: &lt;br /&gt;
&lt;br /&gt;
1. Understanding the working of the rpl border router code &amp;lt;br&amp;gt;&lt;br /&gt;
2. Starting a simulation on Cooja simulator. &amp;lt;br&amp;gt; &lt;br /&gt;
3. Observing the results &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code building blocks. ==&lt;br /&gt;
 &lt;br /&gt;
We will using the following files &lt;br /&gt;
border-router.c &lt;br /&gt;
Go to the location /contiki-2.7/examples/ipv6/rpl-udp   and use either udp-client.c or udp-server.c to create a network of nodes.  &lt;br /&gt;
These nodes will form a DODAG with the border router set as the root. The border router will receive the prefix through a SLIP connection and it will be communicated to the rest of the nodes in the network. &lt;br /&gt;
Refer to the following code snippets in the file border-router.c In this piece of code the node configured as the border router waits for the prefix to be set. Once the prefix is set, the border router is set as the root of the DODAG after which it sets the prefix.  &lt;br /&gt;
 &lt;br /&gt;
 /* Request prefix until it has been received */ &lt;br /&gt;
  while(!prefix_set) { &lt;br /&gt;
    etimer_set(&amp;amp;et, CLOCK_SECOND); &lt;br /&gt;
    request_prefix(); &lt;br /&gt;
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&amp;amp;et)); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
  dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)dag_id); &lt;br /&gt;
  if(dag != NULL) { &lt;br /&gt;
    rpl_set_prefix(dag, &amp;amp;prefix, 64); &lt;br /&gt;
    PRINTF(&amp;quot;created a new RPL dag\n&amp;quot;); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
Explain the key points in the code. Include snippets. Add at least one Diagram. &lt;br /&gt;
&lt;br /&gt;
== Compiling the code ==&lt;br /&gt;
 &lt;br /&gt;
The code for RPL border router can be found at /contiki-2.7/examples/ipv6/rpl-border-router. Use the following command to compile the code for the border router &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-border-router &lt;br /&gt;
make TARGET=sky. &amp;lt;/pre&amp;gt;   &lt;br /&gt;
Once this command has been successfully executed a file named border-router.sky will be created. This file will be used to program one of the motes as the border router on Cooja.  &lt;br /&gt;
For the purpose of this tutorial we will  select  TMote Sky  as our target. &lt;br /&gt;
&lt;br /&gt;
In order to demonstrate the functioning of the border router we will create a network of nodes with the border router as the root. For creating such a network we will user the udp-server.c code.  &lt;br /&gt;
This code can be found at /contiki-2.7/examples/ipv6/rpl-udp . Use the following command to compile the code for rpl-udp &lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-udp &lt;br /&gt;
make TARGET=sky &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once this command has been successfully executed a file named udp-server.sky will be created. This file will be used to program the remaining nodes in Cooja simulator. These nodes will form a DAG with the rpl border router as the root.&lt;br /&gt;
&lt;br /&gt;
== Testing on Cooja ==&lt;br /&gt;
 &lt;br /&gt;
Upon the successful completion of the above mentioned steps we are ready to create a simulation in Cooja.  &lt;br /&gt;
Start the Cooja simulator using the following command &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd /contiki-2.7/tools/cooja &lt;br /&gt;
ant run&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
When the GUI launches execute the following steps to create a simulation. &amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
1. From &amp;#039;File&amp;#039; select &amp;#039;New Simulation&amp;#039;. Select UDGM, enter the name of the simulation and click on create. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Click on Motes. From the drop down menu select &amp;#039;Add New Motes&amp;#039; followed by &amp;#039;Create new motes&amp;#039; and select the mote type as Sky. &amp;lt;br&amp;gt;&lt;br /&gt;
3. Browse to the location /contiki-2.7/examples/ipv6/rpl-border-router and select the file rpl-border-router.sky. Click on &amp;#039;Create&amp;#039;. Add one mote of this type. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Repeat step 2 and 3 but this time browse to the location /contiki-2.7/examples/ipv6/rpl-udp  and select the file udp-server.sky. Add 3 - 4 motes of the type udp-server &amp;lt;br&amp;gt;&lt;br /&gt;
5. Once the motes have been added you can position the motes.&lt;br /&gt;
&lt;br /&gt;
[[File:Cooja_motes.png]]&lt;br /&gt;
&lt;br /&gt;
6. Now, we need to create a bridge between the RPL network simulated on Cooja and the local machine. This can be done by right clicking on the mote which is programmed as the border router. Select &amp;#039;More tools for border router&amp;#039; and then select &amp;#039;Serial Socket (SERVER)&amp;#039;. You will get the following message on the successful completion of this step.Note that the message says &amp;#039;Listening on port 60001&amp;#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Serial_Socket.png]]&lt;br /&gt;
&lt;br /&gt;
7. Now start the simulation by clicking on Start&lt;br /&gt;
&lt;br /&gt;
== Tunslip utility ==&lt;br /&gt;
 &lt;br /&gt;
As mentioned in the introduction a border router helps in connecting one network to another. In this example the border router is used to route data between an RPL network and an external network. Till now we have only created the RPL network. Now we need to simulate the scenario in which this RPL network is connected to an external network. For this purpose we will use the Tunslip utility provided in Contiki. In this example tunslip creates a bridge between the RPL network and the local machine. &lt;br /&gt;
tunslip6.c can be found in /contiki-2.7/tools &lt;br /&gt;
Compile the tunslip6 code.&lt;br /&gt;
&amp;lt;pre&amp;gt;make tunslip6 &amp;lt;/pre&amp;gt; &lt;br /&gt;
Make a connection between the RPL network and your local machine. &lt;br /&gt;
&amp;lt;pre&amp;gt;sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64&amp;lt;/pre&amp;gt;&lt;br /&gt;
On the successful execution this command the following output will be printed on the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;slip connected to ``127.0.0.1:60001&amp;#039;&amp;#039;&lt;br /&gt;
opened tun device ``/dev/tun0&amp;#039;&amp;#039;&lt;br /&gt;
ifconfig tun0 inet `hostname` up&lt;br /&gt;
ifconfig tun0 add aaaa::1/64&lt;br /&gt;
ifconfig tun0 add fe80::0:0:0:1/64&lt;br /&gt;
ifconfig tun0&lt;br /&gt;
&lt;br /&gt;
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  &lt;br /&gt;
          inet addr:127.0.1.1  P-t-P:127.0.1.1  Mask:255.255.255.255&lt;br /&gt;
          inet6 addr: fe80::1/64 Scope:Link&lt;br /&gt;
          inet6 addr: aaaa::1/64 Scope:Global&lt;br /&gt;
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1&lt;br /&gt;
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0&lt;br /&gt;
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0&lt;br /&gt;
          collisions:0 txqueuelen:500 &lt;br /&gt;
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)&lt;br /&gt;
&lt;br /&gt;
Rime started with address 0.18.116.1.0.1.1.1&lt;br /&gt;
MAC 00:12:74:01:00:01:01:01 Contiki 2.7 started. Node id is set to 1.&lt;br /&gt;
CSMA ContikiMAC, channel check rate 8 Hz, radio channel 26&lt;br /&gt;
Tentative link-local IPv6 address fe80:0000:0000:0000:0212:7401:0001:0101&lt;br /&gt;
Starting &amp;#039;Border router process&amp;#039; &amp;#039;Web server&amp;#039;&lt;br /&gt;
*** Address:aaaa::1 =&amp;gt; aaaa:0000:0000:0000&lt;br /&gt;
Got configuration message of type P&lt;br /&gt;
Setting prefix aaaa::&lt;br /&gt;
Server IPv6 addresses:&lt;br /&gt;
 aaaa::212:7401:1:101&lt;br /&gt;
 fe80::212:7401:1:101&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Go back to the Cooja simulator GUI and look at the dialogue box. The message has now changed to &amp;#039;Client connected: /127.0.0.1&amp;#039;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Client_Connected.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Verifying Results ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can verify that the address of the border router has been set by using the ping command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7401:1:101&lt;br /&gt;
PING aaaa::212:7401:1:101(aaaa::212:7401:1:101) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=1 ttl=64 time=86.0 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=2 ttl=64 time=33.6 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=3 ttl=64 time=82.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=4 ttl=64 time=43.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=5 ttl=64 time=70.1 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7401:1:101 ping statistics ---&lt;br /&gt;
5 packets transmitted, 5 received, 0% packet loss, time 4006ms&lt;br /&gt;
rtt min/avg/max/mdev = 33.669/63.090/86.015/20.985 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also ping one of the other nodes in the network. Here we are pinging node 4&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7404:4:404&lt;br /&gt;
PING aaaa::212:7404:4:404(aaaa::212:7404:4:404) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=1 ttl=63 time=670 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=2 ttl=63 time=703 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=3 ttl=63 time=746 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=4 ttl=63 time=674 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7404:4:404 ping statistics ---&lt;br /&gt;
5 packets transmitted, 4 received, 20% packet loss, time 4001ms&lt;br /&gt;
rtt min/avg/max/mdev = 670.230/698.666/746.619/30.514 ms&lt;br /&gt;
user@instant-contiki:~/contiki-2.7$ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IPv6 address of a node can be checked from the log screen on Cooja. Filter the nodes by their ID&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Node_Address.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Issues you might face ==&lt;br /&gt;
&lt;br /&gt;
1. Make sure that you enter the IPv6 address properly in the command sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64 . There should be no spaces in aaaa::1/64. Otherwise the code will give unexpected behavior.&lt;br /&gt;
2. In when you pause the simulation the SLIP connection is lost. It might not work properly on resuming the simulation. In such cases reload the simulation. Create a fresh SLIP connection and then run the simulation again.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Ckapoor</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1072</id>
		<title>RPL Border Router</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1072"/>
				<updated>2014-11-08T09:26:24Z</updated>
		
		<summary type="html">&lt;p&gt;Ckapoor: /* Verifying Results */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction: ==&lt;br /&gt;
  &lt;br /&gt;
Border routers are routers that can be found at the edge of a network. Their function is to connect one network to another. In this tutorial we will learn how to run a simulation using the border router in Contiki In the example which we will discuss in the rest of this tutorial the border router will be used to route data between a WSN (using RPL) and an external IP network.  &lt;br /&gt;
Objective:  &lt;br /&gt;
The objective of this tutorial is to give you an understanding of the RPL Border Router code on Contiki OS and learn how to simulate the code on Cooja &lt;br /&gt;
What will you learn at the end of this tutorial. At the end of the tutorial you would have learnt the following: &lt;br /&gt;
&lt;br /&gt;
1. Understanding the working of the rpl border router code &amp;lt;br&amp;gt;&lt;br /&gt;
2. Starting a simulation on Cooja simulator. &amp;lt;br&amp;gt; &lt;br /&gt;
3. Observing the results &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code building blocks. ==&lt;br /&gt;
 &lt;br /&gt;
We will using the following files &lt;br /&gt;
border-router.c &lt;br /&gt;
Go to the location /contiki-2.7/examples/ipv6/rpl-udp   and use either udp-client.c or udp-server.c to create a network of nodes.  &lt;br /&gt;
These nodes will form a DODAG with the border router set as the root. The border router will receive the prefix through a SLIP connection and it will be communicated to the rest of the nodes in the network. &lt;br /&gt;
Refer to the following code snippets in the file border-router.c In this piece of code the node configured as the border router waits for the prefix to be set. Once the prefix is set, the border router is set as the root of the DODAG after which it sets the prefix.  &lt;br /&gt;
 &lt;br /&gt;
 /* Request prefix until it has been received */ &lt;br /&gt;
  while(!prefix_set) { &lt;br /&gt;
    etimer_set(&amp;amp;et, CLOCK_SECOND); &lt;br /&gt;
    request_prefix(); &lt;br /&gt;
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&amp;amp;et)); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
  dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)dag_id); &lt;br /&gt;
  if(dag != NULL) { &lt;br /&gt;
    rpl_set_prefix(dag, &amp;amp;prefix, 64); &lt;br /&gt;
    PRINTF(&amp;quot;created a new RPL dag\n&amp;quot;); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
Explain the key points in the code. Include snippets. Add at least one Diagram. &lt;br /&gt;
&lt;br /&gt;
== Compiling the code ==&lt;br /&gt;
 &lt;br /&gt;
The code for RPL border router can be found at /contiki-2.7/examples/ipv6/rpl-border-router. Use the following command to compile the code for the border router &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-border-router &lt;br /&gt;
make TARGET=sky. &amp;lt;/pre&amp;gt;   &lt;br /&gt;
Once this command has been successfully executed a file named border-router.sky will be created. This file will be used to program one of the motes as the border router on Cooja.  &lt;br /&gt;
For the purpose of this tutorial we will  select  TMote Sky  as our target. &lt;br /&gt;
&lt;br /&gt;
In order to demonstrate the functioning of the border router we will create a network of nodes with the border router as the root. For creating such a network we will user the udp-server.c code.  &lt;br /&gt;
This code can be found at /contiki-2.7/examples/ipv6/rpl-udp . Use the following command to compile the code for rpl-udp &lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-udp &lt;br /&gt;
make TARGET=sky &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once this command has been successfully executed a file named udp-server.sky will be created. This file will be used to program the remaining nodes in Cooja simulator. These nodes will form a DAG with the rpl border router as the root.&lt;br /&gt;
&lt;br /&gt;
== Testing on Cooja ==&lt;br /&gt;
 &lt;br /&gt;
Upon the successful completion of the above mentioned steps we are ready to create a simulation in Cooja.  &lt;br /&gt;
Start the Cooja simulator using the following command &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd /contiki-2.7/tools/cooja &lt;br /&gt;
ant run&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
When the GUI launches execute the following steps to create a simulation. &amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
1. From &amp;#039;File&amp;#039; select &amp;#039;New Simulation&amp;#039;. Select UDGM, enter the name of the simulation and click on create. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Click on Motes. From the drop down menu select &amp;#039;Add New Motes&amp;#039; followed by &amp;#039;Create new motes&amp;#039; and select the mote type as Sky. &amp;lt;br&amp;gt;&lt;br /&gt;
3. Browse to the location /contiki-2.7/examples/ipv6/rpl-border-router and select the file rpl-border-router.sky. Click on &amp;#039;Create&amp;#039;. Add one mote of this type. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Repeat step 2 and 3 but this time browse to the location /contiki-2.7/examples/ipv6/rpl-udp  and select the file udp-server.sky. Add 3 - 4 motes of the type udp-server &amp;lt;br&amp;gt;&lt;br /&gt;
5. Once the motes have been added you can position the motes.&lt;br /&gt;
&lt;br /&gt;
[[File:Cooja_motes.png]]&lt;br /&gt;
&lt;br /&gt;
6. Now, we need to create a bridge between the RPL network simulated on Cooja and the local machine. This can be done by right clicking on the mote which is programmed as the border router. Select &amp;#039;More tools for border router&amp;#039; and then select &amp;#039;Serial Socket (SERVER)&amp;#039;. You will get the following message on the successful completion of this step.Note that the message says &amp;#039;Listening on port 60001&amp;#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Serial_Socket.png]]&lt;br /&gt;
&lt;br /&gt;
7. Now start the simulation by clicking on Start&lt;br /&gt;
&lt;br /&gt;
== Tunslip utility ==&lt;br /&gt;
 &lt;br /&gt;
As mentioned in the introduction a border router helps in connecting one network to another. In this example the border router is used to route data between an RPL network and an external network. Till now we have only created the RPL network. Now we need to simulate the scenario in which this RPL network is connected to an external network. For this purpose we will use the Tunslip utility provided in Contiki. In this example tunslip creates a bridge between the RPL network and the local machine. &lt;br /&gt;
tunslip6.c can be found in /contiki-2.7/tools &lt;br /&gt;
Compile the tunslip6 code.&lt;br /&gt;
&amp;lt;pre&amp;gt;make tunslip6 &amp;lt;/pre&amp;gt; &lt;br /&gt;
Make a connection between the RPL network and your local machine. &lt;br /&gt;
&amp;lt;pre&amp;gt;sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64&amp;lt;/pre&amp;gt;&lt;br /&gt;
On the successful execution this command the following output will be printed on the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;slip connected to ``127.0.0.1:60001&amp;#039;&amp;#039;&lt;br /&gt;
opened tun device ``/dev/tun0&amp;#039;&amp;#039;&lt;br /&gt;
ifconfig tun0 inet `hostname` up&lt;br /&gt;
ifconfig tun0 add aaaa::1/64&lt;br /&gt;
ifconfig tun0 add fe80::0:0:0:1/64&lt;br /&gt;
ifconfig tun0&lt;br /&gt;
&lt;br /&gt;
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  &lt;br /&gt;
          inet addr:127.0.1.1  P-t-P:127.0.1.1  Mask:255.255.255.255&lt;br /&gt;
          inet6 addr: fe80::1/64 Scope:Link&lt;br /&gt;
          inet6 addr: aaaa::1/64 Scope:Global&lt;br /&gt;
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1&lt;br /&gt;
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0&lt;br /&gt;
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0&lt;br /&gt;
          collisions:0 txqueuelen:500 &lt;br /&gt;
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)&lt;br /&gt;
&lt;br /&gt;
Rime started with address 0.18.116.1.0.1.1.1&lt;br /&gt;
MAC 00:12:74:01:00:01:01:01 Contiki 2.7 started. Node id is set to 1.&lt;br /&gt;
CSMA ContikiMAC, channel check rate 8 Hz, radio channel 26&lt;br /&gt;
Tentative link-local IPv6 address fe80:0000:0000:0000:0212:7401:0001:0101&lt;br /&gt;
Starting &amp;#039;Border router process&amp;#039; &amp;#039;Web server&amp;#039;&lt;br /&gt;
*** Address:aaaa::1 =&amp;gt; aaaa:0000:0000:0000&lt;br /&gt;
Got configuration message of type P&lt;br /&gt;
Setting prefix aaaa::&lt;br /&gt;
Server IPv6 addresses:&lt;br /&gt;
 aaaa::212:7401:1:101&lt;br /&gt;
 fe80::212:7401:1:101&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Go back to the Cooja simulator GUI and look at the dialogue box. The message has now changed to &amp;#039;Client connected: /127.0.0.1&amp;#039;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Client_Connected.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Verifying Results ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can verify that the address of the border router has been set by using the ping command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7401:1:101&lt;br /&gt;
PING aaaa::212:7401:1:101(aaaa::212:7401:1:101) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=1 ttl=64 time=86.0 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=2 ttl=64 time=33.6 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=3 ttl=64 time=82.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=4 ttl=64 time=43.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=5 ttl=64 time=70.1 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7401:1:101 ping statistics ---&lt;br /&gt;
5 packets transmitted, 5 received, 0% packet loss, time 4006ms&lt;br /&gt;
rtt min/avg/max/mdev = 33.669/63.090/86.015/20.985 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also ping one of the other nodes in the network. Here we are pinging node 4&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7404:4:404&lt;br /&gt;
PING aaaa::212:7404:4:404(aaaa::212:7404:4:404) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=1 ttl=63 time=670 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=2 ttl=63 time=703 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=3 ttl=63 time=746 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=4 ttl=63 time=674 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7404:4:404 ping statistics ---&lt;br /&gt;
5 packets transmitted, 4 received, 20% packet loss, time 4001ms&lt;br /&gt;
rtt min/avg/max/mdev = 670.230/698.666/746.619/30.514 ms&lt;br /&gt;
user@instant-contiki:~/contiki-2.7$ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IPv6 address of a node can be checked from the log screen on Cooja. Filter the nodes by their ID&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Node_Address.png]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Ckapoor</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1071</id>
		<title>RPL Border Router</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1071"/>
				<updated>2014-11-08T09:24:56Z</updated>
		
		<summary type="html">&lt;p&gt;Ckapoor: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction: ==&lt;br /&gt;
  &lt;br /&gt;
Border routers are routers that can be found at the edge of a network. Their function is to connect one network to another. In this tutorial we will learn how to run a simulation using the border router in Contiki In the example which we will discuss in the rest of this tutorial the border router will be used to route data between a WSN (using RPL) and an external IP network.  &lt;br /&gt;
Objective:  &lt;br /&gt;
The objective of this tutorial is to give you an understanding of the RPL Border Router code on Contiki OS and learn how to simulate the code on Cooja &lt;br /&gt;
What will you learn at the end of this tutorial. At the end of the tutorial you would have learnt the following: &lt;br /&gt;
&lt;br /&gt;
1. Understanding the working of the rpl border router code &amp;lt;br&amp;gt;&lt;br /&gt;
2. Starting a simulation on Cooja simulator. &amp;lt;br&amp;gt; &lt;br /&gt;
3. Observing the results &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code building blocks. ==&lt;br /&gt;
 &lt;br /&gt;
We will using the following files &lt;br /&gt;
border-router.c &lt;br /&gt;
Go to the location /contiki-2.7/examples/ipv6/rpl-udp   and use either udp-client.c or udp-server.c to create a network of nodes.  &lt;br /&gt;
These nodes will form a DODAG with the border router set as the root. The border router will receive the prefix through a SLIP connection and it will be communicated to the rest of the nodes in the network. &lt;br /&gt;
Refer to the following code snippets in the file border-router.c In this piece of code the node configured as the border router waits for the prefix to be set. Once the prefix is set, the border router is set as the root of the DODAG after which it sets the prefix.  &lt;br /&gt;
 &lt;br /&gt;
 /* Request prefix until it has been received */ &lt;br /&gt;
  while(!prefix_set) { &lt;br /&gt;
    etimer_set(&amp;amp;et, CLOCK_SECOND); &lt;br /&gt;
    request_prefix(); &lt;br /&gt;
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&amp;amp;et)); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
  dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)dag_id); &lt;br /&gt;
  if(dag != NULL) { &lt;br /&gt;
    rpl_set_prefix(dag, &amp;amp;prefix, 64); &lt;br /&gt;
    PRINTF(&amp;quot;created a new RPL dag\n&amp;quot;); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
Explain the key points in the code. Include snippets. Add at least one Diagram. &lt;br /&gt;
&lt;br /&gt;
== Compiling the code ==&lt;br /&gt;
 &lt;br /&gt;
The code for RPL border router can be found at /contiki-2.7/examples/ipv6/rpl-border-router. Use the following command to compile the code for the border router &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-border-router &lt;br /&gt;
make TARGET=sky. &amp;lt;/pre&amp;gt;   &lt;br /&gt;
Once this command has been successfully executed a file named border-router.sky will be created. This file will be used to program one of the motes as the border router on Cooja.  &lt;br /&gt;
For the purpose of this tutorial we will  select  TMote Sky  as our target. &lt;br /&gt;
&lt;br /&gt;
In order to demonstrate the functioning of the border router we will create a network of nodes with the border router as the root. For creating such a network we will user the udp-server.c code.  &lt;br /&gt;
This code can be found at /contiki-2.7/examples/ipv6/rpl-udp . Use the following command to compile the code for rpl-udp &lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-udp &lt;br /&gt;
make TARGET=sky &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once this command has been successfully executed a file named udp-server.sky will be created. This file will be used to program the remaining nodes in Cooja simulator. These nodes will form a DAG with the rpl border router as the root.&lt;br /&gt;
&lt;br /&gt;
== Testing on Cooja ==&lt;br /&gt;
 &lt;br /&gt;
Upon the successful completion of the above mentioned steps we are ready to create a simulation in Cooja.  &lt;br /&gt;
Start the Cooja simulator using the following command &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd /contiki-2.7/tools/cooja &lt;br /&gt;
ant run&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
When the GUI launches execute the following steps to create a simulation. &amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
1. From &amp;#039;File&amp;#039; select &amp;#039;New Simulation&amp;#039;. Select UDGM, enter the name of the simulation and click on create. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Click on Motes. From the drop down menu select &amp;#039;Add New Motes&amp;#039; followed by &amp;#039;Create new motes&amp;#039; and select the mote type as Sky. &amp;lt;br&amp;gt;&lt;br /&gt;
3. Browse to the location /contiki-2.7/examples/ipv6/rpl-border-router and select the file rpl-border-router.sky. Click on &amp;#039;Create&amp;#039;. Add one mote of this type. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Repeat step 2 and 3 but this time browse to the location /contiki-2.7/examples/ipv6/rpl-udp  and select the file udp-server.sky. Add 3 - 4 motes of the type udp-server &amp;lt;br&amp;gt;&lt;br /&gt;
5. Once the motes have been added you can position the motes.&lt;br /&gt;
&lt;br /&gt;
[[File:Cooja_motes.png]]&lt;br /&gt;
&lt;br /&gt;
6. Now, we need to create a bridge between the RPL network simulated on Cooja and the local machine. This can be done by right clicking on the mote which is programmed as the border router. Select &amp;#039;More tools for border router&amp;#039; and then select &amp;#039;Serial Socket (SERVER)&amp;#039;. You will get the following message on the successful completion of this step.Note that the message says &amp;#039;Listening on port 60001&amp;#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Serial_Socket.png]]&lt;br /&gt;
&lt;br /&gt;
7. Now start the simulation by clicking on Start&lt;br /&gt;
&lt;br /&gt;
== Tunslip utility ==&lt;br /&gt;
 &lt;br /&gt;
As mentioned in the introduction a border router helps in connecting one network to another. In this example the border router is used to route data between an RPL network and an external network. Till now we have only created the RPL network. Now we need to simulate the scenario in which this RPL network is connected to an external network. For this purpose we will use the Tunslip utility provided in Contiki. In this example tunslip creates a bridge between the RPL network and the local machine. &lt;br /&gt;
tunslip6.c can be found in /contiki-2.7/tools &lt;br /&gt;
Compile the tunslip6 code.&lt;br /&gt;
&amp;lt;pre&amp;gt;make tunslip6 &amp;lt;/pre&amp;gt; &lt;br /&gt;
Make a connection between the RPL network and your local machine. &lt;br /&gt;
&amp;lt;pre&amp;gt;sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64&amp;lt;/pre&amp;gt;&lt;br /&gt;
On the successful execution this command the following output will be printed on the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;slip connected to ``127.0.0.1:60001&amp;#039;&amp;#039;&lt;br /&gt;
opened tun device ``/dev/tun0&amp;#039;&amp;#039;&lt;br /&gt;
ifconfig tun0 inet `hostname` up&lt;br /&gt;
ifconfig tun0 add aaaa::1/64&lt;br /&gt;
ifconfig tun0 add fe80::0:0:0:1/64&lt;br /&gt;
ifconfig tun0&lt;br /&gt;
&lt;br /&gt;
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  &lt;br /&gt;
          inet addr:127.0.1.1  P-t-P:127.0.1.1  Mask:255.255.255.255&lt;br /&gt;
          inet6 addr: fe80::1/64 Scope:Link&lt;br /&gt;
          inet6 addr: aaaa::1/64 Scope:Global&lt;br /&gt;
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1&lt;br /&gt;
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0&lt;br /&gt;
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0&lt;br /&gt;
          collisions:0 txqueuelen:500 &lt;br /&gt;
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)&lt;br /&gt;
&lt;br /&gt;
Rime started with address 0.18.116.1.0.1.1.1&lt;br /&gt;
MAC 00:12:74:01:00:01:01:01 Contiki 2.7 started. Node id is set to 1.&lt;br /&gt;
CSMA ContikiMAC, channel check rate 8 Hz, radio channel 26&lt;br /&gt;
Tentative link-local IPv6 address fe80:0000:0000:0000:0212:7401:0001:0101&lt;br /&gt;
Starting &amp;#039;Border router process&amp;#039; &amp;#039;Web server&amp;#039;&lt;br /&gt;
*** Address:aaaa::1 =&amp;gt; aaaa:0000:0000:0000&lt;br /&gt;
Got configuration message of type P&lt;br /&gt;
Setting prefix aaaa::&lt;br /&gt;
Server IPv6 addresses:&lt;br /&gt;
 aaaa::212:7401:1:101&lt;br /&gt;
 fe80::212:7401:1:101&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Go back to the Cooja simulator GUI and look at the dialogue box. The message has now changed to &amp;#039;Client connected: /127.0.0.1&amp;#039;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Client_Connected.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Verifying Results ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can verify that the address of the border router has been set by using the ping command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7401:1:101&lt;br /&gt;
PING aaaa::212:7401:1:101(aaaa::212:7401:1:101) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=1 ttl=64 time=86.0 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=2 ttl=64 time=33.6 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=3 ttl=64 time=82.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=4 ttl=64 time=43.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=5 ttl=64 time=70.1 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7401:1:101 ping statistics ---&lt;br /&gt;
5 packets transmitted, 5 received, 0% packet loss, time 4006ms&lt;br /&gt;
rtt min/avg/max/mdev = 33.669/63.090/86.015/20.985 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also ping one of the other nodes in the network. Here we are pinging node 4&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7404:4:404&lt;br /&gt;
PING aaaa::212:7404:4:404(aaaa::212:7404:4:404) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=1 ttl=63 time=670 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=2 ttl=63 time=703 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=3 ttl=63 time=746 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=4 ttl=63 time=674 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7404:4:404 ping statistics ---&lt;br /&gt;
5 packets transmitted, 4 received, 20% packet loss, time 4001ms&lt;br /&gt;
rtt min/avg/max/mdev = 670.230/698.666/746.619/30.514 ms&lt;br /&gt;
user@instant-contiki:~/contiki-2.7$ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IPv6 address of a node can be checked from the log screen on Cooja.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Node_Address.png]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Ckapoor</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1070</id>
		<title>RPL Border Router</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1070"/>
				<updated>2014-11-08T09:24:01Z</updated>
		
		<summary type="html">&lt;p&gt;Ckapoor: /* Tunslip utility */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction: ==&lt;br /&gt;
  &lt;br /&gt;
Border routers are routers that can be found at the edge of a network. Their function is to connect one network to another. In this tutorial we will learn how to run a simulation using the border router in Contiki In the example which we will discuss in the rest of this tutorial the border router will be used to route data between a WSN (using RPL) and an external IP network.  &lt;br /&gt;
Objective:  &lt;br /&gt;
The objective of this tutorial is to give you an understanding of the RPL Border Router code on Contiki OS and learn how to simulate the code on Cooja &lt;br /&gt;
What will you learn at the end of this tutorial. At the end of the tutorial you would have learnt the following: &lt;br /&gt;
&lt;br /&gt;
1. Understanding the working of the rpl border router code &amp;lt;br&amp;gt;&lt;br /&gt;
2. Starting a simulation on Cooja simulator. &amp;lt;br&amp;gt; &lt;br /&gt;
3. Observing the results &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code building blocks. ==&lt;br /&gt;
 &lt;br /&gt;
We will using the following files &lt;br /&gt;
border-router.c &lt;br /&gt;
Go to the location /contiki-2.7/examples/ipv6/rpl-udp   and use either udp-client.c or udp-server.c to create a network of nodes.  &lt;br /&gt;
These nodes will form a DODAG with the border router set as the root. The border router will receive the prefix through a SLIP connection and it will be communicated to the rest of the nodes in the network. &lt;br /&gt;
Refer to the following code snippets in the file border-router.c In this piece of code the node configured as the border router waits for the prefix to be set. Once the prefix is set, the border router is set as the root of the DODAG after which it sets the prefix.  &lt;br /&gt;
 &lt;br /&gt;
 /* Request prefix until it has been received */ &lt;br /&gt;
  while(!prefix_set) { &lt;br /&gt;
    etimer_set(&amp;amp;et, CLOCK_SECOND); &lt;br /&gt;
    request_prefix(); &lt;br /&gt;
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&amp;amp;et)); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
  dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)dag_id); &lt;br /&gt;
  if(dag != NULL) { &lt;br /&gt;
    rpl_set_prefix(dag, &amp;amp;prefix, 64); &lt;br /&gt;
    PRINTF(&amp;quot;created a new RPL dag\n&amp;quot;); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
Explain the key points in the code. Include snippets. Add at least one Diagram. &lt;br /&gt;
&lt;br /&gt;
== Compiling the code ==&lt;br /&gt;
 &lt;br /&gt;
The code for RPL border router can be found at /contiki-2.7/examples/ipv6/rpl-border-router. Use the following command to compile the code for the border router &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-border-router &lt;br /&gt;
make TARGET=sky. &amp;lt;/pre&amp;gt;   &lt;br /&gt;
Once this command has been successfully executed a file named border-router.sky will be created. This file will be used to program one of the motes as the border router on Cooja.  &lt;br /&gt;
For the purpose of this tutorial we will  select  TMote Sky  as our target. &lt;br /&gt;
&lt;br /&gt;
In order to demonstrate the functioning of the border router we will create a network of nodes with the border router as the root. For creating such a network we will user the udp-server.c code.  &lt;br /&gt;
This code can be found at /contiki-2.7/examples/ipv6/rpl-udp . Use the following command to compile the code for rpl-udp &lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-udp &lt;br /&gt;
make TARGET=sky &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once this command has been successfully executed a file named udp-server.sky will be created. This file will be used to program the remaining nodes in Cooja simulator. These nodes will form a DAG with the rpl border router as the root.&lt;br /&gt;
&lt;br /&gt;
== Testing on Cooja ==&lt;br /&gt;
 &lt;br /&gt;
Upon the successful completion of the above mentioned steps we are ready to create a simulation in Cooja.  &lt;br /&gt;
Start the Cooja simulator using the following command &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd /contiki-2.7/tools/cooja &lt;br /&gt;
ant run&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
When the GUI launches execute the following steps to create a simulation. &amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
1. From &amp;#039;File&amp;#039; select &amp;#039;New Simulation&amp;#039;. Select UDGM, enter the name of the simulation and click on create. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Click on Motes. From the drop down menu select &amp;#039;Add New Motes&amp;#039; followed by &amp;#039;Create new motes&amp;#039; and select the mote type as Sky. &amp;lt;br&amp;gt;&lt;br /&gt;
3. Browse to the location /contiki-2.7/examples/ipv6/rpl-border-router and select the file rpl-border-router.sky. Click on &amp;#039;Create&amp;#039;. Add one mote of this type. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Repeat step 2 and 3 but this time browse to the location /contiki-2.7/examples/ipv6/rpl-udp  and select the file udp-server.sky. Add 3 - 4 motes of the type udp-server &amp;lt;br&amp;gt;&lt;br /&gt;
5. Once the motes have been added you can position the motes.&lt;br /&gt;
&lt;br /&gt;
[[File:Cooja_motes.png]]&lt;br /&gt;
&lt;br /&gt;
6. Now, we need to create a bridge between the RPL network simulated on Cooja and the local machine. This can be done by right clicking on the mote which is programmed as the border router. Select &amp;#039;More tools for border router&amp;#039; and then select &amp;#039;Serial Socket (SERVER)&amp;#039;. You will get the following message on the successful completion of this step.Note that the message says &amp;#039;Listening on port 60001&amp;#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Serial_Socket.png]]&lt;br /&gt;
&lt;br /&gt;
7. Now start the simulation by clicking on Start&lt;br /&gt;
&lt;br /&gt;
== Tunslip utility ==&lt;br /&gt;
 &lt;br /&gt;
As mentioned in the introduction a border router helps in connecting one network to another. In this example the border router is used to route data between an RPL network and an external network. Till now we have only created the RPL network. Now we need to simulate the scenario in which this RPL network is connected to an external network. For this purpose we will use the Tunslip utility provided in Contiki. In this example tunslip creates a bridge between the RPL network and the local machine. &lt;br /&gt;
tunslip6.c can be found in /contiki-2.7/tools &lt;br /&gt;
Compile the tunslip6 code.&lt;br /&gt;
&amp;lt;pre&amp;gt;make tunslip6 &amp;lt;/pre&amp;gt; &lt;br /&gt;
Make a connection between the RPL network and your local machine. &lt;br /&gt;
&amp;lt;pre&amp;gt;sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64&amp;lt;/pre&amp;gt;&lt;br /&gt;
On the successful execution this command the following output will be printed on the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;slip connected to ``127.0.0.1:60001&amp;#039;&amp;#039;&lt;br /&gt;
opened tun device ``/dev/tun0&amp;#039;&amp;#039;&lt;br /&gt;
ifconfig tun0 inet `hostname` up&lt;br /&gt;
ifconfig tun0 add aaaa::1/64&lt;br /&gt;
ifconfig tun0 add fe80::0:0:0:1/64&lt;br /&gt;
ifconfig tun0&lt;br /&gt;
&lt;br /&gt;
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  &lt;br /&gt;
          inet addr:127.0.1.1  P-t-P:127.0.1.1  Mask:255.255.255.255&lt;br /&gt;
          inet6 addr: fe80::1/64 Scope:Link&lt;br /&gt;
          inet6 addr: aaaa::1/64 Scope:Global&lt;br /&gt;
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1&lt;br /&gt;
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0&lt;br /&gt;
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0&lt;br /&gt;
          collisions:0 txqueuelen:500 &lt;br /&gt;
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)&lt;br /&gt;
&lt;br /&gt;
Rime started with address 0.18.116.1.0.1.1.1&lt;br /&gt;
MAC 00:12:74:01:00:01:01:01 Contiki 2.7 started. Node id is set to 1.&lt;br /&gt;
CSMA ContikiMAC, channel check rate 8 Hz, radio channel 26&lt;br /&gt;
Tentative link-local IPv6 address fe80:0000:0000:0000:0212:7401:0001:0101&lt;br /&gt;
Starting &amp;#039;Border router process&amp;#039; &amp;#039;Web server&amp;#039;&lt;br /&gt;
*** Address:aaaa::1 =&amp;gt; aaaa:0000:0000:0000&lt;br /&gt;
Got configuration message of type P&lt;br /&gt;
Setting prefix aaaa::&lt;br /&gt;
Server IPv6 addresses:&lt;br /&gt;
 aaaa::212:7401:1:101&lt;br /&gt;
 fe80::212:7401:1:101&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Go back to the Cooja simulator GUI and look at the dialogue box. The message has now changed to &amp;#039;Client connected: /127.0.0.1&amp;#039;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Client_Connected.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can verify that the address of the border router has been set by using the ping command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7401:1:101&lt;br /&gt;
PING aaaa::212:7401:1:101(aaaa::212:7401:1:101) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=1 ttl=64 time=86.0 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=2 ttl=64 time=33.6 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=3 ttl=64 time=82.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=4 ttl=64 time=43.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=5 ttl=64 time=70.1 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7401:1:101 ping statistics ---&lt;br /&gt;
5 packets transmitted, 5 received, 0% packet loss, time 4006ms&lt;br /&gt;
rtt min/avg/max/mdev = 33.669/63.090/86.015/20.985 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also ping one of the other nodes in the network. Here we are pinging node 4&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7404:4:404&lt;br /&gt;
PING aaaa::212:7404:4:404(aaaa::212:7404:4:404) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=1 ttl=63 time=670 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=2 ttl=63 time=703 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=3 ttl=63 time=746 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=4 ttl=63 time=674 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7404:4:404 ping statistics ---&lt;br /&gt;
5 packets transmitted, 4 received, 20% packet loss, time 4001ms&lt;br /&gt;
rtt min/avg/max/mdev = 670.230/698.666/746.619/30.514 ms&lt;br /&gt;
user@instant-contiki:~/contiki-2.7$ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IPv6 address of a node can be checked from the log screen on Cooja.&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Node_Address.png]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Ckapoor</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1069</id>
		<title>RPL Border Router</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1069"/>
				<updated>2014-11-08T09:23:36Z</updated>
		
		<summary type="html">&lt;p&gt;Ckapoor: /* Tunslip utility */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction: ==&lt;br /&gt;
  &lt;br /&gt;
Border routers are routers that can be found at the edge of a network. Their function is to connect one network to another. In this tutorial we will learn how to run a simulation using the border router in Contiki In the example which we will discuss in the rest of this tutorial the border router will be used to route data between a WSN (using RPL) and an external IP network.  &lt;br /&gt;
Objective:  &lt;br /&gt;
The objective of this tutorial is to give you an understanding of the RPL Border Router code on Contiki OS and learn how to simulate the code on Cooja &lt;br /&gt;
What will you learn at the end of this tutorial. At the end of the tutorial you would have learnt the following: &lt;br /&gt;
&lt;br /&gt;
1. Understanding the working of the rpl border router code &amp;lt;br&amp;gt;&lt;br /&gt;
2. Starting a simulation on Cooja simulator. &amp;lt;br&amp;gt; &lt;br /&gt;
3. Observing the results &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code building blocks. ==&lt;br /&gt;
 &lt;br /&gt;
We will using the following files &lt;br /&gt;
border-router.c &lt;br /&gt;
Go to the location /contiki-2.7/examples/ipv6/rpl-udp   and use either udp-client.c or udp-server.c to create a network of nodes.  &lt;br /&gt;
These nodes will form a DODAG with the border router set as the root. The border router will receive the prefix through a SLIP connection and it will be communicated to the rest of the nodes in the network. &lt;br /&gt;
Refer to the following code snippets in the file border-router.c In this piece of code the node configured as the border router waits for the prefix to be set. Once the prefix is set, the border router is set as the root of the DODAG after which it sets the prefix.  &lt;br /&gt;
 &lt;br /&gt;
 /* Request prefix until it has been received */ &lt;br /&gt;
  while(!prefix_set) { &lt;br /&gt;
    etimer_set(&amp;amp;et, CLOCK_SECOND); &lt;br /&gt;
    request_prefix(); &lt;br /&gt;
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&amp;amp;et)); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
  dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)dag_id); &lt;br /&gt;
  if(dag != NULL) { &lt;br /&gt;
    rpl_set_prefix(dag, &amp;amp;prefix, 64); &lt;br /&gt;
    PRINTF(&amp;quot;created a new RPL dag\n&amp;quot;); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
Explain the key points in the code. Include snippets. Add at least one Diagram. &lt;br /&gt;
&lt;br /&gt;
== Compiling the code ==&lt;br /&gt;
 &lt;br /&gt;
The code for RPL border router can be found at /contiki-2.7/examples/ipv6/rpl-border-router. Use the following command to compile the code for the border router &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-border-router &lt;br /&gt;
make TARGET=sky. &amp;lt;/pre&amp;gt;   &lt;br /&gt;
Once this command has been successfully executed a file named border-router.sky will be created. This file will be used to program one of the motes as the border router on Cooja.  &lt;br /&gt;
For the purpose of this tutorial we will  select  TMote Sky  as our target. &lt;br /&gt;
&lt;br /&gt;
In order to demonstrate the functioning of the border router we will create a network of nodes with the border router as the root. For creating such a network we will user the udp-server.c code.  &lt;br /&gt;
This code can be found at /contiki-2.7/examples/ipv6/rpl-udp . Use the following command to compile the code for rpl-udp &lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-udp &lt;br /&gt;
make TARGET=sky &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once this command has been successfully executed a file named udp-server.sky will be created. This file will be used to program the remaining nodes in Cooja simulator. These nodes will form a DAG with the rpl border router as the root.&lt;br /&gt;
&lt;br /&gt;
== Testing on Cooja ==&lt;br /&gt;
 &lt;br /&gt;
Upon the successful completion of the above mentioned steps we are ready to create a simulation in Cooja.  &lt;br /&gt;
Start the Cooja simulator using the following command &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd /contiki-2.7/tools/cooja &lt;br /&gt;
ant run&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
When the GUI launches execute the following steps to create a simulation. &amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
1. From &amp;#039;File&amp;#039; select &amp;#039;New Simulation&amp;#039;. Select UDGM, enter the name of the simulation and click on create. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Click on Motes. From the drop down menu select &amp;#039;Add New Motes&amp;#039; followed by &amp;#039;Create new motes&amp;#039; and select the mote type as Sky. &amp;lt;br&amp;gt;&lt;br /&gt;
3. Browse to the location /contiki-2.7/examples/ipv6/rpl-border-router and select the file rpl-border-router.sky. Click on &amp;#039;Create&amp;#039;. Add one mote of this type. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Repeat step 2 and 3 but this time browse to the location /contiki-2.7/examples/ipv6/rpl-udp  and select the file udp-server.sky. Add 3 - 4 motes of the type udp-server &amp;lt;br&amp;gt;&lt;br /&gt;
5. Once the motes have been added you can position the motes.&lt;br /&gt;
&lt;br /&gt;
[[File:Cooja_motes.png]]&lt;br /&gt;
&lt;br /&gt;
6. Now, we need to create a bridge between the RPL network simulated on Cooja and the local machine. This can be done by right clicking on the mote which is programmed as the border router. Select &amp;#039;More tools for border router&amp;#039; and then select &amp;#039;Serial Socket (SERVER)&amp;#039;. You will get the following message on the successful completion of this step.Note that the message says &amp;#039;Listening on port 60001&amp;#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Serial_Socket.png]]&lt;br /&gt;
&lt;br /&gt;
7. Now start the simulation by clicking on Start&lt;br /&gt;
&lt;br /&gt;
== Tunslip utility ==&lt;br /&gt;
 &lt;br /&gt;
As mentioned in the introduction a border router helps in connecting one network to another. In this example the border router is used to route data between an RPL network and an external network. Till now we have only created the RPL network. Now we need to simulate the scenario in which this RPL network is connected to an external network. For this purpose we will use the Tunslip utility provided in Contiki. In this example tunslip creates a bridge between the RPL network and the local machine. &lt;br /&gt;
tunslip6.c can be found in /contiki-2.7/tools &lt;br /&gt;
Compile the tunslip6 code.&lt;br /&gt;
&amp;lt;pre&amp;gt;make tunslip6 &amp;lt;/pre&amp;gt; &lt;br /&gt;
Make a connection between the RPL network and your local machine. &lt;br /&gt;
&amp;lt;pre&amp;gt;sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64&amp;lt;/pre&amp;gt;&lt;br /&gt;
On the successful execution this command the following output will be printed on the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;slip connected to ``127.0.0.1:60001&amp;#039;&amp;#039;&lt;br /&gt;
opened tun device ``/dev/tun0&amp;#039;&amp;#039;&lt;br /&gt;
ifconfig tun0 inet `hostname` up&lt;br /&gt;
ifconfig tun0 add aaaa::1/64&lt;br /&gt;
ifconfig tun0 add fe80::0:0:0:1/64&lt;br /&gt;
ifconfig tun0&lt;br /&gt;
&lt;br /&gt;
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  &lt;br /&gt;
          inet addr:127.0.1.1  P-t-P:127.0.1.1  Mask:255.255.255.255&lt;br /&gt;
          inet6 addr: fe80::1/64 Scope:Link&lt;br /&gt;
          inet6 addr: aaaa::1/64 Scope:Global&lt;br /&gt;
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1&lt;br /&gt;
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0&lt;br /&gt;
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0&lt;br /&gt;
          collisions:0 txqueuelen:500 &lt;br /&gt;
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)&lt;br /&gt;
&lt;br /&gt;
Rime started with address 0.18.116.1.0.1.1.1&lt;br /&gt;
MAC 00:12:74:01:00:01:01:01 Contiki 2.7 started. Node id is set to 1.&lt;br /&gt;
CSMA ContikiMAC, channel check rate 8 Hz, radio channel 26&lt;br /&gt;
Tentative link-local IPv6 address fe80:0000:0000:0000:0212:7401:0001:0101&lt;br /&gt;
Starting &amp;#039;Border router process&amp;#039; &amp;#039;Web server&amp;#039;&lt;br /&gt;
*** Address:aaaa::1 =&amp;gt; aaaa:0000:0000:0000&lt;br /&gt;
Got configuration message of type P&lt;br /&gt;
Setting prefix aaaa::&lt;br /&gt;
Server IPv6 addresses:&lt;br /&gt;
 aaaa::212:7401:1:101&lt;br /&gt;
 fe80::212:7401:1:101&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Go back to the Cooja simulator GUI and look at the dialogue box. The message has now changed to &amp;#039;Client connected: /127.0.0.1&amp;#039;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Client_Connected.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can verify that the address of the border router has been set by using the ping command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7401:1:101&lt;br /&gt;
PING aaaa::212:7401:1:101(aaaa::212:7401:1:101) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=1 ttl=64 time=86.0 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=2 ttl=64 time=33.6 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=3 ttl=64 time=82.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=4 ttl=64 time=43.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=5 ttl=64 time=70.1 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7401:1:101 ping statistics ---&lt;br /&gt;
5 packets transmitted, 5 received, 0% packet loss, time 4006ms&lt;br /&gt;
rtt min/avg/max/mdev = 33.669/63.090/86.015/20.985 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also ping one of the other nodes in the network. Here we are pinging node 4&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7404:4:404&lt;br /&gt;
PING aaaa::212:7404:4:404(aaaa::212:7404:4:404) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=1 ttl=63 time=670 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=2 ttl=63 time=703 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=3 ttl=63 time=746 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=4 ttl=63 time=674 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7404:4:404 ping statistics ---&lt;br /&gt;
5 packets transmitted, 4 received, 20% packet loss, time 4001ms&lt;br /&gt;
rtt min/avg/max/mdev = 670.230/698.666/746.619/30.514 ms&lt;br /&gt;
user@instant-contiki:~/contiki-2.7$ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IPv6 address of a node can be checked from the log screen on Cooja.&lt;br /&gt;
[[File:Node_Address.png]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Ckapoor</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=File:Node_Address.png&amp;diff=1068</id>
		<title>File:Node Address.png</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=File:Node_Address.png&amp;diff=1068"/>
				<updated>2014-11-08T09:22:41Z</updated>
		
		<summary type="html">&lt;p&gt;Ckapoor: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ckapoor</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1067</id>
		<title>RPL Border Router</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1067"/>
				<updated>2014-11-08T09:20:59Z</updated>
		
		<summary type="html">&lt;p&gt;Ckapoor: /* Tunslip utility */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction: ==&lt;br /&gt;
  &lt;br /&gt;
Border routers are routers that can be found at the edge of a network. Their function is to connect one network to another. In this tutorial we will learn how to run a simulation using the border router in Contiki In the example which we will discuss in the rest of this tutorial the border router will be used to route data between a WSN (using RPL) and an external IP network.  &lt;br /&gt;
Objective:  &lt;br /&gt;
The objective of this tutorial is to give you an understanding of the RPL Border Router code on Contiki OS and learn how to simulate the code on Cooja &lt;br /&gt;
What will you learn at the end of this tutorial. At the end of the tutorial you would have learnt the following: &lt;br /&gt;
&lt;br /&gt;
1. Understanding the working of the rpl border router code &amp;lt;br&amp;gt;&lt;br /&gt;
2. Starting a simulation on Cooja simulator. &amp;lt;br&amp;gt; &lt;br /&gt;
3. Observing the results &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code building blocks. ==&lt;br /&gt;
 &lt;br /&gt;
We will using the following files &lt;br /&gt;
border-router.c &lt;br /&gt;
Go to the location /contiki-2.7/examples/ipv6/rpl-udp   and use either udp-client.c or udp-server.c to create a network of nodes.  &lt;br /&gt;
These nodes will form a DODAG with the border router set as the root. The border router will receive the prefix through a SLIP connection and it will be communicated to the rest of the nodes in the network. &lt;br /&gt;
Refer to the following code snippets in the file border-router.c In this piece of code the node configured as the border router waits for the prefix to be set. Once the prefix is set, the border router is set as the root of the DODAG after which it sets the prefix.  &lt;br /&gt;
 &lt;br /&gt;
 /* Request prefix until it has been received */ &lt;br /&gt;
  while(!prefix_set) { &lt;br /&gt;
    etimer_set(&amp;amp;et, CLOCK_SECOND); &lt;br /&gt;
    request_prefix(); &lt;br /&gt;
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&amp;amp;et)); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
  dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)dag_id); &lt;br /&gt;
  if(dag != NULL) { &lt;br /&gt;
    rpl_set_prefix(dag, &amp;amp;prefix, 64); &lt;br /&gt;
    PRINTF(&amp;quot;created a new RPL dag\n&amp;quot;); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
Explain the key points in the code. Include snippets. Add at least one Diagram. &lt;br /&gt;
&lt;br /&gt;
== Compiling the code ==&lt;br /&gt;
 &lt;br /&gt;
The code for RPL border router can be found at /contiki-2.7/examples/ipv6/rpl-border-router. Use the following command to compile the code for the border router &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-border-router &lt;br /&gt;
make TARGET=sky. &amp;lt;/pre&amp;gt;   &lt;br /&gt;
Once this command has been successfully executed a file named border-router.sky will be created. This file will be used to program one of the motes as the border router on Cooja.  &lt;br /&gt;
For the purpose of this tutorial we will  select  TMote Sky  as our target. &lt;br /&gt;
&lt;br /&gt;
In order to demonstrate the functioning of the border router we will create a network of nodes with the border router as the root. For creating such a network we will user the udp-server.c code.  &lt;br /&gt;
This code can be found at /contiki-2.7/examples/ipv6/rpl-udp . Use the following command to compile the code for rpl-udp &lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-udp &lt;br /&gt;
make TARGET=sky &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once this command has been successfully executed a file named udp-server.sky will be created. This file will be used to program the remaining nodes in Cooja simulator. These nodes will form a DAG with the rpl border router as the root.&lt;br /&gt;
&lt;br /&gt;
== Testing on Cooja ==&lt;br /&gt;
 &lt;br /&gt;
Upon the successful completion of the above mentioned steps we are ready to create a simulation in Cooja.  &lt;br /&gt;
Start the Cooja simulator using the following command &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd /contiki-2.7/tools/cooja &lt;br /&gt;
ant run&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
When the GUI launches execute the following steps to create a simulation. &amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
1. From &amp;#039;File&amp;#039; select &amp;#039;New Simulation&amp;#039;. Select UDGM, enter the name of the simulation and click on create. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Click on Motes. From the drop down menu select &amp;#039;Add New Motes&amp;#039; followed by &amp;#039;Create new motes&amp;#039; and select the mote type as Sky. &amp;lt;br&amp;gt;&lt;br /&gt;
3. Browse to the location /contiki-2.7/examples/ipv6/rpl-border-router and select the file rpl-border-router.sky. Click on &amp;#039;Create&amp;#039;. Add one mote of this type. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Repeat step 2 and 3 but this time browse to the location /contiki-2.7/examples/ipv6/rpl-udp  and select the file udp-server.sky. Add 3 - 4 motes of the type udp-server &amp;lt;br&amp;gt;&lt;br /&gt;
5. Once the motes have been added you can position the motes.&lt;br /&gt;
&lt;br /&gt;
[[File:Cooja_motes.png]]&lt;br /&gt;
&lt;br /&gt;
6. Now, we need to create a bridge between the RPL network simulated on Cooja and the local machine. This can be done by right clicking on the mote which is programmed as the border router. Select &amp;#039;More tools for border router&amp;#039; and then select &amp;#039;Serial Socket (SERVER)&amp;#039;. You will get the following message on the successful completion of this step.Note that the message says &amp;#039;Listening on port 60001&amp;#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Serial_Socket.png]]&lt;br /&gt;
&lt;br /&gt;
7. Now start the simulation by clicking on Start&lt;br /&gt;
&lt;br /&gt;
== Tunslip utility ==&lt;br /&gt;
 &lt;br /&gt;
As mentioned in the introduction a border router helps in connecting one network to another. In this example the border router is used to route data between an RPL network and an external network. Till now we have only created the RPL network. Now we need to simulate the scenario in which this RPL network is connected to an external network. For this purpose we will use the Tunslip utility provided in Contiki. In this example tunslip creates a bridge between the RPL network and the local machine. &lt;br /&gt;
tunslip6.c can be found in /contiki-2.7/tools &lt;br /&gt;
Compile the tunslip6 code.&lt;br /&gt;
&amp;lt;pre&amp;gt;make tunslip6 &amp;lt;/pre&amp;gt; &lt;br /&gt;
Make a connection between the RPL network and your local machine. &lt;br /&gt;
&amp;lt;pre&amp;gt;sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64&amp;lt;/pre&amp;gt;&lt;br /&gt;
On the successful execution this command the following output will be printed on the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;slip connected to ``127.0.0.1:60001&amp;#039;&amp;#039;&lt;br /&gt;
opened tun device ``/dev/tun0&amp;#039;&amp;#039;&lt;br /&gt;
ifconfig tun0 inet `hostname` up&lt;br /&gt;
ifconfig tun0 add aaaa::1/64&lt;br /&gt;
ifconfig tun0 add fe80::0:0:0:1/64&lt;br /&gt;
ifconfig tun0&lt;br /&gt;
&lt;br /&gt;
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  &lt;br /&gt;
          inet addr:127.0.1.1  P-t-P:127.0.1.1  Mask:255.255.255.255&lt;br /&gt;
          inet6 addr: fe80::1/64 Scope:Link&lt;br /&gt;
          inet6 addr: aaaa::1/64 Scope:Global&lt;br /&gt;
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1&lt;br /&gt;
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0&lt;br /&gt;
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0&lt;br /&gt;
          collisions:0 txqueuelen:500 &lt;br /&gt;
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)&lt;br /&gt;
&lt;br /&gt;
Rime started with address 0.18.116.1.0.1.1.1&lt;br /&gt;
MAC 00:12:74:01:00:01:01:01 Contiki 2.7 started. Node id is set to 1.&lt;br /&gt;
CSMA ContikiMAC, channel check rate 8 Hz, radio channel 26&lt;br /&gt;
Tentative link-local IPv6 address fe80:0000:0000:0000:0212:7401:0001:0101&lt;br /&gt;
Starting &amp;#039;Border router process&amp;#039; &amp;#039;Web server&amp;#039;&lt;br /&gt;
*** Address:aaaa::1 =&amp;gt; aaaa:0000:0000:0000&lt;br /&gt;
Got configuration message of type P&lt;br /&gt;
Setting prefix aaaa::&lt;br /&gt;
Server IPv6 addresses:&lt;br /&gt;
 aaaa::212:7401:1:101&lt;br /&gt;
 fe80::212:7401:1:101&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Go back to the Cooja simulator GUI and look at the dialogue box. The message has now changed to &amp;#039;Client connected: /127.0.0.1&amp;#039;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Client_Connected.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can verify that the address of the border router has been set by using the ping command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7401:1:101&lt;br /&gt;
PING aaaa::212:7401:1:101(aaaa::212:7401:1:101) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=1 ttl=64 time=86.0 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=2 ttl=64 time=33.6 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=3 ttl=64 time=82.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=4 ttl=64 time=43.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=5 ttl=64 time=70.1 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7401:1:101 ping statistics ---&lt;br /&gt;
5 packets transmitted, 5 received, 0% packet loss, time 4006ms&lt;br /&gt;
rtt min/avg/max/mdev = 33.669/63.090/86.015/20.985 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also ping one of the other nodes in the network. Here we are pinging node 4&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7404:4:404&lt;br /&gt;
PING aaaa::212:7404:4:404(aaaa::212:7404:4:404) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=1 ttl=63 time=670 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=2 ttl=63 time=703 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=3 ttl=63 time=746 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=4 ttl=63 time=674 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7404:4:404 ping statistics ---&lt;br /&gt;
5 packets transmitted, 4 received, 20% packet loss, time 4001ms&lt;br /&gt;
rtt min/avg/max/mdev = 670.230/698.666/746.619/30.514 ms&lt;br /&gt;
user@instant-contiki:~/contiki-2.7$ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The IPv6 address of a node can be checked from the log screen on Cooja.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Ckapoor</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1066</id>
		<title>RPL Border Router</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1066"/>
				<updated>2014-11-08T09:14:51Z</updated>
		
		<summary type="html">&lt;p&gt;Ckapoor: /* Tunslip utility */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction: ==&lt;br /&gt;
  &lt;br /&gt;
Border routers are routers that can be found at the edge of a network. Their function is to connect one network to another. In this tutorial we will learn how to run a simulation using the border router in Contiki In the example which we will discuss in the rest of this tutorial the border router will be used to route data between a WSN (using RPL) and an external IP network.  &lt;br /&gt;
Objective:  &lt;br /&gt;
The objective of this tutorial is to give you an understanding of the RPL Border Router code on Contiki OS and learn how to simulate the code on Cooja &lt;br /&gt;
What will you learn at the end of this tutorial. At the end of the tutorial you would have learnt the following: &lt;br /&gt;
&lt;br /&gt;
1. Understanding the working of the rpl border router code &amp;lt;br&amp;gt;&lt;br /&gt;
2. Starting a simulation on Cooja simulator. &amp;lt;br&amp;gt; &lt;br /&gt;
3. Observing the results &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code building blocks. ==&lt;br /&gt;
 &lt;br /&gt;
We will using the following files &lt;br /&gt;
border-router.c &lt;br /&gt;
Go to the location /contiki-2.7/examples/ipv6/rpl-udp   and use either udp-client.c or udp-server.c to create a network of nodes.  &lt;br /&gt;
These nodes will form a DODAG with the border router set as the root. The border router will receive the prefix through a SLIP connection and it will be communicated to the rest of the nodes in the network. &lt;br /&gt;
Refer to the following code snippets in the file border-router.c In this piece of code the node configured as the border router waits for the prefix to be set. Once the prefix is set, the border router is set as the root of the DODAG after which it sets the prefix.  &lt;br /&gt;
 &lt;br /&gt;
 /* Request prefix until it has been received */ &lt;br /&gt;
  while(!prefix_set) { &lt;br /&gt;
    etimer_set(&amp;amp;et, CLOCK_SECOND); &lt;br /&gt;
    request_prefix(); &lt;br /&gt;
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&amp;amp;et)); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
  dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)dag_id); &lt;br /&gt;
  if(dag != NULL) { &lt;br /&gt;
    rpl_set_prefix(dag, &amp;amp;prefix, 64); &lt;br /&gt;
    PRINTF(&amp;quot;created a new RPL dag\n&amp;quot;); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
Explain the key points in the code. Include snippets. Add at least one Diagram. &lt;br /&gt;
&lt;br /&gt;
== Compiling the code ==&lt;br /&gt;
 &lt;br /&gt;
The code for RPL border router can be found at /contiki-2.7/examples/ipv6/rpl-border-router. Use the following command to compile the code for the border router &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-border-router &lt;br /&gt;
make TARGET=sky. &amp;lt;/pre&amp;gt;   &lt;br /&gt;
Once this command has been successfully executed a file named border-router.sky will be created. This file will be used to program one of the motes as the border router on Cooja.  &lt;br /&gt;
For the purpose of this tutorial we will  select  TMote Sky  as our target. &lt;br /&gt;
&lt;br /&gt;
In order to demonstrate the functioning of the border router we will create a network of nodes with the border router as the root. For creating such a network we will user the udp-server.c code.  &lt;br /&gt;
This code can be found at /contiki-2.7/examples/ipv6/rpl-udp . Use the following command to compile the code for rpl-udp &lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-udp &lt;br /&gt;
make TARGET=sky &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once this command has been successfully executed a file named udp-server.sky will be created. This file will be used to program the remaining nodes in Cooja simulator. These nodes will form a DAG with the rpl border router as the root.&lt;br /&gt;
&lt;br /&gt;
== Testing on Cooja ==&lt;br /&gt;
 &lt;br /&gt;
Upon the successful completion of the above mentioned steps we are ready to create a simulation in Cooja.  &lt;br /&gt;
Start the Cooja simulator using the following command &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd /contiki-2.7/tools/cooja &lt;br /&gt;
ant run&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
When the GUI launches execute the following steps to create a simulation. &amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
1. From &amp;#039;File&amp;#039; select &amp;#039;New Simulation&amp;#039;. Select UDGM, enter the name of the simulation and click on create. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Click on Motes. From the drop down menu select &amp;#039;Add New Motes&amp;#039; followed by &amp;#039;Create new motes&amp;#039; and select the mote type as Sky. &amp;lt;br&amp;gt;&lt;br /&gt;
3. Browse to the location /contiki-2.7/examples/ipv6/rpl-border-router and select the file rpl-border-router.sky. Click on &amp;#039;Create&amp;#039;. Add one mote of this type. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Repeat step 2 and 3 but this time browse to the location /contiki-2.7/examples/ipv6/rpl-udp  and select the file udp-server.sky. Add 3 - 4 motes of the type udp-server &amp;lt;br&amp;gt;&lt;br /&gt;
5. Once the motes have been added you can position the motes.&lt;br /&gt;
&lt;br /&gt;
[[File:Cooja_motes.png]]&lt;br /&gt;
&lt;br /&gt;
6. Now, we need to create a bridge between the RPL network simulated on Cooja and the local machine. This can be done by right clicking on the mote which is programmed as the border router. Select &amp;#039;More tools for border router&amp;#039; and then select &amp;#039;Serial Socket (SERVER)&amp;#039;. You will get the following message on the successful completion of this step.Note that the message says &amp;#039;Listening on port 60001&amp;#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Serial_Socket.png]]&lt;br /&gt;
&lt;br /&gt;
7. Now start the simulation by clicking on Start&lt;br /&gt;
&lt;br /&gt;
== Tunslip utility ==&lt;br /&gt;
 &lt;br /&gt;
As mentioned in the introduction a border router helps in connecting one network to another. In this example the border router is used to route data between an RPL network and an external network. Till now we have only created the RPL network. Now we need to simulate the scenario in which this RPL network is connected to an external network. For this purpose we will use the Tunslip utility provided in Contiki. In this example tunslip creates a bridge between the RPL network and the local machine. &lt;br /&gt;
tunslip6.c can be found in /contiki-2.7/tools &lt;br /&gt;
Compile the tunslip6 code.&lt;br /&gt;
&amp;lt;pre&amp;gt;make tunslip6 &amp;lt;/pre&amp;gt; &lt;br /&gt;
Make a connection between the RPL network and your local machine. &lt;br /&gt;
&amp;lt;pre&amp;gt;sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64&amp;lt;/pre&amp;gt;&lt;br /&gt;
On the successful execution this command the following output will be printed on the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;slip connected to ``127.0.0.1:60001&amp;#039;&amp;#039;&lt;br /&gt;
opened tun device ``/dev/tun0&amp;#039;&amp;#039;&lt;br /&gt;
ifconfig tun0 inet `hostname` up&lt;br /&gt;
ifconfig tun0 add aaaa::1/64&lt;br /&gt;
ifconfig tun0 add fe80::0:0:0:1/64&lt;br /&gt;
ifconfig tun0&lt;br /&gt;
&lt;br /&gt;
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  &lt;br /&gt;
          inet addr:127.0.1.1  P-t-P:127.0.1.1  Mask:255.255.255.255&lt;br /&gt;
          inet6 addr: fe80::1/64 Scope:Link&lt;br /&gt;
          inet6 addr: aaaa::1/64 Scope:Global&lt;br /&gt;
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1&lt;br /&gt;
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0&lt;br /&gt;
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0&lt;br /&gt;
          collisions:0 txqueuelen:500 &lt;br /&gt;
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)&lt;br /&gt;
&lt;br /&gt;
Rime started with address 0.18.116.1.0.1.1.1&lt;br /&gt;
MAC 00:12:74:01:00:01:01:01 Contiki 2.7 started. Node id is set to 1.&lt;br /&gt;
CSMA ContikiMAC, channel check rate 8 Hz, radio channel 26&lt;br /&gt;
Tentative link-local IPv6 address fe80:0000:0000:0000:0212:7401:0001:0101&lt;br /&gt;
Starting &amp;#039;Border router process&amp;#039; &amp;#039;Web server&amp;#039;&lt;br /&gt;
*** Address:aaaa::1 =&amp;gt; aaaa:0000:0000:0000&lt;br /&gt;
Got configuration message of type P&lt;br /&gt;
Setting prefix aaaa::&lt;br /&gt;
Server IPv6 addresses:&lt;br /&gt;
 aaaa::212:7401:1:101&lt;br /&gt;
 fe80::212:7401:1:101&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Go back to the Cooja simulator GUI and look at the dialogue box. The message has now changed to &amp;#039;Client connected: /127.0.0.1&amp;#039;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Client_Connected.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can verify that the address of the border router has been set by using the ping command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7401:1:101&lt;br /&gt;
PING aaaa::212:7401:1:101(aaaa::212:7401:1:101) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=1 ttl=64 time=86.0 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=2 ttl=64 time=33.6 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=3 ttl=64 time=82.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=4 ttl=64 time=43.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=5 ttl=64 time=70.1 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7401:1:101 ping statistics ---&lt;br /&gt;
5 packets transmitted, 5 received, 0% packet loss, time 4006ms&lt;br /&gt;
rtt min/avg/max/mdev = 33.669/63.090/86.015/20.985 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also ping one of the other nodes in the network. Here we are pinging node 4&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7404:4:404&lt;br /&gt;
PING aaaa::212:7404:4:404(aaaa::212:7404:4:404) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=1 ttl=63 time=670 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=2 ttl=63 time=703 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=3 ttl=63 time=746 ms&lt;br /&gt;
64 bytes from aaaa::212:7404:4:404: icmp_seq=4 ttl=63 time=674 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7404:4:404 ping statistics ---&lt;br /&gt;
5 packets transmitted, 4 received, 20% packet loss, time 4001ms&lt;br /&gt;
rtt min/avg/max/mdev = 670.230/698.666/746.619/30.514 ms&lt;br /&gt;
user@instant-contiki:~/contiki-2.7$ &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Ckapoor</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1065</id>
		<title>RPL Border Router</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=RPL_Border_Router&amp;diff=1065"/>
				<updated>2014-11-08T09:11:08Z</updated>
		
		<summary type="html">&lt;p&gt;Ckapoor: /* Tunslip utility */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Introduction: ==&lt;br /&gt;
  &lt;br /&gt;
Border routers are routers that can be found at the edge of a network. Their function is to connect one network to another. In this tutorial we will learn how to run a simulation using the border router in Contiki In the example which we will discuss in the rest of this tutorial the border router will be used to route data between a WSN (using RPL) and an external IP network.  &lt;br /&gt;
Objective:  &lt;br /&gt;
The objective of this tutorial is to give you an understanding of the RPL Border Router code on Contiki OS and learn how to simulate the code on Cooja &lt;br /&gt;
What will you learn at the end of this tutorial. At the end of the tutorial you would have learnt the following: &lt;br /&gt;
&lt;br /&gt;
1. Understanding the working of the rpl border router code &amp;lt;br&amp;gt;&lt;br /&gt;
2. Starting a simulation on Cooja simulator. &amp;lt;br&amp;gt; &lt;br /&gt;
3. Observing the results &amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Code building blocks. ==&lt;br /&gt;
 &lt;br /&gt;
We will using the following files &lt;br /&gt;
border-router.c &lt;br /&gt;
Go to the location /contiki-2.7/examples/ipv6/rpl-udp   and use either udp-client.c or udp-server.c to create a network of nodes.  &lt;br /&gt;
These nodes will form a DODAG with the border router set as the root. The border router will receive the prefix through a SLIP connection and it will be communicated to the rest of the nodes in the network. &lt;br /&gt;
Refer to the following code snippets in the file border-router.c In this piece of code the node configured as the border router waits for the prefix to be set. Once the prefix is set, the border router is set as the root of the DODAG after which it sets the prefix.  &lt;br /&gt;
 &lt;br /&gt;
 /* Request prefix until it has been received */ &lt;br /&gt;
  while(!prefix_set) { &lt;br /&gt;
    etimer_set(&amp;amp;et, CLOCK_SECOND); &lt;br /&gt;
    request_prefix(); &lt;br /&gt;
    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&amp;amp;et)); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
  dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)dag_id); &lt;br /&gt;
  if(dag != NULL) { &lt;br /&gt;
    rpl_set_prefix(dag, &amp;amp;prefix, 64); &lt;br /&gt;
    PRINTF(&amp;quot;created a new RPL dag\n&amp;quot;); &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
Explain the key points in the code. Include snippets. Add at least one Diagram. &lt;br /&gt;
&lt;br /&gt;
== Compiling the code ==&lt;br /&gt;
 &lt;br /&gt;
The code for RPL border router can be found at /contiki-2.7/examples/ipv6/rpl-border-router. Use the following command to compile the code for the border router &amp;lt;br&amp;gt;&lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-border-router &lt;br /&gt;
make TARGET=sky. &amp;lt;/pre&amp;gt;   &lt;br /&gt;
Once this command has been successfully executed a file named border-router.sky will be created. This file will be used to program one of the motes as the border router on Cooja.  &lt;br /&gt;
For the purpose of this tutorial we will  select  TMote Sky  as our target. &lt;br /&gt;
&lt;br /&gt;
In order to demonstrate the functioning of the border router we will create a network of nodes with the border router as the root. For creating such a network we will user the udp-server.c code.  &lt;br /&gt;
This code can be found at /contiki-2.7/examples/ipv6/rpl-udp . Use the following command to compile the code for rpl-udp &lt;br /&gt;
 &amp;lt;pre&amp;gt;cd /contiki-2.7/examples/ipv6/rpl-udp &lt;br /&gt;
make TARGET=sky &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once this command has been successfully executed a file named udp-server.sky will be created. This file will be used to program the remaining nodes in Cooja simulator. These nodes will form a DAG with the rpl border router as the root.&lt;br /&gt;
&lt;br /&gt;
== Testing on Cooja ==&lt;br /&gt;
 &lt;br /&gt;
Upon the successful completion of the above mentioned steps we are ready to create a simulation in Cooja.  &lt;br /&gt;
Start the Cooja simulator using the following command &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cd /contiki-2.7/tools/cooja &lt;br /&gt;
ant run&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
When the GUI launches execute the following steps to create a simulation. &amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
1. From &amp;#039;File&amp;#039; select &amp;#039;New Simulation&amp;#039;. Select UDGM, enter the name of the simulation and click on create. &amp;lt;br&amp;gt;&lt;br /&gt;
2. Click on Motes. From the drop down menu select &amp;#039;Add New Motes&amp;#039; followed by &amp;#039;Create new motes&amp;#039; and select the mote type as Sky. &amp;lt;br&amp;gt;&lt;br /&gt;
3. Browse to the location /contiki-2.7/examples/ipv6/rpl-border-router and select the file rpl-border-router.sky. Click on &amp;#039;Create&amp;#039;. Add one mote of this type. &amp;lt;br&amp;gt;&lt;br /&gt;
4. Repeat step 2 and 3 but this time browse to the location /contiki-2.7/examples/ipv6/rpl-udp  and select the file udp-server.sky. Add 3 - 4 motes of the type udp-server &amp;lt;br&amp;gt;&lt;br /&gt;
5. Once the motes have been added you can position the motes.&lt;br /&gt;
&lt;br /&gt;
[[File:Cooja_motes.png]]&lt;br /&gt;
&lt;br /&gt;
6. Now, we need to create a bridge between the RPL network simulated on Cooja and the local machine. This can be done by right clicking on the mote which is programmed as the border router. Select &amp;#039;More tools for border router&amp;#039; and then select &amp;#039;Serial Socket (SERVER)&amp;#039;. You will get the following message on the successful completion of this step.Note that the message says &amp;#039;Listening on port 60001&amp;#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Serial_Socket.png]]&lt;br /&gt;
&lt;br /&gt;
7. Now start the simulation by clicking on Start&lt;br /&gt;
&lt;br /&gt;
== Tunslip utility ==&lt;br /&gt;
 &lt;br /&gt;
As mentioned in the introduction a border router helps in connecting one network to another. In this example the border router is used to route data between an RPL network and an external network. Till now we have only created the RPL network. Now we need to simulate the scenario in which this RPL network is connected to an external network. For this purpose we will use the Tunslip utility provided in Contiki. In this example tunslip creates a bridge between the RPL network and the local machine. &lt;br /&gt;
tunslip6.c can be found in /contiki-2.7/tools &lt;br /&gt;
Compile the tunslip6 code.&lt;br /&gt;
&amp;lt;pre&amp;gt;make tunslip6 &amp;lt;/pre&amp;gt; &lt;br /&gt;
Make a connection between the RPL network and your local machine. &lt;br /&gt;
&amp;lt;pre&amp;gt;sudo ./tunslip6 -a 127.0.0.1 aaaa::1/64&amp;lt;/pre&amp;gt;&lt;br /&gt;
On the successful execution this command the following output will be printed on the terminal.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;slip connected to ``127.0.0.1:60001&amp;#039;&amp;#039;&lt;br /&gt;
opened tun device ``/dev/tun0&amp;#039;&amp;#039;&lt;br /&gt;
ifconfig tun0 inet `hostname` up&lt;br /&gt;
ifconfig tun0 add aaaa::1/64&lt;br /&gt;
ifconfig tun0 add fe80::0:0:0:1/64&lt;br /&gt;
ifconfig tun0&lt;br /&gt;
&lt;br /&gt;
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  &lt;br /&gt;
          inet addr:127.0.1.1  P-t-P:127.0.1.1  Mask:255.255.255.255&lt;br /&gt;
          inet6 addr: fe80::1/64 Scope:Link&lt;br /&gt;
          inet6 addr: aaaa::1/64 Scope:Global&lt;br /&gt;
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1&lt;br /&gt;
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0&lt;br /&gt;
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0&lt;br /&gt;
          collisions:0 txqueuelen:500 &lt;br /&gt;
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)&lt;br /&gt;
&lt;br /&gt;
Rime started with address 0.18.116.1.0.1.1.1&lt;br /&gt;
MAC 00:12:74:01:00:01:01:01 Contiki 2.7 started. Node id is set to 1.&lt;br /&gt;
CSMA ContikiMAC, channel check rate 8 Hz, radio channel 26&lt;br /&gt;
Tentative link-local IPv6 address fe80:0000:0000:0000:0212:7401:0001:0101&lt;br /&gt;
Starting &amp;#039;Border router process&amp;#039; &amp;#039;Web server&amp;#039;&lt;br /&gt;
*** Address:aaaa::1 =&amp;gt; aaaa:0000:0000:0000&lt;br /&gt;
Got configuration message of type P&lt;br /&gt;
Setting prefix aaaa::&lt;br /&gt;
Server IPv6 addresses:&lt;br /&gt;
 aaaa::212:7401:1:101&lt;br /&gt;
 fe80::212:7401:1:101&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Go back to the Cooja simulator GUI and look at the dialogue box. The message has now changed to &amp;#039;Client connected: /127.0.0.1&amp;#039;&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:Client_Connected.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can verify that the address of the border router has been set by using the ping command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;user@instant-contiki:~/contiki-2.7$ ping6 aaaa::212:7401:1:101&lt;br /&gt;
PING aaaa::212:7401:1:101(aaaa::212:7401:1:101) 56 data bytes&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=1 ttl=64 time=86.0 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=2 ttl=64 time=33.6 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=3 ttl=64 time=82.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=4 ttl=64 time=43.3 ms&lt;br /&gt;
64 bytes from aaaa::212:7401:1:101: icmp_seq=5 ttl=64 time=70.1 ms&lt;br /&gt;
^C&lt;br /&gt;
--- aaaa::212:7401:1:101 ping statistics ---&lt;br /&gt;
5 packets transmitted, 5 received, 0% packet loss, time 4006ms&lt;br /&gt;
rtt min/avg/max/mdev = 33.669/63.090/86.015/20.985 ms&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Ckapoor</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=File:Cooja_motes.png&amp;diff=1064</id>
		<title>File:Cooja motes.png</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=File:Cooja_motes.png&amp;diff=1064"/>
				<updated>2014-11-08T09:06:29Z</updated>
		
		<summary type="html">&lt;p&gt;Ckapoor: Ckapoor uploaded a new version of &amp;amp;quot;File:Cooja motes.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ckapoor</name></author>	</entry>

	<entry>
		<id>http://anrg.usc.edu/contiki/index.php?title=File:Serial_Socket.png&amp;diff=1063</id>
		<title>File:Serial Socket.png</title>
		<link rel="alternate" type="text/html" href="http://anrg.usc.edu/contiki/index.php?title=File:Serial_Socket.png&amp;diff=1063"/>
				<updated>2014-11-08T09:05:41Z</updated>
		
		<summary type="html">&lt;p&gt;Ckapoor: Ckapoor uploaded a new version of &amp;amp;quot;File:Serial Socket.png&amp;amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Ckapoor</name></author>	</entry>

	</feed>