Skip to content

Commit

Permalink
Renamed --dsr to --broken-nat to reflect the reality
Browse files Browse the repository at this point in the history
  • Loading branch information
insomniacslk committed Sep 20, 2016
1 parent 0216a6e commit 294aaa0
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 25 deletions.
12 changes: 8 additions & 4 deletions documentation/readme/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,12 @@ Dublin Traceroute also features a Python extension on top of the C++ core if you
prefer. The bindings now live in a separate repository, see
[python-dublin-traceroute](https://github.com/insomniacslk/python-dublin-traceroute) .

**The third is that it supports DSR NATs.**
Dublin Traceroute is able to work with Direct Server Response NATs that some hosting providers use. Neither paris-traceroute nor regular traceroute would work with it. When you run a regular traceroute or paris-traceroute through this kind of NAT, you will see no response from all the hops located just after the DSR NAT boxes.
**The third is that it supports broken NATs.**
Dublin Traceroute is able to work with some broken NATs that some hosting providers use
(e.g. I found that Scaleway does that). Neither paris-traceroute nor regular traceroute
would work with it, but it's not their fault as this is a network misconfiguration. When
you run a regular traceroute or paris-traceroute through this kind of NAT, you will see
no response from all the hops located just after these broken NAT boxes.

See the [examples](examples.md) to see Dublin Traceroute at work.

Expand Down Expand Up @@ -223,14 +227,14 @@ Usage:
[--dport=dest_base_port]
[--npaths=num_paths]
[--max-ttl=max_ttl]
[--dsr]
[--broken-nat]

Options:
-s SRC_PORT --sport=SRC_PORT the source port to send packets from
-d DST_PORT --dport=DST_PORT the base destination port to send packets to
-n NPATHS --npaths=NPATHS the number of paths to probe
-t MAX_TTL --max-ttl=MAX_TTL the maximum TTL to probe
-d --dsr the network has a DSR NAT. May help when you only see a few hops
-b --broken-nat the network has a broken NAT configuration (e.g. no payload fixup). May help when you see only a few hops


See documentation at https://dublin-traceroute.net
Expand Down
16 changes: 8 additions & 8 deletions include/dublintraceroute/dublin_traceroute.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class DublinTraceroute {
IPv4Address target_;
const uint8_t npaths_,
max_ttl_;
const bool dsr_; // direct server response
const bool broken_nat_;
std::mutex mutex_tracerouting,
mutex_sniffed_packets;
IPv4Address my_address;
Expand All @@ -57,36 +57,36 @@ class DublinTraceroute {
static const uint16_t default_dstport = 33434;
static const uint8_t default_npaths = 20;
static const uint8_t default_max_ttl = 30;
static const bool default_dsr = false;
static const bool default_broken_nat = false;
DublinTraceroute(
const std::string &dst,
const uint16_t srcport = default_srcport,
const uint16_t dstport = default_dstport,
const uint8_t npaths = default_npaths,
const uint8_t max_ttl = default_max_ttl,
const bool dsr = default_dsr
const bool broken_nat = default_broken_nat
):
srcport_(srcport),
dstport_(dstport),
dst_(dst),
npaths_(npaths),
max_ttl_(max_ttl),
dsr_(dsr)
broken_nat_(broken_nat)
{ }
DublinTraceroute(
const char *dst,
const uint16_t srcport = default_srcport,
const uint16_t dstport = default_dstport,
const uint8_t npaths = default_npaths,
const uint8_t max_ttl = default_max_ttl,
const bool dsr = default_dsr
const bool broken_nat = default_broken_nat
):
srcport_(srcport),
dstport_(dstport),
dst_(std::string(dst)),
npaths_(npaths),
max_ttl_(max_ttl),
dsr_(dsr)
broken_nat_(broken_nat)
{ }
~DublinTraceroute() { std::lock_guard<std::mutex> lock(mutex_tracerouting); };
DublinTraceroute(const DublinTraceroute& source):
Expand All @@ -95,14 +95,14 @@ class DublinTraceroute {
dst_(source.dst_),
npaths_(source.npaths_),
max_ttl_(source.max_ttl_),
dsr_(source.dsr_)
broken_nat_(source.broken_nat_)
{ }

inline const uint16_t srcport() const { return srcport_; }
inline const uint16_t dstport() const { return dstport_; }
inline const uint8_t npaths() const { return npaths_; }
inline const uint8_t max_ttl() const { return max_ttl_; }
inline const bool dsr() const { return dsr_; }
inline const bool broken_nat() const { return broken_nat_; }
inline const std::string &dst() const { return dst_; }
inline const IPv4Address &target() const { return target_; }
void target(const IPv4Address &addr) { target_ = addr; }
Expand Down
4 changes: 2 additions & 2 deletions include/dublintraceroute/traceroute_results.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ class TracerouteResults {
private:
std::shared_ptr<flow_map_t> flows_;
bool compressed_;
bool dsr_;
bool broken_nat_;

public:
TracerouteResults(std::shared_ptr<flow_map_t> flows, const bool dsr /* = false */);
TracerouteResults(std::shared_ptr<flow_map_t> flows, const bool broken_nat /* = false */);
~TracerouteResults() { };
inline flow_map_t &flows() { return *flows_; }
std::shared_ptr<IP> match_packet(const Packet &packet);
Expand Down
2 changes: 1 addition & 1 deletion src/dublin_traceroute.cc
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ TracerouteResults &DublinTraceroute::traceroute() {
}
std::shared_ptr<Sniffer> sniffer(_sniffer);

TracerouteResults *results = new TracerouteResults(flows, dsr());
TracerouteResults *results = new TracerouteResults(flows, broken_nat());

// configure the sniffing handler
auto handler = std::bind(
Expand Down
13 changes: 6 additions & 7 deletions src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ Written by Andrea Barberio - https://insomniac.slackware.it
[--dport=dest_base_port]
[--npaths=num_paths]
[--max-ttl=max_ttl]
[--dsr]
[--broken-nat]
Options:
-s SRC_PORT --sport=SRC_PORT the source port to send packets from
-d DST_PORT --dport=DST_PORT the base destination port to send packets to
-n NPATHS --npaths=NPATHS the number of paths to probe
-t MAX_TTL --max-ttl=MAX_TTL the maximum TTL to probe
-d --dsr the network has a DSR NAT. May help when you only see a few hops
-b --broken-nat the network has a broken NAT configuration (e.g. no payload fixup). May help when you see only a few hops
See documentation at https://dublin-traceroute.net
Expand All @@ -45,7 +45,7 @@ main(int argc, char **argv) {
long dport = DublinTraceroute::default_dstport;
long npaths = DublinTraceroute::default_npaths;
long max_ttl = DublinTraceroute::default_max_ttl;
bool dsr = DublinTraceroute::default_dsr;
bool broken_nat = DublinTraceroute::default_broken_nat;

std::map <std::string, docopt::value> args = docopt::docopt(
USAGE,
Expand Down Expand Up @@ -75,12 +75,11 @@ main(int argc, char **argv) {
CONVERT_TO_LONG_OR_EXIT(arg.second, npaths);
} else if (arg.first == "--max-ttl") {
CONVERT_TO_LONG_OR_EXIT(arg.second, max_ttl);
} else if (arg.first == "--dsr") {
dsr = arg.second.asBool();
} else if (arg.first == "--broken-nat") {
broken_nat = arg.second.asBool();
}
}
#undef CONVERT_TO_LONG_OR_EXIT
std::cout << "Source port: " << sport << std::endl;
if (sport < 1 || sport > 65535) {
std::cerr << "Source port must be between 1 and 65535" << std::endl;
std::exit(EXIT_FAILURE);
Expand Down Expand Up @@ -111,7 +110,7 @@ main(int argc, char **argv) {
dport,
npaths,
max_ttl,
dsr
broken_nat
);
std::cout
<< "Traceroute from 0.0.0.0:" << Dublin.srcport()
Expand Down
6 changes: 3 additions & 3 deletions src/traceroute_results.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
#include "dublintraceroute/icmp_messages.h"


TracerouteResults::TracerouteResults(std::shared_ptr<flow_map_t> flows, const bool dsr = true):
flows_(flows), compressed_(false), dsr_(dsr) {
TracerouteResults::TracerouteResults(std::shared_ptr<flow_map_t> flows, const bool broken_nat = true):
flows_(flows), compressed_(false), broken_nat_(broken_nat) {
}


Expand Down Expand Up @@ -68,7 +68,7 @@ std::shared_ptr<IP> TracerouteResults::match_packet(const Packet &packet) {
unsigned int index = 0;
for (auto &hop: *hops) {
auto &sent = hop.sent()->rfind_pdu<IP>();
if (!dsr_) {
if (!broken_nat_) {
if (sent.src_addr() != inner_ip.src_addr())
continue;
}
Expand Down

0 comments on commit 294aaa0

Please sign in to comment.