Perform the code changes explained below to add a single character to the COAP response payload and print it at the receiver side(Changes highlighted in green):

1.  In the function fn_NetSim_Add_DummyPayload() modify the if condition as shown below:

if(!packet->szPayload &&
packet->pstruAppData &&
packet->pstruAppData->dPacketSize &&
packet->pstruAppData->nAppType != TRAFFIC_EMULATION) /* Don't set payload in emulation */ //&&
//wireshark_flag)

2. In copy_payload function under Application.c i.e adding character X for every response packet.
void copy_payload(UINT8 real[],NetSim_PACKET* packet,unsigned int* payload,APP_INFO* info)
{
    u_short i;
    uint32_t key = 16;
    if (payload)
    {
        if (packet->nControlDataType == packet_COAP_REQUEST)
                real[0] = 'X';

        else
        {

            for (i = 0; i < *payload; i++)
            {
               -----------------
               -------------
        }
    }
}

3. To read and print it on receiver side, go to Application IN Event of Appplcaion run function under Applcaion.c file of application project.
else if (pstruPacket->nControlDataType == packet_COAP_REQUEST)
            {
                APP_INFO* pstruappinfo;
                fnValidatePacket(pstruPacket);
                pstruappinfo = appInfo[pstruPacket->pstruAppData->nApplicationId - 1];
                pstruPacket->pstruAppData->dEndTime = pstruEventDetails->dEventTime;
                //On receiving COAP Packet
 
                if(strcmp(pstruPacket->szPacketType,"COAP_RESPONSE"))
                fprintf(stderr,"COAP_RESPONSE Payload:%c\n", pstruPacket->szPayload->packet[0]);

                appmetrics_dest_add(pstruappinfo, pstruPacket, pstruEventDetails->nDeviceId);
                fn_NetSim_Application_Plot(pstruPacket);
                fn_NetSim_Application_COAP_AppIn(pstruappinfo, pstruPacket);
                //Delete the packet
                fn_NetSim_Packet_FreePacket(pstruPacket);
            }

Related Articles:

https://support.tetcos.com/en/support/solutions/articles/14000041020-how-do-i-change-the-payload-of-a-packet-in-netsim-

https://support.tetcos.com/en/support/solutions/articles/14000106347-wireless-body-area-network-wban-application-reading-sensor-measurements-from-a-csv-xl-file