Simulate Internet-of-Things (IOT) using NetSim

How to simulate Internet-of-Things (IoT) using NetSim


netsim-iot-gui-configurator
NetSim GUI- Configurator

NetSim is a discrete event simulator covering a broad range of wired, wireless, mobile and sensor networks that comes with a user-friendly GUI which features. read on to get an idea of how IOT networks are simulated in NetSim..

NetSim IoT Design

  • Devices: Sensors, Cameras, 6LoWPAN Gateway, Routers, Switches, Access Points, Nodes etc. that can be dragged and dropped for network design
  • Data link and physical layer implementation as per IEEE 802.15.4 standard
  • Network layer support for both on IPv4 and IPv6
  • Adhoc IPv6 Routing support for AODV and RPL
Netsim-iot-analytics-dashboard
NetSim Analytics Dashboard

NetSim Output Analytics

  • Results Dash Board to see the information at a glance
  • Packet and Event Trace with microsecond accuracy and tools to exploit the high resolution of network data
  • Packet Animator to see the flow of packets in the network
  • Visualization scripts for Route formation, Energy consumption etc

NetSim Applications

Know how NetSim is used for emulation of SCADA converged IP Communication networks for smart grids

R&D Projects with Source C Code and Documentation

Continue reading Simulate Internet-of-Things (IOT) using NetSim

Analyzing NetSim Packet trace using Pivot tables

NetSim Packet trace is saved as a spread sheet and can be converted to an Excel table to make the management and analysis of data easier. A table typically contains related data in a series of worksheet rows and columns that have been formatted as a table. By using the table features, you can then manage the data in the table rows and columns independently from the data in other rows and columns on the worksheet.

PivotTables are a great way to summarize, analyse, explore, and present your data, and you can create them with just a few clicks. PivotTables are highly flexible and can be quickly adjusted depending on how you need to display your results. You can also create Pivot Charts based on PivotTables that will automatically update when your PivotTables do.

Following are the steps to analyse the packet trace using pivot tables (using Excel 2013)

Step1. Click on a cell and then click on Format as Table

The Excel would ask you for the range of the data set and in general Excel would automatically choose till the last row, as shown below

Click OK and then the spread sheet will be converted to a table as shown below

Step 2. Next, from the Insert tab, click the PivotTable command.

Step 3. The Create Pivot Table dialog box will appear. Click on OK

Step 4. A blank PivotTable and Field List will appear on a new worksheet

Step 5. Once you create a Pivot Table, you’ll need to decide which fields to add. Each field is simply a column header from the source data. In the Pivot Table Field List, check the box for each field you want to add.

Step 6. If you want to analyse packets sent from all sources to all destinations, then check SOURCE_ID, DESTINATION_ID and CONTROL_PACKET_TYPE/APP_NAME.

Step 7. The selected fields will be added to one of the four areas below the Field List. Click SOURCE_ID, hold it and drag to the ROW field. Similarly, DESTINATION_ID to COLUMNS and CONTROL_PACKET_TYPE/APP_NAME VALUES

Step 8. The Pivot Table will calculate and summarize the selected fields. In this example, the Pivot Table shows the packets sent from all sources to all destinations.

Step 9. The above example shows all the packets which including data packets and control packets.

Step 10. If you wish to know how many were Data and how many were control packets then, check the PACKET_TYPE and drag it to the ROWS field

Step 11. This will look like

Step 12. Further, if you wish to know how many packets got errored and how many were successful, check the PACKET_STATUS field and drag it to the ROWS field.

Video: “How to analyze and visualize simulation output data in NetSim” is available at   https://www.youtube.com/watch?v=edcYMxt-UM8&t=1s

For more information on NetSim please visit http://www.tetcos.com 

Interfacing NetSim with MATLAB

NetSim now provides users the ability to interface with MATLAB in run time


Underlying Theory:
MATLAB provides API’s to start and end the MATLAB process and send data / commands to and from MATLAB. NetSim runs these functions during initialization to simultaneously start-up a MATLAB process and whenever required send data to & from MATLAB in run time. NetSim ends the MATLAB process upon completion of the simulation.

Interfacing: An interfacing file named as NetSim_MATLAB_Interface.c is used to control the MATLAB computational engine and contains the functions –

fn_netsim_matlab_init() – which starts the MATLAB Process

