Applicable VersionsNetSim StandardNetSim Pro


The steps involved may vary across versions of NetSim. Please refer to the respective section below:


Applicable Releasesv14


Introduction

The Graphical User Interface of NetSim allows users to quickly create network scenarios by dragging and dropping devices, connecting them using links with a few simple clicks. Further network traffic can be configured, and device and link properties can be set as per the requirement.

 

Properties of GUI components in NetSim

All components of a network scenario in NetSim GUI such as the Devices, Links, Applications, etc are individually configurable. 

The properties of GUI components in NetSim are read from XML property files which are located in the path <NetSim_Install_Directory>/Docs/UI_xml

 

 

A screenshot of a computer

Description automatically generated

The main GUI property file is the Property.xml file. This can be found in the path <NetSim_Install_Directory>/Docs/UI_xml/Device_Properties

This file contains the properties of different types of devices that are supported in NetSim as shown below:

 

The CommonProperties.xml file contains the properties of protocols running in different layers of the TCP/IP stack as shown below:

A screenshot of a computer

Description automatically generated


Each parameter generally has the following properties associated with it:

 

PROPERTY

VALUE

SCOPE

LOCAL/GLOBAL/LINK

In NetSim device parameters fall under one of the following categories

  • Local – Modification done in one device does not reflect on the other devices. (E.g. Device Name, IP address, etc)
  • Global – Modification done in one device automatically reflects on all the other devices of similar device type in the scenario. (Eg: Network Layer Routing Protocol in MANETs)
  • Link – Modification is done in one device and reflects on all the other devices that are part of the same subnetwork/link. (Eg: WLAN standard modified in access point/ station reflects in all other stations in the same network/ wireless link)

UITYPE

TEXTFIELD/COMBOBOX/LABEL/CHECKBOX

CONFIGNAME

Name of the Parameter that will be written to the XML Configuration.netsim file.

EDITABLE

TRUE/FALSE
In the case of components such as Textfiled, Combobox, Checkbox, etc editable is generally set to True.
 It is set to False in the case of Labels.

ENABLE

TRUE/FALSE

DESCRIPTION

If the description for the parameter is available in the IButton.xml file which is present in the path <NetSim_Install_Directory>/Docs/xmlthen the respective tag name can be specified here.

MAXEXCLUSIVE

The maximum value of the input. This is applicable for parameters of type Integer, Float, etc.
 Not applicable for components such as COMBOBOX, CHECKBOX, etc

MINEXCLUSIVE

The minimum value of the input. This is applicable for parameters of type Integer, Float, etc.
 Not applicable for components such as COMBOBOX, CHECKBOX, etc

RANGE

This is applicable in the case of components such as a COMBOBOX. RANGE will contain the possible values that will be displayed in the Combobox dropdown.
 Not applicable for components such as TEXTFILED, LABEL, etc

NAME

Name of the parameter to be displayed in the GUI of NetSim

DATATYPE

INTEGER/FLOAT/ALL
This refers to the type of user input that will be accepted.
 Not applicable for components such as COMBOBOX, CHECKBOX, etc

DEFAULTVALUE

This contains the default value that will be displayed for this parameter in the user interface.

VISIBLE

TRUE/FALSE

 

Following are examples of parameter definitions for some of the common Component types:

 

TEXTFIELD:

<Property Scope="LOCAL" UIType="TextBox" DataType="STRING" ConfigName="MY_PARAMETER_1" DisplayName="MY_PARAMETER_1" DefaultValue="0.3" ParentValue="DSR" Choices=""  Description="..\Docs\UI_xml\Param_Desc\DeviceDescription\NetworkLayerProperties\MY_PARAMETER_1.rtf" LongDescription="..\Docs\UI_xml\Param_Desc\DeviceDescription\NetworkLayerProperties\MY_PARAMETER_1.rtf"/>

COMBOBOX:

