Skip to main content

Posts

Showing posts from May, 2020

Installing ns-3.37 and ns-3.35 in Ubuntu | Ubuntu 22.04 | NS3

Multiple Versions of ns3 in Ubuntu 22.04 In this post, we are going to install two versions of ns3 namely ns-3.35 and ns-3.37  My OS is : Ubuntu 22.04 LTS (Long Term Support) ns-3.35 uses waf and (./waf --run scratch/first)  ns-3.37 uses cmake  (./ns3 run scratch/first.cc) So we will install both the packages  Go through the video for complete instructions To start with  $ sudo apt update  $ sudo apt install build-essential autoconf automake libxmu-dev g++ python3 python3-dev pkg-config sqlite3 cmake python3-setuptools git qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools gir1.2-goocanvas-2.0 python3-gi python3-gi-cairo python3-pygraphviz gir1.2-gtk-3.0 ipython3 openmpi-bin openmpi-common openmpi-doc libopenmpi-dev autoconf cvs bzr unrar gsl-bin libgsl-dev libgslcblas0 wireshark tcpdump sqlite sqlite3 libsqlite3-dev  libxml2 libxml2-dev libc6-dev libc6-dev-i386 libclang-dev llvm-dev automake python3-pip libxml2 libxml2-dev libboost-all-dev  I have downloaded both the versions of ns3 fr

FlowMonitor for third.cc file in ns3

Flow monitor in ns3 third.cc  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/flowmon-parse-results.py Copy the file to ns-3.27/ or to the scratch/ folder. To run this file $] python scratch/flowmon-parse-results.py 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(temp.name, "Temperature", 15);  temp.value = random_value(0, 35);  return temp; } struct Sensor read_humidity() {  struct Sensor humdidty;  strncpy(humdidty.name, "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