SingleEchoDevice

Files CCore/inc/net/SingleEchoDevice.h CCore/src/net/SingleEchoDevice.cpp

This class is similar to the EchoDevice. But it is working with an endpoint device, not multipoint. It also implements the ConnectionProc interface to count connection lost events. Been attached this device simply reflects incoming packets. This class is useful in a net testing.


class SingleEchoDevice : NoCopy , public PacketEndpointDevice::InboundProc , public PacketEndpointDevice::ConnectionProc
 {
   ....

  public:
  
   enum Event
    {
     Event_inbound,
     
     Event_nopacket,
     Event_badformat,
    
     Event_lost,
     Event_close,

     EventLim
    };
    
   friend const char * GetTextDesc(Event ev); 
   
   using StatInfo = Counters<Event,EventLim> ;
    
  public: 
  
   static const ulen DefaultMaxPackets = 200 ;
  
   explicit SingleEchoDevice(StrLen ep_dev_name,ulen max_packets=DefaultMaxPackets);
   
   ~SingleEchoDevice();
   
   void getStat(StatInfo &ret);
   
   uint64 getTraffic();
 };

Constructor attaches the object to the packet endpoint device, registered under the given name. max_packets limits the packet usage.

getStat() returns the device statistic.

getTraffic() returns the device traffic counter.