A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
flame-rtable.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009 IITP RAS
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Kirill Andreev <andreev@iitp.ru>
18 */
19
20#ifndef FLAME_RTABLE_H
21#define FLAME_RTABLE_H
22
23#include "ns3/mac48-address.h"
24#include "ns3/nstime.h"
25#include "ns3/object.h"
26
27#include <map>
28
29namespace ns3
30{
31namespace flame
32{
33/**
34 * \ingroup flame
35 *
36 * \brief Routing table for FLAME
37 */
38class FlameRtable : public Object
39{
40 public:
41 /// Means all interfaces
42 const static uint32_t INTERFACE_ANY = 0xffffffff;
43 /// Maximum (the best?) path cost
44 const static uint32_t MAX_COST = 0xff;
45
46 /// Route lookup result, return type of LookupXXX methods
48 {
49 Mac48Address retransmitter; ///< retransmitter
50 uint32_t ifIndex; ///< IF index
51 uint8_t cost; ///< cost
52 uint16_t seqnum; ///< sequence number
53
54 /**
55 * Constructor
56 *
57 * \param r retransmitter MAC address
58 * \param i interfce index
59 * \param c cost
60 * \param s sequence number
61 */
64 uint8_t c = MAX_COST,
65 uint16_t s = 0)
66 : retransmitter(r),
67 ifIndex(i),
68 cost(c),
69 seqnum(s)
70 {
71 }
72
73 /**
74 * \returns True for valid route
75 */
76 bool IsValid() const;
77 /**
78 * Compare route lookup results, used by tests
79 *
80 * \param o the object to compare
81 * \returns true if equal
82 */
83 bool operator==(const LookupResult& o) const;
84 };
85
86 public:
87 /**
88 * \brief Get the type ID.
89 * \return the object TypeId
90 */
91 static TypeId GetTypeId();
92
94 ~FlameRtable() override;
95
96 // Delete copy constructor and assignment operator to avoid misuse
97 FlameRtable(const FlameRtable&) = delete;
99
100 void DoDispose() override;
101
102 /**
103 * Add path
104 *
105 * \param destination the destination address
106 * \param retransmitter the retransmitter address
107 * \param interface the interface
108 * \param cost the cost
109 * \param seqnum the sequence number
110 */
111 void AddPath(const Mac48Address destination,
112 const Mac48Address retransmitter,
113 const uint32_t interface,
114 const uint8_t cost,
115 const uint16_t seqnum);
116 /**
117 * \brief Lookup path to destination
118 * \param destination
119 * \return Broadcast if not found
120 */
121 LookupResult Lookup(Mac48Address destination);
122
123 private:
124 /// Routing table entry
125 struct Route
126 {
127 Mac48Address retransmitter; ///< retransmitter
128 uint32_t interface; ///< interface
129 uint32_t cost; ///< cost
130 Time whenExpire; ///< expire when?
131 uint32_t seqnum; ///< sequence number
132 };
133
134 /// Lifetime parameter
136 /// List of routes
137 std::map<Mac48Address, Route> m_routes;
138};
139
140} // namespace flame
141} // namespace ns3
142#endif /* FLAME_PROTOCOL_H */
an EUI-48 address
Definition: mac48-address.h:46
static Mac48Address GetBroadcast()
A base class which provides memory management and object aggregation.
Definition: object.h:89
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
a unique identifier for an interface.
Definition: type-id.h:59
Routing table for FLAME.
Definition: flame-rtable.h:39
LookupResult Lookup(Mac48Address destination)
Lookup path to destination.
Definition: flame-rtable.cc:94
void DoDispose() override
Destructor implementation.
Definition: flame-rtable.cc:61
static const uint32_t INTERFACE_ANY
Means all interfaces.
Definition: flame-rtable.h:42
void AddPath(const Mac48Address destination, const Mac48Address retransmitter, const uint32_t interface, const uint8_t cost, const uint16_t seqnum)
Add path.
Definition: flame-rtable.cc:67
FlameRtable(const FlameRtable &)=delete
static TypeId GetTypeId()
Get the type ID.
Definition: flame-rtable.cc:37
std::map< Mac48Address, Route > m_routes
List of routes.
Definition: flame-rtable.h:137
Time m_lifetime
Lifetime parameter.
Definition: flame-rtable.h:135
static const uint32_t MAX_COST
Maximum (the best?) path cost.
Definition: flame-rtable.h:44
FlameRtable & operator=(const FlameRtable &)=delete
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Route lookup result, return type of LookupXXX methods.
Definition: flame-rtable.h:48
uint16_t seqnum
sequence number
Definition: flame-rtable.h:52
LookupResult(Mac48Address r=Mac48Address::GetBroadcast(), uint32_t i=INTERFACE_ANY, uint8_t c=MAX_COST, uint16_t s=0)
Constructor.
Definition: flame-rtable.h:62
bool operator==(const LookupResult &o) const
Compare route lookup results, used by tests.
Mac48Address retransmitter
retransmitter
Definition: flame-rtable.h:49
Routing table entry.
Definition: flame-rtable.h:126
uint32_t seqnum
sequence number
Definition: flame-rtable.h:131
Mac48Address retransmitter
retransmitter
Definition: flame-rtable.h:127