45 push_back<dtn::data::TrackingBlock>();
49 virtual ~ProbeBundle()
62 virtual ~TrackingBundle() {
77 return find<dtn::data::TrackingBlock>();
85 : dtn::api::
Client(
"", stream, mode), _stream(stream)
93 void printReason(
char code) {
96 ::printf(
" * lifetime expired\n");
99 ::printf(
" * forwarded over unidirectional link\n");
102 ::printf(
" * transmission canceled\n");
105 ::printf(
" * depleted storage\n");
108 ::printf(
" * destination endpoint ID is unintelligible\n");
111 ::printf(
" * no known route to destination from here\n");
114 ::printf(
" * no timely contact with next node on route\n");
117 ::printf(
" * block unintelligible\n");
126 TrackingBundle tb(b);
131 std::stringstream time;
134 if (tb.isAdmRecord()) {
138 std::stringstream type;
140 ::printf(
" %3d: %-48s %-12s %6s\n", (
unsigned int)i, source.c_str(), type.str().c_str(), time.str().c_str());
145 std::stringstream type;
147 ::printf(
" %3d: %-48s %-12s %6s\n", (
unsigned int)i, source.c_str(), type.str().c_str(), time.str().c_str());
152 std::stringstream type;
154 ::printf(
" %3d: %-48s %-12s %6s\n", (
unsigned int)i, source.c_str(), type.str().c_str(), time.str().c_str());
159 std::stringstream type;
161 ::printf(
" %3d: %-48s %-12s %6s\n", (
unsigned int)i, source.c_str(), type.str().c_str(), time.str().c_str());
165 std::stringstream type;
168 ::printf(
" %3d: %-48s %-12s %6s\n", (
unsigned int)i, source.c_str(), type.str().c_str(), time.str().c_str());
174 for (dtn::data::TrackingBlock::tracking_list::const_iterator iter = list.begin(); iter != list.end(); ++iter)
186 void tracepath(
const dtn::data::EID &destination,
size_t timeout,
unsigned char options,
bool tracking)
189 ProbeBundle b(destination, tracking);
197 (*ref.
iostream()) <<
"follow the white rabbit";
209 std::list<dtn::data::Bundle> bundles;
217 std::cout <<
"TRACE TO " << destination.
getString() << std::endl;
220 (*this) << b; (*this).flush();
227 bundles.push_back(recv);
232 formattedLog(i, recv, tm);
234 }
catch (
const std::exception &e) {
238 std::cout << std::endl;
240 cout <<
"Disconnected." << endl;
242 cout <<
"Error while receiving a bundle." << endl;
252 cout <<
"-- dtntracepath (IBR-DTN) --" << endl;
253 cout <<
"Syntax: dtntracepath [options] <dst>" << endl;
254 cout <<
" <dst> set the destination eid (e.g. dtn://node/null)" << endl;
255 cout <<
"* optional parameters *" << endl;
256 cout <<
" -h display this text" << endl;
257 cout <<
" -t <timeout> time in seconds to wait for reports" << endl;
258 cout <<
" -d request deletion report" << endl;
259 cout <<
" -f request forward report" << endl;
260 cout <<
" -r request reception report" << endl;
261 cout <<
" -p add tracking block to record the bundle path" << endl;
264 int main(
int argc,
char *argv[])
266 std::string trace_destination =
"dtn://local";
271 unsigned char report_options = 0x02;
272 bool tracking =
false;
285 while ((opt = getopt(argc, argv,
"ht:fdrp")) != -1)
294 timeout = atoi(optarg);
298 report_options |= 0x01;
302 report_options |= 0x08;
306 report_options |= 0x04;
316 trace_destination = argv[argc - 1];
324 Tracer tracer(mode, conn);
331 tracer.tracepath(trace_destination, timeout, report_options, tracking);
338 std::cerr <<
"Can not connect to the daemon. Does it run?" << std::endl;
340 }
catch (
const std::exception &e) {
341 std::cerr <<
"Unexcepted error: " << e.what() << std::endl;