Skip to content

Commit

Permalink
registration provider/receiver, logging provider/receiver and payload…
Browse files Browse the repository at this point in the history
… provider/receiver use broadcast in local mode
  • Loading branch information
rex-schilasky committed Nov 17, 2023
1 parent 0f41b3a commit 9fb9e02
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 38 deletions.
24 changes: 17 additions & 7 deletions ecal/core/src/ecal_log_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,17 +145,27 @@ namespace eCAL
m_logfile = fopen(m_logfile_name.c_str(), "w");
}

// create log udp sender
// set network attributes
if(m_filter_mask_udp != 0)
{
SSenderAttr attr;
attr.address = UDP::GetLoggingMulticastAddress();
attr.port = UDP::GetLoggingPort();
attr.broadcast = !Config::IsNetworkEnabled();
attr.loopback = true;
attr.ttl = UDP::GetMulticastTtl();
attr.sndbuf = Config::GetUdpMulticastSndBufSizeBytes();
const bool local_only = !Config::IsNetworkEnabled();
if (local_only)
{
attr.address = UDP::LocalBroadcastAddress();
attr.broadcast = true;
}
else
{
attr.address = UDP::GetLoggingMulticastAddress();
attr.broadcast = false;
}
attr.port = UDP::GetLoggingPort();
attr.ttl = UDP::GetMulticastTtl();
attr.loopback = true;
attr.sndbuf = Config::GetUdpMulticastSndBufSizeBytes();

// create udp logging sender
m_udp_sender = std::make_unique<CUDPSender>(attr);
}

Expand Down
25 changes: 17 additions & 8 deletions ecal/core/src/ecal_registration_provider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,23 @@ namespace eCAL
{
// set network attributes
SSenderAttr attr;
attr.address = UDP::GetRegistrationMulticastAddress();
attr.port = UDP::GetRegistrationPort();
attr.ttl = UDP::GetMulticastTtl();
attr.broadcast = !Config::IsNetworkEnabled();
attr.loopback = true;
attr.sndbuf = Config::GetUdpMulticastSndBufSizeBytes();

// create udp sample sender
const bool local_only = !Config::IsNetworkEnabled();
if (local_only)
{
attr.address = UDP::LocalBroadcastAddress();
attr.broadcast = true;
}
else
{
attr.address = UDP::GetRegistrationMulticastAddress();
attr.broadcast = false;
}
attr.port = UDP::GetRegistrationPort();
attr.ttl = UDP::GetMulticastTtl();
attr.loopback = true;
attr.sndbuf = Config::GetUdpMulticastSndBufSizeBytes();

// create udp registration sender
m_reg_sample_snd = std::make_shared<CSampleSender>(attr);
}
else
Expand Down
24 changes: 18 additions & 6 deletions ecal/core/src/ecal_registration_receiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,27 @@ namespace eCAL

if (m_use_network_monitoring)
{
// start registration receive thread
// set network attributes
SReceiverAttr attr;
attr.address = UDP::GetRegistrationMulticastAddress();
attr.port = UDP::GetRegistrationPort();
attr.broadcast = !Config::IsNetworkEnabled();
attr.loopback = true;
attr.rcvbuf = Config::GetUdpMulticastRcvBufSizeBytes();
const bool local_only = !Config::IsNetworkEnabled();
if (local_only)
{
attr.address = UDP::LocalBroadcastAddress();
attr.broadcast = true;
}
else
{
attr.address = UDP::GetRegistrationMulticastAddress();
attr.broadcast = false;
}
attr.port = UDP::GetRegistrationPort();
attr.loopback = true;
attr.rcvbuf = Config::GetUdpMulticastRcvBufSizeBytes();

// create udp registration receiver
m_reg_rcv.Create(attr);

// start registration receiver thread
m_reg_rcv_thread.Start(0, std::bind(&CUdpRegistrationReceiver::Receive, &m_reg_rcv_process, &m_reg_rcv));
}

