Fast Probing
 All Classes Files Functions Variables Typedefs Macros
/home/aomegax/workspace/Fast Probing/main.cpp
Go to the documentation of this file.
1 /*
2  * Fast Probing - An Active Probing Library for IP Options Equipped probes (http://traffic.comics.unina.it/)
3  *
4  * Copyright : (C) 2012 by Pietro Marchetta, Walter de Donato, Francesco Cesareo,
5  * Antonio Pescape' (PI)
6  * of the COMICS (COMputer for Interaction and
7  * CommunicationS) Group, Dipartimento di Informatica
8  * e Sistemistica of the University of Napoli "Federico II".
9  *
10  * email : pietro.marchetta@unina.it , walter.dedonato@unina.it , cesareo.francesco@gmail.com
11  * pescape@unina.it
12  *
13  * This program is free software: you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation, either version 3 of the License, or
16  * (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program. If not, see <http://www.gnu.org/licenses/>.
25  *
26  */
27 
28 #include "lib/fastprobing.h"
29 #include "lib/probereply.h"
30 #include "lib/generaloption.h"
31 #include "lib/util.h"
32 
33 #include <iostream>
34 
35 
36 int main()
37 {
38  std::cout << "Hello Fast Probing!" << std::endl;
39 
40  const hostent* host = gethostbyname("www.caida.org");
41  const in_addr* add_raw = (in_addr*) host->h_addr_list[0];
42 
43  std::string dst_addr = Util::number2string(add_raw->s_addr);
44  std::string ts_addr = dst_addr;
45 
46  // instantiation
47  FastProbing *probe = new FastProbing();
48  ProbeReply *reply = new ProbeReply();
49  GeneralOption *option = new GeneralOption();
50 
51  // setting options campaing
52  option->set_verbose_mode(true); // enable verbose mode
53  option->set_retries(2); // set to 2 the retry number to obtain response probe
54  option->set_timeout(2000); // set time to wait response
55 
56  // send UDP probe
57  probe->udp(option,reply,Util::number2string(add_raw->s_addr)); // send UDP probe to dst_addr
58  if (reply->has_response())
59  reply->print();
60  else
61  std::cout << "No response obtained" << std::endl;
62 
63  // send UDP_TS probe
64  probe->udp_ts(option,reply,dst_addr,ts_addr); // send UDP to dst_addr prespecifying ts_addr four times as timestamp address
65  if (reply->has_response())
66  {
67  reply->print();
68  }
69  else
70  std::cout << "No response obtained" << std::endl;
71 
72  // send ICMP probe
73  probe->icmp(option,reply,dst_addr);
74  if (reply->has_response())
75  reply->print();
76  else
77  std::cout << "No response obtained" << std::endl;
78 
79  //send ICMP_TS probe
80  probe->icmp_ts(option,reply,dst_addr, ts_addr);
81  if (reply->has_response())
82  {
83  reply->print();
84  }
85  else
86  std::cout << "No response obtained" << std::endl;
87 
88  // send TCP probe
89  probe->tcp(option,reply,dst_addr);
90  if (reply->has_response())
91  reply->print();
92  else
93  std::cout << "No response obtained" << std::endl;
94 
95  // send TCP_TS probe
96  probe->tcp_ts(option,reply,dst_addr);
97  if (reply->has_response())
98  {
99  reply->print();
100  }
101  else
102  std::cout << "No response obtained" << std::endl;
103 
104  // send PROTOCOL probe
105  probe->protocol(option,reply,dst_addr);
106  if (reply->has_response())
107  reply->print();
108  else
109  std::cout << "No response obtained" << std::endl;
110 
111  // send PROTOCOL_TS probe
112  probe->protocol_ts(option,reply,dst_addr);
113  if (reply->has_response())
114  {
115  reply->print();
116  }
117  else
118  std::cout << "No response obtained" << std::endl;
119 
120  delete option;
121  option = 0;
122 
123  delete probe;
124  probe = 0;
125 
126  std::cout << "Bye bye Fast Probing!" << std::endl;
127  return 0;
128 }