<Property Scope="LOCAL" UIType="TextBox" DataType="STRING" ConfigName="MY_PARAMETER_1" DisplayName="MY_PARAMETER_1" DefaultValue="0.3" ParentValue="DSR" Choices=""  Description="..\Docs\UI_xml\Param_Desc\DeviceDescription\NetworkLayerProperties\MY_PARAMETER_1.rtf" LongDescription="..\Docs\UI_xml\Param_Desc\DeviceDescription\NetworkLayerProperties\MY_PARAMETER_1.rtf"/>


New parameters can be added to the components of the GUI by editing the XML property files.

 

NetSim XML Configuration file

Based on the Configuration done in the user interface, a Configuration.netsim file is automatically generated. This file gets saved when the network is saved and is used to load the network again in NetSim.

   


Refer NetSim User Manual section on Understanding the Configuration.netsim file for more details.

 

NetSim XML Schema files

The NetSim XML schema file is a description of the NetSim XML Configuration file, which defines the constraints on the structure and content of the Configuration file. It includes the basic syntactical constraints imposed by XML itself and beyond.

 

While loading a saved Configuration.netsim file in the NetSim User Interface, it is validated for the correctness of the values and the presence of required parameters using XML schema files.

 

The Configuration.xsd file is the main schema file of NetSim. Some of the other schema files used are NetSim_Common_type.xsd, LTENR.xsd and Satellite.xsd for specific purposes.

 

NetSim schema files can be found in the following paths:

<NetSim_Install_Directory>/bin/bin_x64 

<NetSim_Install_Directory>/bin/bin_x86

A screenshot of a computer

Description automatically generated

The schema file can be modified to validate new parameters added to the XML property files.

 

Steps involved in adding a new parameter to an existing protocol in NetSim

Adding new parameters to existing protocols in NetSim involves the following steps in general:

  1. Adding parameters to the GUI
  2. Adding variables and default values for the parameter in the protocol C source code
  3. Reading parameters from the XML Configuration file and updating the respective variables

 

Let us consider an example of adding new parameters to the existing Routing Protocol DSR which is available for networks such as MANET, VANET, WSN, and TDMA Radio Networks.

 

Adding parameters to the GUI

By default, the properties of the Dynamic Source Routing(DSR) protocol that can be configured by the user are shown below:

A screenshot of a computer

Description automatically generated

















The Routing Protocol section of the CommonProperties.xml file contains the parameters associated with protocols such as DSR, AODV, ZRP, and OLSR as shown below:

 

A computer screen shot of a computer screen

 

Let us consider adding the following two new parameters to the DSR protocol,

Parameter 1(TEXTFIELD): 

<Property Scope="LOCAL" UIType="TextBox" DataType="STRING" ConfigName="MY_PARAMETER_1" DisplayName="MY_PARAMETER_1" DefaultValue="0.3" ParentValue="DSR" Choices=""  Description="..\Docs\UI_xml\Param_Desc\DeviceDescription\NetworkLayerProperties\MY_PARAMETER_1.rtf" LongDescription="..\Docs\UI_xml\Param_Desc\DeviceDescription\NetworkLayerProperties\MY_PARAMETER_1.rtf"/>

XML

This will add a parameter with the name "MY PARAMETER 1" that accepts user input in a textbox which will by default have a value of 0.0 which can be edited to a float value in the range 1 to 15.

 

Parameter 2(COMBOBOX): 

<Property Scope="Global" UIType="ComboBox" DataType="STRING" ConfigName="MY_PARAMETER_2" DisplayName="MY_PARAMETER_2" DefaultValue="option1" ParentValue="DSR" Choices="option1,option2,option3"  Description="..\Docs\UI_xml\Param_Desc\DeviceDescription\NetworkLayerProperties\MY_PARAMETER_2.rtf" LongDescription="..\Docs\UI_xml\Param_Desc\DeviceDescription\NetworkLayerProperties\MY_PARAMETER_2_TYPE.rtf"/>

This will add a parameter with the name "MY PARAMETER 2" that accepts user selection from a Combobox list (with values Option 1, Option 2, and Option 3) which will by default have Option 1 selected.

 

The parameters mentioned above are added to the CommonProperties.xml file as shown below:


A screen shot of a computer

Description automatically generated


Changes done to the CommonProperties.xml file are saved and NetSim is closed and started again. Now upon opening the properties of a node that supports DSR protocol, say a wireless node  in a MANET network, the newly added parameters will appear as shown below:


 

A screenshot of a computer

Description automatically generated

Upon saving the network configuration the new parameters also get written to the Configuration.netsim file as shown below:


A screenshot of a computer

Description automatically generated

 

While attempting to load the saved configuration file with new parameters in NetSim, schema error will be displayed since the new parameters were not added to the Schema file for validation:

 

A screenshot of a computer error message

Description automatically generated

 

Though users can proceed, discarding the error, it is recommended to update the schema files.

The section of the Configuration.xsd file that contains the section for validation of DSR protocol-related parameters is shown below:


A computer screen with text on it

Description automatically generated

 

The schema file can be updated with the following definitions to validate the newly added parameters:

<xs:attribute name="MY_PARAMETER_1" type="xs:double" use="optional" />
<xs:attribute name="MY_PARAMETER_2" use="optional" >
       <xs:simpleType>
              <xs:restriction base="xs:string">
                <xs:enumeration value="Option 1" />
                <xs:enumeration value="Option 2" />
                <xs:enumeration value="Option 3" />
       </xs:restriction>
       </xs:simpleType>
 </xs:attribute>

  

The schema file with the DSR protocol section updated with the new attributes to validate the DSR parameters is shown below:


A screenshot of a computer program

Description automatically generated


 After saving the updated Configuration.xsd file, close and reopen NetSim. Now loading the saved network configuration with new parameters added to the DSR protocol, will not display any schema errors, since the schema file is updated.

 

Adding variables and default values for the parameter in the protocol C source code

The C source codes of all the protocols implemented in NetSim are provided along with the software. The source codes of each protocol are organized as a separate project which can be modified independently.


A screenshot of a computer

Description automatically generated

 

Refer to the NetSim User Manual to learn more about accessing and modifying the source codes.

Each protocol source code project consists of a main Header file (<Protocol_Name>.h)

The main header file has the function prototypes, declaration of variables, structures, default values, and message formats.

New variables can be declared in the DSR.h header file. DSR protocol has a stru_DSR_DeviceVar which consists of variables to store device-specific parameters.


A screenshot of a computer program

Description automatically generated


 
Variables can be added to this structure to read from the XML Configuration file and store the new parameters added to the DSR protocol.

 

struct stru_DSR_DeviceVar
  {
    unsigned int nRREQIdentification;
    struct stru_DSR_RouteCache* pstruRouteCache; ///< List of routes to particular destination
    struct stru_DSR_SendBuffer* pstruSendBuffer; ///<  Buffer in which packets are added if route to target is not known.
    struct stru_DSR_RouteRequestTable* pstruRREQTable; ///< A table in which entry of RREQ initiated is made.
    enum
    {
      LINK_LAYER_ACK,
      NETWORK_LAYER_ACK,
    }AckType;

    double MY_PARAMETER_1;
    char* MY_PARAMETER_2;
    DSR_MAINT_BUFFER* pstruMaintBuffer; ///< Buffer in which packets sent to next HOP are added.
    struct stru_DSR_Metrics dsrMetrics;
  };


Default values to update the device variables, if the parameter is missing in the configuration file can be defined in the DSR.h header file as shown below;

A screenshot of a computer program

Description automatically generated

 

Reading parameters from the XML Configuration file and updating the respective variables

Each protocol source code project consists of a main C and Header file (<Protocol_Name>.c and <Protocol_Name>.h)

The main C file consists of functions such as:

 

Function

Implementation

fn_NetSim_<Protocol_Name>_Init()

Initializes protocol parameters

fn_NetSim_<Protocol_Name>_Configure()

Reads protocol parameters from the XML Configuration file and updates the protocol variables.

fn_NetSim_<Protocol_Name>_Run()

Handles all protocol-related events and calls to various functions associated with the protocol.

fn_NetSim_<Protocol_Name>_Trace()

Handles writing protocol events to event trace log file

fn_NetSim_<Protocol_Name>_Metrics()

Handles writing protocol-specific metrics

fn_NetSim_<Protocol_Name>_Finish()

