IBR-DTNSuite  0.10
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 #include <ibrdtn/data/BundleID.h>
27 #include <ibrdtn/data/EID.h>
28 #include <ibrcommon/thread/Mutex.h>
29 #include <queue>
30 #include <set>
31 
32 namespace dtn
33 {
34  namespace routing
35  {
37  {
38  public:
40  virtual ~RetransmissionExtension();
41 
42  void notify(const dtn::core::Event *evt) throw ();
43  void componentUp() throw () {};
44  void componentDown() throw () {};
45 
46  private:
47  class RetransmissionData : public dtn::data::BundleID
48  {
49  public:
50  RetransmissionData(const dtn::data::BundleID &id, const dtn::data::EID &destination, const dtn::data::Size retry = 2);
51  virtual ~RetransmissionData();
52 
53 
54  const dtn::data::EID destination;
55 
56  const dtn::data::Timestamp& getTimestamp() const;
57  dtn::data::Size getCount() const;
58 
59  RetransmissionData& operator++();
60  RetransmissionData& operator++(int);
61 
62  bool operator!=(const RetransmissionData &obj);
63  bool operator==(const RetransmissionData &obj);
64 
65  private:
66  dtn::data::Timestamp _timestamp;
67  dtn::data::Size _count;
68  const dtn::data::Size retry;
69  };
70 
71  ibrcommon::Mutex _mutex;
72  std::queue<RetransmissionData> _queue;
73  std::set<RetransmissionData> _set;
74  };
75  }
76 }
77 
78 #endif /* RETRANSMISSIONEXTENSION_H_ */