|
1 /* |
|
2 * Copyright 2004-2006 Intel Corporation |
|
3 * |
|
4 * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 * you may not use this file except in compliance with the License. |
|
6 * You may obtain a copy of the License at |
|
7 * |
|
8 * http://www.apache.org/licenses/LICENSE-2.0 |
|
9 * |
|
10 * Unless required by applicable law or agreed to in writing, software |
|
11 * distributed under the License is distributed on an "AS IS" BASIS, |
|
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 * See the License for the specific language governing permissions and |
|
14 * limitations under the License. |
|
15 */ |
|
16 |
|
17 #ifndef _LINK_H_ |
|
18 #define _LINK_H_ |
|
19 |
|
20 #include <set> |
|
21 #include <oasys/debug/Formatter.h> |
|
22 #include <oasys/serialize/Serialize.h> |
|
23 #include <oasys/thread/SpinLock.h> |
|
24 #include <oasys/util/Ref.h> |
|
25 #include <oasys/util/RefCountedObject.h> |
|
26 |
|
27 #include "bundling/BundleList.h" |
|
28 #include "naming/EndpointID.h" |
|
29 |
|
30 #include "Contact.h" |
|
31 #include "NamedAttribute.h" |
|
32 |
|
33 namespace dtn { |
|
34 |
|
35 class ConvergenceLayer; |
|
36 class CLInfo; |
|
37 class Contact; |
|
38 class Link; |
|
39 class RouterInfo; |
|
40 |
|
41 /** |
|
42 * Typedef for a reference on a link. |
|
43 */ |
|
44 typedef oasys::Ref<Link> LinkRef; |
|
45 |
|
46 /** |
|
47 * Set of links |
|
48 */ |
|
49 class LinkSet : public std::set<LinkRef> {}; |
|
50 |
|
51 /** |
|
52 * Abstraction for a DTN link, i.e. a one way communication channel to |
|
53 * a next hop node in the DTN overlay. |
|
54 * |
|
55 * The state of a link (regarding its availability) is described by |
|
56 * the Link::state_t enumerated type. |
|
57 * |
|
58 * All links in the OPEN state have an associated contact that |
|
59 * represents an actual connection. |
|
60 * |
|
61 * Every link has a unique name associated with it which is used to |
|
62 * identify it. The name is configured explicitly when the link is |
|
63 * created. |
|
64 * |
|
65 * Creating new links: |
|
66 * Links are created explicitly in the configuration file. Syntax is: |
|
67 * @code |
|
68 * link add <name> <nexthop> <type> <conv_layer> <args> |
|
69 * @endcode |
|
70 * See servlib/cmd/LinkCommand.cc for implementation of this TCL cmd. |
|
71 * |
|
72 * ---------------------------------------------------------- |
|
73 * |
|
74 * Links are of three types as discussed in the DTN architecture |
|
75 * ONDEMAND, SCHEDULED, OPPORTUNISTIC. |
|
76 * |
|
77 * The key differences from an implementation perspective are "who" |
|
78 * and "when" manipulates the link state regarding availability. |
|
79 * |
|
80 * ONDEMAND links are initializd in the AVAILABLE state, as one would |
|
81 * expect. It remains in this state until a router explicitly opens |
|
82 * it. |
|
83 * |
|
84 * An ONDEMAND link can then be closed either due to connection |
|
85 * failure or because the link has been idle for too long, both |
|
86 * triggered by the convergence layer. If an ONDEMAND link is closed |
|
87 * due to connection failure, then the contact manager is notified of |
|
88 * this event and periodically tries to re-establish the link. |
|
89 * |
|
90 * For OPPORTUNISTIC links the availability state is set by the code |
|
91 * which detects that there is a new link available to be used. |
|
92 * |
|
93 * SCHEDULED links have their availability dictated by the schedule |
|
94 * implementation. |
|
95 * |
|
96 * ---------------------------------------------------------- |
|
97 * |
|
98 * Links are used for input and/or output. In other words, for |
|
99 * connection-oriented convergence layers like TCP, a link object is |
|
100 * created whenever a new connection is made to a peer or when a |
|
101 * connection arrives from a peer. |
|
102 */ |
|
103 class Link : public oasys::RefCountedObject, |
|
104 public oasys::Logger, |
|
105 public oasys::SerializableObject { |
|
106 public: |
|
107 /** |
|
108 * Valid types for a link. |
|
109 */ |
|
110 typedef enum |
|
111 { |
|
112 LINK_INVALID = -1, |
|
113 |
|
114 /** |
|
115 * The link is expected to be ALWAYS available, and any |
|
116 * convergence layer connection state is always maintained for |
|
117 * it. |
|
118 */ |
|
119 ALWAYSON = 1, |
|
120 |
|
121 /** |
|
122 * The link is expected to be either always available, or can |
|
123 * be made available easily. Examples include DSL (always), |
|
124 * and dialup (easily available). Convergence layers are free |
|
125 * to tear down idle connection state, but are expected to be |
|
126 * able to easily re-establish it. |
|
127 */ |
|
128 ONDEMAND = 2, |
|
129 |
|
130 /** |
|
131 * The link is only available at pre-determined times. |
|
132 */ |
|
133 SCHEDULED = 3, |
|
134 |
|
135 /** |
|
136 * The link may or may not be available, based on |
|
137 * uncontrollable factors. Examples include a wireless link |
|
138 * whose connectivity depends on the relative locations of the |
|
139 * two nodes. |
|
140 */ |
|
141 OPPORTUNISTIC = 4 |
|
142 } |
|
143 link_type_t; |
|
144 |
|
145 /** |
|
146 * Link type string conversion. |
|
147 */ |
|
148 static inline const char* |
|
149 link_type_to_str(link_type_t type) |
|
150 { |
|
151 switch(type) { |
|
152 case ALWAYSON: return "ALWAYSON"; |
|
153 case ONDEMAND: return "ONDEMAND"; |
|
154 case SCHEDULED: return "SCHEDULED"; |
|
155 case OPPORTUNISTIC: return "OPPORTUNISTIC"; |
|
156 default: PANIC("bogus link_type_t"); |
|
157 } |
|
158 } |
|
159 |
|
160 static inline link_type_t |
|
161 str_to_link_type(const char* str) |
|
162 { |
|
163 if (strcasecmp(str, "ALWAYSON") == 0) |
|
164 return ALWAYSON; |
|
165 |
|
166 if (strcasecmp(str, "ONDEMAND") == 0) |
|
167 return ONDEMAND; |
|
168 |
|
169 if (strcasecmp(str, "SCHEDULED") == 0) |
|
170 return SCHEDULED; |
|
171 |
|
172 if (strcasecmp(str, "OPPORTUNISTIC") == 0) |
|
173 return OPPORTUNISTIC; |
|
174 |
|
175 return LINK_INVALID; |
|
176 } |
|
177 |
|
178 /** |
|
179 * The possible states for a link. These are defined as distinct |
|
180 * bitfield values so that various functions can match on a set of |
|
181 * states (e.g. see ContactManager::find_link_to). |
|
182 */ |
|
183 typedef enum { |
|
184 UNAVAILABLE = 1,///< The link is closed and not able to be |
|
185 /// opened currently. |
|
186 |
|
187 AVAILABLE = 2, ///< The link is closed but is able to be |
|
188 /// opened, either because it is an on demand |
|
189 /// link, or because an opportunistic peer |
|
190 /// node is in close proximity but no |
|
191 /// convergence layer session has yet been |
|
192 /// opened. |
|
193 |
|
194 OPENING = 4, ///< A convergence layer session is in the |
|
195 /// process of being established. |
|
196 |
|
197 OPEN = 8, ///< A convergence layer session has been |
|
198 /// established, and the link has capacity |
|
199 /// for a bundle to be sent on it. This may |
|
200 /// be because no bundle is currently being |
|
201 /// sent, or because the convergence layer |
|
202 /// can handle multiple simultaneous bundle |
|
203 /// transmissions. |
|
204 |
|
205 CLOSED = 16 ///< Bogus state that's never actually used in |
|
206 /// the Link state_ variable, but is used for |
|
207 /// signalling the daemon thread with a |
|
208 /// LinkStateChangeRequest |
|
209 |
|
210 } state_t; |
|
211 |
|
212 /** |
|
213 * Convert a link state into a string. |
|
214 */ |
|
215 static inline const char* |
|
216 state_to_str(state_t state) |
|
217 { |
|
218 switch(state) { |
|
219 case UNAVAILABLE: return "UNAVAILABLE"; |
|
220 case AVAILABLE: return "AVAILABLE"; |
|
221 case OPENING: return "OPENING"; |
|
222 case OPEN: return "OPEN"; |
|
223 case CLOSED: return "CLOSED"; |
|
224 } |
|
225 |
|
226 NOTREACHED; |
|
227 } |
|
228 |
|
229 /** |
|
230 * Static function to create appropriate link object from link type. |
|
231 */ |
|
232 static LinkRef create_link(const std::string& name, link_type_t type, |
|
233 ConvergenceLayer* cl, const char* nexthop, |
|
234 int argc, const char* argv[], |
|
235 const char** invalid_argp = NULL); |
|
236 |
|
237 /** |
|
238 * Constructor / Destructor |
|
239 */ |
|
240 Link(const std::string& name, link_type_t type, |
|
241 ConvergenceLayer* cl, const char* nexthop); |
|
242 |
|
243 /** |
|
244 * Constructor for unserialization. |
|
245 */ |
|
246 Link(const oasys::Builder& b); |
|
247 |
|
248 /** |
|
249 * Handle and mark deleted link. |
|
250 */ |
|
251 virtual void delete_link(); |
|
252 |
|
253 /** |
|
254 * Reconfigure the link parameters. |
|
255 */ |
|
256 virtual bool reconfigure_link(int argc, const char* argv[]); |
|
257 |
|
258 virtual void reconfigure_link(AttributeVector& params); |
|
259 |
|
260 /** |
|
261 * Virtual from SerializableObject |
|
262 */ |
|
263 void serialize(oasys::SerializeAction* action); |
|
264 |
|
265 /** |
|
266 * Hook for subclass to parse arguments. |
|
267 */ |
|
268 virtual int parse_args(int argc, const char* argv[], |
|
269 const char** invalidp = NULL); |
|
270 |
|
271 /** |
|
272 * Hook for subclass to post events to control the initial link |
|
273 * state, after all initialization is complete. |
|
274 */ |
|
275 virtual void set_initial_state(); |
|
276 |
|
277 /** |
|
278 * Return the type of the link. |
|
279 */ |
|
280 link_type_t type() const { return static_cast<link_type_t>(type_); } |
|
281 |
|
282 /** |
|
283 * Return the string for of the link. |
|
284 */ |
|
285 const char* type_str() const { return link_type_to_str(type()); } |
|
286 |
|
287 /** |
|
288 * Return whether or not the link is open. |
|
289 */ |
|
290 bool isopen() const { return ( (state_ == OPEN) ); } |
|
291 |
|
292 /** |
|
293 * Return the availability state of the link. |
|
294 */ |
|
295 bool isavailable() const { return (state_ != UNAVAILABLE); } |
|
296 |
|
297 /** |
|
298 * Return whether the link is in the process of opening. |
|
299 */ |
|
300 bool isopening() const { return (state_ == OPENING); } |
|
301 |
|
302 /** |
|
303 * Returns true if the link has been deleted; otherwise returns false. |
|
304 */ |
|
305 bool isdeleted() const; |
|
306 |
|
307 /** |
|
308 * Return the actual state. |
|
309 */ |
|
310 state_t state() const { return static_cast<state_t>(state_); } |
|
311 |
|
312 /** |
|
313 * Sets the state of the link. Performs various assertions to |
|
314 * ensure the state transitions are legal. |
|
315 * |
|
316 * This function should only ever be called by the main |
|
317 * BundleDaemon thread and helper classes. All other threads must |
|
318 * use a LinkStateChangeRequest event to cause changes in the link |
|
319 * state. |
|
320 * |
|
321 * The function isn't protected since some callers (i.e. |
|
322 * convergence layers) are not friend classes but some functions |
|
323 * are run by the BundleDaemon thread. |
|
324 */ |
|
325 void set_state(state_t state); |
|
326 |
|
327 /** |
|
328 * Set/get the create_pending_ flag on the link. |
|
329 */ |
|
330 void set_create_pending(bool create_pending = true) |
|
331 { create_pending_ = create_pending; } |
|
332 bool is_create_pending() const { return create_pending_; } |
|
333 |
|
334 /** |
|
335 * Set/get the usable_ flag on the link. |
|
336 */ |
|
337 void set_usable(bool usable = true) { usable_ = usable; } |
|
338 bool is_usable() const { return usable_; } |
|
339 |
|
340 /** |
|
341 * Return the current contact information (if any). |
|
342 */ |
|
343 const ContactRef& contact() const { return contact_; } |
|
344 |
|
345 /** |
|
346 * Set the contact information. |
|
347 */ |
|
348 void set_contact(Contact* contact) |
|
349 { |
|
350 // XXX/demmer check this invariant |
|
351 ASSERT(contact_ == NULL); |
|
352 contact_ = contact; |
|
353 } |
|
354 |
|
355 /** |
|
356 * Store convergence layer state associated with the link. |
|
357 */ |
|
358 void set_cl_info(CLInfo* cl_info) |
|
359 { |
|
360 ASSERT((cl_info_ == NULL && cl_info != NULL) || |
|
361 (cl_info_ != NULL && cl_info == NULL)); |
|
362 |
|
363 cl_info_ = cl_info; |
|
364 } |
|
365 |
|
366 /** |
|
367 * Accessor to the convergence layer state. |
|
368 */ |
|
369 CLInfo* cl_info() const { return cl_info_; } |
|
370 |
|
371 /** |
|
372 * Store router state associated with the link. |
|
373 */ |
|
374 void set_router_info(RouterInfo* router_info) |
|
375 { |
|
376 ASSERT((router_info_ == NULL && router_info != NULL) || |
|
377 (router_info_ != NULL && router_info == NULL)); |
|
378 |
|
379 router_info_ = router_info; |
|
380 } |
|
381 |
|
382 /** |
|
383 * Accessor to the convergence layer state. |
|
384 */ |
|
385 RouterInfo* router_info() const { return router_info_; } |
|
386 |
|
387 /** |
|
388 * Accessor to this contact's convergence layer. |
|
389 */ |
|
390 ConvergenceLayer* clayer() const { return clayer_; } |
|
391 |
|
392 /** |
|
393 * Accessor to this links name |
|
394 */ |
|
395 const char* name() const { return name_.c_str(); } |
|
396 |
|
397 /** |
|
398 * Accessor to this links name as a c++ string |
|
399 */ |
|
400 const std::string& name_str() const { return name_; } |
|
401 |
|
402 /** |
|
403 * Accessor to next hop string |
|
404 */ |
|
405 const char* nexthop() const { return nexthop_.c_str(); } |
|
406 |
|
407 /** |
|
408 * Accessor to next hop string |
|
409 */ |
|
410 const std::string& nexthop_str() const { return nexthop_; } |
|
411 |
|
412 /** |
|
413 * Override for the next hop string. |
|
414 */ |
|
415 void set_nexthop(const std::string& nexthop) { nexthop_.assign(nexthop); } |
|
416 |
|
417 /** |
|
418 * Accessor to the reliability bit. |
|
419 */ |
|
420 bool is_reliable() const { return reliable_; } |
|
421 |
|
422 /** |
|
423 * Accessor to set the reliability bit when the link is created. |
|
424 */ |
|
425 void set_reliable(bool r) { reliable_ = r; } |
|
426 |
|
427 /** |
|
428 * Accessor to set the remote endpoint id. |
|
429 */ |
|
430 void set_remote_eid(const EndpointID& remote) { |
|
431 remote_eid_.assign(remote); |
|
432 } |
|
433 |
|
434 /** |
|
435 * Accessor to the remote endpoint id. |
|
436 */ |
|
437 const EndpointID& remote_eid() { return remote_eid_; } |
|
438 |
|
439 /** |
|
440 * Accessor for the link's queue of bundles that are awaiting |
|
441 * transmission. |
|
442 */ |
|
443 const BundleList* queue() { return &queue_; } |
|
444 |
|
445 /** |
|
446 * Return whether or not the queue is full, based on the |
|
447 * configured queue limits. |
|
448 */ |
|
449 bool queue_is_full() const; |
|
450 |
|
451 /** |
|
452 * Return whether or not the queue has space, based on the |
|
453 * configured queue limits. |
|
454 */ |
|
455 bool queue_has_space() const; |
|
456 |
|
457 /** |
|
458 * Accessor for the link's list of bundles that have been |
|
459 * transmitted but for which the convergence layer is awaiting |
|
460 * acknowledgement. |
|
461 */ |
|
462 const BundleList* inflight() { return &inflight_; } |
|
463 |
|
464 /// @{ |
|
465 /** |
|
466 * Accessor functions to add/remove bundles from the link queue |
|
467 * and inflight list, keeping the statistics in-sync with the |
|
468 * state of the lists. |
|
469 */ |
|
470 bool add_to_queue(const BundleRef& bundle, size_t total_len); |
|
471 bool del_from_queue(const BundleRef& bundle, size_t total_len); |
|
472 bool add_to_inflight(const BundleRef& bundle, size_t total_len); |
|
473 bool del_from_inflight(const BundleRef& bundle, size_t total_len); |
|
474 /// @} |
|
475 |
|
476 /** |
|
477 * Virtual from formatter |
|
478 */ |
|
479 int format(char* buf, size_t sz) const; |
|
480 |
|
481 /** |
|
482 * Debugging printout. |
|
483 */ |
|
484 void dump(oasys::StringBuffer* buf); |
|
485 |
|
486 /************************************************************** |
|
487 * Link Parameters |
|
488 */ |
|
489 struct Params { |
|
490 /** |
|
491 * Default constructor. |
|
492 */ |
|
493 Params(); |
|
494 |
|
495 /** |
|
496 * MTU of the link, used to control proactive fragmentation. |
|
497 */ |
|
498 u_int mtu_; |
|
499 |
|
500 /** |
|
501 * Minimum amount to wait between attempts to re-open the link |
|
502 * (in seconds). |
|
503 * |
|
504 * Default is set by the various Link types but can be overridden |
|
505 * by configuration parameters. |
|
506 */ |
|
507 u_int min_retry_interval_; |
|
508 |
|
509 /** |
|
510 * Maximum amount to wait between attempts to re-open the link |
|
511 * (in seconds). |
|
512 * |
|
513 * Default is set by the various Link types but can be overridden |
|
514 * by configuration parameters. |
|
515 */ |
|
516 u_int max_retry_interval_; |
|
517 |
|
518 /** |
|
519 * Seconds of idle time before the link is closed. Must be |
|
520 * zero for always on links (i.e. they are never closed). |
|
521 * |
|
522 * Default is 30 seconds for on demand links, zero for |
|
523 * opportunistic links. |
|
524 */ |
|
525 u_int idle_close_time_; |
|
526 |
|
527 /** |
|
528 * Conservative estimate of the maximum amount of time that |
|
529 * the link may be down during "normal" operation. Used by |
|
530 * routing algorithms to determine how long to leave bundles |
|
531 * queued on the down link before rerouting them. Fefault is |
|
532 * 30 seconds. |
|
533 */ |
|
534 u_int potential_downtime_; |
|
535 |
|
536 /** |
|
537 * Whether or not to send the previous hop header on this |
|
538 * link. Default is false. |
|
539 */ |
|
540 bool prevhop_hdr_; |
|
541 |
|
542 /** |
|
543 * Abstract cost of the link, used by routing algorithms. |
|
544 * Default is 100. |
|
545 */ |
|
546 u_int cost_; |
|
547 |
|
548 /** @{ |
|
549 * |
|
550 * Configurable high / low limits on the number of |
|
551 * bundles/bytes that should be queued on the link. |
|
552 * |
|
553 * The high limits are used by Link::is_queue_full() to |
|
554 * indicate whether or not more bundles can be queued onto the |
|
555 * link to effect backpressure from the convergence layers. |
|
556 * |
|
557 * The low limits can be used by the router to determine when |
|
558 * to re-scan the pending bundle lists |
|
559 */ |
|
560 u_int qlimit_bundles_high_; |
|
561 u_int64_t qlimit_bytes_high_; |
|
562 u_int qlimit_bundles_low_; |
|
563 u_int64_t qlimit_bytes_low_; |
|
564 /// @} |
|
565 }; |
|
566 |
|
567 /** |
|
568 * Seconds to wait between attempts to re-open an unavailable |
|
569 * link. Initially set to min_retry_interval_, then doubles up to |
|
570 * max_retry_interval_. |
|
571 */ |
|
572 u_int retry_interval_; |
|
573 |
|
574 /** |
|
575 * Accessor for the parameter structure. |
|
576 */ |
|
577 const Params& params() const { return params_; } |
|
578 Params& params() { return params_; } |
|
579 |
|
580 /************************************************************* |
|
581 * Link Statistics |
|
582 */ |
|
583 struct Stats { |
|
584 /** |
|
585 * Number of times the link attempted to be opened. |
|
586 */ |
|
587 u_int contact_attempts_; |
|
588 |
|
589 /** |
|
590 * Number of contacts ever successfully opened on the link |
|
591 * (equivalent to the number of times the link was open) |
|
592 */ |
|
593 u_int contacts_; |
|
594 |
|
595 /** |
|
596 * Number of bundles transmitted over the link. |
|
597 */ |
|
598 u_int bundles_transmitted_; |
|
599 |
|
600 /** |
|
601 * Total byte count transmitted over the link. |
|
602 */ |
|
603 u_int bytes_transmitted_; |
|
604 |
|
605 /** |
|
606 * Number of bundles with cancelled transmission. |
|
607 */ |
|
608 u_int bundles_cancelled_; |
|
609 |
|
610 /** |
|
611 * The total uptime of the link, not counting the current |
|
612 * contact. |
|
613 */ |
|
614 u_int uptime_; |
|
615 |
|
616 /** |
|
617 * The availablity of the link, as measured over time by the |
|
618 * convergence layer. |
|
619 */ |
|
620 u_int availability_; |
|
621 |
|
622 /** |
|
623 * The reliability of the link, as measured over time by the |
|
624 * convergence layer. This is different from the is_reliable |
|
625 * setting, which indicates whether the convergence layer should |
|
626 * expect acks from the peer. |
|
627 */ |
|
628 u_int reliability_; |
|
629 }; |
|
630 |
|
631 /** |
|
632 * Accessor for the stats structure. |
|
633 */ |
|
634 Stats* stats() { return &stats_; } |
|
635 |
|
636 /** |
|
637 * Reset the stats. |
|
638 */ |
|
639 void reset_stats() const |
|
640 { |
|
641 memset(&stats_, 0, sizeof(stats_)); |
|
642 } |
|
643 |
|
644 /** |
|
645 * Dump a printable version of the stats. |
|
646 */ |
|
647 void dump_stats(oasys::StringBuffer* buf); |
|
648 |
|
649 /// @{ Accessors for the link queue stats |
|
650 u_int bundles_queued() { return bundles_queued_; } |
|
651 u_int bytes_queued() { return bytes_queued_; } |
|
652 u_int bundles_inflight() { return bundles_inflight_; } |
|
653 u_int bytes_inflight() { return bytes_inflight_; } |
|
654 /// @} |
|
655 |
|
656 /** |
|
657 * Accessor for the Link state lock. |
|
658 */ |
|
659 oasys::Lock* lock() { return &lock_; } |
|
660 |
|
661 protected: |
|
662 friend class BundleActions; |
|
663 friend class BundleDaemon; |
|
664 friend class ContactManager; |
|
665 friend class ParamCommand; |
|
666 |
|
667 /** |
|
668 * Open the link. Protected to make sure only the friend |
|
669 * components can call it and virtual to allow subclasses to |
|
670 * override it. |
|
671 */ |
|
672 virtual void open(); |
|
673 |
|
674 /** |
|
675 * Close the link. Protected to make sure only the friend |
|
676 * components can call it and virtual to allow subclasses to |
|
677 * override it. |
|
678 */ |
|
679 virtual void close(); |
|
680 |
|
681 /// Type of the link |
|
682 int type_; |
|
683 |
|
684 /// State of the link |
|
685 u_int32_t state_; |
|
686 |
|
687 /// Flag, that when set to true, indicates that the link has been deleted. |
|
688 bool deleted_; |
|
689 |
|
690 /// Flag, that when set to true, indicates that the creation of the |
|
691 /// link is pending; the convergence layer will post a creation event |
|
692 /// when the creation is complete. While creation is pending, the |
|
693 /// link cannot be opened nor can bundles be queued for it. |
|
694 bool create_pending_; |
|
695 |
|
696 /// Flag, that when set to true, indicates that the link is allowed |
|
697 /// to be used to transmit bundles. |
|
698 bool usable_; |
|
699 |
|
700 /// Next hop address |
|
701 std::string nexthop_; |
|
702 |
|
703 /// Internal name of the link |
|
704 std::string name_; |
|
705 |
|
706 /// Whether or not this link is reliable |
|
707 bool reliable_; |
|
708 |
|
709 /// Parameters of the link |
|
710 Params params_; |
|
711 |
|
712 /// Default parameters of the link |
|
713 static Params default_params_; |
|
714 |
|
715 /// Lock to protect internal data structures and state. |
|
716 oasys::SpinLock lock_; |
|
717 |
|
718 /// Queue of bundles currently active or pending transmission on the Link |
|
719 BundleList queue_; |
|
720 |
|
721 /// Queue of bundles that have been sent but not yet acknowledged |
|
722 BundleList inflight_; |
|
723 |
|
724 /** @{ |
|
725 * |
|
726 * Data counters about the link queues, both in terms of bundles |
|
727 * and bytes. |
|
728 * |
|
729 * *_queued: the link queue size |
|
730 * *_inflight: transmitted but not yet acknowledged |
|
731 */ |
|
732 u_int bundles_queued_; |
|
733 u_int bytes_queued_; |
|
734 u_int bundles_inflight_; |
|
735 u_int bytes_inflight_; |
|
736 /** @} */ |
|
737 |
|
738 /// Stats for the link |
|
739 mutable Stats stats_; |
|
740 |
|
741 /// Current contact. contact_ != null iff link is open |
|
742 ContactRef contact_; |
|
743 |
|
744 /// Pointer to convergence layer |
|
745 ConvergenceLayer* clayer_; |
|
746 |
|
747 /// Convergence layer specific info, if needed |
|
748 CLInfo* cl_info_; |
|
749 |
|
750 /// Router specific info, if needed |
|
751 RouterInfo* router_info_; |
|
752 |
|
753 /// Remote's endpoint ID (eg, dtn://hostname.dtn) |
|
754 EndpointID remote_eid_; |
|
755 |
|
756 /// Destructor -- protected since links shouldn't be deleted |
|
757 virtual ~Link(); |
|
758 }; |
|
759 |
|
760 } // namespace dtn |
|
761 |
|
762 #endif /* _LINK_H_ */ |