Handles deallocating memory assigned to variables during protocol initialization

 

The equivalent functions that are part of DSR.c file are shown below:

 

A screenshot of a computer program

Description automatically generated

 

APIs related to reading from XML can be found in the Stack.h file which is part of the Include directory of the NetSim Source Code Repository.

A screen shot of a computer program

Description automatically generated

 

The following API can be used to read parameters associated with a protocol from the XML configuration file:

 

getXmlVar(var,name,xmlNode,flag,type,protocol)

Where,

var refers to the variable in which the parameter's value being read will be stored.

name refers to the name of the parameter in the XML configuration that needs to be read.

xmlNode refers to the pointer to an XML element whose attributes are to be read

flag takes the value 0 or 1

type refers to the data type of the parameter being read. type can be one of these - _INT, _DOUBLE, _FLOAT, _STRING, _BOOL, _CHAR, _SHORT, _UINT, _UCHAR, _USHORT, _UINT8, _UINT16,

protocol refers to the name of the protocol whose parameters are being read

 

The function fn_NetSim_DSR_Configure() can be modified to read the new parameters added as part of DSR protocol as shown below:


_declspec(dllexport) int fn_NetSim_DSR_Configure(void** var)
{  
  int i = fn_NetSim_DSR_Configure_F(var);
  void* xmlNetSimNode;
  NETSIM_ID nDeviceId = 0;
  NETSIM_ID nInterfaceId = 0;
  char* szVal;
  xmlNetSimNode = var[2];
  if (var[3])
    nDeviceId = *((NETSIM_ID*)var[3]);
  if (var[4])
    nInterfaceId = *((NETSIM_ID*)var[4]);
  if (nDeviceId)
  {
    DSR_DEVICE_VAR* devVar = DSR_DEV_VAR(nDeviceId);
    getXmlVar(&devVar->MY_PARAMETER_1, MY_PARAMETER_1, xmlNetSimNode, 0, _DOUBLE, DSR);
    getXmlVar(&devVar->MY_PARAMETER_2, MY_PARAMETER_2, xmlNetSimNode, 0, _STRING, DSR);
  }
  return i;
}

 

Building the source codes and running simulations

The modifications done to the DSR.c and DSR.h files are saved and the DSR source code project is built. After this upon simulating network configuration with the new parameters added, it is read and updated in the Protocol source codes. These variables can be further accessed and used in the respective sections of the DSR protocol source codes.

 

Similarly, additional variables can be added to other protocols that are part of NetSim.

 


Applicable Releasesv11.1v12v13


Introduction

The Graphical User Interface of NetSim allows users to quickly create network scenarios by dragging and dropping devices, connecting them using links with a few simple clicks. Further network traffic can be configured, device and link properties can be set as per the requirement.


Properties of GUI components in NetSim

All components of a network scenario in NetSim GUI such as the Devices, Links, Applications, etc are individually configurable. 

The properties of GUI components in NetSim are read from XML property files which are located in the path <NetSim_Install_Directory>/Docs/xml


The main GUI property file is the Property.xml file. This can be found in the path <NetSim_Install_Directory>/Docs/xml/Properties

This file contains the properties of different types of devices that are supported in NetSim as shown below:



The CommonProperties.xml file contains the properties of protocols running in different layers of the TCP/IP stack as shown below:


Each parameter generally has the following properties associated with it:


PROPERTY
VALUE

CHANGE_EFFECT

LOCAL/GLOBAL/LINK
In NetSim device parameters fall under one of the following categories
  • Local – Modification done in one device does not reflect on the other devices. (E.g. Device Name, IP address, etc)
  • Global – Modification done in one device automatically reflects on all the other devices of similar device type in the scenario. (Eg: Network Layer Routing Protocol in MANETs)
  • Link – Modification is done in one device reflects on all the other devices that are part of the same subnetwork/link. (Eg: WLAN standard modified in access point/ station reflects in all other stations in the same network/ wireless link)

