Ns3 Projects for B.E/B.Tech M.E/M.Tech PhD Scholars.  Phone-Number:9790238391   E-mail: ns3simulation@gmail.com

Best Simulator for Wireless Sensor Networks

          In general, there are several simulators in the field of wireless sensor network and mainly Cooja is denoted as the best simulator for wireless sensor networks. In addition, some the simulators have been enlisted in the following.

  • Python
  • Matlab
  • OMNeT++
  • Ns-3

       For your reference, our technical experts have highlighted the sample source code based on RPL code for node configuration in the WSN simulator.

static void
print_network_status(void)
{
int i;
uint8_t state;
uip_ds6_defrt_t *default_route;
#if RPL_WITH_STORING
uip_ds6_route_t *route;
#endif /* RPL_WITH_STORING */
#if RPL_WITH_NON_STORING
rpl_ns_node_t *link;
#endif /* RPL_WITH_NON_STORING */
PRINTF("--- Network status ---\n");
/* Our IPv6 addresses */
PRINTF("- Server IPv6 addresses:\n");
for(i = 0; i < UIP_DS6_ADDR_NB; i++) {
state = uip_ds6_if.addr_list[i].state;
if(uip_ds6_if.addr_list[i].isused &&
(state == ADDR_TENTATIVE || state == ADDR_PREFERRED)) {
PRINTF("-- ");
PRINT6ADDR(&uip_ds6_if.addr_list[i].ipaddr);
PRINTF("\n");
}
}
/* Our default route */
PRINTF("- Default route:\n");
default_route = uip_ds6_defrt_lookup(uip_ds6_defrt_choose());
if(default_route != NULL) { PRINTF("-- ");
PRINT6ADDR(&default_route->ipaddr);
PRINTF(" (lifetime: %lu seconds)\n",
(unsigned long)default_route->lifetime.interval);
} else {
PRINTF("-- None\n");
}
#if RPL_WITH_STORING
/* Our routing entries */
PRINTF("- Routing entries (%u in total):\n", uip_ds6_route_num_routes());
route = uip_ds6_route_head();
while(route != NULL) {
PRINTF("-- ");
PRINT6ADDR(&route->ipaddr);
PRINTF(" via ");
PRINT6ADDR(uip_ds6_route_nexthop(route));
PRINTF(" (lifetime: %lu seconds)\n",
(unsigned long)route->state.lifetime);
route = uip_ds6_route_next(route);
}
#endif
#if RPL_WITH_NON_STORING
/* Our routing links */
PRINTF("- Routing links (%u in total):\n", rpl_ns_num_nodes());
link = rpl_ns_node_head();
while(link != NULL) {
uip_ipaddr_t child_ipaddr;
uip_ipaddr_t parent_ipaddr;
rpl_ns_get_node_global_addr(&child_ipaddr, link);
rpl_ns_get_node_global_addr(&parent_ipaddr, link->parent);
PRINTF("-- ");
PRINT6ADDR(&child_ipaddr);
if(link->parent == NULL) {
memset(&parent_ipaddr, 0, sizeof(parent_ipaddr));
PRINTF(" --- DODAG root ");
} else {
PRINTF(" to ");
PRINT6ADDR(&parent_ipaddr);
}
PRINTF(" (lifetime: %lu seconds)\n", (unsigned long)link->lifetime);
link = rpl_ns_node_next(link);
}
#endif
uint16_t parent_etx = get_preferred_parent_etx();
const linkaddr_t *preferred_parent_addr = get_preferred_parent_addr();
PRINTF("- Link statistics: Parent ETX: addr %d %d etx %d\n",
preferred_parent_addr->u8[6], preferred_parent_addr->u8[7], parent_etx);
PRINTF("----------------------\n");
}

        On the other hand, we have highlighted the process to run the WSN simulation using Cooja through the implementation of below mentioned commands in terminal.

cd contiki/tools/cooja

ant run

Opening Cooja in Contiki

        Then, we have to select the configuration file to start the simulation window as shown in the following image.

        Finally, we have highlighted the result that is acquired through the implementation of WSN simulation.

Result of WSN Simulation

          If you have any issues, then feel free to ring us and clarify your doubts.