43 set(DESTINATION_IS_SINGLETON, !group);
46 push_back<dtn::data::TrackingBlock>();
50 virtual ~ProbeBundle()
63 virtual ~TrackingBundle() {
78 return find<dtn::data::TrackingBlock>();
86 : dtn::api::
Client(
"", stream, mode), _stream(stream)
94 void printReason(
char code) {
97 ::printf(
" * lifetime expired\n");
100 ::printf(
" * forwarded over unidirectional link\n");
103 ::printf(
" * transmission canceled\n");
106 ::printf(
" * depleted storage\n");
109 ::printf(
" * destination endpoint ID is unintelligible\n");
112 ::printf(
" * no known route to destination from here\n");
115 ::printf(
" * no timely contact with next node on route\n");
118 ::printf(
" * block unintelligible\n");
127 TrackingBundle tb(b);
132 std::stringstream time;
135 if (tb.isAdmRecord()) {
139 std::stringstream type;
141 ::printf(
" %3d: %-48s %-12s %6s\n", (
unsigned int)i, source.c_str(), type.str().c_str(), time.str().c_str());
146 std::stringstream type;
148 ::printf(
" %3d: %-48s %-12s %6s\n", (
unsigned int)i, source.c_str(), type.str().c_str(), time.str().c_str());
153 std::stringstream type;
155 ::printf(
" %3d: %-48s %-12s %6s\n", (
unsigned int)i, source.c_str(), type.str().c_str(), time.str().c_str());
160 std::stringstream type;
162 ::printf(
" %3d: %-48s %-12s %6s\n", (
unsigned int)i, source.c_str(), type.str().c_str(), time.str().c_str());
166 std::stringstream type;
169 ::printf(
" %3d: %-48s %-12s %6s\n", (
unsigned int)i, source.c_str(), type.str().c_str(), time.str().c_str());
175 for (dtn::data::TrackingBlock::tracking_list::const_iterator iter = list.begin(); iter != list.end(); ++iter)
187 void tracepath(
const dtn::data::EID &destination,
bool group,
size_t timeout,
unsigned char options,
bool tracking)
190 ProbeBundle b(destination, tracking, group);
198 (*ref.
iostream()) <<
"follow the white rabbit";
210 std::list<dtn::data::Bundle> bundles;
218 std::cout <<
"TRACE TO " << destination.
getString() << std::endl;
221 (*this) << b; (*this).flush();
228 bundles.push_back(recv);
233 formattedLog(i, recv, tm);
235 }
catch (
const std::exception &e) {
239 std::cout << std::endl;
241 cout <<
"Disconnected." << endl;
243 cout <<
"Error while receiving a bundle." << endl;
253 cout <<
"-- dtntracepath (IBR-DTN) --" << endl;
254 cout <<
"Syntax: dtntracepath [options] <dst>" << endl;
255 cout <<
" <dst> set the destination eid (e.g. dtn://node/null)" << endl << endl;
256 cout <<
"* optional parameters *" << endl;
257 cout <<
" -h Display this text" << endl;
258 cout <<
" -t <seconds> Time to wait for reports (default: 10)" << endl;
259 cout <<
" -d Request deletion report" << endl;
260 cout <<
" -f Request forward report" << endl;
261 cout <<
" -r Request reception report" << endl;
262 cout <<
" -p Add tracking block to record the bundle path" << endl;
263 cout <<
" -g Destination is a group endpoint" << endl;
266 int main(
int argc,
char *argv[])
268 std::string trace_destination =
"dtn://local";
273 unsigned char report_options = 0x02;
274 bool tracking =
false;
288 while ((opt = getopt(argc, argv,
"ht:fdrpg")) != -1)
297 timeout = atoi(optarg);
301 report_options |= 0x01;
305 report_options |= 0x08;
309 report_options |= 0x04;
323 trace_destination = argv[argc - 1];
331 Tracer tracer(mode, conn);
338 tracer.tracepath(trace_destination, group, timeout, report_options, tracking);
345 std::cerr <<
"Can not connect to the daemon. Does it run?" << std::endl;
347 }
catch (
const std::exception &e) {
348 std::cerr <<
"Unexcepted error: " << e.what() << std::endl;