COMPONENTTEXTFIELD/COMBOBOX/LABEL/CHECKBOX
CONFIG_NAMEName of the Parameter that will be written to the XML Configuration.netsim file.
EDITABLETRUE/FALSE
In the case of components such as Textfiled, Combobox, Checkbox, etc editable is generally set to True.
It is set to False in the case of Labels.
ENABLETRUE/FALSE
IBUTTON_TAGNAMEIf the description for the parameter is available in the IButton.xml file which is present in the path <NetSim_Install_Directory>/Docs/xmlthen the respective tag name can be specified here.
MAX_RANGEThe maximum value of the input. This is applicable for parameters of type Integer, Float, etc.
Not applicable for components such as COMBOBOX, CHECKBOX, etc
MIN_RANGEThe minimum value of the input. This is applicable for parameters of type Integer, Float, etc.
Not applicable for components such as COMBOBOX, CHECKBOX, etc
RANGEThis is applicable in the case of components such as a COMBOBOX. RANGE will contain the possible values that will be displayed in the Combobox dropdown.
Not applicable for components such as TEXTFILED, LABEL, etc
NAMEName of the parameter to be displayed in the GUI of NetSim
TYPEINTEGER/FLOAT/ALL
This refers to the type of user input that will be accepted.
Not applicable for components such as COMBOBOX, CHECKBOX, etc
VALUEThis contains the default value that will be displayed for this parameter in the user interface.
VISIBLETRUE/FALSE


Following are examples of parameter definitions for some of the common Component types:


TEXTFIELD:

<PARAMETER CHANGE_EFFECT="LOCAL" COMPONENT="TEXTFIELD" CONFIG_NAME="DEVICE_NAME" EDITABLE="TRUE" ENABLE="TRUE" IBUTTON_TAGNAME="DeviceName" MAX_RANGE="15" MIN_RANGE="1" NAME="Device Name" TYPE="ALL" VALUE="WIRED NODE" VISIBLE="TRUE"/>


COMBOBOX:

<PARAMETER CHANGE_EFFECT="LOCAL" COMPONENT="COMBOBOX" CONFIG_NAME="WIRESHARK_OPTION" EDITABLE="FALSE" ENABLE="TRUE" IBUTTON_TAGNAME="WIRESHARK_OPTION" NAME="WireShark Capture" RANGE="Disable,Online,Offline" VALUE="Disable" VISIBLE="TRUE">
    <SELECTION NAME="Disable"/>
    <SELECTION NAME="Online"/>
    <SELECTION NAME="Offline"/>
</PARAMETER>


LABEL:

<PARAMETER CHANGE_EFFECT="LOCAL" COMPONENT="LABEL" CONFIG_NAME="DEVICE_TYPE" EDITABLE="FALSE" ENABLE="TRUE" IBUTTON_TAGNAME="DeviceType" MAX_RANGE="15" MIN_RANGE="1" NAME="Device Type" TYPE="String" VALUE="CR_CPE" VISIBLE="FALSE"/>

New parameters can be added to the components of the GUI by editing the XML property files.


NetSim XML Configuration file

Based on the Configuration done in the user interface, a Configuration.netsim file is automatically generated. This file gets saved when the network is saved and is used to load the network again in NetSim.


Refer NetSim User Manual section on Understanding the Configuration.netsim file for more details.


NetSim XML Schema files

The NetSim XML schema file is a description of the NetSim XML Configuration file, which defines the constraints on the structure and content of the Configuration file. It includes the basic syntactical constraints imposed by XML itself and beyond.


While loading a saved Configuration.netsim file in NetSim User Interface, it is validated for the correctness of the values and the presence of required parameters using XML schema files.


The Configuration.xsd file is the main schema file of NetSim. Some of the other schema files used are NetSim_Common_type.xsd, LTENR.xsd and Satellite.xsd for specific purposes.


NetSim schema files can be found in the following paths:

<NetSim_Install_Directory>/bin/bin_x64 

<NetSim_Install_Directory>/bin/bin_x86



The schema file can be modified to validate new parameters added to the XML property files.


Steps involved in adding a new parameter to an existing protocol in NetSim

