-
Notifications
You must be signed in to change notification settings - Fork 0
/
clienticmp.h
46 lines (34 loc) · 923 Bytes
/
clienticmp.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
* Paweł Kapica, 334579
* Sieci Komputerowe
* Duże zadanie zaliczeniowe
*
*/
#ifndef CLIENTICMP_H
#define CLIENTICMP_H
#include "utils.h"
class ClientICMP
{
public:
ClientICMP(boost::asio::io_service& io_srv, std::string dest);
void measure_latency();
bool finished();
private:
void start_send();
void start_receive();
void handle_send(const boost::system::error_code& error, size_t bytes);
void handle_timeout(const boost::system::error_code& error);
void handle_receive(size_t length);
static std::string initialize_body();
bool finished_ = false;
boost::mutex mtx_;
boost::asio::ip::icmp::resolver resolver_;
boost::asio::ip::icmp::endpoint destination_;
boost::asio::ip::icmp::socket socket_;
boost::asio::deadline_timer timer_;
uint64_t time_sent_ = 0;
boost::asio::streambuf reply_buffer_;
std::string dest_;
static const std::string BODY; //ICMP body
};
#endif //CLIENTICMP.H