bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
bitsim::distributed::LossyTransport Class Referencefinal

A transport that delays and loses some of the messages of another, as a network would. More...

#include <transport.h>

Inheritance diagram for bitsim::distributed::LossyTransport:
Collaboration diagram for bitsim::distributed::LossyTransport:

Classes

struct  Config

Public Member Functions

 LossyTransport (std::unique_ptr< Transport > inner, const Config &config)
void publish (const std::string &bytes) override
 Send bytes to every other participant.
std::optional< std::string > receive (std::chrono::milliseconds timeout) override
 The next message from another participant, waiting at most timeout.
uint_t n_lost () const noexcept
Public Member Functions inherited from bitsim::distributed::Transport
virtual ~Transport ()=default

Detailed Description

A transport that delays and loses some of the messages of another, as a network would.

Every received message is held back for latency plus a random jitter, and dropped with probability loss, both drawn from a generator seeded with seed. Messages can overtake each other when the jitter is larger than the time between them. It is for testing how a simulation copes, without a network.

Constructor & Destructor Documentation

◆ LossyTransport()

bitsim::distributed::LossyTransport::LossyTransport ( std::unique_ptr< Transport > inner,
const Config & config )

Member Function Documentation

◆ n_lost()

uint_t bitsim::distributed::LossyTransport::n_lost ( ) const
inlinenoexcept

◆ publish()

void bitsim::distributed::LossyTransport::publish ( const std::string & bytes)
inlineoverridevirtual

Send bytes to every other participant.

Implements bitsim::distributed::Transport.

◆ receive()

std::optional< std::string > bitsim::distributed::LossyTransport::receive ( std::chrono::milliseconds timeout)
overridevirtual

The next message from another participant, waiting at most timeout.

Implements bitsim::distributed::Transport.


The documentation for this class was generated from the following files: