Skip to main content


Showing posts from May, 2020

FlowMonitor for file in ns3

Flow monitor in ns3  See the video for full instruction and hands on Step 1:  Include the header #include "ns3/flow-monitor.h" #include "ns3/flow-monitor-helper.h" Step 2:  include the follwing above the Simulator::Run() // Flow monitor  Ptr<FlowMonitor> flowMonitor; FlowMonitorHelper flowHelper; flowMonitor = flowHelper.InstallAll(); Include the following line after the Simulator::Run() flowMonitor->SerializeToXmlFile("flowthird.xml", true, true); $] ./waf --run scratch/third thirdflow.xml $] ./waf --run "scratch/third --nCsma=10 --nWifi=10" We have done Step2: compilation Step 3: How to process .xml file in ns3, there is a python file to rpocess the flowmonitor xml files. copy the /home/pradeepkumar/ns-allinone-3.27/ns-3.27/src/flow-monitor/examples/ Copy the file to ns-3.27/ or to the scratch/ folder. To run this file $] python scratch/ flowthird.xml $] python scratch/flowmon-pa

Virtual Sensor implementation in Contiki NG OS

Native Temperature, Humidity and Pressure Sensor in Contiki NG  Implementation of Three sensors namely temperature, humidity and pressure sensor in contiki NG OS. We need four files namely Step 1: Create a Folder called temperature/ in the folder contiki-ng/examples/ and then copy paste the following four files to the above folder. // mytemp.h #ifndef MYTEMP_H #define MYTEMP_H struct Sensor {  char name[15];  float value; }; struct Sensor read_temperature(); struct Sensor read_humidity(); struct Sensor read_pressure(); #endif // mytemp.c #include "mytemp.h" #include <string.h> #include <stdlib.h> float random_value(float min, float max) {  float scale = rand() / (float) RAND_MAX;  return min + scale * (max - min); } struct Sensor read_temperature() {  struct Sensor temp;  strncpy(, "Temperature", 15);  temp.value = random_value(0, 35);  return temp; } struct Sensor read_humidity() {  struct Sensor humdidty;  strncpy(, "Humidity

Counter Design in Contiki NG Operating System

Counter Design in Contiki NG OS $] make TARGET=native Step 1 - Files needed  myowncounter.h, myowncounter.c and ngcounter.c Makefile. Inside the folder contiki-ng/examples/myowncounter Step 2:  //myowncounter.h #ifndef MYOWNCOUNTER_H #define MYOWNCOUNTER_H int next_round(int temp); #endif Step 3:  //myowncounter.c #include "myowncounter.h" int next_round(int temp) { if(temp>59) temp=1; else  temp++; return temp; } Step 4:  //ngcounter.c #include "contiki.h" #include "sys/etimer.h" #include "mycounter.h" #include <stdio.h> PROCESS(mycounter_process, "My Counter Process"); AUTOSTART_PROCESSES(&mycounter_process); static struct etimer et; static int count=0; PROCESS_THREAD(mycounter_process,ev,data) { PROCESS_BEGIN(); while(1) { etimer_set(&et, CLOCK_SECOND*2); PROCESS_WAIT_EVENT_UNTIL(etimer_Expired(&et)); count=next_round(count); printf("Count Value : %d\n",count); } PROCESS_END(); } Step 5: Mak