13 participant_rebroadcast_ttl_ (0),
14 trusted_peers_ (), banned_peers_ (),
15 packet_drop_rate_ (0.0), packet_drop_burst_ (1),
16 max_send_bandwidth_ (-1), max_total_bandwidth_ (-1),
93 *lhs_base = *rhs_base;
135 *lhs_base = *rhs_base;
184 bool condition =
false;
197 bool condition =
false;
210 bool condition =
false;
337 uint32_t types, jobject &
object)
342 "QoSTransportSettings::add: " 343 "Adding Java record filter to receive queue\n");
350 uint32_t types, jobject &
object)
357 uint32_t types, jobject &
object)
386 #ifdef _MADARA_PYTHON_CALLBACKS_ 390 uint32_t types, boost::python::object &
object)
397 uint32_t types, boost::python::object &
object)
404 uint32_t types, boost::python::object &
object)
412 boost::python::object &
object)
419 boost::python::object &
object)
426 boost::python::object &
object)
510 unsigned char * source,
int size,
int max_size)
const 513 for (filters::BufferFilters::const_iterator i =
buffer_filters_.begin ();
516 size = (*i)->encode (source, size, max_size);
525 unsigned char * source,
int size,
int max_size)
const 528 for (filters::BufferFilters::const_reverse_iterator i =
buffer_filters_.rbegin ();
531 size = (*i)->decode (source, size, max_size);
676 int64_t send_bandwidth)
690 int64_t total_bandwidth)
729 prefix +
".participant_rebroadcast_ttl").
to_integer ();
731 std::vector <std::string> trusted_keys, banned_keys;
733 trusted_peers.
keys (trusted_keys);
734 banned_peers.
keys (banned_keys);
736 for (
size_t i = 0; i < trusted_keys.size (); ++i)
741 for (
size_t i = 0; i < banned_keys.size (); ++i)
747 prefix +
".packet_drop_rate").
to_double ();
754 prefix +
".max_send_bandwidth").
to_integer ();
756 prefix +
".max_total_bandwidth").
to_integer ();
777 prefix +
".participant_rebroadcast_ttl").
to_integer ();
779 std::vector <std::string> trusted_keys, banned_keys;
781 trusted_peers.
keys (trusted_keys);
782 banned_peers.
keys (banned_keys);
784 for (
size_t i = 0; i < trusted_keys.size (); ++i)
789 for (
size_t i = 0; i < banned_keys.size (); ++i)
795 prefix +
".packet_drop_rate").
to_double ();
802 prefix +
".max_send_bandwidth").
to_integer ();
804 prefix +
".max_total_bandwidth").
to_integer ();
826 knowledge.
set (prefix +
".participant_rebroadcast_ttl",
829 for (std::map <std::string, int>::const_iterator i =
trusted_peers_.begin ();
835 for (std::map <std::string, int>::const_iterator i =
banned_peers_.begin ();
845 knowledge.
set (prefix +
".max_send_bandwidth",
847 knowledge.
set (prefix +
".max_total_bandwidth",
871 knowledge.
set (prefix +
".participant_rebroadcast_ttl",
874 for (std::map <std::string, int>::const_iterator i =
trusted_peers_.begin ();
880 for (std::map <std::string, int>::const_iterator i =
banned_peers_.begin ();
890 knowledge.
set (prefix +
".max_send_bandwidth",
892 knowledge.
set (prefix +
".max_total_bandwidth",
This class encapsulates an entry in a KnowledgeBase.
virtual void load_text(const std::string &filename, const std::string &prefix="transport")
Loads the settings from a text file.
bool is_trusted(const std::string &peer) const
Checks if a peer is trusted.
knowledge::KnowledgeRecord filter(const knowledge::KnowledgeRecord &input, const std::string &name, transport::TransportContext &context) const
Filters an input according to its filter chain.
void add_trusted_peer(const std::string &peer)
Adds a trusted peer.
virtual void load(const std::string &filename, const std::string &prefix="transport")
Loads the settings from a binary file.
void clear_receive_filters(uint32_t types)
Clears the list of filters for the specified types.
int filter_decode(unsigned char *source, int size, int max_size) const
Calls decode on the the buffer filter chain.
int64_t save_context(const std::string &filename) const
Saves the context to a file.
void clear(uint32_t types)
Clears the list of filters for the specified types.
size_t get_number_of_receive_filtered_types(void) const
Returns the number of types that are filtered after received.
void add_send_filter(uint32_t types, knowledge::KnowledgeRecord(*function)(knowledge::FunctionArguments &, knowledge::Variables &))
Adds a filter that will be applied to certain types before sending.
void clear_aggregate_filters(void)
Clears the aggregate filters.
void attach(knowledge::ThreadSafeContext *context)
Attaches a context to the various filtering systems.
void clear_receive_aggregate_filters(void)
Clears the list of receive time aggregate filters.
void print_num_filters(void) const
Prints the number of filters chained for each type.
void clear_send_aggregate_filters(void)
Clears the list of send time aggregate filters.
double to_double(void) const
converts the value to a float/double
Abstract base class for implementing aggregate record filters via a functor interface.
void keys(std::vector< std::string > &curkeys) const
Returns the keys within the map.
int get_drop_type(void) const
Returns the policy type for packet drops.
void add_rebroadcast_filter(uint32_t types, knowledge::KnowledgeRecord(*function)(knowledge::FunctionArguments &, knowledge::Variables &))
Adds a filter that will be applied to certain types after receiving and before rebroadcasting (if TTL...
int64_t get_send_bandwidth_limit(void) const
Returns the limit for sending on this transport in bytes per second.
knowledge::KnowledgeRecord filter_receive(const madara::knowledge::KnowledgeRecord &input, const std::string &name, transport::TransportContext &context) const
Filters an input according to the receive filter chain.
void attach(ThreadSafeContext *context)
Attaches a context.
void clear_rebroadcast_filters(uint32_t types)
Clears the list of filters for the specified types.
This class stores variables and their values for use by any entity needing state information in a thr...
void operator=(const QoSTransportSettings &settings)
Assignment operator.
MADARA_Export utility::Refcounter< logger::Logger > global_logger
unsigned char get_rebroadcast_ttl(void) const
Gets the time to live for rebroadcasting (number of rebroadcasts per message).
bool remove_trusted_peer(const std::string &peer)
Removes a trusted peer, if it exists in the list.
Abstract base class for implementing individual record filters via a functor interface.
Provides knowledge logging services to files and terminals.
Holds basic transport settings.
void add_filter(filters::BufferFilter *filter)
Adds a buffer filter to the chain.
knowledge::KnowledgeRecordFilters send_filters_
A container for filters applied before sending from this host.
std::vector< KnowledgeRecord > FunctionArguments
double get_deadline(void) const
Returns the latency deadline in seconds.
madara::knowledge::KnowledgeRecord get(const std::string &key, const KnowledgeReferenceSettings &settings=KnowledgeReferenceSettings(false))
Retrieves a knowledge value.
Provides context about the transport.
unsigned char rebroadcast_ttl_
number of rebroadcasts for receivers to ultimately do.
virtual void load_text(const std::string &filename, const std::string &prefix="transport")
Loads the settings from a text file.
virtual void save(const std::string &filename, const std::string &prefix="transport") const
Saves the settings from a binary file.
Provides container classes for fast knowledge base access and mutation.
size_t get_number_of_send_aggregate_filters(void) const
Returns the number of aggregate filters applied before sending @ return the number of aggregate filte...
void set_deadline(double deadline)
Sets the packet deadline in seconds.
void add_receive_filter(uint32_t types, knowledge::KnowledgeRecord(*function)(knowledge::FunctionArguments &, knowledge::Variables &))
Adds a filter that will be applied to certain types after receiving and before applying to the local ...
unsigned char participant_rebroadcast_ttl_
This field is meant to limit the number of rebroadcasts that this transport will participate in...
bool remove_banned_peer(const std::string &peer)
Removes a trusted peer, if it exists in the list.
int set(const std::string &key, madara::knowledge::KnowledgeRecord::Integer value=madara::knowledge::KnowledgeRecord::MODIFIED)
Sets a location within the map to the specified value.
virtual void save_text(const std::string &filename, const std::string &prefix="transport") const
Saves the settings from a text file.
void clear_rebroadcast_aggregate_filters(void)
Clears the list of rebroadcast time aggregate filters.
int packet_drop_type_
Drop rate type.
void print_num_filters_send(void) const
Prints the number of filters chained for each type to the send filter.
void set_total_bandwidth_limit(int64_t bandwidth)
Sets a bandwidth limit for receiving and sending over the transport.
knowledge::KnowledgeRecord filter_rebroadcast(const madara::knowledge::KnowledgeRecord &input, const std::string &name, transport::TransportContext &context) const
Filters an input according to the rebroadcast filter chain.
size_t get_number_of_buffer_filters(void) const
Returns the number of buffer filters.
uint64_t get_drop_burst(void) const
Returns the bursts of packet drops.
#define madara_logger_ptr_log(logger, level,...)
Fast version of the madara::logger::log method for Logger pointers.
void print_num_filters_receive(void) const
Prints the number of filters chained for each type to the receive filter.
virtual ~QoSTransportSettings()
Destructor.
This class stores a map of strings to KaRL variables.
This class provides a distributed knowledge base to users.
madara::knowledge::KnowledgeRecord::Integer Integer
QoSTransportSettings()
Default constructor.
void set_rebroadcast_ttl(unsigned char ttl)
Sets the time to live for our packets.
::std::map< std::string, KnowledgeRecord > KnowledgeMap
int64_t save_as_karl(const std::string &filename) const
Saves the context to a file as karl assignments, rather than binary.
size_t get_number_of_receive_aggregate_filters(void) const
Returns the number of aggregate filters applied after receiving @ return the number of aggregate filt...
size_t get_number_of_filtered_types(void) const
Returns the number of types that have filters.
double deadline_
Deadline for packets at which packets drop.
void clear_buffer_filters(void)
Clears the list of buffer filters.
Integer to_integer(void) const
converts the value to an integer
filters::BufferFilters buffer_filters_
buffer filters have an encode and decode method
size_t get_number_of_aggregate_filters(void) const
Returns the number of aggregate update filters.
void print_num_filters_rebroadcast(void) const
Prints the number of filters chained for each type to the rebroadcast filter.
int64_t max_send_bandwidth_
Maximum send bandwidth usage per second before packets drop.
void add_banned_peer(const std::string &peer)
Adds a banned peer.
Container for quality-of-service settings.
int filter_encode(unsigned char *source, int size, int max_size) const
Calls encode on the the buffer filter chain.
std::map< std::string, int > trusted_peers_
A container of all trusted peers.
void set_send_bandwidth_limit(int64_t bandwidth)
Sets a bandwidth limit for sending on this transport in bytes per sec.
int64_t get_total_bandwidth_limit(void) const
Returns the total limit for this transport in bytes per second.
std::map< std::string, int > banned_peers_
A container of all banned peers.
int set(const VariableReference &variable, const std::string &value, const EvalSettings &settings=EvalSettings(false, false, true, false, false))
Atomically sets the value of a variable to a string.
Provides functions and classes for the distributed knowledge base.
knowledge::KnowledgeRecord filter_send(const madara::knowledge::KnowledgeRecord &input, const std::string &name, transport::TransportContext &context) const
Filters an input according to send's filter chain.
void clear_send_filters(uint32_t types)
Clears the list of filters for the specified types.
MADARA_Export std::string file_to_string(const std::string &filename)
Reads a file into a string.
size_t get_number_of_send_filtered_types(void) const
Returns the number of types that are filtered before send.
double packet_drop_rate_
Rate for dropping packets.
int64_t max_total_bandwidth_
Maximum bandwidth usage for the transport (receive/send) before drop.
madara::knowledge::KnowledgeRecord evaluate(const std::string &expression, const EvalSettings &settings=EvalSettings())
Evaluates an expression.
virtual void save_text(const std::string &filename, const std::string &prefix="transport") const
Saves the settings from a text file.
virtual void load(const std::string &filename, const std::string &prefix="transport")
Loads the settings from a binary file.
int64_t load_context(const std::string &filename, bool use_id=true, const KnowledgeUpdateSettings &settings=KnowledgeUpdateSettings(true, true, true, false))
Loads the context from a file.
uint64_t packet_drop_burst_
Burst of packet drops.
double get_drop_rate(void) const
Returns the percentage of dropped packets to enforce on sends.
Abstract base class for implementing buffer filters via a functor interface.
void add(uint32_t types, knowledge::KnowledgeRecord(*function)(FunctionArguments &, Variables &))
Adds a filter to the list of types.
void enable_participant_ttl(unsigned char maximum_ttl=255)
Enables rebroadcast support up to a certain time to live for other agent's messages.
void update_drop_rate(double drop_rate, int drop_type=PACKET_DROP_DETERMINISTIC, uint64_t drop_burst=1)
Updates a packet drop rate, type, and burst.
size_t get_number_of_rebroadcast_filtered_types(void) const
Returns the number of types that are filtered before rebroadcast.
size_t get_number_of_rebroadcast_aggregate_filters(void) const
Returns the number of aggregate filters applied before rebroadcasting @ return the number of aggregat...
Provides an interface for external functions into the MADARA KaRL variable settings.
knowledge::KnowledgeRecordFilters receive_filters_
A container for receive filters.
knowledge::KnowledgeRecordFilters rebroadcast_filters_
A container for rebroadcast filters.
virtual void save(const std::string &filename, const std::string &prefix="transport") const
Saves the settings from a binary file.
unsigned char get_participant_ttl(void) const
Returns the maximum time to live participation of this transport in rebroadcasting of other agent's m...