Expand Down
2 changes: 1 addition & 1 deletion ecal/core/src/io/udp_configurations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace eCAL
}
else
{
// both in v1 and v2, the mulicast group is returned as the adress for the registration layer
// both in v1 and v2, the multicast group is returned as the adress for the registration layer
return Config::GetUdpMulticastGroup();
}
}
Expand Down
25 changes: 20 additions & 5 deletions ecal/core/src/mon/ecal_monitoring_threads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,30 @@ namespace eCAL
CLoggingReceiveThread::CLoggingReceiveThread(LogMessageCallbackT log_cb_) :
m_network_mode(false), m_log_cb(log_cb_)
{
// set network attributes
SReceiverAttr attr;
attr.address = UDP::GetLoggingMulticastAddress();
attr.port = UDP::GetLoggingPort();
attr.broadcast = !Config::IsNetworkEnabled();
attr.loopback = true;
attr.rcvbuf = Config::GetUdpMulticastRcvBufSizeBytes();
const bool local_only = !Config::IsNetworkEnabled();
if (local_only)
{
attr.address = UDP::LocalBroadcastAddress();
attr.broadcast = true;
}
else
{
attr.address = UDP::GetLoggingMulticastAddress();
attr.broadcast = false;
}
attr.port = UDP::GetLoggingPort();
attr.loopback = true;
attr.rcvbuf = Config::GetUdpMulticastRcvBufSizeBytes();

// create udp logging receiver
m_log_rcv.Create(attr);

// start logging receiver thread
m_log_rcv_thread.Start(0, std::bind(&CLoggingReceiveThread::ThreadFun, this));

// allocate receive buffer
m_msg_buffer.resize(MSG_BUFFER_SIZE);
}

Expand Down
22 changes: 17 additions & 5 deletions ecal/core/src/readwrite/ecal_reader_udp_mc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,24 @@ namespace eCAL

void CUDPReaderLayer::Initialize()
{
// set network attributes
SReceiverAttr attr;
attr.address = Config::GetUdpMulticastGroup();
attr.port = UDP::GetPayloadPort();
attr.broadcast = false;
attr.loopback = true;
attr.rcvbuf = Config::GetUdpMulticastRcvBufSizeBytes();
const bool local_only = !Config::IsNetworkEnabled();
if (local_only)
{
attr.address = UDP::LocalBroadcastAddress();
attr.broadcast = true;
}
else
{
attr.address = Config::GetUdpMulticastGroup();
attr.broadcast = false;
}
attr.port = UDP::GetPayloadPort();
attr.loopback = true;
attr.rcvbuf = Config::GetUdpMulticastRcvBufSizeBytes();

// create udp receiver
rcv.Create(attr);
}

Expand Down
22 changes: 16 additions & 6 deletions ecal/core/src/readwrite/ecal_writer_udp_mc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,27 @@ namespace eCAL

// set network attributes
SSenderAttr attr;
attr.address = UDP::GetPayloadMulticastAddress(topic_name_);
attr.port = UDP::GetPayloadPort();
attr.ttl = UDP::GetMulticastTtl();
attr.sndbuf = Config::GetUdpMulticastSndBufSizeBytes();
const bool local_only = !Config::IsNetworkEnabled();
if (local_only)
{
attr.address = UDP::LocalBroadcastAddress();
attr.broadcast = true;
}
else
{
attr.address = UDP::GetPayloadMulticastAddress(topic_name_);
attr.broadcast = false;
}
attr.port = UDP::GetPayloadPort();
attr.ttl = UDP::GetMulticastTtl();
attr.sndbuf = Config::GetUdpMulticastSndBufSizeBytes();

// create udp/sample sender with activated loop-back
attr.loopback = true;
attr.loopback = true;
m_sample_sender_loopback = std::make_shared<CSampleSender>(attr);

// create udp/sample sender without activated loop-back
attr.loopback = false;
attr.loopback = false;
m_sample_sender_no_loopback = std::make_shared<CSampleSender>(attr);

m_created = true;
Expand Down

0 comments on commit 9fb9e02

Please sign in to comment.