| Applicable Versions | NetSim Standard | NetSim Pro |
| Applicable Releases | v15.0 |
Prerequisite: Understanding of the M/D/1 queuing experiment available in the NetSim Experiment Manual.

NetSim GUI provides options for selecting Constant and Exponential distributions for packet size and inter-arrival time. Users can customize these distributions by modifying the code in the Distribution.c file within the Application project.
For example, users can comment out the code under the Exponential distribution case and replace it with their own implementation. When simulations are run with the Exponential distribution selected in the GUI, the custom distribution code will be executed.
Section 9 of the NetSim User Manual explains how users can write and integrate their own code.
Note that the ‘arrival time’ depends on the inter-arrival time value, while the ‘service time’ depends on the packet size and link speed. However, if the packet size exceeds approximately 1500 bytes, the IP layer fragments the packet. As a result, the simulation results may slightly differ from the exact theoretical values.
Refer to the function fn_NetSim_TrafficGenerator_Custom(), which is part of the Database_FTP_Custom.c file in the Application project. By varying the input arguments to this function, users can model their own mathematical distributions for packet sizes and inter-arrival times. The function also contains comments that explain its usage, expected arguments, and how function calls can be made.
The variable associated with AppInfo, which is usually passed as input to the args parameter of the function
fnDistribution(
DISTRIBUTION nDistributionType,
double* fDistOut,
unsigned long* uSeed,
unsigned long* uSeed1,
double* args
)
is declared in the Application.h file within the stru_Application_DataInfo structure. This structure contains parameters such as packet size, inter-arrival time, packet size distribution, and inter-arrival time distribution.
Other related articles:
1. How do I trace the flow of function calls in NetSim source codes?
2. A detailed article on how to modify codes for building a M/G/1 queue in NetSim, written by Shivank Garg of IIT Kanpur is available at https://github.com/shivankgarg98/NetSim-Experiments/blob/master/General_Queuing_System_in_NetSim.md