How do I Run a Program in Ns3
Let’s start this article to know about the essential processes that are deployed to run ns3 program.
Ns3 Program Creation
En route for the initiation of this process, the file extension .cc is deployed to create and store the simulation program in the scratch folder.
Sample Ns3 Program Code
To showcase some sample ns3 program codes for your reference, we have enlisted the some significant processes with programming code.
- Energy model configuration
basicSourceHelper.Set ("BasicEnergySourceInitialEnergyJ", DoubleValue (1.0));
EnergySourceContainer sources = basicSourceHelper.Install (c);
radioEnergyHelper.Set ("TxCurrentA", DoubleValue (0.0174));
radioEnergyHelper.Set ("RxCurrentA", DoubleValue (0.0197));
DeviceEnergyModelContainer deviceModels = radioEnergyHelper.Install (devices, sources);
basicHarvesterHelper.Set ("PeriodicHarvestedPowerUpdateInterval", TimeValue (Seconds (harvestingUpdateInterval)));
basicHarvesterHelper.Set ("HarvestablePower", StringValue ("ns3::UniformRandomVariable[Min=0.0|Max=0.1]"));
EnergyHarvesterContainer harvesters = basicHarvesterHelper.Install (sources);
- Header file initialization
Run Ns3 Program
Finally, we have to run the simulation program based on Ns3 through the implementation of the commands that are highlighted below.
sudo ./waf –run ProgramCode –vis
Notably, we have illustrated the result that is acquired through the program execution through the below mentioned screen.
If you guys feel that you are lacking somewhere just take a while to interact with our technical experts and we hope that you have acquired some required information about running ns3 program through this article.