Difference between revisions of "RPL Border Router"
(→Tunslip utility) |
(→Tunslip utility) |
||
Line 81: | Line 81: | ||
<pre>make tunslip6 </pre> | <pre>make tunslip6 </pre> | ||
Make a connection between the RPL network and your local machine. | Make a connection between the RPL network and your local machine. | ||
− | |||
<pre>sudo ./ tunslip6 -a 127.0.0.1 aaaa ::1/64</pre> | <pre>sudo ./ tunslip6 -a 127.0.0.1 aaaa ::1/64</pre> | ||
+ | On the successful execution this command the following output will be printed on the terminal. | ||
== References == | == References == |
Revision as of 22:19, 7 November 2014
Contents
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:
1. Understanding the working of the rpl border router code
2. Starting a simulation on Cooja simulator.
3. 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. Use the following command to compile the code for the border router
cd /contiki-2.7/examples/ipv6/rpl-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 . Use the following command to compile the code for rpl-udp
cd /contiki-2.7/examples/ipv6/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
When the GUI launches execute the following steps to create a simulation.
1. From 'File' select 'New Simulation'. Select UDGM, enter the name of the simulation and click on create.
2. Click on Motes. From the drop down menu select 'Add New Motes' followed by 'Create new motes' and select the mote type as Sky.
3. Browse to the location /contiki-2.7/examples/ipv6/rpl-border-router and select the file rpl-border-router.sky. Click on 'Create'. Add one mote of this type.
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
5. Once the motes have been added you can position the motes.
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 'More tools for border router' and then select 'Serial Socket (SERVER)'. You will get the following message on the successful completion of this step.
7. Now start the simulation by clicking on Start
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
On the successful execution this command the following output will be printed on the terminal.