NetSim User Manual
NetSim User Manual
NetSim ®
Accelerate Network R & D
User Manual
By
The information contained in this document represents the current view of TETCOS LLP on
the issues discussed as of the date of publication. Because TETCOS LLP must respond to
changing market conditions, it should not be interpreted to be a commitment on the part of
TETCOS LLP, and TETCOS LLP cannot guarantee the accuracy of any information presented
after the date of publication.
The publisher has taken care in the preparation of this document but makes no expressed or
implied warranty of any kind and assumes no responsibility for errors or omissions. No liability
is assumed for incidental or consequential damages in connection with or arising out of the
use of the information contained herein.
Copyright in the whole and every part of this manual belongs to TETCOS LLP and may not be
used, sold, transferred, copied or reproduced in whole or in part in any manner or in any media
to any person, without the prior written consent of TETCOS LLP. If you use this manual you
do so at your own risk and on the understanding that TETCOS LLP shall not be liable for any
loss or damage of any kind.
TETCOS LLP may have patents, patent applications, trademarks, copyrights, or other
intellectual property rights covering subject matter in this document. Except as expressly
provided in any written license agreement from TETCOS LLP, the furnishing of this document
does not give you any license to these patents, trademarks, copyrights, or other intellectual
property. Unless otherwise noted, the example companies, organizations, products, domain
names, e-mail addresses, logos, people, places, and events depicted herein are fictitious, and
no association with any real company, organization, product, domain name, email address,
logo, person, place, or event is intended or should be inferred.
Rev 13.0 (V), March 2021, TETCOS LLP. All rights reserved.
Contact us at
TETCOS LLP
# 214, 39th A Cross, 7th Main, 5th Block Jayanagar,
Bangalore - 560 041, Karnataka, INDIA.
Phone: +91 80 26630624
E-Mail: [email protected]
Visit: www.tetcos.com
Table of Contents
3 NetSim GUI...................................................................................................................... 45
3.1 Menus in the NetSim Home Screen ....................................................................... 45
3.1.1 Creating “New” Simulations ........................................................................ 49
3.1.2 Environment Settings .................................................................................. 50
3.2 Modeling and Simulating a simple network ............................................................ 53
3.2.1 Creating a Network scenario ...................................................................... 53
3.2.2 Configuring devices and links in the scenario ............................................ 55
3.2.3 Display Settings .......................................................................................... 56
3.2.4 Copy/Paste.................................................................................................. 57
3.2.5 Modeling Application Traffic........................................................................ 59
3.2.6 Logging Packet/ Event Trace...................................................................... 60
3.2.7 Run Simulation ............................................................................................ 60
3.2.8 ACL Configuration....................................................................................... 61
3.3 Saving & Opening experiments and Printing results ............................................. 65
3.3.1 Opening Saved Experiments: ..................................................................... 65
3.3.2 Saving an Experiment................................................................................. 66
3.4 NetSim Keyboard Shortcuts ................................................................................... 66
3.5 NetSim Interactive Simulation ................................................................................ 67
3.5.1 Simulation specific (Not applicable for file based interactive simulation) .. 70
3.5.2 Ping Command ........................................................................................... 70
3.5.3 Route Commands ....................................................................................... 72
7.2.1 How to use Visual Studio to edit the Configuration file? .......................... 129
7.2.2 Sections of Configuration file .................................................................... 130
7.2.3 Sample Configuration file.......................................................................... 131
7.2.4 Configuration.xsd file ................................................................................ 131
10.2.3 Implement Weibull Distribution of MATLAB in NetSim using .m file: ....... 247
10.2.4 Plot a histogram in MATLAB per a Weibull distribution (using .m file) .... 249
10.3 Interfacing tail with NetSim ................................................................................... 253
10.4 Adding Custom Performance Metrics .................................................................. 257
10.5 Simulation Time and its relation to Real Time (Wall clock) ................................. 261
10.6 Adding Custom Plots ............................................................................................ 262
10.6.1 Plotting SNR for each UE-gNB pair in 5G NR.......................................... 262
10.7 Environment Variables in NetSim......................................................................... 268
10.8 Best practices for running large scale simulations............................................... 269
10.9 Batch experimentation and automated simulations ............................................. 270
1 NetSim – Introduction
Building the model: Create a network with devices, links, applications etc.
Running the simulation: Run the discrete event simulation (DES) and log different
performance metrics.
Visualizing the simulation: Use the packet animator to view the flow of packets.
Analyzing the results: Examine output performance metrics such as throughput,
delay, loss etc. at multiple levels - network, link, queue, application etc.
Developing your own protocol / algorithm: Extend existing algorithms by
modifying the simulator’s source C code.
NetSim comes in three versions: Academic, Standard and Pro. The academic version is used
for lab experimentation and teaching. The standard version is used for R & D at educations
institutions while NetSim Pro version addresses the needs of defense and industry. The
standard and pro versions are available as components in NetSim v13.0 from which users can
choose and assemble. A comparison of the features in the three versions are tabulated below
Table 1-1.
Reference
Component No Networks / Protocols Supported International
Standards
Internetworks
Ethernet - Fast & Gigabit, ARP, Routing - RIP, OSPF,
WLAN - 802.11 a / b / g /p / n / ac & e,
Propagation models - HATA Urban / Suburban,
COST 231 HATA urban / Suburban, Indoor Home /
Office / Factory, Friis Free Space, Log Distance.
Shadowing - Constant, Lognormal. Fading - Rayleigh,
Nakagami
IPv4, Firewalls, Queuing - Round Robin, FIFO, IEEE 802.3
Priority, WFQ,
TCP, - Old Tahoe, Tahoe, Reno, New Reno, BIC, IEEE 802.11
Component 1 CUBIC, Window Scaling, SACK a/b/g/n/ac/p/e
(Base. Required UDP
for all Common Modules
components) Traffic Generator: Voice, Video, FTP, Database,
HTTP, Email, P2P, Custom, CBR.
Virtual Network Stack, RFCs 2453, 2328,
Simulation Kernel, 826, 793, 2001 and
Command Line Interface 768
Command Line Interpreter
Metrics Engine with packet and event trace
Plot Generator
Packet Animator,
Packet Encryption
External Interfaces: MATLAB, Wireshark
Advanced Routing
Multicast Routing - IGMP, PIM, Access Control Lists,
IETF RFC’s 1771 &
Component 3 Detailed Layer 3 switch mode, Virtual LAN (VLAN),
3121
Public IP, Network Address Translation (NAT)
Table 1-2: Different Components (Technology Libraries) in Pro and Standard versions of NetSim
Visual Studio Community edition (or higher) is required for writing and debugging custom
code.
2.1.2 License Server (for running Host-ID/ Dongle locked floating licenses, not
applicable for node locked licenses)
Any one system will have to be made as the license server, and it is to this PC that the
license is locked, either via its MAC ID or via a dongle. The dongle is a USB device which
controls the licensing. The system (hardware / OS) requirements is same as that applicable
for NetSim clients. USB Port is required for connecting and running the dongle. Client
systems should be able to communicate with license server through the network.
Figure 2-1: User Account Control message window appears and select Yes button.
Setup prepares the installation wizard and software installation begins with a Welcome
Screen. Click on Next button to continue with the installation.
Express Installation will install the third-party tools silently along with NetSim without displaying
any prompts for the user.
Custom Installation is a step-by-step approach in which a user will be prompted to carry out
the installation process and the same applies to the installation of the third-party tools which
happens alongside with NetSim.
Choose the Express (Single click) option and click on the Install button.
Figure 2-4: Select Express (Single click) radio button and Click on install
NetSim installation starts and users can see that the third-party tools are getting installed one
by one silently.
Figure 2-8: Select Finish button to complete the installation process of NetSim.
Otherwise, Choose the Custom (Step-by-step) option and click on the Install button.
Figure 2-9: Select Custom (Step-by-Step) radio button and Click on install.
Now the user will be prompted to select the components to be installed. The list of components
is available for selection and assembly only in the Standard and Pro versions of NetSim.
NetSim Academic version is available as a single package.
Note: In Standard and Pro Versions of NetSim, the Choose Components screen will display only those components
for which the licenses are obtained by the user. Also, Network Emulator and Real Time Protocol are available as
Add-On along with NetSim.
Figure 2-10: list of components is available for selection and assembly only in the Standard and Pro
versions
Note: Select all the supporting applications for complete installation of the software as shown below:
In the next screen, you will be requested to enter the installation path. Select the path in which
the software needs to be installed and click on Next button.
In the next screen, you will be requested to enter the Start Menu folder name. By default, it
shows NetSim Standard for Standard version install of NetSim. Click on the Install button to
start the installation.
For NetSim Academic Version, Adobe Flash Player, WinPcap, Wireshark will be installed.
For NetSim Standard and Pro Versions, along with WinPcap and Wireshark installation,
Python installation will start automatically. (If not deselected during 3rd party software
selection)
You will get the Npcap Setup Finished window. Click on Finish button.
Figure 2-32: Installation Complete dialog box and select next button
You will get the Wireshark Completing Setup window. Select the option I want to manually
reboot later and Click on Finish button.
Figure 2-33: Select the option I want to manually reboot later and Click on Finish button
NetSim Standard Setup Installation proceeds further.
SUMO Set Up installation wizard appears. Click on Next button to continue with Sumo
installation.
This will take you to the pywin 32-224 installation wizard. To install Pywin32, Click on Next
button.
This completes the Installation of python software. NetSim complete Setup wizard appears as
shown below. Click on Finish button to complete the installation process of NetSim.
2. Open command prompt and paste the copied location as shown below.
NetSim_Standard_13_0_14_HW_64bit.exe/S /silent=1
><setup location/S<space>/silent=1
Figure 2-54: User Account Control message window appears and select Yes
After successful installation, NetSim automatically detects if any workspaces (of prior
versions/installations) are present. If yes, NetSim opens a window named, “Import Compatible
workspaces”, via which users can import these workspaces into new version of NetSim.
A default workspace will be created and set as current workspace if none of the compatible
workspace are selected and clicked on Proceed.
The following window appears if the current workspace is deleted or removed after re-
installation of NetSim.
The “Relocate the workspace” option will allow the user to select a new location for the
workspace which was removed/ deleted. User can also ignore the message by selecting
“Ignore” option and clicking on OK button.
This section guides you to install the RLMDongle Driver software from the CD-ROM.
Each prompt displayed during the process tells you what it is about to do and prompts to
either continue or Exit.
Setup prepares the installation wizard and the driver software installation begins with a
Welcome Screen. Click on Next button.
Figure 2-57: Sentinel Runtime Setup window and select Next button
Note: Any other program running during the installation of the Dongle will affect the proper installation
of the software.
Sentinel Runtime Setup License Agreement appears. Read the license agreement carefully,
scroll down to read the complete license agreement. If the requirement of the license
agreement is accepted, Click on I accept the license agreement and click on Next button
else quit the setup by clicking Cancel button.
Figure 2-58: Sentinel Runtime Setup License Agreement window appears and select Next button
Figure 2-60: Sentinel Runtime is installed successfully and select Finish button
Now the RLM driver software is installed successfully. If the driver has been successfully
installed, then upon connecting the Dongle in the USB port, a red light will glow (Refer
picture below Figure 2-61). If the driver is not properly installed, this light will not glow when
the dongle is connected to the USB Port.
Copy the NetSim License Server folder and paste it on Desktop. Check that it has
the license file. If not copy the paste the license file into the License server folder
Double click on NetSim License Server folder from Desktop.
Double click on rlm.exe
For hardware dongle-based users: After the Driver Software installation, connect the
RLM dongle to the system USB port. Double click on My Computer and access the
CD Drive. This CD contents will have the NetSim License server folder.
Note: For running NetSim, rlm.exe must be running in the server (license server) system and the server system
IP address must be entered correctly. Without running rlm.exe, NetSim won’t run.
While running rlm.exe, the screen will appear as shown below Figure 2-62.
Figure 2-62: When NetSim license server system running, window appears
After running rlm.exe, double click the NetSim icon in the Desktop. The screen given below
will be obtained. Enter the Server IP address where the rlm.exe is running and click OK.
3 NetSim GUI
The graphical user interface (GUI) allows users to interact with the simulator for creating,
modifying and saving, simulation experiments and workspaces. This is much easier to use
when compared to command line or text-based simulator interfaces. NetSim GUI comprises
of the Home Screen, Design Window, Results Window, Animation Window and Plots Window.
See the following image for an example of the NetSim Home screen as shown below Figure
3-1.
1. New Simulation: Use this menu to simulate different types of networks in NetSim. You
can simulate the following the types of networks: Internetworks, Legacy Networks,
Mobile Adhoc networks, Cellular Networks, Wireless Sensor Networks, Internet of
Things, Cognitive Radio Networks, LTE/LTE-A Networks, 5G NR (newly added
component in v12), VANETs, and Satellite Communication. Only the networks
(components) for which licenses are available will be shown. The networks
(components) shown at the bottom with grey background cannot be directly clicked
and entered. These features can be accessed through other components given the
dependencies.
2. Your work: Use this menu to load saved configuration files from the current
workspace. You can view, modify or re-run existing simulations. Along with this, users
can also export the saved files from the current workspace to their preferred location
on their PC’s.
3. Examples: Use this menu to perform simulations of different kinds categorized
technology-wise. Users can choose any network which they want to work and further
go down by using a double click on it or by a click on the arrow pointer which will take
you to the next level. By a click on any simulation file will open a pre-existing simulation
file which users can run and analyze the results. Users can click on the book icon
present in the right-hand side of each network which opens the corresponding pdf files.
This helps the users with all information about the current simulation as well as the
entire network technology.
4. License Settings: Use this menu to perform the following. Click on License Settings
provides users with three sub-menus related to License information.
License Server Information: Use this menu to view details about the NetSim License
Server from where the client is checking out licenses.
End User License Agreement: Use this menu to view the end user license
agreement. You will see the following details on NetSim Home screen, if you click the
End User License Agreement menu item: Grant of License and Use of the Services,
License Restrictions, License Duration, Upgrade and Support Service etc.
NetSim Home screen displays libraries for components for which you have purchased
licenses.
Note: You can select or clear libraries and control access to NetSim users, only if you
are using floating licenses.
See the following image for an example of what the NetSim Home screen displays, if
you click the Configure Installed Components/Libraries menu item.
Select the checkboxes for the component libraries (types of networks) that
NetSim users must be allowed to simulate.
Clear the checkboxes for the component libraries (types of networks) that
NetSim users must not be allowed to simulate.
The Internetwork component is greyed out. You cannot clear the Internetworks
component because Internetworks is a base component that is required for all the other
components to work.
5. Documentation: Use this section to open the following NetSim help documents:
These include the User Manual which consists of complete description about all the
features in NetSim and how it can be used by the end users, the Technology Libraries
which provides users with an access to a detailed description of various Network
Technologies present in NetSim through individual pdf files, and Source code help
which comes along with Standard and Pro Versions of NetSim, allows users to gain a
better understanding of the underlying code structure for in-depth analysis.
6. Learn: Use this section to learn more about the software which includes the following:
Videos section can be used to view videos related to NetSim in TETCOS YouTube
channel. This channel helps users by providing frequent updates on what’s new in
NetSim, topics related to various network technologies covering different versions of
NetSim, and monthly webinars. The Experiments Manual section grants you access
to a well-designed experiments manual covering various networking concepts which
helps users to easily understand different networks and also gain ideas to carry out
their own experimentations in NetSim.
7. Support: Use this section to reach TETCOS helpdesk. Contact Technical Support
link can be used to raise a trouble ticket, you can also write to us via Email to
[email protected], and Answers/FAQ link grants you access to our Knowledge
Base which contains answers to all your questions most of the time. Users can utilize
the wealth of information present in it, which are further classified into the following:
FAQs, Technologies/Protocols, Modelling/UI/Results, and Writing your own code in
NetSim.
8. Contact Us: Use this section to contact us and know more information about our
product. You can write to us via Email to [email protected] or contact us via Phone
to our official number +91 76760 54321.
9. Website: Use this link www.tetcos.com to visit our website which consists of vast
information that will assist you through all walks of NetSim.
The Simulation window loads up once user selects the desired network technology from the
New Menu. Click on New Simulation and select the desired kind of network to simulate.
Save
Save as
The settings menu provides user’s access to the simulation environment settings.
The Grid coordinate system has its origin at the upper left of the drawing area, and positive Y
is down while positive X is to the right.
For Map view users can configure the latitude and longitude respectively.
This menu contains link to NetSim Videos on TETCOS YouTube Channel and NetSim
Experiments manual.
Documentation
This menu contains link to NetSim User Manual, Technology Libraries and NetSim Source
Code Help.
In this example, a network with two subnets is designed. Let us say the subnet 1 consists of
two wired nodes connected via a Switch and the other subnet consists of one wired node. Both
the subnets are connected using a Router. Traffic in the Network flows from a wired node in
subnet 1 to the wired node in subnet 2.
Step 1: Drop the devices. Click on Node icon and select Wired Node.
Step 2: Connecting devices: Select the link and then left click on one device, free the mouse
button, then click on the second device and free the mouse button. The wired links may
disappear if you right click anywhere in the environment. Clicking and dragging without freeing
the mouse pointer would displace the device in the environment.
Step 1: To configure any device, right click on the device and select properties as shown
Figure 3-18.
Step 2: To configure the links, right click on any Link and select Properties as shown Figure
3-20.
In NetSim, users can Turn-On or Turn-Off display information such as IP Address of the
devices, link speed etc. For doing this click on Display settings as shown below Figure 3-21.
Figure 3-21: Turn-On or Turn-Off display information such as IP Address of the devices, link speed
etc
In NetSim the device ID serves as a “device identifier” while the IP Address is an “Interface
identifier”
3.2.4 Copy/Paste
In NetSim simple copy paste can be used. Using this feature users can copy all the properties
of a device and create a new device with similar properties.
Right click on the device, click on copy and then right click and click paste. The sequence is
shown below Figure 3-22/Figure 3-23/Figure 3-24/Figure 3-25/Figure 3-26.
Figure 3-23: Right click on the user device and Select copy
After the network is configured, user needs to model traffic from Wired Node 2 to Wired Node
3. This is done using the application icon. Click on the Application icon present on the ribbon
as shown below Figure 3-27.
Packet and Event Trace files are useful for detailed simulation analysis. By default, these are
not enabled since it slows down the simulation. To enable logging of Packet Trace / Event
Trace click on the icon in the tool bar as shown below. Set the file name and select the required
attributes to be logged. For more information, please refer sections 8.4 and 8.5 respectively.
Figure 3-29: Packet Trace and Event Trace options present on ribbon
3.2.7 Run Simulation
For simulating the network scenario created, click on Run Simulation present in the Ribbon.
Routers provide basic traffic filtering capabilities, such as blocking Internet traffic, with access
control lists (ACLs). An ACL is a sequential list of permit or deny statements that apply to
addresses or upper-layer protocols. These lists tell the router what types of packets to: permit
or deny. When using an access-list to filter traffic, a permit statement is used to “allow” traffic,
while a deny statement is used to “block” traffic.
[PERMIT, DENY] [INBOUND, OUTBOUND, BOTH] PROTO SRC DEST SPORT DPORT IFID
To create a new rule in the ACL use command as shown below to block UDP packet
in Interface_2 and Interface_3 of the Router_3
Disable TCP in all nodes (Wired Node and Router)
Click on run simulation option and In the Run time Interaction tab set Interactive
Simulation as True and click on Accept.
Set the Simulation Time as 500 sec or more. Click Ok
Right click on Router_3 and select NetSim Console. Use the command as follows:
NetSim>acl enable
ACL is enable
NetSim>aclconfig
ROUTER_3/ACLCONFIG>acl print
Usage: [PERMIT, DENY] [INBOUND, OUTBOUND, BOTH] PROTO SRC DEST SPORT
DPORT IFID
OK!
OK!
ROUTER_3/ACLCONFIG>print
ROUTER_3/ACLCONFIG>exit
NetSim>acl disable
ACL is disable
NetSim>
3.2.8.3 Results
The impact of ACL rule applied over the simulation traffic can be observed in the
IP_Metrics_Table in the simulation results window, In Router_3 number of packets blocked by
firewall has been shown below
Note: Results will vary based on time of ACL command are executed
Figure 3-34: In Animation Window before applying ACL rules see the packet flow
After applying ACL rule Packet flows up to Router_3 only
Figure 3-35: In Animation Window after applying ACL rules see the packet flow
The impact of ACL rule applied over the simulation traffic can be observed in the Application
throughput plot. Throughput graph will show a drop after ACL is set. If ACL is disabled after a
while, application packets will start flowing across the router. The Application throughput plot
will show a drop and increase(Moving througput graph) in throughput after setting ACL and
disabling ACL respectively.
Example: ACL rule applied at around 50sec user can see the drop in throughput in the graph,
since router blocks UDP packets in the plot. Once ACL has been disabled at around 240sec
router permits packets and hence throughput can be observed in the plot shown below Figure
3-36.
During Simulation: Users can save by using the short cut CTRL + S.
After Simulation: From Network Window: Click on File > Save button on the top left. Next,
specify the Experiment Name, Description (Optional) and click on Save.
Keys Function
Home Screen
Ctrl + N Open a New Network
Ctrl + O Open a Saved Network
Ctrl + E Open a Examples
Design Window (Any Network)
Ctrl + C Copy
Ctrl + V Paste
Ctrl + R Open Run Simulation Window
Ctrl + S Save the Experiment
Shift + Ctrl + S Save As (To Save under different name)
Open Image/Screenshot of the network
Ctrl + P
scenario that is designed in the GUI
Alt+ F4 Close Window
F1 User Manual Help
Ctrl + '+/-' Zoom In/Zoom Out
Mouse Click (Left) Select a device
Ctrl + A Select All devices in the design environment
Ctrl + Mouse Click (Left) and Drag Select devices within a selected area
Deletes the selected devices in the
Delete
Environment along with any links it may have
Simulation Console
This section will demonstrate how to perform Interactive simulation for a simple network
scenario. Let us consider Internetworks. To create a new scenario, go to New Internetworks.
Click & drop Wired Nodes and Router onto the Simulation Environment and link them as shown
below Figure 3-39 or otherwise Open the scenario for Interactive Simulation which is available
in “<NetSim Install Dir>\Docs\ Sample_Configuration\Internetworks\Interactive Simulation”.
Figure 3-40: Run time Interaction tab set Interactive Simulation as True
Click on run simulation and set Simulation Time as 500 sec. (It is recommended to
specify a longer simulation time to ensure that there is sufficient time for the user to
execute the various commands and see the effect of that before Simulation ends) and
click OK
Simulation (NetSimCore.exe) will start running and will display a message “waiting for
first client to connect” as shown below Figure 3-41.
3.5.1 Simulation specific (Not applicable for file based interactive simulation)
Pause
PauseAt
Continue
Stop
Exit
Reconnect
PauseAt: To pause the currently running simulation with respect to particular time (Ex: To
Pause simulation at 70.2 sec use command as PauseAt 70.2)
The ping command is one of the most often used networking utilities for troubleshooting
network problems.
You can use the ping command to test the availability of a networking device (usually
a computer) on a network.
When you ping a device, you send that device a short message, which it then sends
back (the echo)
If you receive a reply then the device is in Network, if you don’t then the device is faulty,
disconnected, switched off, incorrectly configured.
You can use the ping cmd with an IP address or Device name.
ICMP_Status should be set as True in all nodes(Wired_Node and Router)
Open Wireshark and apply filter ICMP. We can see the ping request and reply packets
in Wireshark.
route print
route delete
route add
In order to view the entire contents of the IP routing table, use following commands route
print.
route print
already added static routes to the table, everything you see here will be dynamically
generated.
In order to delete route in the IP routing table you will type a command using the
following syntax
So, to delete the route with destination network 11.5.0.0, all we’d have to do is type
this command.
To check whether route has been deleted or not check again using route print
command.
To add a static route to the table, you will type a command using the following syntax.
So, for example, if you wanted to add a route specifying that all traffic bound for the
11.5.1.2 subnet went to a gateway at 11.5.1.1
If you were to use the route print command to look at the table now, you would see
your new static route.
In general, users need not change the workspace and can use the default workspace.
The user wants to modify the underlying source code of NetSim as is typically in
research applications. The modified code will be saved in that workspace.
A user chooses to save and organize a large number of experiments. These can be
saved under different workspaces provided by that user.
The same PC/NetSim build is shared between multiple users.
The default workspace of NetSim will have the Master Source code and the Master Binaries
(Compiled files)
A default workspace is created in a user selected directory when NetSim is run for the first
time after installation. Choose the path where user wants the default workspace to be created
and click on OK.
The created experiment can be saved by clicking on File > Save button on the top left corner
of the design window.
Users can also select the files which are to be saved into the experiment folder.
The Configuration file will be mandatorily saved into the experiment folder.
Optional: Simulation output files such as Metrics.xml, Animation files, Event Trace
file, Packet Trace file and Plot data (if enabled).
Optional: Protocol logs (if written) or Custom Log files (if codes have been modified
for logging)
In our example, we saved the experiment with the name MANET and this experiment can be
found in the default workspace path as shown below Figure 4-6.
Figure 4-8: Save popup window along with Experiment Name and Description
It will be displayed when mouse pointer is placed over the experiment name in the list shown
as part of the Your Work menu.
Users can rename the experiment or Open the folder where the experiment is saved or
Delete the experiment or Export the experiment by right-clicking on the experiment in the
Your Work window as shown below Figure 4-10.
Figure 4-10: User options to “rename the experiment” or to “open folder” by right clicking on the
experiment
In this example, we have saved all the files related to the experiment. Hence, all the files will
be stored in the experiment folder Figure 4-11.
Figure 4-12: Export option present in Your work in NetSim Home Screen
If you click on Export, an Export Experiment pop-up window appears where Users can select
the files which are to be exported as part of the experiment. The Configuration file is mandatory
and other files are optional. The destination path can be selected to export the experiment.
Figure 4-16: Select Workspace options present in Your work Menu window
Figure 4-23: Added by default Binaries, Source Code Icons to Selected Experiments list
Binaries, Source Code (available only for Standard and Pro) and Icons are added by default
as shown above. Users can add all experiments present in the current workspace by clicking
on All Experiments check box or if the user want to add particular experiment, user can right
click on the desired experiment’s name and click on Add option.
After selecting the experiments, user can export the workspace by Clicking on Export button
as shown below Figure 4-24.
Figure 4-24: Select All Experiments check box and then click on Export
This will open a window as shown below where users can enter the path to which the
workspace is to be exported and then click on ok as shown in below Figure 4-25.
Figure 4-25: Select the path by clicking on browse option in Export Workspace window
The workspace will be exported to the path selected with an extension <workspace
name>.netsim_wsp as shown below.
Figure 4-27: Export individual experiments by right clicking on the experiment and select Add to add
the experiment to the export list
The added experiments will be available in the export list shown below Figure 4-28.
Figure 4-30: Select the path by clicking on browse option for Source and Destination
The imported workspace will be set as the current workspace. The imported workspace can
be seen by clicking on Your Work >> Workspace option >> More Options as shown below
Figure 4-31.
User can import the configuration file also through giving the path from which the configuration
file has to be imported, then describe the experiment name and click on OK.
Figure 4-35: Delete a workspace by clicking on the delete icon in Your work window
Deleting current workspace is not allowed. Deleting a workspace will delete all saved
experiments and code modifications done in that workspace.
Users can then modify the protocol codes and build the solution. Then users can create a
network in NetSim or open the saved experiment which involves the protocol that has been
modified and click on run simulation. This simulation will run per the modified code.
The changes in the source codes applies to the current workspace only.
NetSim comes with inbuilt examples to help you understand how the different types of
networks work.
The devices models in NetSim represent common networking devices in a generic way and
do not model any specific vendor’s implementation of the device. In real-world networks, each
device has specific vendor implementation of networking protocols.
5.1 Internetworks
An Internetwork is a collection of two or more computer networks (typically Local Area
Networks or LANs) which are interconnected to form a bigger network.
Internetworks library in NetSim covers Ethernet, Address Resolution Protocol (ARP), Wireless
LAN – 802.11 a / b / g / n / ac and e, Internet Protocol (IP), Transmission Control Protocol
(TCP), Virtual LAN (VLAN), User Datagram Protocol (UDP), and routing protocols such as
Routing Information Protocol (RIP), Open Shortest Path First (OSPF), Internet Group
Management Protocol (IGMP), and Protocol Independent Multicast (PIM).
To view help documentation users can either click on “Technology Libraries” under
documentation in the home screen or click the ‘Book’ link located next to Internetworks in
examples. The help documentation explains the following:
Introduction
Simulation GUI
Model Features
Featured Examples
Reference Documents
Latest FAQ available online
NetSim Legacy Network library cover Pure Aloha and Slotted Aloha.
ALOHA is a protocol that was developed at the University of Hawaii and used for satellite
communication systems in the Pacific. ALOHA protocol was designed to send and receive
To simulate Legacy Networks, click on New Simulation and then under Legacy networks click
on either Pure Aloha or Slotted Aloha
To view help documentation either click on “Technology Libraries” under documentation in the
home screen or click the ‘Book’ link located next Legacy Networks in examples. The help
documentation explains the following:
Introduction
Simulation GUI
Model Features
Featured Examples
Reference Documents
Latest FAQ available online
NetSim cellular networks library covers Global System for Mobile communication (GSM) and
Code-Division Multiple Access (CDMA).
To simulate Cellular Networks, click on New Simulation and then under Cellular networks click
on either GSM or CDMA.
To view help documentation either click on “Technology Libraries” under documentation in the
home screen or click the ‘Book’ link located next Cellular Networks in examples. The help
documentation explains the following:
Introduction
Simulation GUI
Model Features
Featured Examples
Reference Documents
Latest FAQ available online
Multicast Routing –
o Internet Group Management Protocol (IGMP)
o Protocol Independent Multicast (PIM)
Access Control Lists (ACLs)
Virtual LAN (VLAN)
Public IP and Network Address Translation (NAT)
To simulate the above-mentioned routing protocols, click on New Simulation and then
Internetworks.
2. Click the Advanced-Routing example you wish to simulate. NetSim UI loads the
example.
To view help documentation users can either click on “Technology Libraries” under
documentation in the home screen or they can click the ‘Book’ link located next to Advanced
Routing in examples. The help documentation explains the following:
Simulation GUI
Model Features
Featured Examples
Reference Documents
Latest FAQ available online
5.5 MANETs
Mobile Ad-hoc Network (MANET) is an ad hoc network that can change locations and
configure itself on the fly. Because MANETS are mobile, they use wireless connections to
connect to various networks.
To simulate MANET, click on New Simulation and then select Mobile Adhoc networks.
To view help documentation either click on “Technology Libraries” under documentation in the
home screen or click the ‘Book’ link located next MANET Networks in examples. The help
documentation explains the following:
Introduction
Simulation GUI
Model Features
Featured Examples
Reference Documents
Latest FAQ available online
WSN in NetSim is part of NetSim’s IOT library and covers 802.15.4 MAC, PHY with MANET
routing protocols.
To simulate WSN, click on New Simulation and then Wireless Sensor Networks.
To view help documentation either click on “Technology Libraries” under documentation in the
home screen or click the ‘Book’ link located next to IOT-WSN examples. The help
documentation explains the following:
Introduction
Simulation GUI
Model Features
Featured Examples
Reference Documents
Latest FAQ available online
In NetSim, IOT is modeled as a WSN that connects to the internet via a 6LowPAN Gateway.
WSN for IoT uses the following protocols: AODV with IPv6 addressing at the L3 layer and
802.15.4 at the MAC & PHY layers. WSN sends data to the LowPAN Gateway which uses a
Zigbee (802.15.4) interface and a WAN Interface. The Zigbee interface connects wirelessly to
the WSN and the WAN interface connects to the Internet. Additionally, users can also simulate
and analyze energy model for IoT.
To view help documentation either click on “Technology Libraries” under documentation in the
home screen or click the ‘Book’ link located next to IOT-WSN examples. The help
documentation explains the following:
Introduction
Simulation GUI
Model Features
Featured Examples
Reference Documents
Latest FAQ available online
network control and abstracts the physical infrastructure for applications and network services.
This approach enables enterprises and service providers to respond quickly to the changing
business requirements.
Unlike other technologies, and due to the way SDN works it is not available as a menu item
under New Simulation. SDN can be configured when running Internetworks, MANET, IOT,
WSN, Cognitive Radio, LTE or VANETs
To view help documentation either click on “Technology Libraries” under documentation in the
home screen or click the ‘Book’ link located next to Software Defined Network examples. The
help documentation explains the following:
About SDN
SDN in NetSim
Model Features
Featured Examples
Reference Documents
Latest FAQ available online
NetSim Cognitive Radio module is based on the IEEE 802.22 standard. Additionally, you can
connect a Cognitive Radio with Internetwork devices and run all the protocols supported in
Internetworks.
To simulate Cognitive Radio, click on New Simulation and then Cognitive Radio Networks
To view help documentation either click on “Technology Libraries” under documentation in the
home screen or click the ‘Book’ link located next to Cognitive Radio examples. The help
documentation explains the following:
Introduction
Simulation GUI
Model Features
Featured Examples
Reference Documents
Latest FAQ available online
5.10 LTE
Long Term Evolution (LTE) is a standard for 4G wireless broadband technology that offers
increased network capacity and speed to mobile device users. LTE offers higher peak data
transfer rates -- up to 100 Mbps downstream and 30 Mbps upstream.
Additionally, you can connect an LTE Network with Internetwork devices and run all the
protocols supported in Internetworks.
To simulate LTE/LTE-A networks, click on New Simulation and then select LTE/LTE-A
Networks.
To view help documentation either click on “Technology Libraries” under documentation in the
home screen or click the ‘Book’ link located next to LTE and LTE-A examples. The help
documentation explains the following:
Introduction
Simulation GUI
Model Features
Featured Examples
Reference Documents
Latest FAQ available online
5.11 5G NR
NetSim 5G library features full stack, end-to-end, packet level simulation of 5G NR networks.
The 5G library is based on Rel 15 / 3GPP 38.xxx series.
NetSim 5G library models all layers of the protocol stack as well as applications running over
the network. This 5G library is architected to connect to the base component of NetSim (and
in turn to other components) which provides functionalities such as TCP/IP stack protocols,
Wireless protocols, Routing algorithms, Mobility, Output Metrics, Animation, Traces etc.
5.11.1 5G NR Examples
To view help documentation either click on “Technology Libraries” under documentation in the
home screen or click the ‘Book’ link located next to 5G NR examples. The help documentation
explains the following:
Introduction
Simulation GUI
Model Features
Featured Examples
Specifications scheduled for next release.
Ver 13.0 Page 102 of 281
© TETCOS LLP. All rights reserved
Reference Documents
5.12 VANETs
Vehicular Ad-Hoc Network (VANET) is a subset of a Mobile Ad-Hoc Network or MANET that
allows vehicle-to-vehicle and vehicle-to-roadside communications to ensure safe
transportation.
To view help documentation either click on “Technology Libraries” under documentation in the
home screen or click the ‘Book’ link located next to VANET examples. The help documentation
explains the following:
Introduction
Simulation GUI
Model Features
Featured Examples
Reference Documents
Latest FAQ available online
The satellite can be thought of as a relay station. It operates on the bent-pipe (transparent
star) principle, sending back to Earth what comes in, with only amplification and a shift from
uplink to downlink frequency.
The Satellite MAC layer protocol supported in NetSim is TDMA for forward link and MF-TDMA
for return link (based on the DVB S2 standards). The forward link is in the Ku band (12 – 18
GHz) while the return link is in the Ka band (24 – 60 GHz)
To simulate Satellite Communication networks, click on New Simulation and then click on
Satellite Comm. Networks
To view help documentation users can either click on “Technology Libraries” under
documentation in the home screen or click the ‘Book’ link located next to Satellite-
Communication in examples. The help documentation explains the following:
Introduction
Simulation GUI
Model Features
Featured Examples
Reference Documents
To simulate TDMA Radio Networks, click on New Simulation TDMA Radio Networks and
select TDMA/DTDMA in MAC/PHY layer of the devices.
Note: TDMA Radio Network component is available only in NetSim pro version.
To view help documentation either click on “Technology Libraries” under documentation in the
home screen or click the ‘Book’ link located next to TDMA Radio Networks examples. The help
documentation explains the following:
Introduction
Simulation GUI
Model Features
Featured Examples
Reference Documents
Latest FAQ available online.
Applications are generally parameterized in terms of packet size, inter-packet arrival time,
priority, transport protocol running below etc. Therefore, each application has its own
distinctive traffic pattern and creates its own unique load on the network.
Different applications have differing levels of complexity. Some applications are used to quickly
model basic requirements while in other cases parameters can be accurately modeled to
carefully reproduce real world characteristics. For example, if the goal is to analyze protocol
behavior, then using a simple CBR application (that generates a certain number of packets
every second of a fixed size) would suffice.
1. CBR
2. Custom
3. COAP
4. Database
5. FTP
6. Email
7. HTTP
8. PEER_TO_PEER
9. Video
10. Voice
11. Sensor App
12. Erlang Call
13. BSM
14. Emulation (available only if Emulator Add-on is licensed)
To set up the application click on the application icon from the tool bar as shown below Figure
6-1.
These application models have default values set, for the various application properties, to
model standard application behavior. Users can modify the parameters to model their own
applications.
Application Type: It specifies the type of application such as CBR, Custom, Peer to
Peer, COAP, Email, HTTP, FTP, Voice, Video, Database, Erlang Call, Sensor App,
BSM, and Emulation.
Application ID: This property represents the unique identification number of the
application.
Source Count: This property represents number of sources for the application. Voice,
Video, FTP, Database and Custom applications have only one source.
Source ID: This property represents the unique identification number of the source.
Destination ID: This property represents the unique identification numbers of the
destination.
For Unicast Applications, users can select the ID of a device in the network as the Destination
ID.
For Multicast Applications, users can enter the number of multicast destinations in the
Destination Count filed and specify the Device ID’s of the destination devices separated by
comma (“,”) in the Destination ID field. E.g., 6, 7, 8
Start time: This property represents the start time of the application in seconds.
End time: This property represents the end time of the application in seconds.
For example, if Start time is 1s and end time is 10s then application starts generating traffic at
the 1st second and stops at the 10th second.
Encryption: Encrypts Application packet payload using algorithms such as AES, DES, XOR
and TEA. The effect of encryption can be analyzed by enabling Wireshark option in either the
source or the destination devices. Refer Section 8.7 on “Packet Capture and Analysis Using
Wireshark” for further details.
In NetSim the packet size remains constant when encrypting using these algorithms.
Therefore, using different encryption models will not have any impact on the network
performance metrics that NetSim outputs. NetSim does not perform decryption of the packet
at the receiver end since it does not have any impact on the performance metrics generated.
Random Startup: If random start up is set true, application will start at a random time between
0 and inter-arrival time. Having a random start-up time provides more realism to the model
since all applications need not necessarily start at time = 0 in the real world.
QoS: NetSim provides QoS differentiation for the different types of applications through four
defined scheduling service types, also called QoS classes as shown below Table 6-1.
Table 6-1: Different QoS classes with Description and Priority in NetSim
Priority: The priority is automatically set based on the QoS class set by the user. Depending
on the scheduling algorithm the router would process packets, with different priorities,
differently.
Session Protocol: Session Protocol is applicable only for applications that support RTP
(Real-time Transport Protocol)
Transport Protocol: This parameter is newly added to the Applications window where by
default it selects the Transport Layer Protocol (either TCP or UDP) depending on the
application that is set by the user.
Note: Users can also change the value of this parameter according to the transport protocol they intend to run a
particular application.
....
Peer to Peer File size distribution - Peer-to-peer network does not have
(Constant, Exponential the notion of clients or servers but
distribution) only equal peer nodes that
simultaneously functioning as both
Value – Size of the file bytes
"clients" and "servers" to the other
nodes on the network.
Piece size - Each file is bytes
divided into equal sized Ex – Torrent, LimeWire etc.
pieces. This property
represents the size of
each piece
HTTP – Inter Arrival Time seconds HTTP is a protocol that utilizes TCP
Hyper Text (Constant, Exponential to transfer its information between
Transfer distribution) – It is the time computers (usually Web servers
Protocol gap between two and clients).
successive HTTP requests
TCP should mandatorily be set as
the transport layer protocol.
Page size (Constant, bytes
Exponential distribution) –
It is the size of each page
Multicast response – -
Represents the server
responds to multicast
response or not
It is a specialized web transfer
NSTART – Limit the -
protocol for use with constrained
number of simultaneous
nodes and constrained (e.g., low-
outstanding interactions
power, lossy) networks and
that a client maintains to a
designed for M2M applications
given server
DEFAULT_LEISURE – -
This setting is only
relevant in multicast
scenarios, outside the
scope of the EST-coaps
draft
PROBING_RATE: A -
parameter which specifies
the rate of re-sending
Non-confirmable
messages.
Ver 13.0 Page 112 of 281
© TETCOS LLP. All rights reserved
Ack required – It -
represents whether the
ack for the
request/response to be
sent or not
Ex – FileZilla
....
Suppression models -
available for VBR –
Deterministic, Markov
chain
Erlang Call Packet size (Constant, bytes The erlang is a unit of traffic density
Exponential distribution) – in a telecommunications system.
It is the size of the packet One erlang is the equivalent of one
call
Packet Inter Arrival Time µs
(Constant, Exponential
distribution) - It is the gap Note – Distribution is constant only
between two successful for all codec types except custom
packets
Suppression model -
available for VBR –
Deterministic, Markov
chain
Sensor App Packet size (Constant bytes Used to create application between
distribution) – It is the size two sensors
of the packet
Ex – Smart home, Smart water etc.
BSM – Packet size (Constant, bytes The BSM Application class sends
Basic safety Exponential distribution) – and receives the IEEE 1609 WAVE
message It is the size of the packet (Wireless Access in Vehicular
Environments) Basic Safety
Ex – Traffic management
Destination Real IP -
Specifies the real IP
Address of destination
device in Emulation
Destination Port -
Specifies the Port no used
for reception by
Application running in
destination device
For Voice and Erlang call applications, Codec option is available as follows.
Codec
Codec stands for Coder-decoder. Codecs are devices which encode / decode digital data
streams. Codec is the component of any voice system that translates between analog speech
and the bits used to transmit them. Every codec transmits a burst of data in a packet that can
be reconstructed into voice.
Five different standards of voice codec’s available in NetSim are G.711, G.729, G.723, GSM-
FR, GSM-EFR which can be selected depending on the variations required. Packet size and
Inter-arrival time value will vary depending on the codec value chosen.
G.711: G.711 is a Pulse code modulation (PCM) of voice frequencies on a 64-kbps channel.
G.711 uses a sampling rate of 8,000 samples per second. Non-uniform quantization with 8
bits is used to represent each sample, resulting in a 64-kbps bit rate. There are two types of
standard compression algorithms are used.
µ-law algorithm.
A-law algorithm.
G.729: The G.729 speech codec uses audio data compression algorithm and compress the
data at bit rates that vary between 6.4 and 12.4 kbps. Coding of speech at 8 kbps using
conjugate-structure algebraic-code-excited linear prediction (CS-ACELP).
G.723: G.723 is an ITU standard for speech codecs that uses the ADPCM method and
provides good quality audio at 24 and 40 Kbps.
GSM-FR: GSM–Full Rate (GSM-FR) speech codec was developed in early 1990s and was
adopted by the 3GPP for mobile telephony. The codec operates on each 20ms frame of
speech signals sampled at 8 KHz and generates compressed bit-streams with an average bit-
rate of 13 kbps. The codec uses Regular Pulse Excited – Long Term Prediction – Linear
Predictive Coder (RPE-LTP) technique to compress speech. The codec provides voice activity
detection (VAD) and comfort noise generation (CNG) algorithms and an inherent packet loss
concealment (PLC) algorithm for handling frame erasures. The codec was primarily developed
for mobile telephony over GSM networks.
GSM-EFR: GSM enhanced full rate speech codec is a speech coding standard that was
developed in order to improve the quite poor quality of GSM-Full Rate (FR) codec. Working at
12.2 kbps the EFR provides wire like quality in any noise free and background noise
conditions. The EFR 12.2 kbps speech coding standard is compatible with the
highest AMR mode (both are ACELP).
CUSTOM: It is similar to the CUSTOM application type explained in the table above.
Video Models
Model Type
Continuous Normal VBR – This model is the simplest of all models. It uses Normal
Distribution for the generation of bits per pixel. In this model, consecutive packet sizes
are independent of each other.
o Frames per second – Number of frames arriving per second. This is in the range
of 10 – 100.
o Pixels per frame -Number of pixels in each frame. This is in the range of 10000 –
100000.
o Bits per pixel (µ) – Mean value of the normal distribution used to generate the
value of bits per pixel.
o Bits per pixel (Σ) – Standard Deviation of the normal distribution used to generate
the value of bits per pixel.
The generation rate for video application can be calculated by using the
formula Generation Rate (bits per second) = fps * ppf * bpp
where, fps = frames per second, ppf = pixel per frame, bpp (µ) = bits per
pixel (mean)
Users can set the above-mentioned parameters in the Application
Properties.
Continuous State Autoregressive Markov –This model incorporates the
autocorrelation between the frames. Also, current packet size depends on the previous
packet size via the first order autoregressive Markov process.
o Frames per second – Number of frames arriving per second. This is in the range
of 10 – 50.
o Pixels per frame - Number of pixels in each frame. This is in the range of 10000 –
100000.
o Constants A, B– First order autoregressive Markov process λ(n) can be generated
by the recursive relation λ(n) = aλ(n-1)+bw(n).
o Eta– The steady-state average E(λ)and discreet auto covariance C(n) are given by
E(λ) = (b / (1-a) ) η C(n)=(b2/(1-a2))an where η is the Gaussian parameter.
Quantized State Continuous Time Markov –In this model the bit rate is quantized
into finite discrete levels. This model takes uniform quantization step as A bits/pixel.
There are M + 1 possible levels (0, A… MA). Transitions between levels are assumed
to occur with exponential rates that may depend on the current level. This model is
approximating the bit rate by a continuous time process λ(t) with discrete jumps at
random Poisson time.
o Frames per second – Number of frames arriving per second. This is in the range
of 10 – 100.
o Pixels per frame - Number of pixels in each frame. This is in the range of 10000 –
100000.
o No of Multiplexed Sources– This model considers the aggregate instantaneous
input rate λN (t) instead of the single source bit rate λ (t). The total rate is the sum
of N independent random processes each with mean E (λ) and variance C (0) at
steady state. Therefore, the steady state- mean of λN (t) will be E (λ N) =N x E (λ)
bits/pixel.
o Quantization Level– This model takes uniform quantization step as A bits/pixel.
There are M + 1 possible levels (0, A, MA). Transitions between levels are assumed
to occur with exponential rates that may depend on the current level.
Simple IPB Composite Model–In this model, the frames are organized as
IBBPBBPBBPBBIBBPBB… i.e., 12 frames in a Group of Pictures (GOP). Generate X0
from a Gaussian distribution N(0, y 0). Set initial value N0= 0, D0 = 1.
For k = 1, 2,…, N-1, calculate Φkj , j = 1, 2,…,k iteratively using the following formulae
Dk = Dk-1 –(N2k-1/Dk-1)
Φkk = Nk / Dk
mk = j = 1ΣkΦkjXk-j
Finally, each Xk is chosen from N (mk, y k). Thus, we get a process X with ACF approximating
to r (k).
Where d= H-0.5.
H is called the Hurst parameter k-β is used as the ACF of a self-similar process. We get the
value of H parameter for a self-similar process using the relationship,
Β = 2 – 2H
Distribution of these data is Gaussian. For data to be Beta distributed, the following mapping
is being used.
o Frames per second – Number of frames arriving per second. This is in the range
of 10 – 50.
o Gamma I, Gamma B, Gamma P, Eta I, Eta B, Eta P, Beta I, Beta P, Beta B –
Refer i-button help of Simple IPB Composite Model.
𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺 𝑅𝑅𝑅𝑅𝑅𝑅𝑅𝑅 (𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀) = (𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃 𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠 (𝑏𝑏𝑏𝑏𝑏𝑏𝑏𝑏𝑠𝑠) ∗ 8) / 𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼 𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎 𝑡𝑡𝑡𝑡𝑡𝑡𝑡𝑡 (µ𝑠𝑠)
Video
The traffic generation rate for Video applications are based on the
CONTINUOUS_NORMAL_VBR model. This CONTINUOUS_NORMAL_VBR model is the
Ver 13.0 Page 120 of 281
© TETCOS LLP. All rights reserved
simplest of all video models in NetSim. It uses Normal Distribution for the generation of bits
per pixel. In this model, consecutive packet sizes are independent of each other. The
generation rate for video application can be calculated by using the formula shown below:
Example: Frames per second = 20, pixels per frame = 10000, bits per pixel = 0.52 then the
generation rate would be
Voice
𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺 𝑅𝑅𝑅𝑅𝑅𝑅𝑅𝑅 (𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀) = (𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃 𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠 (𝑏𝑏𝑏𝑏𝑏𝑏𝑏𝑏𝑏𝑏) ∗ 8) / 𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼 𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎 𝑡𝑡𝑡𝑡𝑡𝑡𝑡𝑡 (µ𝑠𝑠))
HTTP
𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺 𝑅𝑅𝑅𝑅𝑅𝑅𝑅𝑅 (𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀) = (𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃 𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠 (𝑏𝑏𝑏𝑏𝑏𝑏𝑏𝑏𝑏𝑏) ∗ 8 ∗ 𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃 𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐) / 𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼 𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎 𝑡𝑡𝑡𝑡𝑡𝑡𝑡𝑡 (𝑠𝑠)
Example: Page size = 20000 Bytes, Page Count = 2, Inter arrival time = 3s
FTP
𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺 𝑅𝑅𝑅𝑅𝑅𝑅𝑅𝑅 (𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀) = (𝐹𝐹𝐹𝐹𝐹𝐹𝐹𝐹 𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠 (𝑏𝑏𝑏𝑏𝑏𝑏𝑏𝑏𝑏𝑏) ∗ 8) / 𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼 𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎 𝑡𝑡𝑡𝑡𝑡𝑡𝑡𝑡 (𝑠𝑠)
Database
𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺 𝑅𝑅𝑅𝑅𝑅𝑅𝑅𝑅 (𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀) = (𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃 𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠 (𝑏𝑏𝑏𝑏𝑏𝑏𝑏𝑏𝑏𝑏) ∗ 8) / 𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼 𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎 𝑡𝑡𝑡𝑡𝑡𝑡𝑡𝑡 (µ𝑠𝑠)
BSM
𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺𝐺 𝑅𝑅𝑅𝑅𝑅𝑅𝑅𝑅 (𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀) = (𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃 𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠 (𝑏𝑏𝑏𝑏𝑏𝑏𝑏𝑏𝑏𝑏) ∗ 8) / 𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼𝐼 𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎 𝑡𝑡𝑡𝑡𝑡𝑡𝑡𝑡 (µ𝑠𝑠)
Priority will have an impact on network performance when multiple applications with different
priorities are configured in a network. These packets will be queued and dequeued from the
router buffer based on the priority.
For example, we can estimate that a certain node generates 1200 packets per minute. These
packets are randomly generated within a minute, but there are on average 1200 packets per
minute. If 1200 packets generated per minute that, on average, one packet is generated every
60 / 1200 = 0.05 seconds. So, let’s define a variable λ = 1/ 0.05 = 20 and call it the rate
parameter. The rate parameter λ is a measure of frequency: the average rate of events
(packets) per unit of time (in this case, seconds).
Knowing this, we can ask questions like, what is the probability that a packet will be generated
within the next second? What’s the probability within the next 10 seconds? There’s a well-
known function to answer such questions. It’s called the cumulative distribution function for
the exponential distribution, and it looks like this:
𝐹𝐹(𝑥𝑥 ) = 1 − 𝑒𝑒 −𝜆𝜆𝜆𝜆
Figure 6-3: Plot for cumulative distribution function for the exponential distribution
Basically, the more time passes, the more likely it is that a packet is generated. The word
“exponential”, in this context, refers to exponential decay. As time passes, the probability of
having no packets generated decays towards zero – and correspondingly, the probability of
having at least one packet generated increases towards one.
The probability of generating a packet within the next 0.05 seconds is F (0.05) ≈ 0.63
The probability of generating a packet within 1 second is F (1) ≈ 0.999999998
In particular, note that after 0.05 seconds – the prescribed average time between packets –
the probability is F (0.05) ≈ 0.63.
We simply write a function to determine the exact amount of time until the next packet. This
function should return random numbers, but not the uniform kind of random number produced
by most generators. We want to generate random numbers in a way that follows our
exponential distribution.
Given that the inverse of the exponential function is ln, it’s easy to write this analytically, where
R is the random value between 0 and 1:
1 − 𝑅𝑅
𝑇𝑇 = − 𝑙𝑙𝑙𝑙𝑙𝑙𝑒𝑒
𝜆𝜆
The simple way of selecting this via the UI is to select exponential distribution for inter-arrival
time inside application properties.
Application path is the current workspace location of the NetSim that you want to run. The
default application path will be something like
“C:\Users\PC\Documents\NetSim_13.0.14_64_std_default\bin\bin_x64” for 64-bit and
“C:\Users\PC\Documents\NetSim_13.0.14_32_std_default\bin\bin_x86” for 32-bit. For
more information on NetSim workspace, Refer Section 4 “Workspaces and Experiments”.
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 IO path can be got by
Start Run %temp%/NetSim. Once you reach this folder, the user can notice that the
path would be something like
“C:\Users\PC\AppData\Local\Temp\NetSim\std13.0.14_x64”
The IO path is the path where the Configuration.netsim (NetSim Configuration file) of the
scenario, that will be simulated, should be present.
App path and IO path can also be same, i.e., Configuration.netsim can be placed inside the
app path (if the app path has the write permission). Otherwise, users can create a folder for
IO path and Configuration.netsim can be placed inside that folder.
Note: Sample configuration.netsim files are available in the <NetSim installation Directory>/Docs/
Sample_Configurations folder of the NetSim install directory inside the respective protocol folder names.
To run NetSim through command line, copy the app path where NetSimCore.exe is present
and paste it in the command prompt.
Note: File path should be always added in the command prompt within double quotes. For example,
>cd “C:\Users\PC\Documents\NetSim_13.0.14_64_std_default\bin\bin_x64”
For floating licenses, type the following in the command prompt. The type of license can be
seen by clicking on Help About NetSim in GUI of NetSim.
Where,
<app path> contains all files of NetSim including NetSimCore.exe. Specifying the app
path is optional. NetSim will take the current path as app path if not specified.
<iopath> contains Configuration.netsim. (Configuration.xsd is available in the bin
folder of NetSim’s current workspace path
<C:\Users\PC\Documents\NetSim_13.0.14_64_std_default\bin\bin_x64> for 64-bit
and <C:\Users\PC\Documents\NetSim_13.0.14_64_std_default\bin\bin_x86> for
32-bit). Refer section 7.2.4 to know about 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.
Note: Please contact your network administrator / lab in-charge to know the IP address of the PC where
the NetSim license server is running.
The following screenshot is the example of running NetSim through CLI where the ip address
of the NetSim license server is 192.168.0.9.
Figure 7-1: Running NetSim through CLI mode for floating license
For cloud licenses and node-locked licenses, type the following in the command prompt
>NetSimCore.exe<space>apppath<space><apppath><space>iopath<space><io
path><space>-license<space><license file path>
Where,
The following screenshot is the example of running NetSim through CLI for the node locked or
cloud license.
Figure 7-2: Running NetSim through CLI mode for Cloud and Node lock licenses
Once simulation is complete the text files that are requested by the end user in
Configuration.netsim will be written in the <iopath>.
To know more about the options that are available to run NetSim via CLI, type the following in
the command prompt.
>NetSimCore.exe –h
With Quick Edit mode, you can copy text between a command window and Windows-based
programs, and you can also paste text into a command window by using a right-click
operation. To use Quick edit mode in command prompt users can run the command prompt
Right Click the icon in the upper-left corner of the Command Prompt window, and then
Click Properties In the options, enable Quick Edit mode and click on OK.
The simulation engine that contains DLLs and NetSimCore.exe reads this
Configuration.netsim, executes the simulation and writes output metrics files. The GUI then
displays the metrics based on the text files written by the backend.
In order to run NetSim through command line (CLI), the user must create the
Configuration.netsim file furnishing all the details about the devices, links and the environment
of the desired scenario.
In Visual Studio, XML view provides an editor for editing raw XML and provides IntelliSense
and color coding. After you type the element name and press the CTRL+ SPACE, you will be
presented with a list of attributes that the element supports. This is known as “IntelliSense”.
Using this feature, you can select the options that are required to create the desired scenario.
Color coding is followed to indicate the elements and the attributes in a unique fashion.
The following screenshot displays the Configuration.netsim which is opened through the Visual
Studio as shown below Figure 7-5.
EXPERIMENT_INFORMATION
GUI_INFORMATION
NETWORK_CONFIGURATION
SIMULATION_PARAMETER
PROTOCOL_CONFIGURATION
STATISTICS_COLLECTION
EXPERIMENT_INFORMATION:
This section contains the details about the user credentials, such as the user mode (Admin or
Exam or Practice), experiment name, date on which the experiment is created and the
comments about the experiment. This section plays a significant role while running NetSim
through GUI.
GUI_INFORMATION:
This section contains the GUI information like the environment length, view type etc. and the
network name which is desired to be run.
NETWORK_CONFIGURATION:
This section is used to configure the devices and the links of the desired network at each layer
of the TCP/IP stack. It consists of DEVICE_CONFIGURATION, CONNECTION and
APPLICATION_CONFIGURATION. DEVICE_CONFIGURATION configures the devices in
the desired network while the CONNECTION configures the links in the desired network and
APPLICATION configures the Applications.
SIMULATION_PARAMETER:
PROTOCOL_CONFIGURATION:
IPV4 and static ARP are enabled or disabled in this section. The text files illustrating the static
routing and static ARP can be obtained by enabling the corresponding tags in the
Configuration.netsim.
STATISTICS_COLLECTION:
The packet trace and the event trace can be observed in the text files which are created by
enabling the tags in this section. The required fields of the packet trace can be enabled in the
PACKET_TRACE while the event trace can be enabled in the EVENT_TRACE of this section.
Sample “Configuration.netsim” file will be installed in user system along with the software at
<NetSim installed Path>\Docs\ Sample_Configuration\ <Network Technology>.User can open
and edit these files using Visual Studio 2015/2017/2019 or any XML editor. The purpose of
providing the sample “Configuration.netsim” file is to assist the user in writing a network
scenario manually by analyzing the format for that specific network technology.
Configuration.xsd is an XML schema Definition file which is present in the bin folder of
NetSim’s current workspace path <C:\Users\PC\Documents\NetSim_13.0.14_64_std_default
\bin\bin_x64> for 64-bit and <C:\Users\PC\Documents\NetSim_13.0.14_64_std_default
\bin\bin_x86> for 32-bit.
Configuration.xsd file can be placed inside the <iopath> along with the configuration.netsim
file to verify the contents in the configuration.netsim file. This file checks and validates the
structure and vocabulary of a configuration.netsim document against the grammatical rules of
the appropriate XML language.
It is not mandatory to place the configuration.xsd file along with the Configuration.netsim file
in the iopath. But if it is done, then it will be easier to check & validate changes that are done
to the Configuration.netsim file.
Results are organized per interface, per device, per application and per link. In addition,
summary metrics are aggregated and presented system-wide (network-level). Information in
the trace files contain individual packet flow and individual event execution. Protocol log files
records a myriad of information pertaining to protocol operation necessary for in-depth analysis
and debugging.
The results can be exported as a .csv file and opened in a spread sheet software like Excel.
Results can also be exported in .html format and opened in a browser.
If plots are enabled, NetSim plots Instantaneous (50 ms averaging window), Cumulative
moving average and Time Average for link and application throughputs.
The ‘re-plot’ option can be used to change the X-value Min and Max, and to change the
averaging window for plotting the instantaneous throughput.
The buffer occupancy over time can be plotted by setting Buffer Occupancy Plot Enabled to
True. This parameter is available wherever there are buffers in NetSim such as in Router –
WAN Port – Network Layer as shown Figure 8-3.
Figure 8-3: Buffer Occupancy Plot Enabled to True in WAN Port – Network Layer
Upon simulation the buffer occupancy plot can be opened from the Results Window and
would look like what is shown below Figure 8-4.
The TCP Congestion window over time can be plotted by setting Congestion Window Plot
Enabled to True. This parameter is available wherever in the end nodes in NetSim where
TCP has been enabled, for example Wired Node – Transport Layer.
Figure 8-5: Set TCP Congestion Plot Enabled to True in Transport Layer
Upon simulation the TCP congestion window plot can be opened from the Results Window
and would look like what is shown below Figure 8-6.
Here users can view the values of the metrics obtained based on the overall network and also
displays the values of the metrics pertaining to each link.
Formula:
Total Bytes transmitted is counted for successful data packets and control packets.
The calculation is based on the packet size (bytes) at the PHY layer, which would include app
layer payload plus the overheads of all layers. Error and collision packets are not included in
this calculation and only successful packets are counted for calculation of this metric.
Packets_ Transmitted - It is the total number of packets transmitted in the link. Along
with data packets, it includes protocol control packets like ARP Request, ARP Reply,
TCP_ACK, TCP_SYN, RTS, CTS, WLAN_ACK, OSPF_ HELLO, RIP packets etc.
Packets_ errored - Total number of packets error in the link inclusive of data and
control packets.
Packets_ collided - Total number of packets collided in the link including data and
control packets.
Bytes_ Transmitted - It is the total number of bytes transmitted in the link. It is equal
to the sum of the ‘Payload_ Transmitted’ and ‘Overhead_ Transmitted’ transmitted in
the link.
Payload_ Transmitted - It is the total payload transmitted in the link.
Overhead_ Transmitted - It is the total overhead transmitted in the link. It includes the
layer wise overheads and all control packets in the link.
Displays the values of the queue metrics for the devices containing buffer queue like routers,
access points etc.
The Performance metrics tables of protocols such as TCP, UDP, IP, IEEE802.11, LTE, AODV
and DSR are provided in the respective technology library documentation.
Displays device related metrics like ARP table, IP forwarding tables. This is also dependent
upon the type of network/technology simulated.
IP_Forwarding Table
Switch MAC Address Table: These metrics will be displayed when we run networks having
Switches.
8.1.13 CR metrics
BS Id - It is the Id of the BS
Channel Number - It represents the channel number at which the BS is operating.
Frequency - It is the frequency of the channel at which the BS is operating.
Spectral efficiency - It refers to the information rate that can be transmitted over a
given bandwidth in a specific communication system. It is a measure of how efficiently
a limited frequency spectrum is utilized by the physical layer protocol, and sometimes
by the media access control protocol.
Jitter
𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃 𝐽𝐽𝐽𝐽𝐽𝐽𝐽𝐽𝐽𝐽𝐽𝐽 (𝜇𝜇𝜇𝜇) = |𝐸𝐸𝐸𝐸𝐸𝐸𝐸𝐸𝐸𝐸𝐸𝐸𝐸𝐸𝐸𝐸 𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷 𝑜𝑜𝑜𝑜 𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶 𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝 − 𝐸𝐸𝐸𝐸𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑 𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷 𝑜𝑜𝑜𝑜 𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃 𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃|
Delay - It is the average amount of time taken (calculated for all successful packets) to
reach the destination application layer from when the packet is sent from source’s
application later. It would APP_IN time at destination – APP_OUT time at source.
8.1.15 IP Metrics
IP layer metrics calculated for the overall network and displayed for each device.
In the Application metrics table, in addition to packets generated and packets received,
additional information on duplicate packets that were received can be obtained. This is
achieved by adding the following environment variable:
1. The metrics are calculated at each layer and might not be equivalent to the same metric
calculated at a different layer. For exactness and precision, we recommend users also
verify the results with the event trace & packet trace generated by NetSim.
2. Broadcast / Multicast application will have no entries under Application Metrics in
Results window if there are zero packets received. In other words, it will not show ‘0’
throughput. Users may notice that ‘0’ throughput is shown for unicast applications, and
this is because of the way Broadcast/Multicast application metrics is architected in
NetSim.
The following table lists the various files that will be written in the NetSim install directory/ IO
path on completion of simulation.
S. No File Contents
Contains the metrics of the network
1 Metrics.xml that is simulated recently.
Contains the information of captured
2 Node.pcap packets that is recently simulated.
Contains the status of the
LicenseErrorLog.txt communication between the NetSim
3
dongle and the client
Table 8-1: Different results files written at the end of simulation in I/O Path
If NetSim runs via the UI, then the metrics will be displayed automatically at the end of
simulation with illustrative tables.
If NetSim runs via CLI, then the metrics will be written into Metrics.txt and MetricsGraph.txt.
XL/CSV file:
Figure 8-10: Option Export Results (.xls/.csv) to export all the metrics
A web formatted (html file) report can be generated for simulations performed in NetSim, using
the Print button present in the results window as shown below Figure 8-11.
The packet animation would then be recorded and the user can view the animation from the
NetSim Packet Animation window as shown below Figure 8-14.
Packet Animation table is also provided for users to see the flow of packets along with packet
animation.
Figure 8-16: Table Filters option available in the Packet Animator Window
Note: Packet Animation table would be displayed only if Packet Trace is enabled in the
network before running the simulation.
NetSim Packet Animation can be customized using the View More drop-down list provided
with the display settings as shown below Figure 8-17.
Device Name
IP address of devices
VLAN ID
Application Flow
Node Movement
Packet Flow
Battery Level
Route tables etc alongside animation
Note: The options displayed under View more drop down are dependent on the network that
is simulated and features that are enabled.
Create a scenario with 3 wired nodes, 2 switches and 1 router and connect it based on
the following scenario.
Disable TCP in all the wired nodes.
Click on application and set Source_Id and Destination_Id as 1 and 2 respectively.
Set Simulation time = 100s. After clicking on Run Simulation, edit Static ARP
Configuration tab by setting Static ARP as Disable. Click on OK button to simulate.
Case 2: Across-Router-IP-forwarding
If the router has the address of NODE-3 in its routing table, ARP protocol ends here
and data transfer starts that is PACKET_ID 1 is being sent from NODE-1 to NODE-3.
In other case, Router sends ARP_Request to appropriate subnet and after getting the
MAC ADDRESS of the NODE-3, it forwards the packet which it has received from
NODE-1.
When a node has to send data to a node with known IP address but unknown MAC
address, it sends an ARP request. If destination is in same subnet as the source (found
through subnet mask) then it sends the ARP (broadcast ARP message) request,
otherwise it forwards it to the default gateway.
Former case happens in case of intra-LAN communication. The destination node
sends an ARP response which is then forwarded by the switch to the initial node. Then
data transmission starts.
In latter case, a totally different approach is followed. Source sends the ARP request
to the default gateway and gets back the MAC address of default gateway. (If it knows
which router to send then it sends ARP request to the corresponding router and not to
Default gateway).
When source sends data to default gateway (a router in this case), the router
broadcasts ARP request for the destined IP address in the appropriate subnet. On
getting the ARP response from destination, router then sends the data packet to
destination node.
Note: The following procedure applies to Windows 10 Operating system only. Users with other
versions of Windows can use third-party video capture tools (Link to a list of common tools) to
save NetSim packet animation as a video.
To quickly capture NetSim packet animation, launch the packet animation window. Before
playing the animation, press Windows key + G on the keyboard to open Game bar. (or Select
windows settings and then select Gaming option for Game bar related settings). Now start
recording by pressing record option as shown below. (Shortcut to start recording Windows
key + Alt + R)
Figure 8-22: In packet animation window press Windows key + G on the keyboard and Select Start
recording
Then select the checkbox “Enable gaming features for this app to record gameplay” option.
Figure 8-23: Select the checkbox “Enable gaming features for this app to record gameplay” option
Once you select the checkbox, recording window will open as shown below.
The packet trace is written whenever a packet is received at a device. For example, if we have
transmission N1 -> N2 -> N3, then the packet trace is written for every packet being received
at N2 and at N3. Note that it not written for every packet being transmitted by N1 and the
subsequently by N2. This means that packet which are transmitted from N1 but which may
have been errored or collided before being received by N2 are not written in the packet trace.
By providing a host of information and parameters of every packet that flows through the
network, packet trace provides necessary forensics for users to catch logical errors without
setting a lot of breakpoints or restarting the program often. 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.
Note: By default, packet tracing option is turned off. Turning on Packet Trace will slow down the simulation
significantly. After simulation, users would get the “open packet trace” link in the metrics window (will also
get Packet_Trace.csv file in the saved folder).
Step 1: Open the trace file. (In this example packet trace is opened)
Step 2: Click the arrow in the header of the column you want to filter. In the list of text or
numbers, uncheck the (Select All) box at the top of the list, and then check the boxes of the
items you want to show.
For example, click on arrow of SOURCE_ID and uncheck the “Select all” check box and select
NODE 2 then click on OK.
All the rows which are having NODE 2 as source id will be shown below Figure 8-28.
Figure 8-27: Select Transmitter ID arrow mark in the header in packet trace
8.4.2 Observing packet flow in the Network through packet trace file
Open the packet trace file, Click the arrow in the header of the column PACKET_ID and
uncheck the “Select all” check box and select the packet id which you want to observe, for
example 1, and then click on OK.
Figure 8-29: Select Packet ID arrow mark in the header in packet trace
Scenario is as shown below Figure 8-30 and traffic flow is from Wired Node 2 to Wired Node
3.
In a scenario source and destinations are fixed but transmitter and receiver are changed. For
example, in the above scenario NODE-2 is the source and NODE-3 is the destination, but
when NODE- 2 sending the packet to the ROUTER-1 then NODE-2 is the transmitter and
ROUTER-1 is the receiver. When ROUTER-1 sending the packet to the NODE-3, ROUTER-
1 is the transmitter and NODE-3 is the receiver.
NetSim Packet trace is saved as a spread sheet. Packet Trace 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.
If you enable packet trace, Open Packet Trace link present in the Simulation Results Window
can be used to load the packet Trace file in MS-Excel. Formats the spread sheet as a table
for convenient analysis.
Figure 8-33: Sheet 2 of the packet trace file has a pivot table
Sheet 3 of the packet trace has a blank pivot table – Pivot Table (Custom) which can be used
to create additional pivot tables from scratch.
Figure 8-34: Sheet 3 of the packet trace file has a blank pivot table
Steps to analyse the packet trace using pivot tables
Step 1: Click on Packet Trace in the result dashboard, you can find 3 sheets will be created
i.e. Packet Trace, Pivot Table (TX-RX), Pivot Table (Custom)
Figure 8-35: Packet Trace, Pivot Table (TX-RX), Pivot Table (Custom) in packet trace
Step 2: Click on Pivot Table (Custom) to create your own pivot table.
Figure 8-36: Select Blank Pivot Table (Custom) to create your own pivot table
Once you open the sheet PivotTable (Custom), you'll need to decide which fields to add.
Each field is simply a column header from the source data. In the PivotTable Field List,
check the box for each field you want to add.
• 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 as
shown below Figure 8-37.
• 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 to VALUES.
Figure 8-38: Selected fields add to one of the four areas below the Field List
• The PivotTable will calculate and summarize the selected fields. In this example, the
PivotTable shows the packets sent from all sources to all destinations.
• The above example shows all the packets which including data packets and control
packets.
• If you wish to know how many Data and how many were control packets then, check
the PACKET_TYPE and drag it to the ROWS field as shown below Figure 8-40.
Figure 8-40: Select the PACKET_TYPE Check Box and drag it to the ROWS fields
We explain this using a packet trace generated per the following network scenario.
Insert a column after PHY_LAYER_END_TIME, then select the whole column and
calculate delay for each and every packet by using the formula.
=PHY_LAYER_END_TIME – APPLICATION_LAYER_ARRIVAL_TIME
Figure 8-50: Drag and drop DELAY value that we have calculated earlier to
ROWS and VALUES field
Click on Count of DELAY drop down and select Value Field settings, then Select SUM
and click on OK.
Figure 8-51: Select Count of DELAY drop down and select Value Field settings as SUM
Again, Drag and drop DELAY to VALUES field.
Figure 8-54: Compare the obtained DELAY with Application Metrics DELAY
To calculate DELAY for VOICE application, filter DESTINATION_ID to Node-5,
RECEIVER_ID to Node-5, CONTROL_PACKET_TYPE/APP_NAME to APP2_VOICE
and PACKET_STATUS to Successful
Similarly calculate and compare DELAY for other applications by following the above
procedure.
To explain how users can perform Throughput Analysis, we have used same network design
example as was used for Delay analysis above.
After loading the packet trace switch to sheet Pivot Table (Custom), drag and drop
SOURCE_ID, RECEIVER_ID, CONTROL_PACKET_TYPE / APP_NAME and
PACKET_STATUS to FILTERS field.
Similarly drag and drop APP_LAYER_PAYLOAD to ROWS field and VALUES field.
Filter SOURCE_ID to NODE-2, CONTROL_PACKET_TYPE APP_NAME to
APP1_CBR, PACKET_STATUS to Successful and RECEIVER_ID to NODE-3
Click on Count of APP_LAYER_PAYLOAD drop down and select Value Field settings,
then Select Sum and click on OK.
The pivot table would look like.
Figure 8-56: Calculate the throughput by using the formula in Pivot Table
EmptyCell=GETPIVOTDATA("APP_LAYER_PAYLOAD(Bytes)",$A$6,"APP_LAYER_PA
YLOAD(Bytes)",1460)*8/10000000
Now compare the throughput calculated using pivot table with the Application Metrics
throughput.
Figure 8-57: Compared the calculated throughput using pivot table with the Application
Metrics throughput
To calculate THROUGHPUT for VOICE application, filter SOURCE_ID to Node-4,
RECEIVER_ID to Node-5, CONTROL_PACKET_TYPE/APP_NAME to APP2_VOICE
and PACKET_STATUS to Successful
Similarly calculate and compare THROUGHPUT for other applications by following the
above procedure.
In a pivot table, you can create a new field that performs a calculation on the sum of other
pivot fields.
Figure 8-58: Drag and drop Sleeted Fields to one of the four areas
below the Field List
Filter SOURCE_ID to Node 2, Node 4 and Node 6, then RECEIVER_ID to Node 3,
Node 5 and Node 7 and PACKET_STATUS to successful
PHY_LAYER_START_TIME Specifies the time at which packet starts betting transmitted in the link
(μs) between Transmitter_ID and Receiver_ID
PHY_LAYER_END_TIME
Specifies the time at which packet reaches Phy_Layer of Receiver_ID
(μs)
APP_LAYER_PAYLOAD
Specifies the size of the Payload at Application Layer
(Bytes)
TRX_LAYER_PAYLOAD
Specifies the size of the Payload at Transport Layer
(Bytes)
NW_LAYER_PAYLOAD
Specifies the size of the Payload at Network Layer
(Bytes)
MAC_LAYER_PAYLOAD
Specifies the size of the Payload at Data Link Layer
(Bytes)
PHY_LAYER_PAYLOAD
Specifies the size of the Payload at Physical Layer
(Bytes)
PHY_LAYER_OVERHEAD
Specifies the size of the overhead in Physical layer
(Bytes)
PACKET_STATUS Specifies whether the Packet is Successful, Collided or Errored
Specifies the Port Number at Source Node. Port Numbers are chosen
LOCAL_ADDRESS
randomly by NetSim.
Specifies the Port Number at Destination Node. Port Numbers are
FOREIGN_ADDRESS
chosen randomly by NetSim.
CWND (bytes) Specifies the current size of the TCP congestion window
SEQ_NO If TCP is enabled, it specifies the TCP Sequence number of the packet
If TCP is enabled, it specifies the TCP Acknowledgement number of
ACK_NO
the packet
Each line in the packet trace represents one hop of one packet.
NetSim’s Network Stack forms the core of NetSim and its architectural aspects are
diagrammatically explained below. It exactly mirrors the TCP/IP stack and has the following
five layers.
Network Stack accepts inputs from the end-user in the form of Configuration file and the data
flows as packets from one layer to another layer in the Network Stack.
All packets, when transferred between devices move up and down the stack, and all events in
NetSim fall under one of these ten categories of events, namely, Physical IN, Data Link IN,
Network IN, Transport IN, Application IN, Application Out, Transport OUT, Network OUT,
Data Link OUT and Physical OUT. The IN events occur when the packets are entering a
device while the OUT events occur while the packet is leaving a device. In addition to these
events there can be TIMER events associated with each protocol.
Figure 8-65: Flow of one packet from a Wired node to a Wireless node
Every device in NetSim has an instance of the Network Stack shown above. Switches &
Access points have a 2-layer stack, while routers have a 3 layer stack. End-nodes have a 5
layer stack.
The protocol engines are called based on the layer at which the protocols operate. For
example, TCP is called during execution of Transport IN or Transport OUT events, while
802.11b WLAN is called during execution of MAC IN, MAC OUT, PHY IN and PHY OUT
events.
When these protocols are in operation, they in turn generate events for NetSim's discrete event
engine to process. These are known as SUB EVENTS. All SUB EVENTS, fall into one of the
above 10 types of EVENTS and TIMER events if applicable.
Each event gets added in the Simulation kernel by the protocol operating at the particular layer
of the Network Stack. The required sub events are passed into the Simulation kernel. These
sub events are then fetched by the Network Stack in order to execute the functionality of each
protocol. At the end of Simulation, Network Stack writes trace files and the Metrics files that
assist the user in analyzing the performance metrics and statistical analysis.
The event trace records every single event along with associated information such as time
stamp, event ID, event type etc. in a text file or .csv file which can be stored at a user defined
location. Apart from a host of information, the event trace has two special information fields for
diagnostics.
A log of the file name and line number from where the event was generated (Please
refer “Writing Custom Code in NetSim Debugging your code Via CLI”) and
Note: Turning on Event Trace will slow down the simulation significantly
If NetSim runs via GUI, event trace can be turned on by clicking the Event Trace icon in the
tool bar and selecting the required fields in the event trace.
If NetSim runs via CLI, then the event trace can be turned on by enabling the event trace in
the STATISTICS_COLLECTION tag of the configuration file. Following is a screenshot of a
Configuration.netsim file with Event Trace disabled:
Figure 8-66: Open Configuration.netsim in Visual Studio and Event Trace disabled
You can see that the STATUS is set to DISABLE, file name and file path are not set. To enable
Event trace these parameters can be modified by editing the Configuration file. Open
Configuration.netsim file and provide the file name, path and set status as Enable. Following
is a screenshot of a Configuration.netsim file with Event Trace enabled:
2. Click Event Trace option (Open Event Trace) in the Simulation results window as
shown in below Figure 8-68.
Note: Event tracing is available only in NetSim standard and pro versions.
1. Drag and drop the Event_Type, Protocol_Name Fields into FILTERS, Packet_Id into
ROWS and Device_Id into COLUMNS.
2. Drag and Drop Event_Time Field into VALUES twice, then both will show Sum of
Event_Time. Recheck that you have dropped the Event_Time field twice.
3. Click on the second Event_Time field in the VALUES and select the Value Field
Settings.
Figure 8-71: Select Second Event_Time field in the VALUES and select the Value Field Settings
Figure 8-73: Sleeted Fields to one of the four areas Field list
6. In the Event_Type select APPLICATION_IN and APPLICATION_OUT,
Protocol_Name select APPLICATION and in Column Labels select the Source_Id
and Destination_Id. In our example source node ID is 1 and destination node ID is 10
Figure 8-74: Select the Event type, Protocol Name, Source and Destination ID etc
And the Pivot Table created will be as shown (1 in the table is Source_Id and 10 is the
Destination_Id)
Figure 8-76: Select Entire empty column H then and enter the formula =IF(AND(LEN(A1),
INT(A1)=A1),F1-G1*B1) in function and press CTRL+ENTER
𝑆𝑆𝑆𝑆𝑆𝑆 𝑜𝑜𝑜𝑜 𝑡𝑡ℎ𝑒𝑒 𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷 𝑜𝑜𝑜𝑜 𝑡𝑡ℎ𝑒𝑒 𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠 𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟 𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎 𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑 𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝 𝑏𝑏𝑏𝑏 𝑡𝑡ℎ𝑒𝑒 𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑
App Delay =
𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇 𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛 𝑜𝑜𝑜𝑜 𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠 𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎𝑎 𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑 𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝𝑝 𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟 𝑏𝑏𝑏𝑏 𝑡𝑡ℎ𝑒𝑒 𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑
Note: If the packet size is > 1500 then fragmentation occurs and the packet is received as multiple
segments. In NetSim the destination counts each segment as different packet.
Figure 8-78: Compare the Application_Metrics_Tables Delay and Pivot table Delay
Figure 8-79: Sleeted Fields to one of the four areas Field list
Then Select the Event_Type as APPLICATION_IN, Protocol_Name as APPLICATION and
Device_Id as the Destination (in this case 10).
Figure 8-80: Select the Event type, Protocol Name, Source and Destination ID etc
𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇𝑇ℎ𝑒𝑒𝑒𝑒𝑒𝑒𝑒𝑒𝑒𝑒𝑒𝑒𝑒𝑒𝑒𝑒𝑒𝑒𝑒𝑒𝑒𝑒𝑒𝑒
2. App Throughput =
𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑖𝑖𝑖𝑖𝑖𝑖
This give the Application Throughput in Mbps (Multiplied by 8 to convert Bytes to bits, and
divided by 100000 to convert into Mega)
Figure 8-82: Compare the Application_Metrics_Tables throughput and Pivot table throughput
NetSim provides functionality to capture packets in the virtual nodes. The pcap file written by
NetSim contains fields of packet layer 3 and above. This pcap file can be opened using the
popular software, Wireshark (formerly Ethereal).
To enable packet capture in Wireshark, Right Click on the device where wireshark should be
run. In the properties, go to General_Properties and set the Wireshark Capture parameter as
Online.
If enabled, Wireshark Capture automatically starts during simulation and displays all the
captured packets. To view the details of the packet displayed, click-on the packet as shown
below Figure 8-84.
In the above figure, the details of the packet are displayed in both tree form and bytes form. In
the tree form, user can expand the data by clicking on the part of the tree and view detailed
information about each protocol in each packet.
Display filters allow you to concentrate on the packets you are interested in while hiding the
currently uninteresting ones. Packets can be filtered by protocol, presence of a field, values of
field’s etc. To select packets based on protocol, type the protocol in which you are interested
in the Filter: field of the Wireshark window and presenter to initiate the filter. In the figure below
Figure 8-86, tcp protocol is filtered.
Figure 8-87: Filtered SYN Flag and ACK Flag are set to 1 in a TCP Stream
8.6.4 Analyzing packets in Wireshark
A network conversation is the traffic between two specific end points. For example, an IP
conversation is all the traffic between two IP addresses. In Wireshark, Go to Statistics Menu
Conversations as shown below Figure 8-88.
The flow graph feature provides a quick and easy to use way of checking connections between
a client and a server. It can show where there might be issues with a TCP connection, such
as timeouts, re-transmitted frames, or dropped connections. To access flow graph, go to
Statistics Menu Flow Graph and select the flow type. By default, you can see the flow
graph of all the packets. To get the TCP flow, select TCP flow in “Flow Type” dropdown box
and you will obtain the flow as shown Figure 8-96.
There are various important steps in this process, and each of these steps has various options
as explained in the subsequent pages.
1. Under the Workloads tab users can select Desktop Development with C++ as
shown below Figure 9-1.
2. Under the Individual components tab select VC++2015.3 V140 toolset for desktop
(x86,x64).
Figure 9-2: In Individual components tab select VC++2015.3 V140 toolset for desktop
(x86,x64).
9.1.2 Modifying code
DLL is the shared library concept, implemented by Microsoft. All DLL files have a .dll file
extension. DLLs provide a mechanism for sharing code and data to upgrade functionality
without requiring applications to be re-linked or re-compiled. It is not possible to directly
execute a DLL, since it requires an EXE for the operating system to load it through an entry
point. NetSim requires Visual Studio Compiler for building DLL’s.
Note: Make sure that Visual Studio 2015 or above is installed in your system.
Refer section 4.12 section “How does a user open and modify source codes” to open NetSim
Source Codes
1. After this you may modify the source codes of any project. You can also add new files
to the project if required. As an example, let us make a simple source code modification
to TCP. Inside Solution Explorer pane in Visual Studio, double click on TCP project.
Then open TCP.c file by double clicking on it. Using the drop down list of functions that
are part of the current file, choose fn_Netsim_TCP_Init().
1. Identify the build of NetSim that is installed in your system from NetSim Home Screen
as shown below Figure 9-6.
Figure 9-7: Based on the build of NetSim select Win32/x64 in Visual studio
3. Choose x64 for 64 bit version of NetSim and Win32 for 32 bit version of NetSim. After
changing the solution platform, changes will be automatically applied to all projects that
are displayed in the Solution Explorer.
4. Now rebuild the network by right clicking on the project header and selecting Rebuild
creates a Dll file in the bin folder of NetSim’s current workspace path
<C:\Users\PC\Documents\NetSim_13.0.14_64_std_default\bin\bin_x64> for 64-bit
and <C:\Users\PC\Documents\NetSim_13.0.14_64_std_default\bin\bin_x86> for 32-
bit which contains your modifications. If build is successful a message similar to the
following will be displayed in the output window as shown below Figure 9-8.
Figure 9-8: Build is successful a message similar to the following will be displayed in the output
window
9.1.4 Running Simulation
1. After rebuilding the code, user can run the simulation via GUI (Please refer section 3).
In this case, user can create a scenario in any network which involves TCP protocol.
Running the simulation with the custom DLL will initially display a warning message as
shown below Figure 9-9.
Figure 9-9: Modified Project display a DLL warning message to NetSim Console
2. The warning message lists the Dll files which have been modified in the bin folder
(bin\bin_x86 for 32-bit and bin\bin_x64 for 64-bit) of NetSim’s current workspace path.
After pressing any key, the statement “Source is modified” will be printed to console as
shown below Figure 9-10.
The following are the list of projects that are part of NetSim source codes present in
<NetSim_Install_Directory>/src/Simulation directory and their dependencies:
PROJECT DEPENDENCY
Application IP
Cellular Application
CLIInterpertor Firewall, IP
Cognitive Radio Application
Ethernet Firewall
IEEE802_11 Battery Model
OSPF IP
Routing IP
RPL IP
ZigBee Battery Model
ZRP IP
Aloha -
AODV -
ARP` -
Battery Model -
CSMACD -
DSR -
Firewall -
IEEE1609 -
IP -
LTE NR
Mobility -
P2P -
SDN -
Support Function -
TCP -
Token_BR -
UDP -
UWAN
DTDMA -
TDMA -
Satellite Comm. Networks -
/sdl enables a superset of the baseline security checks provided by /GS and overrides /GS-.
By default, /sdl is off. /sdl- disables the additional security checks.
Warning Equivalent
enabled by command-line Description
/sdl switch
A unary minus operator was applied to an unsigned
C4146 /we4146
type, resulting in an unsigned result.
A negative integral constant converted to unsigned
C4308 /we4308
type, resulting in a possibly meaningless result.
Use of continue, break or goto keywords in a
C4532 /we4532 __finally/finally block has undefined behavior during
abnormal termination.
C4533 /we4533 Code initializing a variable will not be executed.
C4700 /we4700 Use of an uninitialized local variable.
Use of a potentially uninitialized local pointer
C4703 /we4703
variable.
Buffer overrun when specific C run-time (CRT)
C4789 /we4789
functions are used.
C4995 /we4995 Use of a function marked with pragma deprecated.
C4996 /we4996 Use of a function marked as deprecated.
Implementation: Add fprintf (stderr, “<MESSAGE>”) statement inside the source code of TCP
as shown below to print “Hello World” when custom built dll is executing.
_getch();
Step 1: Create a file with the name NodeFailure.txt inside the bin folder of NetSim’s current
workspace path <C:\Users\PC\Documents\NetSim_13.0.14_64_std_default\bin\bin_x64> for
64-bit and <C:\Users\PC\Documents\NetSim_13.0.14_32_std_default\bin\bin_x86> for 32-
bit. The file will contain two columns: one being the Node ID of the device to be failed and
other being the failure time (in microseconds).
For example, to fail Node Id 2 from10th sec onwards and fail Node Id 1 from 90th sec onwards,
the NodeFailure.txt file will be as follows Figure 9-14.
Step 3: The function fn_NetSim_DSR_Init() will execute before the protocol execution starts.
So, in this function, we will read the NodeFailure.txt and save information regarding which
nodes will fail at which time. Add the following code inside the specified function.
int i;
FILE *fp1;
char *pszFilepath;
char pszConfigInput[1000];
pszFilepath = fnpAllocateMemory(36,sizeof(char)*50);
strcpy(pszFilepath,pszAppPath);
strcat(pszFilepath,"/NodeFailure.txt");
fp1 = fopen(pszFilepath,"r");
i=0;
if(fp1)
while(fgets(pszConfigInput,500,fp1)!= NULL)
sscanf(pszConfigInput,"%d %d",&NodeArray[i],&TimeArray[i]);
i+=1;
fclose(fp1);
Step 4: The fn_NetSim_DSR_Run() is the main function to handle all the protocol
functionalities. So, add the following code to the function at the start.
int i,nFlag=1;
if(nFlag)
for(i=0;i<100;i++)
pstruEventDetails->nInterfaceId = 0;
pstruEventDetails->pPacket=NULL;
return 0;
int NodeArray[200];
int TimeArray[200];
Step 7: Create a scenario in MANET where data packets should be travelling from source to
destination through the mentioned node in NodeFailure.txt file. For that user can increase the
pathloss exponent value and the distance among the nodes. User can utilize Packet Animation
to check the node failure (i.e. no packets are forwarded by failed nodes) after the mentioned
time.
Debugging your code via GUI there are two methods available.
Using _getch()
Using Environment Variables (NETSIM_BREAK)
Step 1: Perform the required modification of the protocol source code and add _getch() (used
to hold the program execution until the user enters a character) statement inside init function
of the modified protocol. For example, take DSR protocol and add the following lines of code
in the init function as shown in the below screenshot Figure 9-15.
_getch();
Step 3: In NetSim, create a network scenario where the protocol is being used and start the
simulation. In the console window user would get a warning message shown in the below
screenshot Figure 9-16 and the simulation will pause for user input (because of _getch()
added in the init function)
Figure 9-19: Control goes to the project and stops at the break point in the source code
After execution of the function, the control goes back to NetSim and then comes back to the
custom code the next time the function is called in the simulation.
To stop debugging and continue execution, press Shift+F5 (key). This then gives the control
back to NetSim, for normal execution to continue.
Note: Setting NETSIM_BREAK Environment Variable will cause the simulation to slow down and it is
recommended to remove this Environment Variables after debugging the simulation
Step 3: Click New in System variables. Type “NETSIM_BREAK” as Variable name and any
positive integer as variable value (e.g., 2). Click OK. The value of the variable is the event ID
at which you want NetSim Simulation to break. In this example we have set the value to 2,
which means that the simulation will break at the previous event.
Figure 9-21: Add Variable name and Variable Value in New in System Variable
Step 4: Open NetSim and then open the source codes. Please refer Section 4.12 “How does
a user open and modify source codes” for more information.
Simulation will break at event ID 1 as we have set the environment variable to 2 as shown
below Figure 9-23.
Step 8: Inside Solution Explorer pane in Visual Studio, double click on TCP project. Then open
TCP.c file by double clicking on it. Using the drop down list of functions that are part of the
current file, choose fn_NetSim_TCP_Run().
Step 9: In Visual Studio, Set the breakpoint in the code by clicking on the grey area on the left
of the line or by right clicking on the line and selecting Breakpoint->Insert Breakpoint.
Figure 9-28: Control goes to the project and stops at the break point in the source code.
After execution of the function, the control goes back to NetSim and then comes back to the
custom code the next time the function is called in the simulation. To stop debugging and
continue execution, press Shift+F5 (key). This then gives the control back to NetSim, for
normal execution to continue.
If NETSIM_BREAK environment variable is set, NetSim event trace file additionally logs the
file name and line number of the source code where the event was added as shown below:
Figure 9-29: NetSim event trace file additionally added two columns the file name and line number of
the source code.
Modify the DSR protocol and build the code. Create a scenario on MANET then follow the
below steps.
Step 1: Open the Command prompt. Press “windows+R” and type “cmd”.
Step 2: To run the NetSim via CLI copy the path where “NetSimCore.exe” is present.
>cd <apppath>
>NetSimCore.exe<space>-apppath<space><apppath><space>-
iopath<space><iopath><space>-license<space>5053@<ServerIP Address><space> -d
Figure 9-30: Run the NetSim via CLI Mode use the following Command.
Press enter, now you can see the following screen.
Attach to NetSimCore.exe.
Step 6: Go to command prompt which is already opened in Step 3. Enter the Event Id.
Note: If you don’t want to stop at any event you can specify 0 as event id.
Figure 9-36: Control goes to the project and stops at the break point in the source code
All debugging options like step over (F10), step into (F11), step out (Shift + F11), continue (F5)
are available.
After execution of the function, the control goes back to NetSim and then comes back to the
custom code the next time the function is called in the simulation.
To stop debugging press Shift+F5. This then gives the control back to NetSim, for normal
execution to continue.
To debug your own (custom) code, it is often helpful to know which section of the code (file
name & line number) generated the event under study. There are 2 ways to enable this feature.
Procedure 1
Step 1: Open configuration.netsim file and provide the file name, path and set status as
Enable.
Figure 9-37: Enable Event Trace by editing Configuration.netsim and provide the file name, path and
set status as Enable
Step 2: Run the NetSim via CLI in debug mode (Refer NetSim Help in Section 7Running
Simulation via CLI) with –d as the fourth parameters.
Press enter.
Figure 9-40: NetSim writes the file name and line number of the source code in Event Trace
Note: In the above trace file Event Id 56 is triggered inside the IEEE802_11_Phy.c file which is present in
IEEE802_11 project. Since all the lib files are opaque to the end user, you cannot see the source code of
the lib file. However, Event Id 56 is triggered at line number 396 of IEEE802_11_Phy.c file and you can find
the location of the event by opening the IEEE802_11_Phy.c file as shown below.
Step 3: Click New. Type “NETSIM_BREAK” as Variable name and any negative integer as
Variable value. Click OK.
Figure 9-43: Enter Variable name and Value in New System Variable
Step 4: Restart the system.
Step 5: Now perform simulation in NetSim (Enable event trace in GUI). Upon running, NetSim
will write the file name and line number of the source code that generated each event.
Figure 9-44: NetSim writes the file name and line number of the source code in Event Trace
9.3.4 Viewing & Accessing variables
To see the value of a variable, when debugging hover the mouse over the variable name in
the code. A text box with variable contents appears. If the variable is a structure and contains
other variables, then click on the plus sign which is there to the left of the text box. Users can
pin the variable to watch by clicking on the pin icon to the right of that variable in the text box.
During the process of debug users would come across variables that are defined outside the
source file being built as a .dll. Such variables cannot be viewed directly when added in the
watch tab, as this would throw the error.
A program database (.pdb) file, also called a symbol file, maps the identifiers that a user
creates in source files for classes, methods, and other code to the identifiers that are used in
the compiled executables of the project. The .pdb file also maps the statements in the source
code to the execution instructions in the executables. The debugger uses this information to
determine: the source file and the line number displayed in the Visual Studio IDE and the
location in the executable to stop at when a user sets a breakpoint. A symbol file also contains
the original location of the source files, and optionally, the location of a source server where
the source files can be retrieved from.
When a user debugs a project in the Visual Studio IDE, the debugger knows exactly where to
find the .pdb and source files for the code. If the user wants to debug code outside their project
source code, such as the Windows or third-party code the project calls, the user has to specify
the location of the .pdb (and optionally, the source files of the external code) and those files
need to exactly match the build of the executables.
The pdb files are usually available in NetSim’s install directory, else write to
[email protected] for the latest copy of these debug files. Go to Tools >
options>debugging>load all symbols.
Figure 9-48: Go to Tools > options > debugging > load all symbols in Visual Studio
Note: If the load symbols menu option is greyed, then it means symbols are already loaded
In the watch window, the variable which the user has to watch should be edited by double
clicking on it and prefixing {,, NetworkStack.dll} to the variable name and pressing enter. (The
name of the respective file in which the variable is defined should be mentioned - in this case
NetworkStack.dll).
Each protocol in NetSim has a separate Dll file which contains the variables and functions
which can be shared. In case of cross layer protocol implementations variables of one protocol
may have to be accessed from another Dll.
An example is given below showing how Physical layer parameters of devices running
IEEE802.11 can be accessed in the Network Layer with DSR protocol configured.
#ifndef SHARE_VARIABLE
_declspec(dllexport) IEEE802_PHY_VAR *var1;
#else
_declspec(dllimport) IEEE802_PHY_VAR *var1;
#endif
In the example, the code line must be written in IEEE802_11_Phy.h file present inside
IEEE802_11 folder.
Figure 9-50: Code Modification done in IEEE802_11_Phy.h file present inside IEEE802_11 folder
In the main function where a user wishes to find the dReceivedPower_mw, the variable must
be assigned the respective value. In the above case, the following line of code must be written
inside fn_NetSim_IEEE802_11_PhyIn() function in IEEE802_11_Phy.c file present inside
IEEE802_11 folder.
var1 = DEVICE_PHYVAR(pstruEventDetails->nDeviceId,pstruEventDetails-
>nInterfaceId);
Note that the parameters given in the macro or any function which assigns a value to the
variable must be defined beforehand in the code. Here nDeviceId and nInterfaceId are defined
beforehand.
Figure 9-51: Code Modification done in IEEE802_11_Phy.c file present inside IEEE802_11 folder
The IEEE802_11 project must be built and the resulting libIEEE802.11.dll file which gets
created in the bin folder of NetSim’s current workspace
<C:\Users\PC\Documents\NetSim_13.0.14_64_std_default\bin\bin_x64> for 64-bit and
<C:\Users\PC\NetSim_13.0.14_32_std_default\bin\bin_x86> for 32-bit NetSim.
The Object file IEEE802_11.lib which is also got created in the lib folder located in the
current workspace path
<C:\Users\PC\Documents\NetSim_13.0.14_64_std_default\src\Simulation\lib_x64> for 64-bit
and <C:\Users\PC\Documents\NetSim_13.0.14_32_std_default\src\Simulation\lib> for 32-bit.
Now expand the DSR project in solution explorer. For accessing the IEEE802_11 variable, the
following lines must be added in DSR.h file
#define SHARE_VARIABLE
#pragma comment(lib,"IEEE802_11.lib")
Figure 9-52: Accessing the IEEE802_11 variable, Modification done in DSR.h file
Add the following lines of code to the DSR.c file as shown below Figure 9-53.
#include "../IEEE802_11/IEEE802_11_Phy.h"
#include "../BatteryModel/BatteryModel.h"
Figure 9-53: Add the following lines of code to the DSR.c file in DSR Project
In the fn_NetSim_DSR_Run() function add the following lines of code to print the value of
dReceivedPower_mw variable from DSR project.
if (var1)
fprintf(stderr, "\n Remaining Energy(mJ): %lf\n"
,battery_get_remaining_energy((ptrBATTERY)var1->battery));
The DSR project must be built and the resulting libDSR.dll file gets created in the bin folder
of NetSim’s current workspace path
<C:\Users\PC\Documents\NetSim_13.0.14_64_std_default\bin\bin_x64> for 64-bit and
<C:\Users\PC\Documents\NetSim_13.0.14_32_std_default\bin\bin_x86> for 32-bit. When a
scenario is run, the remaining energy of the node will be printed to the simulation console as
shown below Figure 9-55.
Users can try printing the Device ID, Application ID, Duplicate Ack Count etc.
pstruEventDetails->dEventTime,
DEVICE_POSITION(pstruEventDetails->nDeviceId)->X,
DEVICE_POSITION(pstruEventDetails->nDeviceId)->Y);
_getch();
1. Open the Source codes in Visual studio using the NetSim.sln file.
2. Go to ZigBee project and Open 802_15_4.h file and add a subevent called
“MY_EVENT” inside enum_IEEE802_15_4_Subevent_Type as shown below Figure
9-57.
3. To add a new packet in NetSim first user has to initialize their new packet name inside
802_15_4.h file. Let us assume the new packet be “MY_PACKET” and it is a control
packet. So user has to define it inside the following enum as shown below Figure 9-58.
struct stru_My_Frame
{
int nBeaconId;
int nSuperFrameId;
int nBeaconTime;
double dPayload;
double dOverhead;
double dFrameSize;
};
typedef struct stru_My_Frame MY_FRAME;
enum enum_IEEE_802_15_4_ControlPacket_Type
{
5. Open 802_15_4.c file, go to the case TIMER_EVENT and add the following code to
the subevent type :-
case SUBEVENT_GETLINKQUALITY:
{
--------------------------
}
break;
case MY_EVENT:
{
//my event//
fprintf(stderr, "My_event");
pstruEventDetails->dEventTime = pstruEventDetails->dEventTime + 1 *
SECOND;
pstruEventDetails->nDeviceId = nGlobalPANCoordinatorId;
pstruEventDetails->nInterfaceId = 1;
pstruEventDetails->nEventType = TIMER_EVENT;
pstruEventDetails->nSubEventType = MY_EVENT;
pstruEventDetails->nProtocolId = MAC_PROTOCOL_IEEE802_15_4;
fnpAddEvent(pstruEventDetails);
fn_NetSim_WSN_MY_PACKET();
//my event//
}
break;
Here we are adding a new event inside the timer event, and this event will occur every 1
second in the GlobalPANCoordinator. i.e. sink node. In this event,
fn_NetSim_WSN_MY_PACKET() is called as explained in step 5.
6. Inside 802_15_4.c file, add the following code at the end of the file for sending ack
(broadcast):
int fn_NetSim_WSN_MY_PACKET()
{
double dTime;
NETSIM_ID nDeviceId = pstruEventDetails->nDeviceId;
NETSIM_ID nInterfaceId = pstruEventDetails->nInterfaceId;
IEEE802_15_4_MAC_VAR *pstruMacVar =
DEVICE_MACVAR(nDeviceId, nInterfaceId);
IEEE802_15_4_PHY_VAR *pstruPhyVar =
DEVICE_PHYVAR(nDeviceId, nInterfaceId);
NetSim_PACKET *pstruPacket = pstruEventDetails->pPacket;
NetSim_PACKET *pstruAckPkt;
MY_FRAME *pstruAck;
dTime = pstruEventDetails->dEventTime;
// Create MY_Frame
pstruAckPkt = fn_NetSim_Packet_CreatePacket(MAC_LAYER);
pstruAckPkt->nPacketType = PacketType_Control;
pstruAckPkt->nPacketPriority = Priority_High;
pstruAckPkt->nControlDataType = MY_PACKET;
pstruAck = fnpAllocateMemory(1, sizeof(MY_FRAME));
creates a new packet in NetSim. Since in this example, new packet is created in MAC
layer, it is passed as an argument. Users can give the respective Layer name for
creating packets in any other layers. In the above code users can see the following
line:
strcpy(pstruAckPkt->szPacketType, "MY_PACKET");
8. In 802_15_4.c file, goto fn_NetSim_Zigbee_Init() function and add the following code
in red color to call the timer_event. i.e. MY_EVENT
if (nSubEvent == MY_EVENT)
return "MY_EVENT";
return (fn_NetSim_Zigbee_Trace_F(nSubEvent));
}
10. Save the code and build Zigbee project, libZigBee.dll will get created in the bin folder
of NetSim’s current workspace path
<C:\Users\PC\Documents\NetSim_13.0.14_64_std_default\bin\bin_x64> for 64-bit
and <C:\Users\PC\Documents\NetSim_13.0.14_32_std_default\bin\bin_x86> for 32-
bit. Create a basic scenario in WSN with 2 sensors and 1 sink node.
11. While creating the application between two sensors, set
Figure 9-59: In animation window Sink node broadcasts “MY_PACKET” to the sensor
14. Also, open packet trace and users can filter the control packet and see all the packet
details of “MY_PACKET” written in the packet trace.
Figure 9-60: Filter the Packet Type to control packet and See “MY_PACKET” in Packet Trace
15. To analyse the “MY_EVENT” users can open event trace and filter the subevent type
as “MY_EVENT”. Here users can analyse that the event occurs for every 1 seconds.
Free a packet
o fn_NetSim_Packet_FreePacket_dbg(NetSim_PACKET** pstruPacket,int
line,char* file);
2. stack.h – Network / device / link and event related APIs
o fn_NetSim_Utilities_CalculateDistance(NetSim_COORDINATES*
coordinate1,NetSim_COORDINATES* coordinates2);
Stores the event details. Only one-time memory is allocated. Most used variable
o NETSIM_IPAddress
o isBroadcastIP(NETSIM_IPAddress ip);
o isMulticastIP(NETSIM_IPAddress ip);
Include all the header (.h) files from the include folder
NetworkStack.lib is a “import library” file and has the definitions for the functions
present in the NetworkStack.dll
When developing new protocols users should create their own protocol.h and
declare all the protocol specific variables here. Stack & packet related variables
should be used from stack.h and packet.h
Every protocol should provide the following APIs as hooks to the network stack:
The stack calls this API when reading the config file. Upon reaching the appropriate
protocol definition in the XML file, the stack calls this and passes all these pointers
to the protocol
int (*fn_NetSim_protocol_run)(): This is called by the stack to run the protocol
char* (*fn_NetSim_protocol_trace)(int): This called by the stack to write the event
trace
int(*fn_NetSim_protocol_CopyPacket)(constNetSim_PACKET*
pstruDestPacket,const NetSim_PACKET* pstruSrcPacket):
This is for copying protocol specific parameters / data into the packed
int (*fn_NetSim_protocol_FreePacket)(const NetSim_PACKET* pstruPacket): The
this to free the protocol specific parameters / data in the packet
(*fn_NetSim_protocol_Metrics)(const FILE* fpMetrics): This is to write the metrics
file upon completion of the simulation
int (*fn_NetSim_protocol_Finish)(): To release all memory after completion
char* (*fn_NetSim_protocol_ConfigPacketTrace)(constvoid* xmlNetSimNode); To
configure the packet packet trace in terms of the parameters to be logged
char* (*fn_NetSim_protocol_WritePacketTrace)(const NetSim_PACKET*); To
configure the event trace in terms of the parameters to be logged.
10 Advanced Features
NetSim uses an in-built linear congruential Random Number Generator (RNG) to generate the
randomness. The RNG uses two seeds values to initialize the RNG. Having the same set of
seed values ensures that for a particular network configuration the same output results will be
got, irrespective of the system or time at which the simulation is run. This ensures repeatability
of experimentation.
Modifying the seed value will lead to the generation of a different set of random numbers and
thereby lead to a different sequence of events in NetSim. Therefore, the results are dependent
on the initial seeding of the RNG. Because a particular random seed can potentially result in
an anomalous, or non-representative behavior, it is important for each network scenario to be
simulated with several random number seeds, to ascertain typical performance.
To calculate confidence intervals, users can run multi-seed parametric experiments, where
one or more input parameters are varied, and for each input parameter value, multiple random
number seeds are used to obtain a set of performance metrics.
This interfacing feature can be used to either replace an existing functionality in NetSim or to
incorporate additional functionalities supported by MATLAB. Any existing
command/function/algorithm in MATLAB or a MATLAB M-script can be used.
In general, the following are done when a user interfaces NetSim to MATLAB:
MATLAB functions can be called from NetSim's underlying protocol C source codes using
MATLAB APIs. Following are some of the MATLAB Engine API functions that can be used
from NetSim C source codes:
In this example we will replace the default Rayleigh Fading (part of the path loss calculation)
used in NetSim, with a Fading Power calculated using the Weibull Distribution from
MATLAB.
Note: This example uses 32-bit version of NetSim and MATLAB. Settings will slightly vary in case of 64-bit
version of the software.
Procedure:
1. Create a MATLAB_Interface.c file inside the IEEE802_11 folder which can be found in
the current workspace location of NetSim that you are running and it would be
something like
“C:\Users\PC\Documents\NetSim_13.0.14_64_std_default\src\Simulation\IEEE802_1
1” For more information on NetSim workspace refer Section 4 “Workspaces and
Experiments”. Write the following code inside the MATLAB_Interface.c file:
/*
*
* This is a simple program that illustrates how to call the MATLAB
* Engine functions from NetSim C Code.
*
*/
#include<windows.h>
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
#include"engine.h"
#include"mat.h"
#include"mex.h"
char buf[BUFSIZ];
Engine *ep;
int status;
mxArray *h = NULL, *i = NULL, *j = NULL, *k = NULL;
mxArray *out;
double *result;
double fn_netsim_matlab_init()
{
/*
* Start the MATLAB engine
*/
fprintf(stderr, "\nPress any key to Initialize MATLAB\n");
_getch();
if(!(ep = engOpen(NULL))) {
MessageBox((HWND)NULL, (LPCWSTR)"Can't start MATLAB engine",
(LPCWSTR) "MATLAB_Interface.c", MB_OK);
exit(-1);
}
engEvalString(ep, "desktop");
return 0;
}
double fn_netsim_matlab_run()
{
return *result;
}
double fn_netsim_matlab_finish()
{
fprintf(stderr, "\nPress any key to close MATLAB\n");
_getch();
status = engEvalString(ep, "exit");
return 0;
}
double fn_netsim_matlab_init();
double fn_netsim_matlab_run();
double fn_netsim_matlab_finish();
dFadingPower = propagation_calculate_fadingloss(propagationHandle,
packet->nTransmitterId,ifid,pstruEventDetails->nDeviceId, pstruEventDetails-
>nInterfaceId);
11. Make a call to the fn_netsim_matlab_run() function by adding the following line,
dFadingPower = fn_netsim_matlab_run();
Figure 10-8: Right click on the IEEE802_11 project and select Properties
13. Under C/C++ General, add the following directory to the field ADDITIONAL
INCLUDE DIRECTORIES:
NOTE: To determine path where MATLAB is installed, entering the following command in the MATLAB command
prompt:
matlabroot
15. Under Linker General, add the directory to the field ADDITIONAL LIBRARY
DIRECTORIES:
16. Under Configuration Properties Debugging, Add the following Target path in the
ENVIRONMENT: <Path where MATLAB is installed>\bin\win32
Notes:
1. To do step 14, check the Windows system path by clicking on Start Right click on Computer
Properties Advanced System Settings Environment variables System Variables Open "Path"
for editing.
2. If the machine has more than one MATLAB installed, the directory for the target platform must be ahead
of any other MATLAB directory (for instance, when compiling a 32-bit application, the directory in the
MATLAB 32-bit installation must be the first one on the PATH). To run 64-bit NetSim, users has to change
the above mentioned matlab paths to 64-bit matlab paths.
19. Now Right Click on IEEE802_11 project and select Rebuild.
Note: On Windows systems, engOpen opens a COM channel to MATLAB. The MATLAB software you
registered during installation starts. If you did not register during installation, enter the following
command at the MATLAB prompt:
!matlab -regserver
Figure 10-19: Once Simulation Start and breakpoint gets triggered in Visual Studio
8. Now when debugging (say, by pressing F5 each time) you will find the computation
taking place in the MATLAB Workspace.
Figure 10-21: Added Another breakpoint after the line dFadingPower = fn_netsim_matlab_run()
11. Add the variable dFadingPower in IEEE802_11.Phy.c file, to watch. For this, right
click on the variable dFadingPower and select “Add Watch” option. You will find a
watch window containing the variable name and its value in the bottom left corner.
Figure 10-22: Right Click on dFadingPower and Select “Add Watch” option
12. Now when debugging (say by pressing F5 each time) you will find that the watch
window displays the value of dFadingPower whenever the control reaches the
recently set breakpoint. You will also find that the value of dFadingPower in the Visual
Studio Watch window and the value of i in the MATLAB workspace window are
similar.
Figure 10-23: The Visual Studio Watch window and the value of i in the MATLAB workspace window
are similar
10.2.3 Implement Weibull Distribution of MATLAB in NetSim using .m file:
Procedure:
h=ProbDistUnivParam('weibull',[noncentrality,scale]);
%use makedist() function for matlab 2017
%h=makedist('weibull',noncentrality,scale);
i=random(h,1);
WLAN=i;
2. Place this file in the MATLAB’s default working directory. This will usually be MATLAB’s
root directory or the bin folder in MATLAB’s installation path.
NOTE: To determine path where MATLAB is installed, entering the following command in the MATLAB
command prompt:
matlabroot
double fn_netsim_matlab_run()
result = mxGetPr(out);
return *result;
Procedure:
function WLAN=NETSIM_MATLAB(choice,varargin)
switch(choice)
case'weibull'
h=ProbDistUnivParam('weibull',[varargin{1},varargin{2}]);
%h=makedist('weibull',varargin{1}, varargin{2});
i=random(h,1);
fid = fopen('plotvalues.txt','a+');
fprintf(fid,'%f',i);
fprintf(fid,'\r\n');
fclose('all');
WLAN=i;
case'plothistogram'
fid=fopen('plotvalues.txt');
mx=fscanf(fid,'%f');
hist(mx);
fclose('all');
end
if (strcmp(arr, "weibull") == 0)
{
engPutVariable(ep, "h", h);
sprintf_s(buf,BUFSIZ, "h=NETSIM_MATLAB('weibull',%d,%d)",
weibull_noncentrality, weibull_scale);
status = engEvalString(ep, buf);
out = engGetVariable(ep, "h");
result = mxGetPr(out);
return *result;
}
else if (strcmp(arr, "plothistogram") == 0)
{
status = engEvalString(ep, "NETSIM_MATLAB('plothistogram')");
return 0;
}
else
return 0;
A call to the NetSim_MATLAB() function inside the NetSim_MATLAB.m file is made, for
fading power calculation with parameters distribution(‘weibull’), weibull_noncentrality and
weibull_scale parameters are passed from NetSim.
A call to the NetSim_MATLAB() function inside the NetSim_MATLAB.m file is made, for
plotting histogram for the values generated by MATLAB.
Also add the following call to fn_netsim_matlab_run() function along with a _getch() to plot
the histogram before closing the MATLAB Engine.
Figure 10-25: Added fn_netsim_matlab_run() function along with a _getch() to get histogram plot
before closing the MATLAB Engine
Similarly in the call made to fn_netsim_matlab_run() function in IEEE802_11_Phy.c file
add the parameter “weibull” as shown below:-
Figure 10-27: Modify the Function definition of fn_netsim_matlab_run() function in IEEE802_11.h file
Right Click on IEEE802_11 project and select Rebuild will create a new libIEEE802.11. in
the bin folder of NetSim’s current workspace path
<C:\Users\PC\Documents\NetSim_13.0.14_64_std_default\bin\bin_x64> for 64-bit and
<C:\Users\PC\Documents\NetSim_13.0.14_32_std_default\bin\bin_x86> for 32-bit.
Open NetSim in Administrative mode. Create a Network scenario involving IEEE802_11
say MANET, right click on the environment and select properties. Make sure that the
Channel Characteristics is set to PathLoss and Fading and Shadowing.
You will find that once the Simulation is run MATLAB Command Window starts and once
the Simulation is over a histogram is displayed in MATLAB for the values that were
generated using weibull distribution.
You can also debug the code to understand the communication between NetSim and MATLAB
as explained in the DEBUGGING section above.
The tail command is a command-line utility for outputting the last part of files given to it via
standard input. It writes results to standard output. By default, tail returns the last ten lines of
each file that it is given. It may also be used to follow a file in real-time and watch as new lines
are written to it.
PART 1:
Tail options
PART 2:
tail -n 0 "C:\Users\PC\AppData\Local\Temp\NetSim\ospf_SPF_log.txt" –f
Note: Users need to change the path of the file. In this example we are using ospf_log.txt file
Figure 10-30: Add the following line in fn_NetSim_OSPF_Init() function in ospf.c file present inside
OSPF project
Rebuild the project.
Upon rebuilding, libOSPF.dll will get created in the bin folder of NetSim’s current
workspace path <C:\Users\PC\Documents\NetSim_13.0.14_64_std_default\bin\bin_x64>
for 64-bit and <C:\Users\PC\Documents\NetSim_13.0.14_32_std_default\bin\bin_x86> for
32-bit.
Create a scenario in NetSim as per the screenshot below and run simulation.
In the console window user would get a warning message shown in the below screenshot
Figure 10-32 (because of changed DLL) and then the simulation will pause for user input
(because of _getch() added in the init function)
Figure 10-33: Control goes to the project and stops at the break point in the source code.
Press F5 and check the tail console to watch the ospf_SPF log would look like the following
screenshot Figure 10-34 which calculates the shortest path for Router2.
Figure 10-35: WAN links connected to Router 2 i.e., 11.2.1.2 and 11.5.1.2
In the above screenshot, the shortest path for Router2 is 11.2.1.2 with Metrics 0 since it is
one of the Router2’s interface.
The below screenshot Figure 10-36 calculates the shortest path for Router5 and examines
the WAN links connected to Router5 i.e., 11.4.1.1 and 11.5.1.1
Figure 10-36: WAN links connected to Router 5 i.e., 11.4.1.1 and 11.5.1.1
In the above screenshot Figure 10-36, the shortest path for Router5 is 11.4.1.1 with
Metrics 0 since it is one of the Router5’s interface.
The below screenshot Figure 10-37 calculates the shortest path for Router1 and examines
the WAN links connected to Router1 i.e., 11.2.1.1 and 11.4.1.2
Figure 10-37: WAN links connected to Router1 i.e., 11.2.1.1 and 11.4.1.2
In the above screenshot, the shortest path for Router1 is 11.4.1.2 with Metrics 0 since it is
one of the Router5’s interface.
As shown in the below screenshot, the router1 calculates another new entry i.e. 11.4.1.1
with metrics 100 since it is the next hop (Router5’s 1st interface) connected to Router1
Every protocol has a main C file which contains a Metrics () function. For E.g., TCP project will
have a TCP.c file, UDP will have an UDP.c file etc. In the following example we have added a
new table as part of TCP protocol. TCP.c file contains fn_NetSim_TCP_Metrics() function
where code related to custom metrics is added as shown below:
Figure 10-39: Added Custom metrics table to the Simulation Results window
For illustration, an example regarding Wireless Sensor Network is provided. In this example,
parameters such as Sensor Node Name, Residual Energy, State (On/Off) and turn–off time
are tracked and added to a new table in the Simulation Results window.
Refer Section 8.1 on writing your own code, for more information.
After loading the source codes in Visual Studio, perform the following modifications:
double NetSim_Off_Time[100]; //Supports upto Device ID 100. Array size can be increased
for higher number of Devices/Device ID's
Step 2:
#include "../BatteryModel/BatteryModel.h"
Step 3:
Copy the below code (in red colour) in 802_15_4.c file (inside fn_NetSim_Zigbee_Metrics()
function)
}
PMETRICSNODE menu = init_metrics_node(MetricsNode_Menu, "CUSTOM_METRICS",
NULL);
add_node_to_menu(menu, table);
write_metrics_node(metricsWriter, WriterPosition_Current, NULL, menu);
delete_metrics_node(menu);
//CUSTOM METRICS
return fn_NetSim_Zigbee_Metrics_F(metricsWriter);
}
Step 4:
Copy the below code (in red colour) at the end of ChangeRadioState.c file.
if(isChange)
{
phy->nOldState = nOldState;
phy->nRadioState = nNewState;
}
else
{
phy->nRadioState = RX_OFF;
WSN_MAC(nDeviceId)->nNodeStatus = OFF;
NetSim_Off_Time[nDeviceId] = ldEventTime;
}
return isChange;
}
Step 5:
Build DLL with the modified code and run a Wireless Sensor Network scenario. After
Simulation, user will notice a new Performance metrics named “Custom Metrics” is added. The
newly added NODE_FAILURE_METRICS table is shown below Figure 10-40.
Figure 10-40: Added Custom metrics table to the Simulation Results window
This virtual time is referred to as simulation time to clearly distinguish it from real (wall-clock)
time. NetSim is a discrete event simulator (DES), and in any DES, the progression of the model
over simulation time is decomposed into individual events where change can take place. The
flow of time is only between events and is not continuous. Therefore, simulation time is not
allowed to progress during an event, but only between events. In fact, the simulation time is
always equal to the time at which the current event occurs. Therefore, simulation time can be
viewed as a variable that "jumps" to track the time specified for each new event.
The answer to the question "Will NetSim run for 10 seconds if Simulation time is set to 10
sec?" is, the simulation may take more than 10 seconds (Wall clock) if the network scenario is
very large and heavy traffic load. It may take a much shorter time (wall clock) for small networks
with low traffic loads.
Note that when running in "Emulation mode" simulation time and wall clock will be exactly
synchronized since it involves the transfer of real packets across the virtual network in NetSim.
Users can also log additional parameters with respect to time and get them plotted in NetSim
results dashboard. Following are some of the API’s which are part of NetSim_Plots.h file that
can be used for this purpose:
fn_NetSim_Install_Metrics_Plot() - This function creates a plot log file and returns a value
of type PNETSIMPLOT which can be stored in a pointer and be used for adding values
using add_plot_data_formatted(). This function can generally be called at simulation start.
This function can be called one time for each plot that is to be generated.
For Eg: If a plot is to be generated for each node. Then this function needs to be called
the number of device times.
add_plot_data_formatted() - This function can be used to add values to the plot log created
using the call to fn_NetSim_Install_Metrics_Plot(). This function needs to be called each
time you want to add new values to the plot log file. The call should be made at appropriate
section of code where the value being plotted changes with time.
SNR measured by UE’s from each gNB can be logged and plotted as part of NetSim results
window without having to use additional tools. Following is one such example where we log
the SNR for each UE-gNB pair and obtain plots at the end of the simulation.
Step 1: Open NetSim source code in NetSim current workspace. For more information, please
refer section “3.12 How does a user open and modify source codes”.
Step 2: Go to LTE_NR project through the solution explorer and open the LTE_NR.c file. In
the function fn_NetSim_LTE_NR_Init(), modify code as shown below:
//custom plot
continue;
switch (data->deviceType)
case LTENR_DEVICETYPE_UE:
continue;
switch (data->deviceType)
case LTENR_DEVICETYPE_GNB:
break;
default:
break;
break;
default:
break;
break;
return ret;
//custom plot
}
Step 3: In the file LTENR_GNBRRC.c go to the function
fn_NetSim_LTENR_RRC_GENERATE_UE_MEASUREMENT_REPORT() and add the lines
of code highlighted in red as shown below:
void fn_NetSIM_LTENR_RRC_GENERATE_UE_MEASUREMENT_REPORT()
NETSIM_ID d = pstruEventDetails->nDeviceId;
NETSIM_ID in = pstruEventDetails->nInterfaceId;
continue;
switch (data->deviceType)
case LTENR_DEVICETYPE_GNB:
temp = MEASUREMENT_REPORT_ALLOC();
temp->ueID = d;
temp->cellID = r + 1;
temp->cellIF = rin + 1;
temp->rs_type = RS_TYPE_SSB;
temp->reportAmount = ReportAmount_r1;
temp->reportInteval = gnbRRC->ueMeasReportInterval;
//custom plot
char plotname[BUFSIZ];
if (fp)
fprintf(fp, "%lf,%lf\n",pstruEventDetails->dEventTime,temp->sinr);
fclose(fp);
//custom plot
LIST_ADD_LAST((void**)&report, temp);
break;
default:
break;
hdr->msg = report;
hdr->msgType = LTENR_MSG_RRC_UE_MEASUREMENT_REPORT;
hdr->SenderID = d;
hdr->SenderIF = in;
fn_NetSIm_LTENR_RRC_ADD_HDR_INTO_PACKET(pstruEventDetails->pPacket, hdr,
ueMEASID, LTENR_MSG_RRC_UE_MEASUREMENT_REPORT);
LTENR_CallPDCPOut();
}
Step 4: In LTENR.c add the following lines #include "NetSim_Plot.h".
Step 5: Save the changes and right-click on the LTE_NR module in the solution explorer and
select Rebuild.
Step 6: Upon a successful build, NetSim will automatically update the modified binaries in the
respective binary folder.
Step 7: Now on running any simulation in LTE/5G NR networks, you will get individual SNR
plots for each UE-GNB/UE-ENB pair, in the NetSim Metrics window under Plots ->LTE_NR
SNR Plot shown below Figure 10-41.
The above results are based on the Handover in 5G NR Experiment which is part of NetSim
v13.0 experiment manual. The plot shows how the SNR drops as UE 3 moves away from GNB
1.
9. NETSIM_AUTO = <int> // If set NetSim will not ask for keypress after simulation. //Useful
to run batch simulations.
10. NETSIM_IO_PATH = <path> // IO path of NetSim from where it will read Config file and
write output file. Equivalent to -IOPATH command in CLI mode.
11. NETSIM_MAP = 1 // Set by Networkstack to inform other modules that simulation is
running per map view.
12. NETSIM_ADVANCE_METRIC // If set, NetSim provides a set of extra metrics.
13. NETSIM_CONFIG_NAME = <FILE NAME> // Config file name. This file must present in
IOPath. If not set default value is Configuration.netsim
14. NETSIM_NEG_ID = 1 // If set, then control packets will have negative id.
15. NETSIM_PACKET_DBG = 1 // If set, then Simulation engine will log the packet creation
and freeing
16. NETSIM_MEMCHECK = 1 // If set, then simulation will enable memory check.
17. NETSIM_MEMCHECK_1 = x // Lower event id
18. NETSIM_MEMCHECK_2 = x // Upper event id
1. Number of Nodes
End nodes
Intermediate devices
2. Total traffic in the network
Number of traffic sources
Average generation rate per source
3. Simulation time
Protocols running
Network Parameters such as Topology, Mobility, Wireless Channel etc.
Enabling/Disabling - Animation, Plots, Traces and Logs
External Interfacing – MATLAB, Wireshark, SUMO
The documentation and codes for batch experimentation script is available TETCOS -
https://www.tetcos.com/file-exchange.html
11 NetSim Emulator
NOTE: Emulator will be featured in NetSim only if license for Emulator Add-on is available
11.1 Introduction
A network simulator mimics the behavior of networks but cannot connect to real networks.
NetSim Emulator enables users to connect NetSim simulator to real hardware and interact
with live applications.
To simulate the different types of Emulations Examples such as PING (both one-way and two-
way communications), Video (one-way communication), File transfer using FileZilla, Skype
etc.
1. Refer to the Emulation Technology Library document, which explains the following:
i. Introduction to Emulation.
ii. How to set up and configure Emulation Server in NetSim
iii. NetSim Emulation Features with added examples
iv. Latest FAQs
2. To access the Emulation Technology Library document,
i. You can access from the Technology Libraries link present under Documentation in
NetSim Homescreen
ii. From the Help Menu inside the design window, choose Technology Libraries Manuals
Emulation.
12 Troubleshooting in NetSim
This section discusses some common issues and solutions:
Note that while running NetSim via CLI, try to ensure that there are no errors in the
Configuration.netsim file. The file, ConfigLog.txt, written to the windows temp path would show
errors, if any, found by NetSim’s config parser.
Simulation does not commence. “No license for product (-1)” is displayed in the command
prompt.
Example:
If “No license for product(-1)” is displayed in the command prompt two times, then check in the
NetSim license server to know about the availability of license and adjust the number of current
users of NetSim, in order to get the license.
Reason: If the command/iopath provided by the user is first written in MS Word and then copy
pasted to Command prompt, some special characters (not visible in command prompt) gets
inserted and on execution, license config dll is not found.
12.3 Configuration.netsim
12.3.1 Invalid attribute in configuration file attributes
Specific attributes in the Configuration file are highlighted with zigzag lines
Reason: If invalid input is given in the Configuration file, then the corresponding attribute is
highlighted as blue lines as shown in the figure given below Figure 12-6.
Note: If the schema file and the configuration file are not present in the same folder, the zigzag lines won’t appear.
So, place the Configuration file and Schema File in the same location or change the path of schema file in the
configuration file.
Simulation does not commence, and error is displayed at the command prompt. Also, red lines
appearing at the tag specifying the Layer in the Configuration file
Reason: This issue arises mainly when the closing tag is not specified correctly for a particular
layer in the Configuration file.
Example: If the closing tag is not specified for the Data link Layer, then the zigzag lines appear
at the starting tags of Data link Layer and the Network Layer.
Figure 12-8: NetSim Run through CLI and following error displayed in the command prompt
Solution: The bug can be fixed by setting the closing tag correctly in the Configuration file
Reason: This issue arises when the schema and the configuration file are not in the same
folder.
Example:
Figure 12-10: Simulation terminates and “NetSim Backend has stopped working” displayed
This problem arises if there is any flaw in the Configuration.netsim or in the dll.
Solution: Check whether the desired scenario has been configured properly in the
Configuration.netsim.
Reason: This error will come if monitor resolution is less than 1024 X 768. For example, 1260
X 720 will also show this error.
12.6 Licensing
12.6.1 No License for product (-1) error
NetSim dongle is running in the server system. When running the NetSim in the Client system
showing “No License for product (-1)” error.
Possible Reasons:
Solution:
1. The installed firewall may block traffic at 5053 port used for licensing. So, either the
user can stop the firewall, or may configure it to allow port 5053.
2. Contact the Network-in-charge and check if the Server system can be pinged from
client.
3. Check whether License Server is running in the Server system or not.
Any Python 2.7 version Installer would work fine for running simulations.
If you have installed python by an external Installer, make sure the Python Path is set.
It would be set automatically by python installer that comes with NetSim.
In case “Pywin 32” is not getting installed, or during simulation, error occurs as “win32
modules not found” try the code below (Run it as a python Code).
import sys
from _winreg import *
# tweak as necessary
version = sys.version[:3]
installpath = sys.prefix
regpath = "SOFTWARE\\Python\\Pythoncore\\%s\\" % (version)
installkey = "InstallPath"
pythonkey = "PythonPath"
pythonpath = "%s;%s\\Lib\\;%s\\DLLs\\" % (
installpath, installpath, installpath
)
def RegisterPy():
try:
reg = OpenKey(HKEY_CURRENT_USER, regpath)
except EnvironmentError as e:
try:
reg = CreateKey(HKEY_CURRENT_USER, regpath)
SetValue(reg, installkey, REG_SZ, installpath)
SetValue(reg, pythonkey, REG_SZ, pythonpath)
CloseKey(reg)
except:
print "*** Unable to register!"
return
print "--- Python", version, "is now registered!"
return
if (QueryValue(reg, installkey) == installpath and
QueryValue(reg, pythonkey) == pythonpath):
CloseKey(reg)
print "=== Python", version, "is already registered!"
return
CloseKey(reg)
print "*** Unable to register!"
print "*** You probably have another Python installation!"
if __name__ == "__main__":
RegisterPy()
12.7.3 VANET Simulation
i. Changing Vehicle (Node) Names, Moving or deleting vehicles etc. are disabled in
Vanets Simulation.
ii. On running simulation, Backend calls Python file.
iii. NetSim protocol engine waits for the Pipes connection to be established.
12.7.4 Python
After establishing the connection, NetSim VANET Library checks for GUI flag, and
sends ‘1’ if animation status is online.
As simulation proceeds, NetSim VANET library sends vehicle name to python, and
receives XY positions, which are passed from python.
Positions are updated and simulation proceeds.
13 NetSim Videos
In order to have a better understanding of NetSim, users can access YouTube channel of
Tetcos at www.youtube.com/tetcos and check out the various videos available.
15 NetSim FAQ/Knowledgebase
NetSim knowledgebase with hundreds on FAQs on how NetSim works is available at
https://tetcos.freshdesk.com/support/home
https://support.tetcos.com/support/solutions/articles/14000101817-list-of