Skip to content

Commit

Permalink
new subfolder for udp message (de)fragmentation io/udp/fragmentation
Browse files Browse the repository at this point in the history
new subfolder for higher level udp protobuf message handling io/udp/protobuf
  • Loading branch information
rex-schilasky committed Dec 5, 2023
1 parent 71c79a8 commit 61455d5
Show file tree
Hide file tree
Showing 17 changed files with 50 additions and 43 deletions.
32 changes: 21 additions & 11 deletions ecal/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,19 +144,25 @@ set(ecal_io_udp_src_npcap
)
endif()

set(ecal_io_udp_fragmentation_src
src/io/udp/fragmentation/rcv_fragments.cpp
src/io/udp/fragmentation/rcv_fragments.h
src/io/udp/fragmentation/snd_fragments.cpp
src/io/udp/fragmentation/snd_fragments.h
)

set(ecal_io_udp_protobuf_src
src/io/udp/protobuf/rcv_logging.cpp
src/io/udp/protobuf/rcv_logging.h
src/io/udp/protobuf/rcv_sample.cpp
src/io/udp/protobuf/rcv_sample.h
src/io/udp/protobuf/snd_sample.cpp
src/io/udp/protobuf/snd_sample.h
)

set(ecal_io_udp_src
src/io/udp/ecal_receiver.h
src/io/udp/msg_type.h
src/io/udp/rcv_logging.cpp
src/io/udp/rcv_logging.h
src/io/udp/rcv_sample.cpp
src/io/udp/rcv_sample.h
src/io/udp/rcv_sample_slot.cpp
src/io/udp/rcv_sample_slot.h
src/io/udp/snd_raw_buffer.cpp
src/io/udp/snd_raw_buffer.h
src/io/udp/snd_sample.cpp
src/io/udp/snd_sample.h
src/io/udp/topic2mcast.h
src/io/udp/udp_configurations.cpp
src/io/udp/udp_configurations.h
Expand Down Expand Up @@ -448,7 +454,9 @@ ecal_add_ecal_shared_library(${PROJECT_NAME}
${ecal_io_mtx_win_src}
${ecal_io_shm_src}
${ecal_io_shm_linux_src}
${ecal_io_shm_win_src}
${ecal_io_shm_win_src}
${ecal_io_udp_fragmentation_src}
${ecal_io_udp_protobuf_src}
${ecal_io_udp_src}
${ecal_io_udp_linux_src}
${ecal_logging_src}
Expand Down Expand Up @@ -568,6 +576,8 @@ if(NOT ${CMAKE_VERSION} VERSION_LESS "3.8.0")
${ecal_io_shm_src}
${ecal_io_shm_linux_src}
${ecal_io_shm_win_src}
${ecal_io_udp_fragmentation_src}
${ecal_io_udp_protobuf_src}
${ecal_io_udp_src}
${ecal_logging_src}
${ecal_monitoring_src}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
* @brief UDP sample receiver to receive messages of type eCAL::pb::Sample
**/

#include "rcv_sample_slot.h"
#include "rcv_fragments.h"

#include <ecal/ecal_log.h>

#include <cstring>

CReceiveSlot::CReceiveSlot()
CMsgDefragmentation::CMsgDefragmentation()
: m_timeout(0.0)
, m_recv_mode(rcm_waiting)
, m_message_id(0)
Expand All @@ -38,9 +38,9 @@ CReceiveSlot::CReceiveSlot()
{
}

CReceiveSlot::~CReceiveSlot() = default;
CMsgDefragmentation::~CMsgDefragmentation() = default;

int CReceiveSlot::ApplyMessage(const struct SUDPMessage& ecal_message_)
int CMsgDefragmentation::ApplyMessage(const struct SUDPMessage& ecal_message_)
{
// reset timeout
m_timeout = std::chrono::duration<double>(0.0);
Expand Down Expand Up @@ -71,7 +71,7 @@ int CReceiveSlot::ApplyMessage(const struct SUDPMessage& ecal_message_)
return(0);
}

int CReceiveSlot::OnMessageStart(const struct SUDPMessage& ecal_message_)
int CMsgDefragmentation::OnMessageStart(const struct SUDPMessage& ecal_message_)
{
// store header info
m_message_id = ecal_message_.header.id;
Expand All @@ -91,7 +91,7 @@ int CReceiveSlot::OnMessageStart(const struct SUDPMessage& ecal_message_)
return(0);
}

int CReceiveSlot::OnMessageData(const struct SUDPMessage& ecal_message_)
int CMsgDefragmentation::OnMessageData(const struct SUDPMessage& ecal_message_)
{
// check message id
if(ecal_message_.header.id != m_message_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@
#pragma once

#include "ecal_def.h"
#include "msg_type.h"
#include "io/udp/msg_type.h"

#include <chrono>
#include <vector>

class CReceiveSlot
class CMsgDefragmentation
{
public:
CReceiveSlot();
virtual ~CReceiveSlot();
CMsgDefragmentation();
virtual ~CMsgDefragmentation();

int ApplyMessage(const struct SUDPMessage& ecal_message_);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

#include "ecal_process.h"

#include "snd_raw_buffer.h"
#include "snd_fragments.h"
#include "io/udp/msg_type.h"

namespace
Expand Down Expand Up @@ -79,7 +79,7 @@ namespace eCAL
return (0);
}

size_t SendSampleBuffer(char* buf_, size_t buf_len_, long bandwidth_, TransmitCallbackT transmit_cb_)
size_t SendFragmentedMessage(char* buf_, size_t buf_len_, long bandwidth_, TransmitCallbackT transmit_cb_)
{
if (buf_ == nullptr) return(0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ namespace eCAL
size_t CreateSampleBuffer(const std::string& sample_name_, const eCAL::pb::Sample& ecal_sample_, std::vector<char>& payload_);

using TransmitCallbackT = std::function<size_t (const void *, const size_t)>;
size_t SendSampleBuffer(char* buf_, size_t buf_len_, long bandwidth_, TransmitCallbackT transmit_cb_);
size_t SendFragmentedMessage(char* buf_, size_t buf_len_, long bandwidth_, TransmitCallbackT transmit_cb_);
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ namespace eCAL
const size_t recv_len = m_udp_receiver.Receive(m_msg_buffer.data(), m_msg_buffer.size(), CMN_UDP_RECEIVE_THREAD_CYCLE_TIME_MS);
if (recv_len > 0)
{
m_log_message.Clear();
if (m_log_message.ParseFromArray(m_msg_buffer.data(), static_cast<int>(recv_len)))
{
if (IsLocalHost(m_log_message) || m_network_mode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#pragma once

#include "ecal_def.h"
#include "udp_receiver.h"
#include "io/udp/udp_receiver.h"
#include "util/ecal_thread.h"

#include <string>
Expand Down Expand Up @@ -56,7 +56,7 @@ namespace eCAL
LogMessageCallbackT m_log_message_callback;

CUDPReceiver m_udp_receiver;
std::shared_ptr<CCallbackThread> m_udp_receiver_thread;
std::shared_ptr<CCallbackThread> m_udp_receiver_thread;

std::vector<char> m_msg_buffer;
eCAL::pb::LogMessage m_log_message;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
#pragma once

#include "ecal_def.h"
#include "udp_receiver.h"
#include "rcv_sample_slot.h"
#include "io/udp/udp_receiver.h"
#include "io/udp/fragmentation/rcv_fragments.h"
#include "util/ecal_thread.h"

#include <chrono>
Expand All @@ -45,7 +45,7 @@

class CUDPSampleReceiver
{
class CSampleReceiveSlot : public CReceiveSlot
class CSampleReceiveSlot : public CMsgDefragmentation
{
public:
explicit CSampleReceiveSlot(CUDPSampleReceiver* sample_receiver_);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
*/

/**
* @brief Sender thread for ecal samples
* @brief UDP sample sender to send messages of type eCAL::pb::Sample
**/

#include <ecal/ecal.h>

#include "snd_sample.h"
#include "snd_raw_buffer.h"
#include "io/udp/fragmentation/snd_fragments.h"

namespace
{
Expand Down Expand Up @@ -52,7 +52,7 @@ namespace eCAL
if (data_size > 0)
{
// and send it
sent_sum = SendSampleBuffer(m_payload.data(), data_size, bandwidth_, std::bind(TransmitToUDP, std::placeholders::_1, std::placeholders::_2, m_udp_sender, m_attr.address));
sent_sum = SendFragmentedMessage(m_payload.data(), data_size, bandwidth_, std::bind(TransmitToUDP, std::placeholders::_1, std::placeholders::_2, m_udp_sender, m_attr.address));

#ifndef NDEBUG
// log it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
*/

/**
* @brief Sender thread for ecal samples
* @brief UDP sample sender to send messages of type eCAL::pb::Sample
**/

#pragma once

#include <memory>

#include "udp_sender.h"
#include "io/udp/udp_sender.h"

#ifdef _MSC_VER
#pragma warning(push, 0) // disable proto warnings
Expand Down
2 changes: 1 addition & 1 deletion ecal/core/src/logging/ecal_log_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#pragma once

#include "io/udp/udp_sender.h"
#include "io/udp/rcv_logging.h"
#include "io/udp/protobuf/rcv_logging.h"

#include <ecal/ecal.h>
#include <ecal/ecal_os.h>
Expand Down
2 changes: 1 addition & 1 deletion ecal/core/src/readwrite/udp/ecal_reader_udp_mc.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

#include "readwrite/ecal_reader_layer.h"

#include "io/udp/rcv_sample.h"
#include "io/udp/protobuf/rcv_sample.h"

#include <map>
#include <memory>
Expand Down
3 changes: 1 addition & 2 deletions ecal/core/src/readwrite/udp/ecal_writer_udp_mc.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@
#pragma warning(pop)
#endif

#include "io/udp/snd_sample.h"
#include "io/udp/udp_sender.h"
#include "io/udp/protobuf/snd_sample.h"
#include "readwrite/ecal_writer_base.h"

#include <string>
Expand Down
2 changes: 1 addition & 1 deletion ecal/core/src/registration/ecal_registration_provider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include "ecal_descgate.h"

#include "io/udp/udp_configurations.h"
#include "io/udp/snd_sample.h"
#include "io/udp/protobuf/snd_sample.h"

#include <chrono>

Expand Down
3 changes: 1 addition & 2 deletions ecal/core/src/registration/ecal_registration_provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@

#pragma once

#include "io/udp/snd_sample.h"
#include "io/udp/udp_sender.h"
#include "io/udp/protobuf/snd_sample.h"

#include "io/shm/ecal_memfile_broadcast.h"
#include "io/shm/ecal_memfile_broadcast_writer.h"
Expand Down
2 changes: 1 addition & 1 deletion ecal/core/src/registration/ecal_registration_receiver.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

#include "ecal_def.h"

#include "io/udp/rcv_sample.h"
#include "io/udp/protobuf/rcv_sample.h"

#include "io/shm/ecal_memfile_broadcast.h"
#include "io/shm/ecal_memfile_broadcast_reader.h"
Expand Down

0 comments on commit 61455d5

Please sign in to comment.