Difference between revisions of "RPL Border Router"

From Contiki
Jump to: navigation, search
(Testing on Cooja)
(Testing on Cooja)
Line 60: Line 60:
 
ant run  
 
ant run  
  
1. When the GUI launches execute the following steps to create a simulation  
+
1. When the GUI launches execute the following steps to create a simulation. <br>
2. From 'File' select 'New Simulation'. Select UDGM, enter the name of the simulation and click on create.  
+
2. From 'File' select 'New Simulation'. Select UDGM, enter the name of the simulation and click on create. <br>
3. Click on Motes. From the drop down menu select 'Add New Motes' and select the mote type as Sky.
+
3. Click on Motes. From the drop down menu select 'Add New Motes' and select the mote type as Sky. <br>
  
 
== Tunslip utility ==
 
== Tunslip utility ==

Revision as of 18:33, 7 November 2014

Introduction:

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. Objective: 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 What will you learn at the end of this tutorial. At the end of the tutorial you would have learnt the following: Understanding the working of the code Starting a simulation on Cooja Observing the results


Code building blocks.

We will using the following files border-router.c 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. 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. 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.

/* Request prefix until it has been received */ 
 while(!prefix_set) { 
   etimer_set(&et, CLOCK_SECOND); 
   request_prefix(); 
   PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et)); 
 } 


 dag = rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t *)dag_id); 
 if(dag != NULL) { 
   rpl_set_prefix(dag, &prefix, 64); 
   PRINTF("created a new RPL dag\n"); 
 } 

Explain the key points in the code. Include snippets. Add at least one Diagram.

Compiling the code

The code for RPL border router can be found at /contiki-2.7/examples/ipv6/rpl-border-router. Go to the location using the following command

cd /contiki-2.7/examples/ipv6/rpl-border-router 

The file name is border-router.c Use the following command to compile the code for the border router make TARGET=sky. 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. For the purpose of this tutorial we will select TMote Sky as our target. 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. This code can be found at /contiki-2.7/examples/ipv6/rpl-udp . Go to the location using the following command

cd /contiki-2.7/examples/ipv6/rpl-udp 

Use the following command to compile the code for rpl-udp make TARGET=sky. 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.


Testing on Cooja

Upon the successful completion of the above mentioned steps we are ready to create a simulation in Cooja. Start the Cooja simulator using the following command

cd /contiki-2.7/tools/cooja ant run

1. When the GUI launches execute the following steps to create a simulation.
2. From 'File' select 'New Simulation'. Select UDGM, enter the name of the simulation and click on create.
3. Click on Motes. From the drop down menu select 'Add New Motes' and select the mote type as Sky.

Tunslip utility

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. tunslip6.c can be found in /contiki-2.7/tools Compile the tunslip6 code make tunslip6 Make a connection between the RPL network and your local machine.

sudo ./ tunslip6 -a 127.0.0.1 aaaa ::1/64


References