Adding new parameters to existing protocols in NetSim involves the following steps in general:

  1. Adding parameters to the GUI
  2. Adding variables and default values for the parameter in the protocol C source code
  3. Reading parameters from the XML Configuration file and updating the respective variables


Let us consider an example of adding new parameters to the existing Routing Protocol DSR which is available for networks such as MANET, VANET, WSN, and TDMA Radio Networks.


Adding parameters to the GUI

By default, the properties of the Dynamic Source Routing(DSR) protocol that can be configured by the user are shown below:




The Routing Protocol section of the CommonProperties.xml file contains the parameters associated with protocols such as DSR, AODV, ZRP, and OLSR as shown below:




Let us consider adding the following two new parameters to DSR protocol,

Parameter 1(TEXTFIELD): 

<PARAMETER CHANGE_EFFECT="LOCAL" COMPONENT="TEXTFIELD" CONFIG_NAME="MY_PARAMETER_1" EDITABLE="TRUE" ENABLE="TRUE" IBUTTON_TAGNAME="" MAX_RANGE="15" MIN_RANGE="1" NAME="MY PARAMETER 1" TYPE="FLOAT" VALUE="0.0" VISIBLE="TRUE"/>

This will add a parameter with the name "MY PARAMETER 1" that accepts user input in a textbox which will by default have a value 0.0 which can be edited to a float value in the range 1 to 15.


Parameter 2(COMBOBOX): 

<PARAMETER CHANGE_EFFECT="GLOBAL" COMPONENT="COMBOBOX" CONFIG_NAME="MY_PARAMETER_2" EDITABLE="FALSE" ENABLE="TRUE" IBUTTON_TAGNAME="" NAME="MY PARAMETER 2" RANGE="Option 1,Option 2,Option 3" VALUE="Option 1" VISIBLE="TRUE">
    <SELECTION NAME="Option 1"/>
    <SELECTION NAME="Option 2"/>
    <SELECTION NAME="Option 3"/>
</PARAMETER>

This will add a parameter with the name "MY PARAMETER 2" that accepts user selection from a Combobox list (with values Option 1, Option 2, and Option 3) which will by default have Option 1 selected.


The parameters mentioned above are added to the CommonProperties.xml file as shown below:



Changes done to the CommonProperties.xml file are saved and NetSim is closed and started again. Now upon opening the properties of a node that supports DSR protocol, say a wireless node  in a MANET network, the newly added parameters will appear as shown below:



Upon saving the network configuration the new parameters also get written to the Configuration.netsim file as shown below:



While attempting to load the saved configuration file with new parameters in NetSim, schema error will be displayed since the new parameters were not added to the Schema file for validation:



Though users can proceed, discarding the error, it is recommended to update the schema files.

The section of the Configuration.xsd file that contains the section for validation of DSR protocol related parameters are shown below:



Schema file can be updated with the following definitions to validate the newly added parameters:

<xs:attribute name="MY_PARAMETER_1" type="xs:double" use="optional" />
<xs:attribute name="MY_PARAMETER_2" use="optional" >
       <xs:simpleType>
              <xs:restriction base="xs:string">
                <xs:enumeration value="Option 1" />
                <xs:enumeration value="Option 2" />
                <xs:enumeration value="Option 3" />
       </xs:restriction>
       </xs:simpleType>
 </xs:attribute>

Schema file with the DSR protocol section updated with the new attributes to validate the DSR parameters is shown below:



After saving the updated Configuration.xsd file, close and reopen NetSim. Now loading the saved network configuration with new parameters added to DSR protocol, will not display any schema errors, since the schema file is updated.


Adding variables and default values for the parameter in the protocol C source code

The C source codes of all the protocols implemented in NetSim are provided along with the software. The source codes of each protocol are organized as a separate project which can be modified independently.



Refer to the NetSim User Manual to know more about accessing and modifying the source codes.


Each protocol source code project consists of a main Header file (<Protocol_Name>.h)


The main header file has the function prototypes, declaration of variables, structures, default values, and message formats.


New variables can be declared in the DSR.h header file. DSR protocol has a stru_DSR_DeviceVar which consists of variables to store device-specific parameters.



Variables can be added to this structure to read from the XML Configuration file and store the new parameters added to DSR protocol.