fn_netsim_matlab_run() – which sends data to and from MATLAB, and sends commands to be processed in MATLAB

fn_netsim_matlab_finish() – which ends the MATLAB Process

ExMATLABCall_Ver2_4web

 

Example of MATLAB call from WLAN PHY layer in NETSIM

Example Application: In this example, we replace NetSim’s default Rayleigh fading with the Nakagami fading model from MATLAB. Calls to the above functions are made at appropriate places in the NetSim code. So, for each packet, MATLAB calculates the Nakagami fading value in run time. This value returned by MATLAB is used by NetSim as the fading power instead of using the Rayleigh model. Note that instead of sending the commands directly from NetSim to MATLAB, we can also use a MATLAB .m file which will contain the commands to be executed by MATLAB.

Video: Interfacing NetSim with MATLAB is available at https://www.youtube.com/watch?v=-c9zGfwci2g

IOT : Accelerate your research using NetSim C libraries

IOT_Scenario_Blog-01
Research areas in IOT
  • Seamless integration of heterogeneous devices
  • Network architecture for IOT
  • Energy management and sustainable operation of IOT
  • 6LoWPAN based IOT design
  • Modeling and simulation of large scale IOT network
Write your own code
  • Create custom protocols using NetSim’s simulation API’s
  • Interface with other software products like MATLAB
  • Debug your code (step-in, step-out, step-over, continue) and watch your variables in sync with simulation
NetSim IOT features
  1. Create scenario , simulate and observe the performance of 6LoWPAN network
  2. Devices: Sensor Motes, 6LoWPAN Gateway, Routers, Switches, AP and Nodes can be used for the scenario building and simulation
  3. Data Link layer: Unslotted CSMA/CA, Slotted CSMA/CA, CCA
  4. Physical layer: Received Power Calculation, Fading, Shadowing, SINR calculation, BER calculation, Collision and error checking
  5. Sensor Mobility model, Sensing parameters, Packet generation, Packet Reception
  6. Radio Energy and Power Management
  7. Network layer can run both on IPV4 and IPv6
  8. Routing via AODV (RFC 3561), OLSR (RFC 3626), ZRP
  9. 6LoWPAN gateway will switch the packet from one network to another
  10. Facility to conduct various experiments for differing input / output parameters
  11. Input: Beacon Order, Super frame Order, Back off Exponent, Power Consumption, Battery life extension, CCA type, Receiver Sensitivity, ED Threshold, Channel Characteristics
  12. Output: Routing Overhead, Delay, Power Consumption, Lifetime of motes, Packet Delivery ratio, Routing Time, Actual Vs. Sensed path of agent

NetSim Emulator – Run live applications over virtual networks

Emulator_BlogWhat is a network emulator?
A NetSim emulator enables you to run real applications over virtual networks with wide selection of network conditions like error, delay, loss etc. Use of an emulator from development through pre-deployment phases obviates the need of redesigning, testing and tuning your applications, thus saving time, effort and eventually cost of setting up a network.

What you can do with NetSim Emulator?
• Network design and validation – Military radios, SCADA, Metro rail etc
• Application performance testing
• R&D in new protocol design
• Perform what-if analysis

What are the benefits of NetSim Emulator?
• Emulate a wide range of technologies – Switching, Routing, MANETs, Cognitive Radio networks, 4G-LTE networks, ZigBee networks
• A cost effective alternative to hardware emulators that have high costs and limited scale
• Reduced learning curve through agile testing in lab without complicated configuration

How does it work?
• Create the desired network in the Emulation server using NetSim GUI
• Run emulation client in the PC’s/VM’s where your live applications run
• Set the device IP addresses per the real PC/VM in the simulated network. Each live PC/VM corresponds to a node in the simulated network.
• Run your application and the emulation server
• Measure your application performance

You may view this introductory video on network emulation and how NetSim emulator works  https://www.youtube.com/watch?v=OwOw10LuYbQ

Discrete Event Simulation and Event Programming in NetSim

The entire source code of NetSim is based on Event Programming since NetSim is a Discrete Event Simulator (DES)

Discrete-event simulation (DES), models the operation of a system as a discrete sequence of events in time. Each event occurs at a particular instant in time and marks a change of state in the system. Between consecutive events, no change in the system is assumed to occur; thus the simulation can directly jump in time from one event to the next.

