Universita' degli Studi di Napoli ''Federico II'' (Italy) |
|
Getting started with ippo-lib This section highlights part of the features of the library. The following code shows how to send typical active probing packet probes toward a destination. Those probes are not equipped with any IP option. // Setting General Options GeneralOption *option = new GeneralOption(); option->set_verbose_mode(true); // enable verbose mode option->set_retries(2); // set the number of retries option->set_timeout(2000); // set the timeout option->src_port(34566); // set source port number option->dst_port(34567); // set destination port number // Create IPPOLib Object IPPOLib* prober = new IPPOLib(); // Create the ProbeReply Object ProbeReply* reply = new ProbeReply(); // contains details about the collected reply // Define the Target IP address D std::string dst_addr = "192.168.15.34"; // Send probes to the Target IP address prober->udp(option, reply, dst_addr); reply->print(); prober->icmp(option, reply, dst_addr); reply->print(); prober->tcp(option, reply, dst_addr); reply->print(); prober->protocol(option, reply, dst_addr); reply->print(); The corresponding output is: UDP: send probe to destination IP 192.168.15.34 [192.168.15.34] UDP 3 from 192.168.15.34 Printing details... Source address 192.168.15.34 Destination address 192.168.20.100 IP protocol 1 IPError Destination address 192.168.15.34 ICMP type 3 ICMP code 3 ICMP: send probe to destination IP 192.168.15.34 [192.168.15.34] ICMP_ECHOREPLY (28 bytes) Printing details... Source address 192.168.15.34 Destination address 192.168.20.100 IP protocol 1 ICMP type 0 ICMP code 0 TCP: send probe to destination IP 192.168.15.34 [192.168.15.34] TCP 60 Printing details... Source address 192.168.15.34 Destination address 192.168.20.100 IP protocol 6 PROTOCOL: send probe to destination IP 192.168.15.34 [192.168.15.34] PROTOCOL TIMEOUT - Try #1 [192.168.15.34] PROTOCOL TIMEOUT - Try #2 No response Note how the PROTOCOL probe (SKIP) did not trigger any reply from the targeted destination while the other probes succesfully collected replies. The following code shows how to send a UDP packet probe equipped with the Prespecified Timestamp Option. All the four prespecified addresses are equal to the targeted destination. // Send Prespecified Timestamp Option equipped // UDP Packet toward D prespecifying four times D prober->udp_ts(option, reply, dst_addr); reply->print();The output is: UDP_TS: send probe to destination IP 192.168.15.34 with prespecified IPs 192.168.15.34, 192.168.15.34, 192.168.15.34, 192.168.15.34 [192.168.15.34] UDP_TS 3 from 192.168.15.34 Printing details... Source address 192.168.15.34 Destination address 192.168.20.100 IP protocol 1 IPError Destination address 192.168.15.34 ICMP type 3 ICMP code 3 Outer Options IP1 192.168.15.34 timestamp 59479588 IP2 192.168.15.34 timestamp 59479588 IP3 192.168.15.34 timestamp 0 IP4 192.168.15.34 timestamp 0 Inner Options IP1 192.168.15.34 timestamp 59479588 IP2 192.168.15.34 timestamp 0 IP3 192.168.15.34 timestamp 0 IP4 192.168.15.34 timestamp 0 Note how the targeted destination replicated the IP option also at the encapsulating IP header.
// Define the Target IP address D std::string dst_addr = "192.168.15.170"; // Send Prespecified Timestamp Option equipped UDP Probes // prespecifying different IPs std::string x_addr = "192.168.15.1"; std::string y_addr = "192.168.15.2"; std::string z_addr = "192.168.15.3"; std::string w_addr = "192.168.15.4"; prober->udp_ts(option, reply, dst_addr, x_addr, y_addr, z_addr, w_addr); reply->print(); prober->udp_ts(option, reply, dst_addr, x_addr, y_addr, z_addr); reply->print(); prober->udp_ts(option, reply, dst_addr, x_addr, y_addr); reply->print(); prober->udp_ts(option, reply, dst_addr, x_addr); reply->print(); The output is: UDP_TS: send probe to destination IP 192.168.15.170 with prespecified IPs 192.168.15.1, 192.168.15.2, 192.168.15.3, 192.168.15.4 [192.168.15.170] UDP_TS 3 from 192.168.15.34 Printing details... Source address 192.168.15.170 Destination address 192.168.20.100 IP protocol 1 IPError Destination address 192.168.15.170 ICMP type 3 ICMP code 3 Outer Options IP1 192.168.15.1 timestamp 55344858 IP2 192.168.15.2 timestamp 55344858 IP3 192.168.15.3 timestamp 0 IP4 192.168.15.4 timestamp 0 UDP_TS: send probe to destination IP 192.168.15.170 with prespecified IPs 192.168.15.1, 192.168.15.2, 192.168.15.3, 192.168.15.3 [192.168.15.31704] UDP_TS 3 from 192.168.15.170 Printing details... Source address 192.168.15.170 Destination address 192.168.20.100 IP protocol 1 IPError Destination address 192.168.15.170 ICMP type 3 ICMP code 3 Outer Options IP1 192.168.15.1 timestamp 55378647 IP2 192.168.15.2 timestamp 55378647 IP3 192.168.15.3 timestamp 0 IP4 192.168.15.3 timestamp 0 UDP_TS: send probe to destination IP 192.168.15.170 with prespecified IPs 192.168.15.1, 192.168.15.2, 192.168.15.2, 192.168.15.2 [192.168.15.170] UDP_TS 3 from 192.168.15.34 Printing details... Source address 192.168.15.170 Destination address 192.168.20.100 IP protocol 1 IPError Destination address 192.168.15.170 ICMP type 3 ICMP code 3 Outer Options IP1 192.168.15.1 timestamp 55989999 IP2 192.168.15.2 timestamp 55989999 IP3 192.168.15.2 timestamp 55989999 IP4 192.168.15.2 timestamp 55989999 UDP_TS: send probe to destination IP 192.168.15.170 with prespecified IPs 192.168.15.1, 192.168.15.1, 192.168.15.1, 192.168.15.1 [192.168.15.170] UDP_TS 3 from 192.168.15.170 Printing details... Source address 192.168.15.170 Destination address 192.168.20.100 IP protocol 1 IPError Destination address 192.168.15.170 ICMP type 3 ICMP code 3 Outer Options IP1 192.168.15.1 timestamp 56044209 IP2 192.168.15.1 timestamp 56044209 IP3 192.168.15.1 timestamp 56044209 IP4 192.168.15.1 timestamp 56044209Documentation and other examples are provided with the IPPOLib library package as well. Download Click here to downlad IPPO-lib. If you are interested in collaborating with us or in opportunities in Traffic, please send an e-mail to Antonio Pescapè |