The payload of the packet is added in the application layer while generating the packet. Note that encryption is done after the payload is added. 

Open NetSim source code in Visual Studio 2015/2017 by double clicking on the NetSim.sln file present in “<NetSim_Install_Directory>/src/Simulation” folder. Go to the Application Project in the solution explorer. Code modifications are done in the copy_payload() function inside the application.c file of the Application project. To change the payload the follow the steps given below:


STEP 1: Create a string containing your data just before the function copy_payload()

For example, 

const char custom_data[]= "This is to demonstrate how users can add their own payload to the

the packet. The payload will further be encrypted if encryption is enabled";


STEP 2:  Inside the for loop in the function copy_payload(), make the modifications as given below (we have commented of the existing code and added the code shown in red) : 


For NetSim v9:


size_t custom_data_len = strlen(custom_data); 

for(i=0;i<*payload;i++)

  {

   /*if(i<len1)

   {

    real[i]=start_data[i];

   }

   else if(i>=*payload-len2)

   {

    real[i]=end_data[len2-*payload+i];

   }

   else

   {

    if(info->encryption==Encryption_XOR)

     real[i] = xor_encrypt('a'+i%26,16);

    else

     real[i] = 'a'+i%26;

   }*/

   if(info->encryption==Encryption_XOR)

     real[i] = xor_encrypt(custom_data[i%custom_data_len],16);

    else

     real[i] = custom_data[i%custom_data_len];

  }



For NetSim v10:


if (payload)
{
    size_t custom_data_len = strlen(custom_data);
for (i = 0; i < *payload; i++)
{
    /*if (info->encryption == Encryption_XOR)
    real[i] = xor_encrypt('a' + i % 26, 16);
    else
    real[i] = 'a' + i % 26;*/


    if (info->encryption == Encryption_XOR)
        real[i] = xor_encrypt(custom_data[i%custom_data_len], 16);
    else
        real[i] = custom_data[i%custom_data_len];

}

..


STEP 3: After the source code is modified, rebuild Application module and replace the newly built libApplication.dll file in the bin folder of NetSim after renaming the original libApplication.dll file to say, libApplication_original.dll as a backup.

 

STEP 4:To view the payload of the packet, Wireshark can be set to online in the Node properties. For instance, user can create a simple scenario in Internetworks with two Wired Nodes connected to a router. Set an application between the two nodes. In either of the Nodes right click and select properties. In the global properties set wireshark to online and run the simulation. 


During the simulation wireshark will automatically execute and will display the packets captured in the wired node. One can view the packet payload in the pane at the bottom, by clicking on the corresponding packet.


User can also change the payload of the packet by reading contents from a file.