42 #ifndef _DWMHOSTPINGER_HH_ 43 #define _DWMHOSTPINGER_HH_ 45 #include <condition_variable> 89 HostPinger(uint16_t identifier,
const std::string & device =
"lo0");
139 bool Start(
int count = 0);
153 typedef std::map<PingDestination,PingDestinationEntry> DestinationMap;
157 std::thread _watcherThread;
158 std::thread _senderThread;
159 std::mutex _watcherReadyMutex;
160 std::unique_lock<std::mutex> _watcherReadyLock;
161 std::condition_variable _watcherReady;
164 uint16_t _identifier;
166 uint16_t _packetRate;
170 DestinationMap _destinations;
176 uint16_t seq, std::string & s);
178 static void PcapCallback(uint8_t *user,
const struct pcap_pkthdr *pchdr,
186 #endif // _DWMHOSTPINGER_HH_ This class abstracts a UNIX socket descriptor.
Definition: DwmSocket.hh:62
Dwm::PingDestinationEntry class definition.
This class encapsulates a time value beyond the UNIX epoch, with microsecond granularity.
Definition: DwmTimeValue.hh:72
float PacketLoss(const PingDestination &destination) const
Returns the percent packet loss for the given destination.
Encapsulates a 'pinger', which can 'ping' one or more hosts using TCP or ICMP.
Definition: DwmHostPinger.hh:64
This class encapsulates an IPv4 address.
Definition: DwmIpv4Address.hh:62
bool Start(int count=0)
Starts the pinger. Returns true on success.
uint32_t PacketsSent(const PingDestination &destination) const
Returns the number of packets sent to the given destination.
Dwm::Socket class definition.
Dwm::Pcap class definition.
Common interface for an IPv4 destination we wish to ping with ICMP or TCP.
Definition: DwmPingDestination.hh:56
Dwm::TimeValue class definition.
virtual void operator()(const PingDestination &destination, const TimeValue &recvTime, const TimeValue &rtt)=0
Operator (). Must be implemented in a derived class.
Definition: DwmBZ2IO.hh:67
static Receiver * SetReceiver(Receiver *receiver)
Registers receiver to receive ping data.
uint32_t PacketsReceived(const PingDestination &destination) const
Returns the number of packets received from the given destination.
Dwm::Ipv4Address class definition.
static Receiver * GetReceiver()
Returns the Receiver registered to receive ping data.
bool Stop()
Stops the pinger. Returns true on success.
bool AddDestination(const PingDestination &destination)
Adds a destination. Returns true on success.
HostPinger(uint16_t identifier, const std::string &device="lo0")
Construct with the given identifier (normally getpid() & 0xFFFF).
This is a pcap wrapper/utility class.
Definition: DwmPcap.hh:57
bool Outstanding() const
Returns true if we have not yet received replies for some of the packets we sent. ...
uint16_t PacketRate() const
Returns the packet rate.
Data callback interface.
Definition: DwmHostPinger.hh:75