IBR-DTN  1.0.0
RetransmissionExtension.h
Go to the documentation of this file.
1 /*
2  * RetransmissionExtension.h
3  *
4  * Copyright (C) 2011 IBR, TU Braunschweig
5  *
6  * Written-by: Johannes Morgenroth <morgenroth@ibr.cs.tu-bs.de>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21 
22 #ifndef RETRANSMISSIONEXTENSION_H_
23 #define RETRANSMISSIONEXTENSION_H_
24 
26 
30 #include "core/TimeEvent.h"
31 
32 #include "core/EventReceiver.h"
33 #include <ibrdtn/data/BundleID.h>
34 #include <ibrdtn/data/EID.h>
35 #include <ibrcommon/thread/Mutex.h>
36 #include <queue>
37 #include <set>
38 
39 namespace dtn
40 {
41  namespace routing
42  {
44  public dtn::core::EventReceiver<dtn::net::TransferAbortedEvent>,
45  public dtn::core::EventReceiver<dtn::routing::RequeueBundleEvent>,
46  public dtn::core::EventReceiver<dtn::core::BundleExpiredEvent>,
47  public dtn::core::EventReceiver<dtn::core::TimeEvent>
48  {
49  public:
51  virtual ~RetransmissionExtension();
52 
56  virtual void eventTransferCompleted(const dtn::data::EID &peer, const dtn::data::MetaBundle &meta) throw ();
57 
58  void raiseEvent(const dtn::net::TransferAbortedEvent &evt) throw ();
59  void raiseEvent(const dtn::routing::RequeueBundleEvent &evt) throw ();
60  void raiseEvent(const dtn::core::BundleExpiredEvent &evt) throw ();
61  void raiseEvent(const dtn::core::TimeEvent &evt) throw ();
62 
63  void componentUp() throw ();
64  void componentDown() throw ();
65 
66  private:
67  class RetransmissionData : public dtn::data::BundleID
68  {
69  public:
70  RetransmissionData(const dtn::data::BundleID &id, const dtn::data::EID &destination, dtn::core::Node::Protocol p = dtn::core::Node::CONN_UNDEFINED, const dtn::data::Size retry = 2);
71  virtual ~RetransmissionData();
72 
73 
74  const dtn::data::EID destination;
75  const dtn::core::Node::Protocol protocol;
76 
77  const dtn::data::Timestamp& getTimestamp() const;
78  dtn::data::Size getCount() const;
79 
80  RetransmissionData& operator++();
81  RetransmissionData& operator++(int);
82 
83  bool operator!=(const RetransmissionData &obj);
84  bool operator==(const RetransmissionData &obj);
85 
86  private:
87  dtn::data::Timestamp _timestamp;
88  dtn::data::Size _count;
89  const dtn::data::Size retry;
90  };
91 
92  ibrcommon::Mutex _mutex;
93  std::queue<RetransmissionData> _queue;
94  std::set<RetransmissionData> _set;
95  };
96  }
97 }
98 
99 #endif /* RETRANSMISSIONEXTENSION_H_ */
virtual void eventTransferCompleted(const dtn::data::EID &peer, const dtn::data::MetaBundle &meta)
void raiseEvent(const dtn::net::TransferAbortedEvent &evt)
size_t Size
Definition: Number.h:34