Event-driven programming is a programming paradigm where flow of program is determined by different events. Thus, Event Programming is the favored method of coding a DES.

In NetSim there are different specific events and its sub-events
and the simulation kernel does the entire event handling. While, inserting an event into the kernel its event time should be mentioned since all events are executed in increasing order of their event time.

The link http://tetcos.com/netsim_gen.html explains in detail how to model, run, visualize and analyze a Discrete Event Simulation of various networks.

Simulation of LTE Networks in NetSim

LTE, an acronym for Long Term Evolution, commonly known as 4G LTE, is a standard for wireless communication of high-speed data for mobile phones and data terminals. It is based on the GSM/EDGE and UMTS/HSPA network technologies, increasing the capacity and speed using a different radio interface together with core network improvements.

  • NetSim LTE implementation is per 3GPP TS 36.xxx standards covering
  • Devices – User Equipment (UE), E-UTRAN Node B (eNB), Mobility Management Entity (MME)
  • Protocol Stack covering NAS (Non access stratum), PDCP (Packet data convergence protocol), RRC (Radio resource control), RLC (Radio link control), Concatenation
  • LTE MAC
  1. Mapping between logical channels and transport channels
  2. Multiplexing of MAC SDUs from one or different logical channels onto transport blocks (TB)
  3. De multiplexing of MAC SDUs from one or different logical channels from transport blocks (TB)
  4. Priority handling between UEs by means of dynamic scheduling
  5. Priority handling between logical channels of one UE
  6. Logical Channel prioritization
  • LTE PHY – OFDM-MIMO Downlink and SC-FDMA uplink, CQI – SNR

LTE

The complete white paper explaining the implementation of LTE in NetSim and detailed comparison against NS-3 test suite is available at http://www.tetcos.com/LTE_Vertification_v8.pdf

LTE is available with NetSim v8 which is expected to be shipped from mid august ’14.

Please contact us for more information about functionality or pricing, or to arrange a demonstration. Email: sales@tetcos.com, Visit: www.tetcos.com

Simulation of 802.11n and 802.11 ac based networks in NetSim

802.11n is an amendment to the IEEE 802.11 wireless networking standards to improve network throughput over the two previous standards—802.11a and 802.11g—with a significant increase in the maximum net data rate from 54 Mbps to 600 Mbps.

IEEE 802.11ac is the fifth generation in Wi-Fi networking standards and will bring fast, high quality video streaming with dramatic improvements in transmission speeds. Entry-level IEEE 802.11ac products will provide a data rate of 433 Mbps, which is at least three times faster than IEEE 802.11n and high-speed IEEE 802.11ac devices will offer wireless transmission in excess of 1 Gbps.
Network_Scenario
802.11n and 802.11 ac features in NetSim v8 (Beta)

Comparison_11n_11ac
Source C codes for 802.11 n and 802.11 ac are provided along with for user modifications

Please contact us for more information about functionality or pricing, or to arrange a demonstration.
(Visit: www.tetcos.com, email: sales@tetcos.com, Ph: + 91 80 2663 0624)

Static routing in NetSim

Static Routing

How to Setup Static Routes in RIP and OSPF

Step1 : In inter-networks, Static Routes can be set for any scenario having a minimum of 3 routers, 2 switches and 3 wired nodes. The easiest way to do this is to first run the scenario with routing protocol set as RIP/OSPF and save the Configuration file

Step 2 : Open the Configuration file with Visual studio. Expand the Router configuration and set the Static Routing information in Application Layer property of the device, by enabling the Static routing status. Then set the appropriate Static routing file name and file path.
RIP
By default:





Change to:





OSPF
By default:





Change to:





Note:
1. Update this information in any one of the router
2. A sample StaticRouting.txt file will be available inside “C:\Program Files\NetSim standard\Docs\Sample_Configuration\Internetworks”. Appropriately modify it for the scenario.
The StaticRouting.txt file contains
1. Device Id of the Router
2. List of entries to add in the routing table
DEVICE_ID:1
ip route 192.168.0.0 255.255.255.0 192.168.0.1 [1]
ip route 192.168.1.0 255.255.255.0 192.168.1.1 [1]
DEVICE_ID:2
ip route 192.168.2.0 255.255.255.0 192.168.2.1 [1]
ip route 192.168.3.0 255.255.255.0 192.168.3.1 [1]

