size_t PCIeInterface::pcie_send_bytes(
unsigned char dds_send_buffer,
size_t size,
uint32_t port)
{
pci_endpoint_test_xfer_param_t param;
static std::chrono::steady_clock::time_point prev_time;
// Calculate the current time
auto current_time = std::chrono::steady_clock::now();
// Calculate the time difference in seconds
std::chrono::duration time_diff = current_time - prev_time;
tx_semaphore_.wait();
std::memcpy(p_send_buffer_, &port, sizeof(port));
std::memcpy((unsigned char) p_send_buffer_ + PCIE_PORT_MSG_OFFSET, dds_send_buffer, size);
size += sizeof(port);
param.size = size;
#ifdef USE_PCIE_DMA
param.flags = PCITEST_FLAGS_USE_DMA;
#endif
int error_status = ioctl(pcie_device_, PCITEST_WRITE, ¶m);
if (error_status < 0)
{
error_handler_.PrintIoctlError(errno);
logError(PCIE_INTERFACE_IOCTL, “Sending bytes failed @PCITEST_WRITE function kernel side”);
return 0;
}
if (size > DATA_64KB && dds_send_buffer[DATA_FRAG_OFFSET] == eprosima::fastrtps::rtps::SubmessageId::DATA_FRAG)
//200ms delay for overlaping processig time in receiver
std::this_thread::sleep_for(std::chrono::milliseconds(200));
if (size > 1024) {
if (dds_send_buffer[74] == 1) || dds_send_buffer[74] == 0) {
double fps = 1.0 / time_diff.count();
double data_rate_bps = (size * 8) / time_diff.count(); // Data rate in bits per second
double data_rate_Bps = size / time_diff.count(); // Data rate in bytes per second
std::cout << “Data Rate: " << data_rate_bps / 1e6 << " Mbps (” << data_rate_Bps / 1e3 << " KBps)" << “\n”;
std::cout << "Transport Layer FPS: " << fps << “\n”;
}
}
// Update the last send time
prev_time = current_time;
tx_semaphore_.signal();
return size;
}
consider the following scenario: In the above function is used to send a data. But if the data is greater than 64 MB the data is fragmented and sent. The information on the number of fragments will be available in the dds_send_buffer[74] value. for eg if data is 150 MB then there will be three fragments. So the above function will be called 3 times with each time the vaue in dds_send_buffer[74] increasing by one till it reaches 3. Then for the next set of 150 MB data the dds_send_buffer[74] willbe set back to 0. How to get the time required for sending the whole data. not just each fragment?