Applicable VersionsNetSim StandardNetSim Pro

Applicable Releasev13.1

The article explains how users can introduce propagation delay in NetSim 5G simulations by modifying the underlying source code. By default, NetSim assumes this propagation delay to be zero since it is several orders of magnitude lower than the PHY slot time.


Users are advised to create a new workspace when making code changes. New workspace creation is explained in section 4.6 of the NetSim v13.1 user manual. MS Visual studio (community edition of higher) is required to edit and build the C codes. 


1. Open NetSim source code in the new NetSim workspace. Refer section “4.13: How does a user open and modify source codes” of the NetSim v13.1 user manual.

2. Go to LTE_NR project through the solution explorer and open the LTE_NR.c file. In the function fn_NetSim_LTE_NR_Run(), inside the PHYSICAL_OUT_EVENT add the lines of code that is highlighted in the red color:



NetSim_PACKET* packet = pstruEventDetails->pPacket;

NETSIM_ID d = pstruEventDetails->nDeviceId;

NETSIM_ID in = pstruEventDetails->nInterfaceId;

NETSIM_ID r = packet->nReceiverId;

double endTime;

double distance2D;

if (r != 0)



 if (rin == 0) break;

 endTime = LTENR_PHY_GetSlotEndTime(d, in);

 distance2D = DEVICE_DISTANCE(packet->nTransmitterId, packet->nReceiverId);

 packet->pstruPhyData->dArrivalTime = pstruEventDetails->dEventTime;

 packet->pstruPhyData->dEndTime = endTime-1+(distance2D/(3*pow(10,2)));

 packet->pstruPhyData->dPacketSize = packet->pstruMacData->dPacketSize;

 packet->pstruPhyData->dPayload = packet->pstruMacData->dPacketSize;

 packet->pstruPhyData->dStartTime = pstruEventDetails->dEventTime;

 pstruEventDetails->dEventTime = endTime - 1;

 pstruEventDetails->nEventType = PHYSICAL_IN_EVENT;

 pstruEventDetails->nDeviceId = r;

 pstruEventDetails->nDeviceType = DEVICE_TYPE(r);

 pstruEventDetails->nInterfaceId = rin;






 3. Save the changes and right-click on the LTE_NR module in the solution explorer and select Rebuild as shown below



 4. Upon a successful build, NetSim will automatically update the modified binaries in the respective binary folder. 


 5Create any 5G scenario. In our example (shown below) we have a UE placed 3000m away from gNB as shown in below

6. Enable packet trace (available in the top ribbon in the design window). Run the simulation.

7. Now, after simulation, go to the NetSim Results window. Since the Packet Trace is enabled prior to simulation, you'll get a hyperlink "Open Packet Trace". Click on the hyperlink. 



8. This will open the trace file in an excel sheet as shown below. The Packet Trace contains 30+ columns, in which various details about each packet transmitted during the simulation is logged.



9. Filter Transmitter_ID column to gNB-7 and Receiver_ID column to UE-8 and Destination_ID column to UE-8 by clicking on the dropdown. To filter, check and uncheck the checkboxes corresponding to each device as per requirement. Click on ok.



The Layer-wise timings will be available in the trace, APP_Layer_Arrival_Time,TRX_Layer_Arrival_Time, NW_Layer_Arrival_Time , MAC_Layer_Arrival_Time , and PHY_Layer_Arrival_Time.




10. Add one more column to the right of PHY_LAYER_END_TIME(US) and add this formula to first row of that column and hit enter,

              “ =([@[PHY_LAYER_END_TIME(US)]]-[@[PHY_LAYER_START_TIME(US)]])”

You will get the results as shown below


There are two components to the packet latency from a gNB to a UE namely (i) transmission time (ii) propagation time. The transmission time depends on the PHY layer slot length, while the propagation delay depends on UE-gNB distance and the speed of light constant. 


In this example, the PHY slot length is 1000µs and guard interval is 1µs. NetSim therefore considers the slot time as be 999µs. If the slot time is subtracted from the column results, we get the propagation delay as

Verification. In our example,