Files CCore/inc/net/Bridge.h CCore/src/net/Bridge.cpp
Bridge is another class for net testing. This class delivers packets between server and multiple clients.
class Bridge : NoCopy
{
....
public:
explicit Bridge(ulen num_clients);
Bridge(ulen num_clients,PacketFormat to_server_format,PacketFormat to_client_format);
~Bridge();
// methods
void setDropRate(uint32 drop_rate,uint32 drop_den);
static StrLen ServerName();
struct ClientName
{
char buf[TextBufLen];
StrLen str;
explicit ClientName(ulen number);
};
// start/stop
friend class StartStopObject<Bridge>;
using StartStop = StartStopObject<Bridge> ;
};
Once a Bridge object is created, it creates and registers a server device and number of client devices. The server device has the name ServerName(). To build a client device name use the inner class ClientName. Numbers of client devices are 1 .. num_clients. The fields str is the built client device name. Server implements the PacketMultipointDevice interface and the PortManager co-interface. Clients implement the PacketEndpointDevice interface and the PortManager co-interface. The port numbering is trivial: all addresses ports are zero. So you can attach to these devices another protocol devices.
The second constructor allows you to specify packet formats to and from server. You may also set the packet drop rate to simulate the packet loss. Use the method setDropRate(). The drop probability is drop_rate/drop_den.
To drive the Bridge, you have to start it using the inner class StartStop.