The above format is per standard Cisco command for static routes
ip route dest_ip mask gateway_ip [distance ]

1. The ip route is the Cisco command to add the static route
2. The dest_ip is the Network address for the destination network
3. The mask is the Subnet mask for the destination network
4. The gateway_ip is the IP address of the next-hop router
5. The distance is the administrative distance for the route. The default is 1 .

Step 3 : After this, run this configuration file through CLI and static routes will be used for routing.

How to fail a node in NetSim

In this section we explain node failure using MANET-DSR as an example

Using Device Id, Identify the Device ID of the particular device.

The fn_NetSim_DSR_Run( ) is the main function to handle all the protocol functionalities

DSR_Run( )

strcpy(pszFilepath,pszIOPath);
strcat(pszFilepath,”/Output.txt”);
fp = fopen(pszFilepath,”r”);
i=0;
if(fp)
{
while(fgets(pszConfigInput,500,fp)!= NULL)
{
sscanf(pszConfigInput,”%d %d”,&NodeArray[i],&TimeArray[i]);
i+=1;
}
}

for(i=0;i<100;i++) if((pstruEventDetails->nDeviceId == NodeArray[i])&&(pstruEventDetails->dEventTime >= TimeArray[i]))
// Node failure happens after a value of time storted in an array
{ // This just returns instead of running DSR functionality when the node is failed
pstruEventDetails->nInterfaceId = 0;
return 0;
}

Note: Add the above lines of code after the variable declarations in the function
Build the .dll by clicking Build ->Build Solution. (The dll will be created inside the Visual studio project->Debug)

Running NetSim via Command Line Interface (CLI)

NetSim provides options to run simulations via the GUI or via CLI. The CLI mode is preferred for automated execution (batch processing) of simulations. This feature is available from v7 onwards. In v7, NetSim can be run via CLI for Internetworks, Advanced Wireless Networks – MANET, Wireless Sensor Networks, Personal Area Networks and Cognitive Radio Networks only. For other networks NetSim v7 can only be run via GUI

Prior to running NetSim through command line interface (CLI), users must understand the following –
Step 1: App Path
App path is the file location in the system in which the NetSim7.0 has been installed.
The app path can be found out by right clicking the NetSim Shortcut in the desktop and selecting Open file location (In Vista and Windows 7) or Find Target (In Windows XP). The app path will be something like “C:\Program Files\NetSim Standard\bin”, depending on where NetSim is installed. The path to the bin folder of NetSim is termed as the app path.
Step 2: IO Path
IO path (Input/output Path) is the path where the input and output files of an application is
written. This is similar to the temp path of windows OS. For NetSim, the iopath is
%temp%/NetSim.  The Configuration.xml file for the scenrio to be simulated should be kept here prior to running the simulation. Note that the IO path must have write permission.
Step 3: Running NetSim through command line for Simulation
To run NetSim through command line, copy the app path where NetSimCore.exe is present and paste it in the command prompt. For floating/roaming licenses, type the following in the command prompt

>NetSimCore.exe<space> -apppath<space><app path><space>-iopath<space><io path><space> -license<space>5053@<Server IP Address>

Where,
<app path> contains all files of NetSim including NetSimCore.exe
<iopath> contains Configuration.xml and Configuration.xsd file
5053 is the port number through which the system communicates with the license server i.e  the system in which the dongle is running (for floating license users)
<Server IP Address> is the IP address of the system where NetSim license server (dongle) is running.

Sample configuration.xml files are available for Internetworks and Cognitive Radio Networks in the <apppath>/Docs/Sample_Configurations folder of the NetSim install directory. Rename the sample file as “Configuration.xml” before running NetSim through CLI. Depending on your system setting, the extension (.xml) might be implicitly present and not visible. In such cases do not add the extension, as that will cause the file to be named as configuration.xml.xml.

For node-locked licenses, type the following in the command prompt

>NetSimCore.exe<space> -apppath<space><app path><space>-iopath<space><io path><space>

Once Simulation is completed successfully and the metircs files that are requested by the end user in Configuration.xml will be written in the iopath. If any of the folder names contains white space, then mention the folder path within double quotes while specifying the folder name in the command prompt.

To know more about the options that are available to run NetSim via CLI, type the following in the command prompt.
>cd <app path>
>NetSimCore.exe -h

NetSim Simplifies Custom Code Development

Most simulation software demand considerable knowledge of the tool by the users before starting to develop code. This is a daunting task. An objective of NetSim is to make code modification and development simpler with a much shorter learning curve. Here are three simple steps on how to start customization of code.
Example: Printing “Hello world” inside NetSim’s TCP protocol.Step 1: Set up your project: Set your compiler such that your project code compiles into a Dynamic Link Library (DLL).Step 2: Copy source code: NetSim’s installation directory contains the source code for all protocols in folder ../NetSim/Simulation/src Copy paste the following files:
a. Header files related to TCP from the path ../src/simulation/include
b. Lib files related to TCP from the path ../src/simulation/lib
c. Source files related to TCP from the path ../src/Simulation/tcp
Step 3: Modify code and replace the binary: Open TCP.c and write the Hello World print statement just after the TCP init function. Then build your code and replace the existing binary of NetSim (libTCP.dll in../NetSim/Simulation/bin) with your libTCP.dll. Next, run a simulation you would see “Hello World” in command line.
Watch this video to see how to write custom code in NetSim

NetSim v7 — Batch Processing

NetSim batch processing allows users to execute of a series of simulations without manual intervention.

Consider the example, where a user wishes to create and simulate thousands of network scenarios and store and analyze the performance metrics of each simulation run. It is impossible to do this manually using the GUI. However, this can be done by writing a batch processing program which runs NetSim via CLI.

An example C program for batch processing of NetSim is available with us and existing customers of NetSim v7 can write to us for a copy. This batch program can be customized by users as desired.

Given below are important sections of the source code of this batch program.

#define apppath “C:\\Program Files (x86)\\NetSim pro7\\bin” // change to your app path
#define iopath “F:\\NetSim_Batch_Processing”                   // change to your IO Path
#define license “5053@192.168.0.10”                             // change to where your license server is running

main ( )
{
{// iterate from MIN to MAX for all of the devices to create configuration files
If { /* If certain network validation conditions are not met write the name of configuration file to                           NetSim_Batch_Log.txt. This file contains all the config files that did not meet the
necessary validation conditions and were not created during the batch execution */
}
Else {
//Create configuration file
fnCreateNetworkConfiguration(fpConfigurationFilePointer);
fnCreateSimulationParameter(fpConfigurationFilePointer);
fnCreateStatisticsCollection(fpConfigurationFilePointer);
}

      } // End of creation of all config files

Create batch file RunAll.bat
// Loop over number of configuration files, call NetSim executable which will write the output files
Run the batch file RunAll.bat
} // Main end

 

The “Virtual” Network Stack in NetSim v7

The Network stack is an implementation of the computer networking protocol suite. NetSim v7 features a virtual implementation of the protocol stack thereby providing closer to real world modeling and analysis capability.
The stack is a five layer TCP/IP design, with modularized IN and OUT events for layered protocol implementation, and a set of clean and well organized interfaces. The network stack also features in-built config file parser, error handler, config error logger, memory manager and metrics module.
NetSim’s virtual stack interfaces with network protocols which are modeled as Finite State Machines (FSM) and the simulation kernel which is a discrete event engine accelerated by a heuristic algorithm.NetSim v7 stack features application programming interfaces at multiple points for custom code development:

  • Network stack API’s – for designing new layers and for cross layer optimization
  • Metrics API’s – for developing new statistical measures
Apart from these API’s, protocol source code is available for designing custom protocols or extending standards-based protocols.

Simulation of 802.22 Cognitive Radio Networks with NetSim

IEEE 802.22 Wireless Regional Area Networks (WRANs) are designed to provide broadband access to data networks. The WRAN systems will use vacant channels in the VHF and UHF bands allocated to the Television Broadcasting Service in the frequency range between 54 MHz and 862 MHz while avoiding interference to the broadcast incumbents in these bands.