struct stru_DSR_DeviceVar
  {

    unsigned int nRREQIdentification;
    struct stru_DSR_RouteCache* pstruRouteCache; ///< List of routes to particular destination
    struct stru_DSR_SendBuffer* pstruSendBuffer; ///<  Buffer in which packets are added if route to target is not known.
    struct stru_DSR_RouteRequestTable* pstruRREQTable; ///< A table in which entry of RREQ initiated is made.
    enum
    {
      LINK_LAYER_ACK,
      NETWORK_LAYER_ACK,
    }AckType;
    double MY_PARAMETER_1;
    char* MY_PARAMETER_2;
    DSR_MAINT_BUFFER* pstruMaintBuffer; ///< Buffer in which packets sent to next HOP are added.
    struct stru_DSR_Metrics dsrMetrics;
  };

Default values to update the device variables, if the parameter is missing in the configuration file can be defined in the DSR.h header file as shown below;




Reading parameters from the XML Configuration file and updating the respective variables

Each protocol source code project consists of a main C and Header file (<Protocol_Name>.c and <Protocol_Name>.h)

The main C file consists of functions such as:


Function
Implementation
fn_NetSim_<Protocol_Name>_Init()Initializes protocol parameters
fn_NetSim_<Protocol_Name>_Configure()Reads protocol parameters from the XML Configuration file and updates the protocol variables.
fn_NetSim_<Protocol_Name>_Run()Handles all protocol related events and calls to various functions associated with the protocol.
fn_NetSim_<Protocol_Name>_Trace()Handles writing protocol events to event trace log file
fn_NetSim_<Protocol_Name>_Metrics()Handles writing protocol specific metrics
fn_NetSim_<Protocol_Name>_Finish()Handles deallocating memory assigned to variables during protocol initialization


The equivalent functions that are part of DSR.c file is shown below:



APIs related to reading from XML can be found in the Stack.h file which is part of the Include directory of the NetSim Source Code Repository.



The following API can be used to read parameters associated with a protocol from the XML configuration file:


getXmlVar(var,name,xmlNode,flag,type,protocol)

Where,

var refers to the variable in which the parameter's value being read will be stored.

name refers to the name of the parameter in the XML configuration that needs to be read.

xmlNode refers to the pointer to an XML element whose attributes are to be read

flag takes the value 0 or 1

type refers to the data type of the parameter being read. type can be one of these - _INT, _DOUBLE, _FLOAT, _STRING, _BOOL, _CHAR, _SHORT, _UINT, _UCHAR, _USHORT, _UINT8, _UINT16,

protocol refers to the name of the protocol whose parameters are being read


The function fn_NetSim_DSR_Configure() can be modified to read the new parameters added as part of DSR protocol as shown below:

_declspec(dllexport) int fn_NetSim_DSR_Configure(void** var)
{  
  int i = fn_NetSim_DSR_Configure_F(var);
  void* xmlNetSimNode;
  NETSIM_ID nDeviceId = 0;
  NETSIM_ID nInterfaceId = 0;
  char* szVal;

  xmlNetSimNode = var[2];
  if (var[3])
    nDeviceId = *((NETSIM_ID*)var[3]);
  if (var[4])
    nInterfaceId = *((NETSIM_ID*)var[4]);

  if (nDeviceId)
  {
    DSR_DEVICE_VAR* devVar = DSR_DEV_VAR(nDeviceId);
    getXmlVar(&devVar->MY_PARAMETER_1, MY_PARAMETER_1, xmlNetSimNode, 0, _DOUBLE, DSR);
    getXmlVar(&devVar->MY_PARAMETER_2, MY_PARAMETER_2, xmlNetSimNode, 0, _STRING, DSR);
  }

  return i;
}


Building the source codes and running simulations

The modifications done to the DSR.c and DSR.h files are saved and the DSR source code project is built. After this upon simulating network configuration with the new parameters added, it is read and updated in the Protocol source codes. These variables can be further accessed and used in the respective sections of the DSR protocol source codes.


Similarly, additional variables can be added to other protocols that are part of NetSim.