14 namespace madara {
namespace transport {
16 namespace mcast = ip::multicast;
23 :
Base (id, config, context)
63 "BasicASIOTransport::setup:" \
64 " No host addresses. Aborting setup.\n");
75 auto addr = ip::address::from_string (addr_parts.first);
76 addresses_.emplace_back (addr, addr_parts.second);
79 "BasicASIOTransport::setup:" \
80 " settings address[%d] to %s:%d\n", i,
81 addresses_.back ().address ().to_string ().c_str (),
83 }
catch (
const boost::system::system_error &e) {
85 "BasicASIOTransport::setup:" \
86 " Error parsing address %s: %s\n",
settings_.
hosts[i].c_str (), e.what ());
92 "BasicASIOTransport::setup:" \
93 " No valid addresses. Aborting setup.\n");
100 }
catch (
const boost::system::system_error &e) {
102 "BasicASIOTransport::setup:" \
103 " Error opening sockets: %s\n", e.what ());
127 asio::socket_base::send_buffer_size send_buffer_option;
128 asio::socket_base::receive_buffer_size receive_buffer_option;
131 socket.get_option(send_buffer_option);
132 int send_buff_size = send_buffer_option.value();
134 socket.get_option(receive_buffer_option);
135 int rcv_buff_size = receive_buffer_option.value();
138 "BasicASIOTransport::setup:" \
139 " default socket buff size is send=%d, rcv=%d\n",
140 send_buff_size, rcv_buff_size);
142 if (send_buff_size < tar_buff_size)
145 "BasicASIOTransport::setup:" \
146 " setting send buff size to settings.queue_length (%d)\n",
149 send_buffer_option = tar_buff_size;
150 socket.set_option (send_buffer_option);
152 socket.get_option (send_buffer_option);
153 send_buff_size = send_buffer_option.value();
156 "BasicASIOTransport::setup:" \
157 " current socket buff size is send=%d, rcv=%d\n",
158 send_buff_size, rcv_buff_size);
161 if (rcv_buff_size < tar_buff_size)
164 "BasicASIOTransport::setup:" \
165 " setting rcv buff size to settings.queue_length (%d)\n",
168 receive_buffer_option = tar_buff_size;
169 socket.set_option (receive_buffer_option);
171 socket.get_option (receive_buffer_option);
172 rcv_buff_size = receive_buffer_option.value();
175 "BasicASIOTransport::setup:" \
176 " current socket buff size is send=%d, rcv=%d\n",
177 send_buff_size, rcv_buff_size);
179 }
catch (
const boost::system::system_error &e) {
181 "BasicASIOTransport::setup:" \
182 " Error setting up sockets: %s\n", e.what ());
233 "BasicASIOTransport::setup:" \
239 std::stringstream thread_name;
240 thread_name <<
"read";
244 "BasicASIOTransport::setup:" \
245 " starting thread %s at %f hertz\n",
246 thread_name.str ().c_str (), hertz);
knowledge::KnowledgeBase knowledge_
knowledge base for threads to use
QoSTransportSettings settings_
void invalidate_transport(void)
Invalidates a transport to indicate it is shutting down.
std::pair< std::string, uint16_t > parse_address(std::string addr)
void close() override
Closes this transport.
int validate_transport(void)
Validates a transport to indicate it is not shutting down.
BasicASIOTransport(const std::string &id, madara::knowledge::ThreadSafeContext &context, TransportSettings &config)
udp::socket socket_
underlying socket
This class stores variables and their values for use by any entity needing state information in a thr...
std::vector< std::string > hosts
Host information for transports that require it.
virtual int setup_sockets()
double read_thread_hertz
number of valid messages allowed to be received per second.
Holds basic transport settings.
#define madara_logger_log(logger, level,...)
Fast version of the madara::logger::log method.
bool no_receiving
if true, never receive over transport
std::vector< udp::endpoint > addresses_
holds all multicast addresses we are sending to
virtual int setup_socket(udp::socket &socket)
uint32_t read_threads
the number of read threads to start
uint32_t queue_length
Length of the buffer used to store history of events.
void terminate(const std::string name)
Requests a specific thread to terminate.
virtual int setup_read_threads()
threads::Threader read_threads_
threads for reading knowledge updates
int setup() override
all subclasses should call this method at the end of its setup
void set_data_plane(knowledge::KnowledgeBase data_plane)
Sets the data plane for new threads.
virtual int setup_read_thread(double hertz, const std::string &name)=0
Copyright (c) 2015 Carnegie Mellon University.
logger::Logger & get_logger(void) const
Gets the logger used for information printing.
virtual int setup(void)
all subclasses should call this method at the end of its setup
Base class from which all transports must be derived.
bool wait(const std::string name, const knowledge::WaitSettings &ws=knowledge::WaitSettings())
Wait for a specific thread to complete.
madara::knowledge::ThreadSafeContext & context_
void use(ThreadSafeContext &original)
Refer to and use another knowledge base's context.
virtual int setup_read_socket()
virtual int setup_write_socket()