Applicable Versions | NetSim Standard | NetSim Pro |
Applicable Releases | v11.1 | v12 |
Note: The processing Delay parameter is available in the device Network Layer properties from v13.0 onwards. For older versions of NetSim, the following procedure can be used to introduce processing delay.
In NetSim the devices are assumed to be infinitely fast. Factors such as CPU or memory usage are not modeled in NetSim. However, processing time can be programmed by modifying the underlying source C codes. The processing time in turn can be some function of CPU usage.
Following is an example where processing time is added for each packet that leaves a ZigBee device:
1. Open NetSim source codes using the Open Code button from Your Work (Open Simulation in v12 and lower versions)
->Workspace Options.
2. Go to the ZigBee project in the solution explorer and open the file 802_15_4.h
3. Add a macro to define processing time as shown below (processing time is in microseconds, users can modify this value as per the requirement):
#ifndef _NETSIM_802_15_4_H_
#define _NETSIM_802_15_4_H_
#ifdef __cplusplus
extern "C" {
#endif
#pragma comment(lib,"PropagationModel.lib")
#pragma comment(lib,"BatteryModel.lib")
#define PROCESSING_TIME 3000
4. Open the file 802_15_4.c and add the lines of code highlighted in red below, inside the PHYSICAL_OUT_EVENT of fn_NetSim_Zigbee_Run() function:
case PHYSICAL_OUT_EVENT:
{
NetSim_EVENTDETAILS pevent;
NETSIM_ID nLoop;
NetSim_PACKET* pstruPacket;
.
.
.
if(pstruPacket->pstruPhyData->dArrivalTime <= NETWORK->ppstruDeviceList[nDevice_Id-1]->ppstruInterfaceList[nDevice_PortId-1]->pstruPhysicalLayer->dLastPacketEndTime)
{
pstruPacket->pstruPhyData->dStartTime = NETWORK->ppstruDeviceList[nDevice_Id-1]->ppstruInterfaceList[nDevice_PortId-1]->pstruPhysicalLayer->dLastPacketEndTime;
}
else
pstruPacket->pstruPhyData->dStartTime = pstruPacket->pstruPhyData->dArrivalTime;
pstruPacket->pstruPhyData->dStartTime += PROCESSING_TIME;
pstruPacket->pstruPhyData->dEndTime = pstruPacket->pstruPhyData->dStartTime + dTxTime;
NETWORK->ppstruDeviceList[nDevice_Id-1]->ppstruInterfaceList[nDevice_PortId-1]->pstruPhysicalLayer->dLastPacketEndTime=pstruPacket->pstruPhyData->dEndTime;
Here processing delay is added to the physical layer start time of the packet, assuming additional processing delay before the packet gets transmitted.
5. Right-click on the ZigBee project and select the Rebuild option. Upon successful rebuild NetSim binaries will get updated as per the code modification done.
6. Now run a simulation to see the impact of the additional processing time added via code in the Delay metric that is part of the Application Metrics table.
Similarly, processing delay can be added for other physical layer protocols in the respective source code modules.
Related articles:
what-is-the-iot-stack-in-netsim-