NetSim v7, expected to be released in April, covers simulation of 802.22 WRAN based cognitive radio networks featuring: MAC layer model containing Super frame, DS-MAP, US-MAP, BW request, Quiet period and Normal mode operation

  1. PHY layer operating through OFDMA.
  2. CR Base station with interfaces to connect with Switch or Router and CPE’s  with a Max 512 CPE’s in each BS
  3. UGS, nrtPS, rtPS and BE QoS classes
  4. Incumbent model, Incumbent detection and channel switching
  5. Connection establishment via CID consisting of a 9-bit station ID (SID) and a 3-bit flow ID (FID).
  6. The cognitive plane consisting of Spectrum Manager, Spectrum Sensing Function, Spectrum Sensing Automaton, Channel Model.


802.22 Primitives with source C Code
The following protocol functionalities are available with source C code for extending existing algorithms: Transmit_SCH, Transmit_FCH, Transmit_DS_MAP, Transmit_US_MAP, Request_BW, Access_Phy_OFDMA, Spectrum_Manager, Spectrum_Sensing_Fn, Spectrum_Sensing_Automation, apart from various Channel_models

Metrics
Network metrics such as Network Throughput, Packet Delay plus CR specific metrics such as throughputs for each QoS class, incumbent detection rate, channel switching rate etc are available.
Packet Trace & Event Trace for CR simulations are also available for performance validation, statistical analysis and custom code de-bugging.

 

NetSim: Packet Trace and Event Trace

NetSim allows users to generate trace files which provide detailed packet & event information useful for performance validation, statistical analysis and custom code de-bugging. The two traces that can be logged in NetSim are:

1. The Event trace: This records every single event along with associated information such as time stamp, event ID, event type etc.

2. The Packet trace: This logs a set of chosen parameters for every packet as it flows through the network such as arrival times, queuing times, departure times, payload, overhead, errors, collisions etc.

How is the trace useful?

a. Learn protocol internals: Window size variation in TCP, Route Table Formation in OSPF, Medium Access in Wi-fi, etc, are examples of protocol functionalities that can be easily understood from the trace.

bLog chosen parameters: NetSim’s trace option features a checkbox based filter where users can select only those packet / event level parameters / information which they want to log.

c. Import easily into spread sheets: Tab ordering enables the trace data to be imported into spreadsheets programs such as excel with ease for statistical analysis. Further, the events / packets are printed per line and have a unique ID and time stamp. This enables users to quickly write custom scripts to parse, inspect, plot and analyze protocol parameters.

d. Debug custom protocol implementations: Users need diagnostics that can catch logical errors without having to set a lot of breakpoints or restarting the program often. A host of information is available in the trace files and in addition the event trace has two special information fields for diagnostics a) A log of the file name and line number from where the event was generated and b) Future event (s) generated while processing the current event.

How to turn on the tracing options

By default, the packet tracing option is turned off. Users can edit the config file and “enable” packet-trace, or users can turn them on using the trace button in the UI. Event-traces are “always-on” and are available with our kernel’s debug library.

 

NetSim – A look at the simulation config file

Sophisticated users model their simulation via a config file that is independent of the GUI. The config file contains all required information to run the simulation including the network topology, devices, links, traffic, statistics, traces etc. Given below are important features of NetSim’s config file:

Model in XML format

Unlike, traditional simulators that use a flat text file, NetSim uses XML format given its advantages.

a. Quicker Understanding: It is easier to understand what the document holds at a glance and has moreprecise declarations of content allowing for more meaningful search results

b. Better Presentation: XML enables the separation of presentation from data and is suitable as a description for complex hierarchical data as is typical in a simulation config file

c. Automatic Format Verification: MSVC allows you to switch between XML view and Data View, and helps to locate syntax error. The schema we provide along with enables statement completion feature, as well as an option to validate the XML data.

Mirror Real Networks

Various network technologies are supported including LAN, WAN, PAN, WSN, Mobile, Cellular, Wireless and Inter-network.

Devices are modeled per the 5 layer TCP / IP stack. Users can set protocol properties in each of these layers in all devices.

Traffic can be configured as applications like FTP, Database, Voice, Video etc. Further, lower level mathematical distributions are available for packet size and inter-arrival time for users to model custom apps.

And finally, the config file provides a simple interface for linking external libraries.

Log traces and analyze metrics

The config file allows you to choose end-to-end metrics you wish to analyze and traces you want to log. A range of statistics is available including throughput, utilization, delay, error, loss etc. The packet trace can be logged in .txt or .csv format and an event trace can be generated for those using our debug libraries.